[go: up one dir, main page]

Menu

[72b583]: / pslib / src / ps_error.c  Maximize  Restore  History

Download this file

39 lines (30 with data), 815 Bytes

 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
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "ps_intern.h"
/* _ps_errorhandler() {{{
* Default error handler, set if none is provided by application.
*/
void _ps_errorhandler(PSDoc *p, int error, const char *str, void *data) {
fprintf(stderr, "PSLib: %s\n", str);
}
/* }}} */
/* ps_error() {{{
* Output an error using the errorhandler for the given document.
*/
void ps_error(PSDoc *p, int type, const char *fmt, ...) {
char msg[256];
va_list ap;
if(type == PS_Warning && p->warnings == ps_false)
return;
va_start(ap, fmt);
vsprintf(msg, fmt, ap);
if (!p->in_error) {
p->in_error = 1; /* avoid recursive errors */
(p->errorhandler)(p, type, msg, p->user_data);
}
/* If the error handler returns the error was non-fatal */
p->in_error = 0;
va_end(ap);
}
/* }}} */