include/error/style.h
1
2
3 #ifndef HT_ERROR_STYLE_H
4 #define HT_ERROR_STYLE_H
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 struct err_style_t {
27 char const *name;
28 void (*format) (
29 err_formatted_stream_t * ,
30 err_v_char_t * ,
31 int ,
32 int ,
33 int ,
34 err_msg_info_t ,
35 err_location_t const * ,
36 char const * ,
37 char const * ,
38 int ,
39 char const * );
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 err_v_char_t *(*post_format) (
73 err_formatted_stream_t *, int , int , err_v_char_t const *);
74
75
76
77 };
78
79
80
81
82 extern err_style_t const err_style_none_s;
83 #define err_style_none (&err_style_none_s)
84
85 extern void err_style_none_format (
86 err_formatted_stream_t *,
87 err_v_char_t *,
88 int, int, int,
89 err_msg_info_t,
90 err_location_t const *,
91 char const *, char const *, int,
92 char const *);
93
94 extern err_v_char_t *err_style_none_post_format (
95 err_formatted_stream_t *, int, int, err_v_char_t const *);
96
97
98
99
100 extern err_style_t const err_style_simple_s;
101 #define err_style_simple (&err_style_simple_s)
102
103 extern void err_style_simple_format (
104 err_formatted_stream_t *,
105 err_v_char_t *,
106 int, int, int,
107 err_msg_info_t,
108 err_location_t const *,
109 char const *, char const *, int,
110 char const *);
111
112 extern err_v_char_t *err_style_simple_post_format (
113 err_formatted_stream_t *, int, int, err_v_char_t const *);
114
115
116
117
118 #define ERR_STYLE_DEFAULT 9999
119 #define ERR_STYLE_NONE 0
120 #define ERR_STYLE_SIMPLE 10
121 #define ERR_STYLE_PLAIN 20
122 #define ERR_STYLE_COLON 21
123 #define ERR_STYLE_QUOTES 22
124 #define ERR_STYLE_QT 30
125 #define ERR_STYLE_QT3 40
126
127 extern int err_style_default_redirect;
128
129 extern err_style_t const err_style_default_s;
130 #define err_style_default (&err_style_default_s)
131
132
133
134
135 extern void err_style_default_format (
136 err_formatted_stream_t *,
137 err_v_char_t *,
138 int, int, int,
139 err_msg_info_t,
140 err_location_t const *,
141 char const *, char const *, int,
142 char const *);
143
144 extern err_v_char_t *err_style_default_post_format (
145 err_formatted_stream_t *, int, int, err_v_char_t const *);
146
147
148
149
150 #define ERR_MSG_COLOR_PREFIX 1
151 #define ERR_MSG_COLOR_SUFFIX 2
152
153 #define ERR_MSG_PART_MIN 8
154 #define ERR_MSG_PART_LOC 8
155 #define ERR_MSG_PART_PROGNAME 9
156 #define ERR_MSG_PART_TAG 10
157 #define ERR_MSG_PART_ADDRESS 11
158 #define ERR_MSG_PART_BODY 12
159 #define ERR_MSG_PART_TIME 13
160 #define ERR_MSG_PART_SPACE 15
161 #define ERR_MSG_PART_MAX 15
162
163 #define ERR_MSG_COLOR_OFF 16
164
165
166
167
168 struct err_markup_t {
169 int open_part;
170 int open_tag;
171
172 char const *(*color) (
173 struct err_markup_t *,
174 int ,
175 int ,
176 ERR_ERWIN_BOOL );
177
178
179 void (*begin_part) (
180 struct err_markup_t *,
181 err_formatted_stream_t * ,
182 err_v_char_t * ,
183 int ,
184 int );
185 };
186
187 typedef struct err_markup_t ErrMarkup;
188 #ifndef __cplusplus
189 typedef struct err_markup_t err_markup_t;
190 #endif
191
192 extern void err_begin_part (
193 err_markup_t *, err_formatted_stream_t *, err_v_char_t *, int part, int tag);
194 extern void err_open_markup (err_markup_t *, err_v_char_t *, int, int);
195 extern void err_end_part (err_markup_t *, err_v_char_t *);
196
197 extern err_markup_t *err_markup_none;
198
199 extern char const *err_markup_none_color (err_markup_t *, int, int, ERR_ERWIN_BOOL);
200
201 extern void err_markup_none_begin_part (
202 err_markup_t *,
203 err_formatted_stream_t *,
204 err_v_char_t *,
205 int,
206 int);
207
208
209
210 extern err_style_t const *err_style_from_int (int);
211
212
213 extern int err_style_from_string_to_int (char const *);
214 extern err_style_t const * err_style_from_string (char const *);
215
216
217
218
219
220 extern int err_position_pieces (err_position_t const *);
221
222
223
224
225
226
227
228
229
230
231
232 extern char const *err_tag_string (int );
233
234
235
236
237 extern char const *err_tag_description (
238 ERR_BOOL * , int , ERR_BOOL );
239
240
241
242
243
244
245 extern err_symbol_t err_tag_abbreviation (int );
246
247
248
249
250
251
252
253
254
255
256 #define ERR_STYLE_LINE_BREAK_NEVER 0
257 #define ERR_STYLE_LINE_BREAK_ALWAYS 1
258 #define ERR_STYLE_LINE_BREAK_TOO_LONG 2
259 #define ERR_STYLE_LINE_BREAK_LOCATION_GIVEN 3
260
261
262 #define ERR_STYLE_COLOR_NEVER 0
263 #define ERR_STYLE_COLOR_ALWAYS 1
264 #define ERR_STYLE_COLOR_IF_TTY 2
265
266
267 #define ERR_STYLE_TIME_NEVER 0
268 #define ERR_STYLE_TIME_ALWAYS 1
269 #define ERR_STYLE_TIME_PROGRESS 2
270
271 #ifdef __cplusplus
272 }
273 #endif
274
275 #endif