diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2008-12-21 17:09:49 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2008-12-21 17:09:49 +0100 |
commit | 07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976 (patch) | |
tree | d99410ede29d8f09f35351cc1beeb0866082ae57 /include | |
parent | 01e67d010b9badcf2ffc65d74b0f9285f26d45e5 (diff) | |
download | wolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.gz wolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.bz2 |
making log a little bit less leaking Unixisms
Diffstat (limited to 'include')
-rw-r--r-- | include/log.h | 66 | ||||
-rw-r--r-- | include/port/stdbool.h | 35 | ||||
-rw-r--r-- | include/port/sys.h | 119 | ||||
-rw-r--r-- | include/port/unused.h | 8 |
4 files changed, 228 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..58f9cbf --- /dev/null +++ b/include/log.h @@ -0,0 +1,66 @@ +#ifndef __LOG_H +#define __LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define log_EMERG 0 /* system is unusable */ +#define log_ALERT 1 /* action must be taken immediately */ +#define log_CRIT 2 /* critical conditions */ +#define log_ERR 3 /* error conditions */ +#define log_WARNING 4 /* warning conditions */ +#define log_NOTICE 5 /* normal but significant condition */ +#define log_INFO 6 /* informational */ +#define log_DEBUG 7 /* debug-level messages */ + +#define log_DEBUG1 ( log_DEBUG + 1 ) +#define log_DEBUG2 ( log_DEBUG + 2 ) +#define log_DEBUG3 ( log_DEBUG + 3 ) +#define log_DEBUG4 ( log_DEBUG + 4 ) +#define log_DEBUG5 ( log_DEBUG + 5 ) + +#define log_KERN (0<<3) /* kernel messages */ +#define log_USER (1<<3) /* random user-level messages */ +#define log_MAIL (2<<3) /* mail system */ +#define log_DAEMON (3<<3) /* system daemons */ +#define log_AUTH (4<<3) /* security/authorization messages */ +#define log_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define log_LPR (6<<3) /* line printer subsystem */ +#define log_NEWS (7<<3) /* network news subsystem */ +#define log_UUCP (8<<3) /* UUCP subsystem */ +#define log_CRON (9<<3) /* clock daemon */ +#define log_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define log_FTP (11<<3) /* ftp daemon */ + +const char *log_syslog_facility_to_str( int facility ); + +int log_str_to_syslog_facility( const char *facility ); + +const char *log_level_to_str( int level ); + +int log_str_to_level( const char *level ); + +void openlogtofile( const char *filename, int level ); + +void openlogtosyslog( const char *ident, int facility, int level ); + +void openlogtostderr( int level ); + +void closelogtofile( void ); + +void closelogtosyslog( void ); + +void closelogtostderr( void ); + +void reopenlogtofile( void ); + +void reopenlogtosyslog( void ); + +void LOG( int level, const char *format, ... ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/port/stdbool.h b/include/port/stdbool.h new file mode 100644 index 0000000..e17c657 --- /dev/null +++ b/include/port/stdbool.h @@ -0,0 +1,35 @@ +#ifndef __STDBOOL_H +#define __STDBOOL_H + +#include "port/sys.h" + +/* C99 Boolean types for compilers without C99 support, see + * http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */ + +/* don't define bool in C++, it exists already! */ +#ifndef __cplusplus + +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#else + +#if !defined HAVE_ENUM_BOOL +typedef enum { + _Bool_must_promote_to_int = -1, + false = 0, + true = 1 +} _Bool; +#endif /* !defined HAVE_ENUM_BOOL */ + +#define bool _Bool + +#define true 1 +#define false 0 + +#define __bool_true_false_are_defined 1 + +#endif /* ifdef HAVE_STDBOOL_H */ + +#endif /* ifndef __cplusplus */ + +#endif /* ifndef STDBOOL_H */ diff --git a/include/port/sys.h b/include/port/sys.h new file mode 100644 index 0000000..65b68e2 --- /dev/null +++ b/include/port/sys.h @@ -0,0 +1,119 @@ +#if defined LINUX +#if OS_MAJOR_VERSION == 2 +#if OS_MINOR_VERSION == 6 +#define _XOPEN_SOURCE 600 +#define HAVE_STDBOOL_H +#define HAVE_STDINT_H +#define HAVE_VSNPRINTF +#define HAVE_SNPRINTF +#define HAVE_VASPRINTF +#define HAVE_ASPRINTF +#define HAVE_STRDUP +#define HAVE_LOCKF +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 6 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 2 */ +#endif /* defined LINUX */ + +#if defined FREEBSD +#if OS_MAJOR_VERSION == 7 +#if OS_MINOR_VERSION == 0 +#define _XOPEN_SOURCE 600 +#define HAVE_STDBOOL_H +#define HAVE_STDINT_H +#define HAVE_VSNPRINTF +#define HAVE_SNPRINTF +#define HAVE_VASPRINTF +#define HAVE_ASPRINTF +#define HAVE_STRDUP +#define HAVE_LOCKF +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 0 */ +#else +#if OS_MAJOR_VERSION == 6 +#if OS_MINOR_VERSION == 2 +#define _XOPEN_SOURCE 600 +#define HAVE_STDBOOL_H +#define HAVE_STDINT_H +#define HAVE_VSNPRINTF +#define HAVE_SNPRINTF +#define HAVE_STRDUP +#define HAVE_LOCKF +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 2 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 6 */ +#endif /* defined OS_MAJOR_VERSION == 7 */ +#endif /* defined FREEBSD */ + +#if defined OPENBSD +#if OS_MAJOR_VERSION == 4 +#if OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 3 +#define _XOPEN_SOURCE 600 +#define HAVE_STDBOOL_H +#define HAVE_STDINT_H +#define HAVE_VSNPRINTF +#define HAVE_SNPRINTF +#define HAVE_VASPRINTF +#define HAVE_ASPRINTF +#define HAVE_STRDUP +#define HAVE_LOCKF +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 3 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 4 */ +#endif /* defined OPENBSD */ + +#if defined SUNOS +#if OS_MAJOR_VERSION == 5 +#if OS_MINOR_VERSION == 8 +#if !defined __cplusplus +#define _XOPEN_SOURCE 600 +#define __EXTENSIONS__ +#endif +#define HAVE_SNPRINTF +#define HAVE_VSNPRINTF +#define HAVE_LOCKF +#define HAVE_ENUM_BOOL +#define HAVE_LINK_H +#else +#if OS_MINOR_VERSION == 10 +#if !defined __cplusplus +#define _XOPEN_SOURCE 600 +#define __EXTENSIONS__ +#endif +#define HAVE_SNPRINTF +#define HAVE_VSNPRINTF +#define HAVE_LOCKF +#define HAVE_STDBOOL_H +#define HAVE_STDINT_H +#define HAVE_STRERROR_R +#else + #error unknown platform +#endif /* OS_MINOR_VERSION == 10 */ +#endif /* OS_MINOR_VERSION == 8 */ +#else + #error unknown platform +#endif /* OS_MAJOR_VERSION == 5 */ +#endif /* defined SUNOS */ + +#if defined CYGWIN +#if OS_MAJOR_VERSION == 5 +#if OS_MINOR_VERSION == 0 +#define _XOPEN_SOURCE 600 +#define HAVE_ENUM_BOOL +#else + #error unknown platform +#endif /* OS_MINOR_VERSION == 0 */ +#else + #error unknown platform +#endif /* OS_MAJOR_VERSION == 5 */ +#endif /* defined CYGWIN */ diff --git a/include/port/unused.h b/include/port/unused.h new file mode 100644 index 0000000..c7692f6 --- /dev/null +++ b/include/port/unused.h @@ -0,0 +1,8 @@ +#ifndef __UNUSED_H +#define __UNUSED_H + +#include "port/sys.h" + +#define UNUSED( x ) if( 0 && (x) ) { } + +#endif /* ifndef __UNUSED_H */ |