-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibftprintf.h
More file actions
executable file
·104 lines (90 loc) · 2.9 KB
/
libftprintf.h
File metadata and controls
executable file
·104 lines (90 loc) · 2.9 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* ************************************************************************** */
/* */
/* :::::::: */
/* libftprintf.h :+: :+: */
/* +:+ */
/* By: nsterk <nsterk@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/09 19:49:08 by nsterk #+# #+# */
/* Updated: 2021/01/12 15:04:14 by nsterk ######## odam.nl */
/* */
/* ************************************************************************** */
#ifndef LIBFTPRINTF_H
# define LIBFTPRINTF_H
# include <stdarg.h>
# include <stdlib.h>
# include "libft/libft.h"
/*
** The t_tab struct stores all necessary information.
** The variables in this struct represent:
**
** format: the string that was passed to ft_printf.
** args: the arguments that were passed to ft_printf.
** ret: total nr of characters printed (return value ft_printf).
** argument: the current argument that is being processed.
**
** FLAGS
** left_justify: minus flag.
** zero, space: zero flag and space flag.
** plus, hash: plus flag and hash flag.
**
** FIELD SPECS
** width: stores value of width specified.
** precision: stores value precision specified.
** precision_bool: set to 1 if precision has been specified.
**
** CONVERSION SPECS
** lenmod: stores length modifier specified.
** 0 = default, 1 = hh, 2 = h, 3 = ll, 4 = l.
** specifier: conversion specifier.
*/
typedef struct s_tab
{
const char *format;
va_list args;
int ret;
char *argument;
int arg_len;
int left_justify;
int zero;
int space;
int plus;
int hash;
int width;
int precision;
int precision_bool;
int lenmod;
char specifier;
} t_tab;
int ft_printf(const char *format, ...);
void initialize(t_tab *tab);
void re_initialize(t_tab *tab);
/*
** Parsing functions.
*/
int parse(t_tab *tab);
int get_width(t_tab *tab);
int get_precision(t_tab *tab);
/*
** Conversion functions and dispatch table to these functions.
*/
int convert_char(t_tab *tab);
int convert_lowhex(t_tab *tab);
int convert_uphex(t_tab *tab);
int convert_int(t_tab *tab);
int convert_unsigned_int(t_tab *tab);
int convert_ptr(t_tab *tab);
int convert_string(t_tab *tab);
typedef int (*t_convert)(t_tab *tab);
/*
** Functions to retrieve arguments that can take len modifiers.
*/
long long get_signed(t_tab *tab);
unsigned long long get_unsigned(t_tab *tab);
/*
** Formatting + printing functions.
*/
int format(t_tab *tab);
int print_char(t_tab *tab);
int print_argument(t_tab *tab);
#endif