aboutsummaryrefslogtreecommitdiff
path: root/header.h
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-10-25 04:42:08 +0200
committerCharles <sircharlesaze@gmail.com>2019-10-25 04:42:08 +0200
commitfeb71e200972bb78fe86130629ef040ef80811a7 (patch)
tree24b84b3f4937ab4eb930e1ad851494d8d49a9775 /header.h
parent1b4df01bfa793fe91a58192a4b79917909bf1614 (diff)
downloadft_printf-feb71e200972bb78fe86130629ef040ef80811a7.tar.gz
ft_printf-feb71e200972bb78fe86130629ef040ef80811a7.tar.bz2
ft_printf-feb71e200972bb78fe86130629ef040ef80811a7.zip
WIP: Added libft submodule, make ft_printf lib
Diffstat (limited to 'header.h')
-rw-r--r--header.h97
1 files changed, 43 insertions, 54 deletions
diff --git a/header.h b/header.h
index ed3d248..c482e94 100644
--- a/header.h
+++ b/header.h
@@ -2,6 +2,7 @@
# define HEADER_H
# include <stdarg.h>
+# include "libft.h"
# define TRUE 1
# define FALSE 0
@@ -13,20 +14,18 @@
# define CONVERSIONS_STR "cspdiuxX%"
-typedef enum
-{
- CONVERSION_CHAR = 0,
- CONVERSION_STR,
- CONVERSION_PTR,
- CONVERSION_DECIMAL,
- CONVERSION_INT,
- CONVERSION_UINT,
- CONVERSION_HEX_LOWER,
- CONVERSION_HEX_UPPER,
- CONVERSION_PERCENT
-} t_conversion;
-
-typedef int t_bool;
+# define CONVERSION_CHAR 'c'
+# define CONVERSION_STR 's'
+# define CONVERSION_PTR 'p'
+# define CONVERSION_DECIMAL 'd'
+# define CONVERSION_INT 'i'
+# define CONVERSION_UINT 'u'
+# define CONVERSION_HEX_LOWER 'x'
+# define CONVERSION_HEX_UPPER 'X'
+# define CONVERSION_PERCENT '%'
+
+typedef char t_conversion;
+typedef int t_bool;
typedef struct
{
@@ -40,78 +39,68 @@ typedef struct
typedef struct
{
- int ap_index;
- t_bool left_adjusted;
- t_bool zero_padding;
- t_maybe_wildcard precision;
- t_maybe_wildcard min_width;
- t_conversion conversion;
- int len;
-} t_pformat;
-
-typedef struct s_list
+ int ap_index;
+ t_bool left_adjusted;
+ t_bool zero_padding;
+ t_maybe_wildcard precision;
+ t_maybe_wildcard min_width;
+ t_conversion conversion;
+ int len;
+} t_pformat;
+
+typedef struct s_pformat_list
{
- struct s_list *next;
- t_pformat *data;
-} t_list;
+ struct s_pformat_list *next;
+ t_pformat *content;
+} t_pformat_list;
/*
** ft_printf.c
*/
-int ft_printf(const char *format, ...);
+int ft_printf(const char *format, ...);
/*
** parse.c
*/
-t_list *parse(const char *format);
-char *isolate_conversion(const char *conversion_start);
-t_pformat *parse_reduced(char *fmt);
+t_pformat_list *parse(const char *format);
+char *isolate_conversion(const char *conversion_start);
+t_pformat *parse_reduced(char *fmt);
/*
** printer.c
*/
-void ft_putstr(char *str);
-void handle_padding(t_pformat *pformat, char *str);
-char *convert_to_str(t_pformat *pformat, va_list ap);
-void handle_precision(t_pformat *pformat, char *str);
+void handle_padding(t_pformat *pformat, char *str);
+char *convert_to_str(t_pformat *pformat, va_list ap);
+void handle_precision(t_pformat *pformat, char *str);
/*
** utils.c
*/
-int ft_atoi(const char *str);
-char *ft_strndup(const char *s1, int n);
-char *ft_strrchr(const char *s, int c);
int strrchr_index(const char *s, char c);
-int ft_strlen(char *str);
-t_bool ft_isdigit(char c);
-int nbrlen_radix(long int nbr, int radix);
-char *ft_itoa_base(long int n, char *base);
-char *ft_strnew(int size);
-char *ft_strdup(char *s);
-char *ft_strcpy(char *dest, const char *src);
/*
** extract.c
*/
-char *extract_ap_index(t_pformat *pformat, char *fmt);
-char *extract_min_width(t_pformat *pformat, char *fmt);
-char *extract_standalone_flags(t_pformat *pformat, char *fmt);
-char *extract_precision(t_pformat *pformat, char *fmt);
+// char *extract_ap_index(t_pformat *pformat, char *fmt);
+
+char *extract_min_width(t_pformat *pformat, char *fmt);
+char *extract_standalone_flags(t_pformat *pformat, char *fmt);
+char *extract_precision(t_pformat *pformat, char *fmt);
/*
** list.c
*/
-t_list *list_new(t_pformat *data);
-t_list *list_destroy(t_list *list);
-void list_push_front(t_list **list, t_list *new_front);
-void list_push_back(t_list **list, t_list *new_back);
-void list_pop_front(t_list **list);
+t_pformat_list *list_new(t_pformat *content);
+void *list_destroy(t_pformat_list **lst);
+void list_push_front(t_pformat_list **lst, t_pformat_list *new);
+void list_push_back(t_pformat_list **lst, t_pformat_list *new);
+void list_pop_front(t_pformat_list **lst);
#endif