"Fossies" - the Fresh Open Source Software Archive 
Member "gamgi0.17.5x/src/io/gamgi_io_error.c" (23 Feb 2022, 12508 Bytes) of package /linux/misc/gamgi-all-0.17.5x.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /******************************************
2 *
3 * $GAMGI/src/io/gamgi_io_error.c
4 *
5 * Copyright (C) 2004 Carlos Pereira
6 *
7 * Distributed under the terms of the GNU
8 * General Public License: $GAMGI/LICENSE
9 *
10 */
11
12 #include "gamgi_engine.h"
13 #include "gamgi_gtk.h"
14 #include "gamgi_mesa.h"
15 #include "gamgi_math.h"
16 #include "gamgi_io.h"
17 #include "gamgi_expat.h"
18 #include "gamgi_global.h"
19
20 #include "gamgi_engine_list.h"
21 #include "gamgi_gtk_dialog.h"
22 #include "gamgi_io_token.h"
23
24 /***************** external function ********************
25 * *
26 * GAMGI_EXPAT_ERROR_ELEMENT *
27 * *
28 ********************************************************/
29
30 gamgi_bool gamgi_io_error_element (const char *element,
31 char *filename, int fileline, gamgi_window *window)
32 {
33 char message[GAMGI_ENGINE_LINE];
34 char shortname[GAMGI_IO_SHORTNAME];
35
36 /**************************************************
37 * element is wrong, it could be anything. *
38 * Regarding its size, the only guarantee *
39 * at this stage is that it is not larger than *
40 * GAMGI_EXPAT_BUFFER, which is usually a large *
41 * number (equal to BUFSIZ by default, which *
42 * is defined in most systems as 8192). Copying *
43 * only its first GAMGI_IO_SHORTNAME char (and *
44 * filling with '\0' unused positions) guarantees *
45 * that the resulting shortname string will not *
46 * blow away the message char array. *
47 **************************************************/
48
49 gamgi_io_token_cut (element, shortname, GAMGI_IO_SHORTNAME);
50
51 sprintf (message,
52 "Invalid element \"%s\" at line %d in file \"%s\"",
53 shortname, fileline, filename);
54
55 gamgi_gtk_dialog_message_create ("Error", message, window);
56
57 return FALSE;
58 }
59
60 /****************** external function *******************
61 * *
62 * GAMGI_EXPAT_IMPORT_ATTRIBUTE *
63 * *
64 ********************************************************/
65
66 gamgi_bool gamgi_io_error_attribute (const char *attribute,
67 char *filename, int fileline, gamgi_window *window)
68 {
69 char message[GAMGI_ENGINE_LINE];
70 char shortname[GAMGI_IO_SHORTNAME];
71
72 /**************************************************
73 * attribute is wrong, it could be anything. *
74 * Regarding its size, the only guarantee *
75 * at this stage is that it is not larger than *
76 * GAMGI_EXPAT_BUFFER, which is usually a large *
77 * number (equal to BUFSIZ by default, which *
78 * is defined in most systems as 8192). Copying *
79 * only its first GAMGI_IO_SHORTNAME char (and *
80 * filling with '\0' unused positions) guarantees *
81 * that the resulting shortname string will not *
82 * blow away the message char array. *
83 **************************************************/
84
85 gamgi_io_token_cut (attribute, shortname, GAMGI_IO_SHORTNAME);
86
87 sprintf (message,
88 "Invalid attribute \"%s\" in element starting at line %d in file \"%s\"",
89 shortname, fileline, filename);
90
91 gamgi_gtk_dialog_message_create ("Error", message, window);
92
93 return FALSE;
94 }
95
96 /***************** external function ********************
97 * *
98 * GAMGI_EXPAT_IMPORT_VALUE *
99 * *
100 ********************************************************/
101
102 gamgi_bool gamgi_io_error_value (const char *value,
103 char *filename, int fileline, gamgi_window *window)
104 {
105 char message[GAMGI_ENGINE_LINE];
106 char shortname[GAMGI_IO_SHORTNAME];
107
108 /**************************************************
109 * value is wrong, it could be anything. *
110 * Regarding its size, the only guarantee *
111 * at this stage is that it is not larger than *
112 * GAMGI_EXPAT_BUFFER, which is usually a large *
113 * number (equal to BUFSIZ by default, which *
114 * is defined in most systems as 8192). Copying *
115 * only its first GAMGI_IO_SHORTNAME char (and *
116 * filling with '\0' unused positions) guarantees *
117 * that the resulting shortname string will not *
118 * blow away the message char array. *
119 **************************************************/
120
121 gamgi_io_token_cut (value, shortname, GAMGI_IO_SHORTNAME);
122
123 sprintf (message,
124 "Invalid parameter \"%s\" in element starting at line %d in file \"%s\"",
125 shortname, fileline, filename);
126
127 gamgi_gtk_dialog_message_create ("Error", message, window);
128
129 return FALSE;
130 }
131
132 /***************** external function ********************
133 * *
134 * GAMGI_EXPAT_IMPORT_CHILD *
135 * *
136 ********************************************************/
137
138 gamgi_bool gamgi_io_error_child (char *filename,
139 int fileline, gamgi_window *window)
140 {
141 char message[GAMGI_ENGINE_LINE];
142
143 sprintf (message,
144 "Invalid parent for element starting at line %d in file \"%s\"",
145 fileline, filename);
146
147 gamgi_gtk_dialog_message_create ("Error", message, window);
148
149 return FALSE;
150 }
151
152 /***************** external function ********************
153 * *
154 * GAMGI_EXPAT_IMPORT_MISSING *
155 * *
156 ********************************************************/
157
158 gamgi_bool gamgi_io_error_missing (char *filename,
159 int fileline, gamgi_window *window)
160 {
161 char message[GAMGI_ENGINE_LINE];
162
163 sprintf (message,
164 "Missing parameters in element starting at line %d in file \"%s\"",
165 fileline, filename);
166
167 gamgi_gtk_dialog_message_create ("Error", message, window);
168
169 return FALSE;
170 }
171
172 /***************** external function ********************
173 * *
174 * GAMGI_EXPAT_IMPORT_INCOMPATIBLE *
175 * *
176 ********************************************************/
177
178 gamgi_bool gamgi_io_error_incompatible (char *filename,
179 int fileline, gamgi_window *window)
180 {
181 char message[GAMGI_ENGINE_LINE];
182
183 sprintf (message,
184 "Incompatible parameters in element starting at line %d in file \"%s\"",
185 fileline, filename);
186
187 gamgi_gtk_dialog_message_create ("Error", message, window);
188
189 return FALSE;
190 }
191
192 /***************** external function ********************
193 * *
194 * GAMGI_EXPAT_IMPORT_EMPTY *
195 * *
196 ********************************************************/
197
198 gamgi_bool gamgi_io_error_empty (char *filename,
199 int fileline, gamgi_window *window)
200 {
201 char message[GAMGI_ENGINE_LINE];
202
203 sprintf (message,
204 "Invalid empty element ending at line %d in file \"%s\"",
205 fileline, filename);
206
207 gamgi_gtk_dialog_message_create ("Error", message, window);
208
209 return FALSE;
210 }
211
212 gamgi_bool gamgi_io_error_multiple (char *filename,
213 int fileline, gamgi_window *window)
214 {
215 char message[GAMGI_ENGINE_LINE];
216
217 sprintf (message,
218 "Multiple object definition in element starting at line %d in file \"%s\"",
219 fileline, filename);
220
221 gamgi_gtk_dialog_message_create ("Error", message, window);
222
223 return FALSE;
224 }
225
226 gamgi_bool gamgi_io_error_resources (char *filename,
227 int fileline, gamgi_window *window)
228 {
229 char message[GAMGI_ENGINE_LINE];
230
231 sprintf (message,
232 "Resources exceeded in element starting at line %d in file \"%s\"",
233 fileline, filename);
234
235 gamgi_gtk_dialog_message_create ("Error", message, window);
236
237 return FALSE;
238 }
239
240 gamgi_bool gamgi_io_error_ref (const char *ref,
241 char *filename, int fileline, gamgi_window *window)
242 {
243 char message[GAMGI_ENGINE_LINE];
244
245 /********************************************
246 * ref was tested before: it is a safe name *
247 ********************************************/
248
249 sprintf (message,
250 "Unknown id \"%s\" in element starting at line %d in file \"%s\"",
251 ref, fileline, filename);
252
253 gamgi_gtk_dialog_message_create ("Error", message, window);
254
255 return FALSE;
256 }
257
258 gamgi_bool gamgi_io_error_cdata (char *filename,
259 int fileline, gamgi_window *window)
260 {
261 char message[GAMGI_ENGINE_LINE];
262
263 sprintf (message,
264 "Invalid character data starting at line %d in file %s",
265 fileline, filename);
266
267 gamgi_gtk_dialog_message_create ("Error", message, window);
268
269 return FALSE;
270 }
271
272 gamgi_bool gamgi_io_error_header (const char *identifier,
273 char *filename, int fileline, gamgi_window *window)
274 {
275 char message[GAMGI_ENGINE_LINE];
276 char shortname[GAMGI_IO_SHORTNAME];
277
278 /**************************************************
279 * identifier is wrong, it could be anything. *
280 * Regarding its size, the only guarantee *
281 * at this stage is that it is not larger than *
282 * GAMGI_EXPAT_BUFFER, which is usually a large *
283 * number (equal to BUFSIZ by default, which *
284 * is defined in most systems as 8192). Copying *
285 * only its first GAMGI_IO_SHORTNAME char (and *
286 * filling with '\0' unused positions) guarantees *
287 * that the resulting shortname string will not *
288 * blow away the message char array. *
289 **************************************************/
290
291 gamgi_io_token_cut (identifier, shortname, GAMGI_IO_SHORTNAME);
292
293 sprintf (message,
294 "Invalid header identifier \"%s\" \n at line %d in file \"%s\"",
295 shortname, fileline, filename);
296
297 gamgi_gtk_dialog_message_create ("Error", message, window);
298
299 return FALSE;
300 }
301
302 gamgi_bool gamgi_io_error_parse (char *filename,
303 int fileline, gamgi_window *window)
304 {
305 char message[GAMGI_ENGINE_LINE];
306
307 sprintf (message,
308 "Invalid file format at line %d in file \"%s\"",
309 fileline, filename);
310
311 gamgi_gtk_dialog_message_create ("Error", message, window);
312
313 return FALSE;
314 }
315
316 gamgi_bool gamgi_io_error_font (char *font, char *filename,
317 int fileline, gamgi_window *window)
318 {
319 char message[GAMGI_ENGINE_LINE];
320
321 sprintf (message,
322 "Unable to handle font file \"%s\" in element starting at line %d in file \"%s\"",
323 font, fileline, filename);
324
325 gamgi_gtk_dialog_message_create ("Error", message, window);
326
327 return FALSE;
328 }
329
330 gamgi_bool gamgi_io_error_open (char *filename,
331 gamgi_window *window)
332 {
333 char message[GAMGI_ENGINE_LINE];
334 char shortname[GAMGI_IO_SHORTNAME];
335
336 /*******************************************
337 * filename is wrong, it could be anything *
338 *******************************************/
339
340 gamgi_io_token_cut (filename, shortname, GAMGI_IO_SHORTNAME);
341
342 sprintf (message,
343 "Unable to open file \"%s\"", shortname);
344
345 gamgi_gtk_dialog_message_create ("Error", message, window);
346
347 return FALSE;
348 }
349
350 gamgi_bool gamgi_io_error_read (char *filename,
351 gamgi_window *window)
352 {
353 char message[GAMGI_ENGINE_LINE];
354
355 sprintf (message,
356 "Unable to read file \"%s\"", filename);
357
358 gamgi_gtk_dialog_message_create ("Error", message, window);
359
360 return FALSE;
361 }
362
363 gamgi_bool gamgi_io_error_write (char *filename,
364 gamgi_window *window)
365 {
366 char message[GAMGI_ENGINE_LINE];
367
368 sprintf (message,
369 "Unable to write file \"%s\"", filename);
370
371 gamgi_gtk_dialog_message_create ("Error", message, window);
372
373 return FALSE;
374 }
375
376 gamgi_bool gamgi_io_error_plane (gamgi_window *window)
377 {
378 gamgi_gtk_dialog_message_create ("Error",
379 "Invalid atomic plane", window);
380
381 return FALSE;
382 }
383
384 gamgi_bool gamgi_io_error_direction (gamgi_window *window)
385 {
386 gamgi_gtk_dialog_message_create ("Error",
387 "Invalid atomic direction", window);
388
389 return FALSE;
390 }
391
392 gamgi_bool gamgi_io_error_local (gamgi_window *window)
393 {
394 gamgi_gtk_dialog_message_create ("Error",
395 "Invalid Local Path", window);
396
397 return FALSE;
398 }
399
400 gamgi_bool gamgi_io_error_remote (gamgi_window *window)
401 {
402 gamgi_gtk_dialog_message_create ("Error",
403 "Invalid Remote Path", window);
404
405 return FALSE;
406 }
407
408 gamgi_bool gamgi_io_error_browser (gamgi_window *window)
409 {
410 gamgi_gtk_dialog_message_create ("Error",
411 "Invalid Browser Path", window);
412
413 return FALSE;
414 }
415
416 void gamgi_io_error_list (gamgi_slist *start, gamgi_window *window)
417 {
418 gamgi_object *object;
419 gamgi_slist *slist;
420 char line[GAMGI_ENGINE_LINE];
421 char string[GAMGI_ENGINE_STRING];
422
423 if (start == NULL) return;
424
425 start = gamgi_engine_slist_invert (start);
426 sprintf (line, "The following objects could not be handled:\n");
427 for (slist = start; slist != NULL; slist = slist->next)
428 {
429 if (slist != start) strcat (line, ", ");
430 if (strlen (line) > GAMGI_ENGINE_LINE - GAMGI_ENGINE_STRING)
431 { strcat (line, "..."); break; }
432
433 object = GAMGI_CAST_OBJECT slist->data;
434 sprintf (string, "%s %d", object->name, object->number);
435 strcat (line, string);
436 }
437
438 gamgi_gtk_dialog_message_create ("Error", line, window);
439 gamgi_engine_slist_remove_all (start);
440 }