"Fossies" - the Fresh Open Source Software Archive 
Member "libspf2-1.2.10/src/include/spf_log.h" (28 Jan 2012, 5096 Bytes) of package /linux/privat/libspf2-1.2.10.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.
For more information about "spf_log.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of either:
4 *
5 * a) The GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1, or (at your option) any
7 * later version,
8 *
9 * OR
10 *
11 * b) The two-clause BSD license.
12 *
13 * These licenses can be found with the distribution in the file LICENSES
14 */
15
16
17
18 #ifndef INC_SPF_LOG
19 #define INC_SPF_LOG
20
21 /**
22 * @file
23 * Error messages and warnings generated internally by the library call
24 * these routines. By default, the messages go to stderr, but you can
25 * define your own routines to deal with the messages instead.
26 *
27 * To use the syslog routines, add code such as:
28 *
29 * openlog(logPrefix,LOG_PID|LOG_CONS|LOG_NDELAY|LOG_NOWAIT,LOG_MAIL);
30 *
31 * SPF_error_handler = SPF_error_syslog;
32 * SPF_warning_handler = SPF_warning_syslog;
33 * SPF_info_handler = SPF_info_syslog;
34 * SPF_debug_handler = SPF_debug_syslog;
35 */
36
37 #include <stdarg.h>
38
39
40 #define SPF_error(errmsg) SPF_errorx( __FILE__, __LINE__, "%s", errmsg )
41 void SPF_errorx( const char *file, int line, const char *format, ... ) __attribute__ ((noreturn)) __attribute__ ((format (printf, 3, 4)));
42 void SPF_errorx2( const char *format, ... );
43 void SPF_errorv( const char *file, int line, const char *format, va_list ap ) __attribute__ ((noreturn)) __attribute__ ((format (printf, 3, 0)));
44
45 #define SPF_warning(errmsg) SPF_warningx( __FILE__, __LINE__, "%s", errmsg )
46 void SPF_warningx( const char *file, int line, const char *format, ... ) __attribute__ ((format (printf, 3, 4)));
47 void SPF_warningx2( const char *format, ... );
48 void SPF_warningv( const char *file, int line, const char *format, va_list ap ) __attribute__ ((format (printf, 3, 0)));
49
50 #define SPF_info(errmsg) SPF_infox( __FILE__, __LINE__, "%s", errmsg )
51 void SPF_infox( const char *file, int line, const char *format, ... ) __attribute__ ((format (printf, 3, 4)));
52 void SPF_infox2( const char *format, ... );
53 void SPF_infov( const char *file, int line, const char *format, va_list ap ) __attribute__ ((format (printf, 3, 0)));
54
55 #define SPF_debug(errmsg) SPF_debugx( __FILE__, __LINE__, "%s", errmsg )
56 void SPF_debugx( const char *file, int line, const char *format, ... ) __attribute__ ((format (printf, 3, 4)));
57 void SPF_debugx2( const char *format, ... );
58 void SPF_debugv( const char *file, int line, const char *format, va_list ap ) __attribute__ ((format (printf, 3, 0)));
59
60
61 #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
62
63 #define SPF_errorf(format, ... ) SPF_errorx( __FILE__, __LINE__, format, __VA_ARGS__ )
64 #define SPF_warningf(format, ... ) SPF_warningx( __FILE__, __LINE__, format, __VA_ARGS__ )
65 #define SPF_infof(format, ... ) SPF_infox( __FILE__, __LINE__, format, __VA_ARGS__ )
66 #define SPF_debugf(format, ... ) SPF_debugx( __FILE__, __LINE__, format, __VA_ARGS__ )
67
68 #elif defined( __GNUC__ )
69
70 #define SPF_errorf(format... ) SPF_errorx( __FILE__, __LINE__, format )
71 #define SPF_warningf(format... ) SPF_warningx( __FILE__, __LINE__, format )
72 #define SPF_infof(format... ) SPF_infox( __FILE__, __LINE__, format )
73 #define SPF_debugf(format... ) SPF_debugx( __FILE__, __LINE__, format )
74
75 #else
76
77 #define SPF_errorf SPF_errorx2
78 #define SPF_warningf SPF_warningx2
79 #define SPF_infof SPF_infox2
80 #define SPF_debugf SPF_debugx2
81
82 #endif
83
84
85 /* These message handler routines print to stderr or stdout, as appropriate. */
86
87 void SPF_error_stdio( const char *file, int line, const char *errmsg ) __attribute__ ((noreturn));
88 void SPF_warning_stdio( const char *file, int line, const char *errmsg );
89 void SPF_info_stdio( const char *file __attribute__ ((unused)), int line __attribute__ ((unused)), const char *errmsg );
90 void SPF_debug_stdio( const char *file, int line, const char *errmsg );
91
92
93 /* These message handler routines send messages to syslog */
94
95 void SPF_error_syslog( const char *file, int line, const char *errmsg ) __attribute__ ((noreturn));
96 void SPF_warning_syslog( const char *file, int line, const char *errmsg );
97 void SPF_info_syslog( const char *file __attribute__ ((unused)), int line __attribute__ ((unused)), const char *errmsg );
98 void SPF_debug_syslog( const char *file, int line, const char *errmsg );
99
100 /* FYI only -- can't be changed without recompiling the library */
101 #define SPF_DEFAULT_ERROR_HANDLER SPF_error_stdio
102 #define SPF_DEFAULT_WARNING_HANDLER SPF_warning_stdio
103 #define SPF_DEFAULT_INFO_HANDLER SPF_info_stdio
104 #define SPF_DEFAULT_DEBUG_HANDLER SPF_debug_stdio
105
106
107 /*
108 * You can assign these global function pointers to whatever routines
109 * you want to handle the various types of messages. Setting them to NULL
110 * will cause the messages to be ignored.
111 */
112
113 extern void (*SPF_error_handler)( const char *, int, const char * ) __attribute__ ((noreturn));
114 extern void (*SPF_warning_handler)( const char *, int, const char * );
115 extern void (*SPF_info_handler)( const char *, int, const char * );
116 extern void (*SPF_debug_handler)( const char *, int, const char * );
117
118 #define SPF_ASSERT_NOTNULL(x) \
119 do { if ((x) == NULL) SPF_error(#x " is NULL"); } while(0)
120
121
122
123
124 #endif