-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.h
More file actions
58 lines (53 loc) · 2.15 KB
/
ft_printf.h
File metadata and controls
58 lines (53 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_printf.h :+: :+: */
/* +:+ */
/* By: jkoers <jkoers@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/03 02:19:33 by jkoers #+# #+# */
/* Updated: 2020/11/30 15:41:45 by jkoers ######## odam.nl */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
# include <stdarg.h>
# include <stdbool.h>
# include <stddef.h>
# ifdef __APPLE__
# define APPLE true
# else
# define APPLE false
# endif
int ft_printf(const char *format, ...);
/*
** This struct is assigned for every converstion (eg. %c), often defined as sp
** @param flag This stores all flags at index. Access: sp.flag['-']
** @param field_width -1 if unknown
** @param precision -1 if unknown
** @param res Pointer to the result of the conversion.
** NULL when malloc fails.
** Garbage if conversion has length 0.
** @param len 0 if there is no conversion to be done.
** Number of chars to print from res
** @param free If res should be freed after writing.
*/
typedef struct s_special
{
bool flag[127];
long field_width;
long precision;
char *res;
size_t len;
bool free;
} t_special;
size_t set_special(t_special *sp, va_list ap, char *percent);
void do_percent(t_special *sp, char *format);
void c(t_special *sp, int c);
void s(t_special *sp, char *s);
void i(t_special *sp, long i);
void u(t_special *sp, unsigned long u);
void x(t_special *sp, unsigned long x, bool uppercase);
void p(t_special *sp, void *p);
void invalid(t_special *sp, char *percent, char *format);
#endif