-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
126 lines (98 loc) · 3.28 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
120
121
122
123
124
125
126
#ifndef MAIN_H
#define MAIN_H
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#define UNUSED(x) (void)(x)
#define BUFFER_SIZE 1024
/* FLAGS */
#define F_MINUS (1 << 0)
#define F_PLUS (1 << 1)
#define F_ZERO (1 << 2)
#define F_HASH (1 << 3)
#define F_SPACE (1 << 4)
/* SIZES */
#define S_LONG (1 << 0)
#define S_SHORT (1 << 1)
/**
* struct frt - Struct op
* @frt: The format.
* @fun: The function associated with the format.
*/
struct frt
{
char frt;
int (*fun)(va_list, char[], int, int, int, int);
};
/**
* struct funct - Struct op
* @fr_t: The format.
* @funct: The function associated.
*/
typedef struct funct
{
char fr_t;
int (*funct)(va_list, char[], int, int, int, int);
} funct;
int _printf(const char *format, ...);
int handle_print(const char *frt, int *i,
va_list argu, char buffer[], int flg, int wid, int pr, int size);
/****************** FUNCTIONS ******************/
/* Funtions to print chars and strings */
int print_char(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_str(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_per(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
/* Functions to print numbers */
int print_int(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_bin(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_unsgnd(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_oct(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_hexadec(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_hexa_upp(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
int print_hexa(va_list typ, char map_to[],
char buffer[], int flg, char flg_ch, int wid, int pr, int size);
/* Function to print non printable characters */
int print_non_printable(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
/* Function to print memory address */
int print_point(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
/* Functions to handle other specifiers */
int hand_flg(const char *format, int *a);
int hand_wid(const char *format, int *a, va_list argu);
int hand_pr(const char *format, int *a, va_list argu);
int hand_size(const char *format, int *a);
/*Function to print string in reverse*/
int print_rev(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
/*Function to print a string in rot 13*/
int print_rot13str(va_list typ, char buffer[],
int flg, int wid, int pr, int size);
/* width handler */
int write_char(char c, char buffer[],
int flg, int wid, int pr, int size);
int write_num(int is_neg, int ind, char buffer[],
int flg, int wid, int pr, int size);
int write_numb(int ind, char bff[], int flg, int wid, int pre,
int len, char padd, char extra_char);
int write_point(char buffer[], int ind, int len,
int wid, int flg, char padd, char extra_char, int padd_start);
int write_unsgnd(int is_neg, int ind,
char buffer[],
int flg, int wid, int pr, int size);
/****************** UTILS ******************/
int is_print(char);
int append_hexa_code(char, char[], int);
int is_dig(char);
long int conv_size_num(long int num, int size);
long int conv_size_unsgnd(unsigned long int num, int size);
#endif /* MAIN_H */