-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
executable file
·119 lines (97 loc) · 2.95 KB
/
main.h
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef _PRINTF_H
#define _PRINTF_H
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <stdlib.h>
#define OUTPUT_BUF_SIZE 1024
#define BUF_FLUSH -1
#define FIELD_BUF_SIZE 50
#define NULL_STRING "(null)"
#define PARAMS_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define CONVERT_LOWERCASE 1
#define CONVERT_UNSIGNED 2
/**
* struct parameters - parameters struct
*
* @unsign: flag if unsigned value
*
* @plus_flag: on if plus_flag specified
* @space_flag: on if hashtag_flag specified
* @hashtag_flag: on if _flag specified
* @zero_flag: on if _flag specified
* @minus_flag: on if _flag specified
*
* @width: field width specified
* @precision: field precision specified
*
* @h_modifier: on if h_modifier is specified
* @l_modifier: on if l_modifier is specified
*
*/
typedef struct parameters
{
unsigned int unsign : 1;
unsigned int plus_flag : 1;
unsigned int space_flag : 1;
unsigned int hashtag_flag : 1;
unsigned int zero_flag : 1;
unsigned int minus_flag : 1;
unsigned int width;
unsigned int precision;
unsigned int h_modifier : 1;
unsigned int l_modifier : 1;
} params_t;
/**
* struct specifier - Struct token
*
* @specifier: format token
* @f: The function associated
*/
typedef struct specifier
{
char *specifier;
int (*f)(va_list, params_t *);
} specifier_t;
/* _put.c module */
int _puts(char *str);
int _putchar(int c);
/* print_functions.c module */
int print_char(va_list ap, params_t *params);
int print_int(va_list ap, params_t *params);
int print_string(va_list ap, params_t *params);
int print_percent(va_list ap, params_t *params);
int print_S(va_list ap, params_t *params);
/* number.c module */
char *convert(long int num, int base, int flags, params_t *params);
int print_unsigned(va_list ap, params_t *params);
int print_address(va_list ap, params_t *params);
/* specifier.c module */
int (*get_specifier(char *s))(va_list ap, params_t *params);
int get_print_func(char *s, va_list ap, params_t *params);
int get_flag(char *s, params_t *params);
int get_modifier(char *s, params_t *params);
char *get_width(char *s, params_t *params, va_list ap);
/* convert_number.c module */
int print_hex(va_list ap, params_t *params);
int print_HEX(va_list ap, params_t *params);
int print_binary(va_list ap, params_t *params);
int print_octal(va_list ap, params_t *params);
/* simple_printers.c module */
int print_from_to(char *start, char *stop, char *except);
int print_rev(va_list ap, params_t *params);
int print_rot13(va_list ap, params_t *params);
/* print_number.c module */
int _isdigit(int c);
int _strlen(char *s);
int print_number(char *str, params_t *params);
int print_number_right_shift(char *str, params_t *params);
int print_number_left_shift(char *str, params_t *params);
/* params.c module */
void init_params(params_t *params, va_list ap);
/* string_fields.c modoule */
char *get_precision(char *p, params_t *params, va_list ap);
/* _prinf.c module */
int _printf(const char *format, ...);
#endif