-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprints.h
137 lines (86 loc) · 3.72 KB
/
prints.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
127
128
129
130
131
132
133
134
135
136
137
#ifndef prints_h
#define prints_h
//extern int _mprints(char*msg,...); // strange errors caused by that
//extern int dprints(int fd, const char *msg,...);
//+header mini_addons.h
//+needs prints.h stdarg.h
//+depends dprints write
//+macro
#define _mprints(...) dprints(STDOUT_FILENO, __VA_ARGS__)
//+doc print the string(s) supplied as arg(s) to stdout,
// this macro has an variable argument count.
//+depends _mprints dprints
//+macro
#define prints(...) _mprints(__VA_ARGS__,0)
//+doc print the string(s) supplied as arg(s) to stdout
// this macro has an variable argument count.
//+depends dprints
//+macro
#define eprints(...) dprints(STDERR_FILENO,__VA_ARGS__,0)
//+doc print the string(s) supplied as arg(s) to stream
// this macro has an variable argument count.
//+depends fileno write strlen dprints
//+macro
#define fprints(F,...) dprints(fileno(F),__VA_ARGS__,0)
//+doc print the string(s) supplied as arg(s) and newline to stdout
//+depends _mprints dprints
//+macro
#define printsl(...) _mprints(__VA_ARGS__,"\n",0)
//+doc print the string(s) supplied as arg(s) and newline to stderr
//+depends dprints
//+macro
#define eprintsl(...) dprints(STDERR_FILENO,__VA_ARGS__,"\n",0)
//+depends write strlen
//+doc write str to stdout. Needs strlen
//+macro print(str) write(STDOUT_FILENO,str,strlen(str))
//+depends write strlen
//+doc write str to stderr. Needs strlen
//+macro eprint(str) write(STDERR_FILENO,str,strlen(str))
//+depends write
//+doc write a newline to stdout
//+macro printl() write(STDOUT_FILENO,"\n",1)
//+depends write
//+doc write a newline to stderr
//+macro eprintl() write(STDERR_FILENO,"\n",1)
//+depends printl print strlen write printf
//+doc write msg to stdout, append a newline. Needs strlen.
//+macro puts(msg) ( print(msg) + printl() )
//+depends eprintl eprint strlen write
//+doc write msg to stderr, append a newline. Needs strlen.
//+macro eputs(msg) ( eprint(msg) + eprintl() )
//+depends write
//+doc write the constant str to stdout. Computes length with sizeof(str) at compile time.
//+macro writes(str) write(STDOUT_FILENO,str,sizeof(str))
//+depends write
//+doc write the constant str to stderr. Computes length with sizeof(str) at compile time.
//+macro ewrites(str) write(STDERR_FILENO,str,sizeof(str))
//+depends write
//+doc write the constant str to stdout, followed by a newline.
// Computes length with sizeof(str) at compile time.
//+macro writesl(str) write(STDOUT_FILENO,str "\n",sizeof(str)+1)
////+macro writesl(str) {write(STDOUT_FILENO,str,sizeof(str));write(STDOUT_FILENO,"\n",1);}
//+depends write
//+doc write the constant str to stderr, followed by a newline.
// Computes length with sizeof(str) at compile time.
//+macro ewritesl(str) write(STDERR_FILENO,str"\n",sizeof(str)+1)
////+macro ewritesl(str) write(STDERR_FILENO,str,sizeof(str));write(STDERR_FILENO,"\n",1)
//+depends write
//+doc write the constant str to fd. Computes length with sizeof(str) at compile time.
//+macro fwrites(fd,str) write(fd,str,sizeof(str))
//+depends write
//+doc write the constant str to fd,followed by a newline.
// Computes length with sizeof(str) at compile time.
//+macro fwritesl(fd,str) write(fd,str"\n",sizeof(str)+1)
////+macro fwritesl(fd,str) write(fd,str,sizeof(str));write(fd,"\n",1)
//+depends fprintfs fputs strlen
//+doc write fmt and arguments to stdout.
// only format %s and %c are recognized
//+macro printfs(fmt,...) fprintfs(stdout, fmt, __VA_ARGS__)
//+depends fprintfs fputs strlen
//+doc write fmt and arguments to stderr.
// only format %s and %c are recognized
//+macro eprintfs(fmt,...) fprintfs(stderr, fmt, __VA_ARGS__)
//+depends fprintfs fputs strlen
//+doc write fmt and arguments to stderr.
//+macro eprintf(fmt,...) fprintf(stderr, fmt, __VA_ARGS__)
#endif