From 5c06038b5f77d0ba399b5b4ab3b1908eb9026821 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sun, 2 Apr 2017 21:41:57 +0200 Subject: [PATCH] first commit --- libftasm/Makefile | 1 + libftasm/includes/error.h | 3 ++- libftasm/srcs/cliopts/cliopts_get.c | 2 +- libftasm/srcs/error/ft_usage.c | 26 ++++++++++++++++++++++++++ libftasm/srcs/ft_printf/ft_printf.c | 2 +- libftasm/srcs/ft_printf/ft_vprintf.c | 2 +- 6 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 libftasm/srcs/error/ft_usage.c diff --git a/libftasm/Makefile b/libftasm/Makefile index 2f64d00d..b1861156 100644 --- a/libftasm/Makefile +++ b/libftasm/Makefile @@ -57,6 +57,7 @@ dlst/ft_dlstnew.c\ dlst/ft_dlstrtostr.c\ dlst/ft_dlstsize.c\ error/error.c\ +error/ft_usage.c\ ft_printf/ft_conversion.c\ ft_printf/ft_fmt_simplify.c\ ft_printf/ft_fmt_validate_conv.c\ diff --git a/libftasm/includes/error.h b/libftasm/includes/error.h index 5ea206a9..bb28df83 100644 --- a/libftasm/includes/error.h +++ b/libftasm/includes/error.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:53:21 by jhalford ### ########.fr */ +/* Updated: 2017/04/02 20:45:00 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,5 +46,6 @@ extern char **g_argv; int error_set(int n, ...); int ft_perror(char *utility); +void ft_usage(char *format, ...); #endif diff --git a/libftasm/srcs/cliopts/cliopts_get.c b/libftasm/srcs/cliopts/cliopts_get.c index 05e8a3f8..f226e6f3 100644 --- a/libftasm/srcs/cliopts/cliopts_get.c +++ b/libftasm/srcs/cliopts/cliopts_get.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */ -/* Updated: 2017/03/25 15:00:35 by jhalford ### ########.fr */ +/* Updated: 2017/04/02 20:45:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/error/ft_usage.c b/libftasm/srcs/error/ft_usage.c new file mode 100644 index 00000000..42add078 --- /dev/null +++ b/libftasm/srcs/error/ft_usage.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_usage.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/04/02 15:08:56 by jhalford #+# #+# */ +/* Updated: 2017/04/02 20:05:28 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_usage(char *format, ...) +{ + va_list ap; + char *usage; + + va_start(ap, format); + usage = NULL; + ft_vasprintf(&usage, format, ap); + ft_dprintf(2, "usage: %s\n", usage); + ft_strdel(&usage); + exit(-1); +} diff --git a/libftasm/srcs/ft_printf/ft_printf.c b/libftasm/srcs/ft_printf/ft_printf.c index d81e505b..53b60560 100644 --- a/libftasm/srcs/ft_printf/ft_printf.c +++ b/libftasm/srcs/ft_printf/ft_printf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:28:56 by jhalford ### ########.fr */ +/* Updated: 2017/04/02 15:22:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/ft_printf/ft_vprintf.c b/libftasm/srcs/ft_printf/ft_vprintf.c index 09ba322c..a2b8a96a 100644 --- a/libftasm/srcs/ft_printf/ft_vprintf.c +++ b/libftasm/srcs/ft_printf/ft_vprintf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */ -/* Updated: 2017/03/22 17:22:30 by gwojda ### ########.fr */ +/* Updated: 2017/04/02 15:22:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */