00001 #ifndef LIBNAGIOS_lnag_utils_h__
00002 #define LIBNAGIOS_lnag_utils_h__
00003
00004 #include <unistd.h>
00005 #include <stdlib.h>
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define NAGIOS_MKVERSION(a, b, c) \
00018 (((a) * 10000) + ((b) * 100) + (c))
00019
00020 #ifdef __cplusplus
00021
00022 # define NAGIOS_BEGIN_DECL extern "C" {
00023
00024
00025
00026
00027 # define NAGIOS_END_DECL }
00028 #else
00029
00030 # define NAGIOS_BEGIN_DECL
00031
00032 # define NAGIOS_END_DECL
00033 #endif
00034
00035 #ifndef NODOXY
00036 # ifndef __GNUC__
00037 # define GCC_VERSION 0
00038 # define __attribute__(x)
00039 # else
00040 # ifdef __GNUC_PATCHLEVEL__
00041 # define GCC_VERSION NAGIOS_MKVERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
00042 # else
00043 # define GCC_VERSION NAGIOS_MKVERSION(__GNUC__, __GNUC_MINOR__, 0)
00044 # endif
00045 # endif
00046 #endif
00047
00048 #if GCC_VERSION >= NAGIOS_MKVERSION(4, 5, 0)
00049 # define NAGIOS_DEPRECATED(version, hint) \
00050 __attribute__((deprecated("This function will be removed in Nagios v" #version ". Please use " #hint " instead")))
00051 #else
00052
00053 # define NAGIOS_DEPRECATED(version, hint) \
00054 __attribute__((deprecated))
00055 #endif
00056
00057
00058
00059
00060 #define OK 0
00061 #define ERROR -2
00062
00063 #ifdef FALSE
00064 #undef FALSE
00065 #endif
00066 #define FALSE 0
00067
00068 #ifdef TRUE
00069 #undef TRUE
00070 #endif
00071 #define TRUE (!FALSE)
00072
00073
00074 #define my_free(ptr) do { if(ptr) { free(ptr); ptr = NULL; } } while(0)
00075
00076 #ifndef ARRAY_SIZE
00077
00078 # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
00079 #endif
00080 #ifndef veclen
00081
00082 # define veclen ARRAY_SIZE
00083 #endif
00084
00085 #ifndef offsetof
00086
00087 # define offsetof(t, f) ((unsigned long)&((t *)0)->f)
00088 #endif
00089
00090
00091 #define CHAR_MAP_INIT(k) { \
00092 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00093 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00094 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00095 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00096 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00097 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00098 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00099 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00100 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00101 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00102 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00103 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00104 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00105 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00106 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00107 k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \
00108 }
00109
00110
00111 #endif