Diffstat (limited to 'libical/src/libical/icalerror.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icalerror.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libical/src/libical/icalerror.h b/libical/src/libical/icalerror.h index 52f5ba9..826c8e8 100644 --- a/libical/src/libical/icalerror.h +++ b/libical/src/libical/icalerror.h | |||
@@ -35,51 +35,55 @@ | |||
35 | #include "config.h" | 35 | #include "config.h" |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define ICAL_SETERROR_ISFUNC | 38 | #define ICAL_SETERROR_ISFUNC |
39 | 39 | ||
40 | 40 | ||
41 | /* This routine is called before any error is triggered. It is called | 41 | /** This routine is called before any error is triggered. It is called |
42 | by icalerror_set_errno, so it does not appear in all of the macros | 42 | by icalerror_set_errno, so it does not appear in all of the macros |
43 | below */ | 43 | below */ |
44 | void icalerror_stop_here(void); | 44 | void icalerror_stop_here(void); |
45 | 45 | ||
46 | void icalerror_crash_here(void); | 46 | void icalerror_crash_here(void); |
47 | 47 | ||
48 | typedef enum icalerrorenum { | 48 | typedef enum icalerrorenum { |
49 | 49 | ICAL_NO_ERROR, /* icalerrno may not be initialized - put it first so and pray that the compiler initialize things to zero */ | |
50 | ICAL_BADARG_ERROR, | 50 | ICAL_BADARG_ERROR, |
51 | ICAL_NEWFAILED_ERROR, | 51 | ICAL_NEWFAILED_ERROR, |
52 | ICAL_ALLOCATION_ERROR, | 52 | ICAL_ALLOCATION_ERROR, |
53 | ICAL_MALFORMEDDATA_ERROR, | 53 | ICAL_MALFORMEDDATA_ERROR, |
54 | ICAL_PARSE_ERROR, | 54 | ICAL_PARSE_ERROR, |
55 | ICAL_INTERNAL_ERROR, /* Like assert --internal consist. prob */ | 55 | ICAL_INTERNAL_ERROR, /* Like assert --internal consist. prob */ |
56 | ICAL_FILE_ERROR, | 56 | ICAL_FILE_ERROR, |
57 | ICAL_USAGE_ERROR, | 57 | ICAL_USAGE_ERROR, |
58 | ICAL_UNIMPLEMENTED_ERROR, | 58 | ICAL_UNIMPLEMENTED_ERROR, |
59 | ICAL_UNKNOWN_ERROR, /* Used for problems in input to icalerror_strerror()*/ | 59 | ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror()*/ |
60 | ICAL_NO_ERROR | ||
61 | 60 | ||
62 | } icalerrorenum; | 61 | } icalerrorenum; |
63 | 62 | ||
64 | /* The libical error enumeration, like errno*/ | 63 | icalerrorenum * icalerrno_return(void); |
65 | extern icalerrorenum icalerrno; | 64 | #define icalerrno (*(icalerrno_return())) |
66 | 65 | ||
67 | /* If true, libicl aborts after a call to icalerror_set_error*/ | 66 | /** If true, libicl aborts after a call to icalerror_set_error |
67 | * | ||
68 | * @warning NOT THREAD SAFE -- recommended that you do not change | ||
69 | * this in a multithreaded program. | ||
70 | */ | ||
68 | extern int icalerror_errors_are_fatal; | 71 | extern int icalerror_errors_are_fatal; |
69 | 72 | ||
70 | /* Warning messages */ | 73 | /* Warning messages */ |
71 | 74 | ||
72 | #ifdef __GNUC__ca | 75 | #ifdef __GNUC__ca |
73 | #define icalerror_warn(message) {fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);} | 76 | #define icalerror_warn(message) {fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);} |
74 | #else /* __GNU_C__ */ | 77 | #else /* __GNU_C__ */ |
75 | #define icalerror_warn(message) {fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);} | 78 | #define icalerror_warn(message) {fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);} |
76 | #endif /* __GNU_C__ */ | 79 | #endif /* __GNU_C__ */ |
77 | 80 | ||
78 | 81 | ||
79 | void icalerror_clear_errno(void); | 82 | void icalerror_clear_errno(void); |
83 | void _icalerror_set_errno(icalerrorenum); | ||
80 | 84 | ||
81 | /* Make an individual error fatal or non-fatal. */ | 85 | /* Make an individual error fatal or non-fatal. */ |
82 | typedef enum icalerrorstate { | 86 | typedef enum icalerrorstate { |
83 | ICAL_ERROR_FATAL, /* Not fata */ | 87 | ICAL_ERROR_FATAL, /* Not fata */ |
84 | ICAL_ERROR_NONFATAL, /* Fatal */ | 88 | ICAL_ERROR_NONFATAL, /* Fatal */ |
85 | ICAL_ERROR_DEFAULT, /* Use the value of icalerror_errors_are_fatal*/ | 89 | ICAL_ERROR_DEFAULT, /* Use the value of icalerror_errors_are_fatal*/ |
@@ -91,20 +95,21 @@ char* icalerror_perror(); | |||
91 | void icalerror_set_error_state( icalerrorenum error, icalerrorstate); | 95 | void icalerror_set_error_state( icalerrorenum error, icalerrorstate); |
92 | icalerrorstate icalerror_get_error_state( icalerrorenum error); | 96 | icalerrorstate icalerror_get_error_state( icalerrorenum error); |
93 | 97 | ||
94 | #ifndef ICAL_SETERROR_ISFUNC | 98 | #ifndef ICAL_SETERROR_ISFUNC |
95 | #define icalerror_set_errno(x) \ | 99 | #define icalerror_set_errno(x) \ |
96 | icalerrno = x; \ | 100 | icalerrno = x; \ |
101 | fprintf(stderr,"Ical error # %d\n", x); \ | ||
97 | if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \ | 102 | if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \ |
98 | (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \ | 103 | (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \ |
99 | icalerror_errors_are_fatal == 1 )){ \ | 104 | icalerror_errors_are_fatal == 1 )){ \ |
100 | icalerror_warn(icalerror_strerror(x)); \ | 105 | icalerror_warn(icalerror_strerror(x)); \ |
101 | assert(0); \ | 106 | assert(0); \ |
102 | } | 107 | } |
103 | #else | 108 | #else |
104 | void icalerror_set_errno(icalerrorenum); | 109 | void icalerror_set_errno(icalerrorenum x); |
105 | #endif | 110 | #endif |
106 | 111 | ||
107 | #ifdef ICAL_ERRORS_ARE_FATAL | 112 | #ifdef ICAL_ERRORS_ARE_FATAL |
108 | #undef NDEBUG | 113 | #undef NDEBUG |
109 | #endif | 114 | #endif |
110 | 115 | ||