-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.h
112 lines (94 loc) · 3.68 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
#ifndef MAIN_H
#define MAIN_H
#include <stdarg.h>
#include <unistd.h>
#include <stdio.h>
#define BUFFER_SIZE 1024
#define UNUSED(x) ((void)(x))
/* SIZES TO BE USED */
#define SHORT 1
#define LONG 2
/* FLAGS TO BE USED */
#define SPACE 16
#define HASH 8
#define MINUS 1
#define PLUS 2
#define ZERO 4
/**
* struct format - structure operator;
*
* @format: associated format;
* @func: a pointer to a function;
*/
typedef struct format
{
char format;
int (*func)(va_list, char[], int, int, int, int);
}
/* a pointer to pointed to a function */
fmt_func;
/* Functions for making Printf like */
int print_handler(const char *format, int *x, va_list arg, char buffer[],
int flags, int width, int precision, int size);
/******* Functions for Project Questions *******/
/* Qu.0: _printf function */
int _printf(const char *format, ...);
void flush_buffer(char buffer[], int *buff_len);
/** Qu.1: Functions for printing Integers **/
int print_int(va_list arg, char buffer[], int flags, int width,
int precision, int size);
/*** Qu.2: Binary printer ***/
int print_binary(va_list arg, char buffer[], int flags, int width,
int precision, int size);
/**** Qu.3: cunstom Conversion specifiers ****/
int print_uns(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_octal(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_hexadec(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_upper_hexa(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_uplo_hexa(va_list arg, char ref_to[], char buffer[], int flags,
char flags_c, int width, int precision, int size);
/***** Qu.4: write handler functions *****/
int write_char(char c, char buffer[], int flags, int width,
int precision, int size);
int write_nsign(int is_negative, int x, char buffer[],
int flags, int width, int precision, int size);
int write_num(int x, char buffer[], int flags, int width, int precision,
int len, char pc, char ext_c);
int write_uns(int is_negative, int x, char buffer[], int flags,
int width, int precision, int size);
int write_pointer(char buffer[], int x, int len, int flags,
int width, char pc, char ext_c, int p_start);
/***** Qu.5: Custom specification for string printer function *****/
int print_string(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_char(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_percent(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int justify_string(char *str, int length, int width, int flags);
/****** Qu.6: function to print address of where pointer point to ******/
int print_pointer(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_non_printable(va_list arg, char buffer[], int flags,
int width, int precision, int size);
/****** Qu.7 - Qu.12: 100 - non-custom conversion specifiers ******/
int check_flags(const char *format, int *x);
int check_width(const char *format, int *x, va_list arg);
int check_precision(const char *format, int *x, va_list arg);
int check_size(const char *format, int *x);
/****** Qu.13-Qu.14: 101 - prototype to printing reverse or tr rot13 *****/
int print_rev(va_list arg, char buffer[], int flags, int width,
int precision, int size);
int print_rot13(va_list arg, char buffer[], int flags, int width,
int precision, int size);
/**** Functions for UTILS ****/
int _isdigit(char c);
int _isprintable(char c);
long int conv_size_num(long int num, int size);
long int conv_size_uns(unsigned long int num, int size);
int append_hexacode(char ascii_code, char buffer[], int x);
#endif /* MAIN_H */