Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
icalerror.h
Go to the documentation of this file.
1/*======================================================================
2 FILE: icalerror.h
3 CREATOR: eric 09 May 1999
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7======================================================================*/
8
9#ifndef ICALERROR_H
10#define ICALERROR_H
11
12#include "libical_ical_export.h"
13
14#include <assert.h>
15#include <stdbool.h>
16#include <stdio.h>
17
29
40LIBICAL_ICAL_EXPORT void icalerror_stop_here(void);
41
48LIBICAL_ICAL_EXPORT void icalerror_crash_here(void);
49
50#ifndef _MSC_VER
51#pragma GCC visibility push(default)
52#endif
63typedef enum icalerrorenum
64{
67
70
73
76
79
82
84 ICAL_INTERNAL_ERROR, /* Like assert --internal consist. prob */
85
88
91
94
96 ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror() */
98#ifndef _MSC_VER
99#pragma GCC visibility pop
100#endif
101
114LIBICAL_ICAL_EXPORT icalerrorenum *icalerror_icalerrno(void);
115
132#define icalerrno (*(icalerror_icalerrno()))
133
146LIBICAL_ICAL_EXPORT void icalerror_set_errors_are_fatal(bool fatal);
147
161LIBICAL_ICAL_EXPORT bool icalerror_get_errors_are_fatal(void);
162
163/* Warning messages */
164
175
176#ifdef __GNUC__
177#define icalerror_warn(message) \
178 { \
179 icalerrprintf("%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message); \
180 }
181#else /* __GNU_C__ */
182#define icalerror_warn(message) \
183 { \
184 icalerrprintf("%s:%d: %s\n", __FILE__, __LINE__, message); \
185 }
186#endif /* __GNU_C__ */
187
199LIBICAL_ICAL_EXPORT void icalerror_clear_errno(void);
200
220
241LIBICAL_ICAL_EXPORT const char *icalerror_strerror(icalerrorenum e);
242
261LIBICAL_ICAL_EXPORT const char *icalerror_perror(void);
262
274LIBICAL_ICAL_EXPORT void icalerror_backtrace(void);
275
289LIBICAL_ICAL_EXPORT void icalerror_set_error_state(icalerrorenum error, icalerrorstate state);
290
297
313LIBICAL_ICAL_EXPORT icalerrorenum icalerror_error_from_string(const char *str);
314
329LIBICAL_ICAL_EXPORT void icalerror_set_errno(icalerrorenum x);
330
331#define icalerror_check_value_type(value, type) ;
332#define icalerror_check_property_type(value, type) ;
333#define icalerror_check_parameter_type(value, type) ;
334#define icalerror_check_component_type(value, type) ;
335
336/* Assert with a message */
348
349#ifdef __GNUC__
350#define icalerror_assert(test, message) \
351 if (icalerror_get_errors_are_fatal() && !(test)) { \
352 icalerrprintf("%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message); \
353 icalerror_stop_here(); \
354 abort(); \
355 }
356#else /*__GNUC__*/
357#define icalerror_assert(test, message) \
358 if (icalerror_get_errors_are_fatal() && !(test)) { \
359 icalerrprintf("%s:%d: %s\n", __FILE__, __LINE__, message); \
360 icalerror_stop_here(); \
361 abort(); \
362 }
363#endif /*__GNUC__*/
364
383#define icalerror_check_arg(test, arg) \
384 if (!(test)) { \
385 icalerror_set_errno(ICAL_BADARG_ERROR); \
386 }
387
407#define icalerror_check_arg_rv(test, arg) \
408 if (!(test)) { \
409 icalerror_set_errno(ICAL_BADARG_ERROR); \
410 return; \
411 }
412
433#define icalerror_check_arg_rz(test, arg) \
434 if (!(test)) { \
435 icalerror_set_errno(ICAL_BADARG_ERROR); \
436 return 0; \
437 }
438
460#define icalerror_check_arg_re(test, arg, error) \
461 if (!(test)) { \
462 icalerror_stop_here(); \
463 icalassert(0); \
464 return error; \
465 }
466
488#define icalerror_check_arg_rx(test, arg, x) \
489 if (!(test)) { \
490 icalerror_set_errno(ICAL_BADARG_ERROR); \
491 return x; \
492 }
493
494/* String interfaces to set an error to NONFATAL and restore it to its original value */
495
511LIBICAL_ICAL_EXPORT icalerrorstate icalerror_supress(const char *error);
512
531LIBICAL_ICAL_EXPORT void icalerror_restore(const char *error, icalerrorstate es);
532
533#endif /* !ICALERROR_H */
void icalerror_crash_here(void)
Triggered to abort the process.
Definition icalerror.c:73
void icalerror_set_errors_are_fatal(bool fatal)
Change if errors are fatal.
Definition icalerror.c:100
icalerrorenum * icalerror_icalerrno(void)
Returns the current icalerrno value.
Definition icalerror.c:39
bool icalerror_get_errors_are_fatal(void)
Determine if errors are fatal.
Definition icalerror.c:105
icalerrorstate
Determine if an error is fatal or non-fatal.
Definition icalerror.h:207
@ ICAL_ERROR_UNKNOWN
Definition icalerror.h:218
@ ICAL_ERROR_FATAL
Definition icalerror.h:209
@ ICAL_ERROR_DEFAULT
Definition icalerror.h:215
@ ICAL_ERROR_NONFATAL
Definition icalerror.h:212
const char * icalerror_perror(void)
Returns the description string for the current error in icalerrno.
Definition icalerror.c:197
icalerrorstate icalerror_get_error_state(icalerrorenum error)
Gets the error state (severity) for a given error.
Definition icalerror.c:222
icalerrorenum
Represents the different types of errors that can be triggered in libical.
Definition icalerror.h:64
@ ICAL_NEWFAILED_ERROR
Definition icalerror.h:72
@ ICAL_BADARG_ERROR
Definition icalerror.h:69
@ ICAL_FILE_ERROR
Definition icalerror.h:87
@ ICAL_ALLOCATION_ERROR
Definition icalerror.h:75
@ ICAL_INTERNAL_ERROR
Definition icalerror.h:84
@ ICAL_NO_ERROR
Definition icalerror.h:66
@ ICAL_MALFORMEDDATA_ERROR
Definition icalerror.h:78
@ ICAL_UNKNOWN_ERROR
Definition icalerror.h:96
@ ICAL_PARSE_ERROR
Definition icalerror.h:81
@ ICAL_UNIMPLEMENTED_ERROR
Definition icalerror.h:93
@ ICAL_USAGE_ERROR
Definition icalerror.h:90
void icalerror_backtrace(void)
Prints backtrace.
Definition icalerror.c:248
void icalerror_set_error_state(icalerrorenum error, icalerrorstate state)
Sets the icalerrorstate for a given icalerrorenum error.
Definition icalerror.c:211
const char * icalerror_strerror(icalerrorenum e)
Finds the description string for error.
Definition icalerror.c:235
void icalerror_set_errno(icalerrorenum x)
Sets the icalerrno to a given error.
Definition icalerror.c:110
void icalerror_restore(const char *error, icalerrorstate es)
Definition icalerror.c:202
void icalerror_stop_here(void)
Triggered before any error is called.
Definition icalerror.c:68
icalerrorenum icalerror_error_from_string(const char *str)
Reads an error from a string.
Definition icalerror.c:169
void icalerror_clear_errno(void)
Resets icalerrno to ICAL_NO_ERROR.
Definition icalerror.c:93
icalerrorstate icalerror_supress(const char *error)
Suppresses a given error.
Definition icalerror.c:182