| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
#include <stdio.h> |
|---|
| 23 |
#include <stdlib.h> |
|---|
| 24 |
#include <stdarg.h> |
|---|
| 25 |
#include <errno.h> |
|---|
| 26 |
#include <err.h> |
|---|
| 27 |
#include <string.h> |
|---|
| 28 |
#include <libxml/globals.h> |
|---|
| 29 |
|
|---|
| 30 |
#include "libswish3.h" |
|---|
| 31 |
|
|---|
| 32 |
extern int SWISH_DEBUG; |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
static FILE *error_handle = NULL; |
|---|
| 36 |
|
|---|
| 37 |
void swish_set_error_handle( FILE *where ) |
|---|
| 38 |
{ |
|---|
| 39 |
error_handle = where; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
void swish_croak(const char *file, int line, const char *func, char *msgfmt,...) |
|---|
| 43 |
{ |
|---|
| 44 |
va_list args; |
|---|
| 45 |
|
|---|
| 46 |
if ( !error_handle ) |
|---|
| 47 |
error_handle = stderr; |
|---|
| 48 |
|
|---|
| 49 |
va_start (args,msgfmt); |
|---|
| 50 |
fprintf (error_handle, "Swish ERROR %s:%d %s: ", file, line, func); |
|---|
| 51 |
vfprintf (error_handle, msgfmt, args); |
|---|
| 52 |
fprintf (error_handle, "\n"); |
|---|
| 53 |
va_end (args); |
|---|
| 54 |
|
|---|
| 55 |
if(!errno) |
|---|
| 56 |
errno = 1; |
|---|
| 57 |
|
|---|
| 58 |
exit(errno); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
void swish_warn(const char *file, int line, const char *func, char *msgfmt,...) |
|---|
| 62 |
{ |
|---|
| 63 |
va_list args; |
|---|
| 64 |
|
|---|
| 65 |
if ( !error_handle ) |
|---|
| 66 |
error_handle = stderr; |
|---|
| 67 |
|
|---|
| 68 |
va_start (args,msgfmt); |
|---|
| 69 |
fprintf (error_handle, "Swish WARNING %s:%d %s: ", file, line, func); |
|---|
| 70 |
vfprintf (error_handle, msgfmt, args); |
|---|
| 71 |
fprintf (error_handle, "\n"); |
|---|
| 72 |
va_end (args); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
void swish_debug(const char *file, int line, const char *func, char *msgfmt,...) |
|---|
| 76 |
{ |
|---|
| 77 |
va_list args; |
|---|
| 78 |
|
|---|
| 79 |
if ( !error_handle ) |
|---|
| 80 |
error_handle = stderr; |
|---|
| 81 |
|
|---|
| 82 |
va_start (args,msgfmt); |
|---|
| 83 |
fprintf (error_handle, "Swish DEBUG %s:%d %s: ", file, line, func); |
|---|
| 84 |
vfprintf (error_handle, msgfmt, args); |
|---|
| 85 |
fprintf (error_handle, "\n"); |
|---|
| 86 |
va_end (args); |
|---|
| 87 |
} |
|---|