From 973ac2479af2cb847557e65989273dc477758051 Mon Sep 17 00:00:00 2001 From: vagrant Date: Mon, 11 Feb 2019 06:20:04 +0000 Subject: [PATCH] added test function --- Makefile | 39 +++++++++++++++++++++++++++++++++++++++ includes/libftprintf.h | 3 ++- srcs/ft_putchar.c | 18 ++++++++++++++++++ srcs/ft_putendl.c | 20 ++++++++++++++++++++ srcs/ft_putstr.c | 19 +++++++++++++++++++ srcs/pf_getflags.c | 22 +++++++++++++++++++++- 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 Makefile create mode 100644 srcs/ft_putchar.c create mode 100644 srcs/ft_putendl.c create mode 100644 srcs/ft_putstr.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3569988 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +#******************************************************************************# +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: tmaze +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2019/02/09 15:12:22 by tmaze #+# #+# # +# Updated: 2019/02/09 15:45:01 by tmaze ### ########.fr # +# # +#******************************************************************************# + +CC := gcc +CCFLAGS := -Wall -Werror -Wextra -g +CCSTD := + +NAME := libftprintf.a + +SRCS := ft_printf.c pf_getflags.c +OBJS_DIR := objs +OBJS := $(SRCS:.c=.o) + +.PHONY = all clean fclean re + +all: $(NAME) + +$(NAME): $(OBJS) + ar rcs $(NAME) $(OBJS) + +%.o: srcs/%.c includes/libftprintf.h + $(CC) $(CCFLAGS) $(CCSTD) $(INCLS) -c $< -o $@ + +clean: + rm -rf $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all diff --git a/includes/libftprintf.h b/includes/libftprintf.h index fcc1490..0ae1547 100644 --- a/includes/libftprintf.h +++ b/includes/libftprintf.h @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/07 13:03:44 by tmaze #+# #+# */ -/* Updated: 2019/02/07 17:03:50 by tmaze ### ########.fr */ +/* Updated: 2019/02/09 14:38:22 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,6 +41,7 @@ typedef struct s_flags char size; } t_flags; +void pf_putflags(t_flags *flags); size_t pf_getflags(const char *format, t_flags *flags); int pf_convc(t_flags *flags, va_list *ap); diff --git a/srcs/ft_putchar.c b/srcs/ft_putchar.c new file mode 100644 index 0000000..0290a79 --- /dev/null +++ b/srcs/ft_putchar.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tmaze +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/04/07 19:03:57 by tmaze #+# #+# */ +/* Updated: 2018/04/07 23:02:29 by tmaze ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/srcs/ft_putendl.c b/srcs/ft_putendl.c new file mode 100644 index 0000000..c7d1cd6 --- /dev/null +++ b/srcs/ft_putendl.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tmaze +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/04/07 22:37:44 by tmaze #+# #+# */ +/* Updated: 2019/01/13 17:44:21 by tmaze ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putendl(char const *s) +{ + if (s != NULL) + ft_putstr(s); + ft_putchar('\n'); +} diff --git a/srcs/ft_putstr.c b/srcs/ft_putstr.c new file mode 100644 index 0000000..3d7077e --- /dev/null +++ b/srcs/ft_putstr.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tmaze +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/04/07 19:13:17 by tmaze #+# #+# */ +/* Updated: 2018/04/12 11:23:29 by tmaze ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_putstr(char const *s) +{ + if (s != NULL) + write(1, s, ft_strlen(s)); +} diff --git a/srcs/pf_getflags.c b/srcs/pf_getflags.c index c45e70b..9f90d7d 100644 --- a/srcs/pf_getflags.c +++ b/srcs/pf_getflags.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/07 14:14:38 by tmaze #+# #+# */ -/* Updated: 2019/02/07 17:11:26 by tmaze ### ########.fr */ +/* Updated: 2019/02/09 14:36:30 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,6 +23,26 @@ void pf_initflags(t_flags *flags) flags->size = '\0'; } +void pf_putflags(t_flags *flags) +{ + ft_putendl("--- putflags ---"); + ft_putstr("convtype->"); + ft_putnbr(flags->convtype); + ft_putstr("/nminus->"); + ft_putchar(flags->minus); + ft_putstr("/nsign->"); + ft_putchar(flags->sign); + ft_putstr("/nhash->"); + ft_putchar(flags->hash); + ft_putstr("/nwidth->"); + ft_putnbr(flags->width); + ft_putstr("/nprecision->"); + ft_putnbr(flags->precision); + ft_putstr("/nsize->"); + ft_putchar(flags->size); + ft_putchar("/n"); +} + size_t pf_getflags(const char *format, t_flags *flags) { size_t i;