1
/* Header file with global definitions for the whole
2
* rsyslog project (including all subprojects like
4
* Begun 2005-09-15 RGerhards
6
#ifndef INCLUDED_RSYSLOG_H
7
#define INCLUDED_RSYSLOG_H
9
/* ############################################################# *
10
* # Config Settings # *
11
* ############################################################# */
12
#define RS_STRINGBUF_ALLOC_INCREMENT 128
14
/* ############################################################# *
15
* # End Config Settings # *
16
* ############################################################# */
19
# undef _LARGEFILE_SOURCE
20
# undef _LARGEFILE64_SOURCE
21
# undef _FILE_OFFSET_BITS
22
# define _LARGEFILE_SOURCE
23
# define _LARGEFILE64_SOURCE
24
# define _FILE_OFFSET_BITS 64
28
# define _GNU_SOURCE 1
31
/* The error codes below are orginally "borrowed" from
32
* liblogging. As such, we reserve values up to -2999
33
* just in case we need to borrow something more ;)
35
enum rsRetVal_ /** return value. All methods return this if not specified otherwise */
37
RS_RET_NOT_IMPLEMENTED = -7, /**< implementation is missing (probably internal error or lazyness ;)) */
38
RS_RET_OUT_OF_MEMORY = -6, /**< memory allocation failed */
39
RS_RET_PROVIDED_BUFFER_TOO_SMALL = -50,/**< the caller provided a buffer, but the called function sees the size of this buffer is too small - operation not carried out */
42
RS_RET_ERR = -3000, /**< generic failure */
43
RS_TRUNCAT_TOO_LARGE = -3001, /**< truncation operation where too many chars should be truncated */
44
RS_RET_FOUND_AT_STRING_END = -3002, /**< some value found, but at the last pos of string */
45
RS_RET_NOT_FOUND = -3003, /**< some requested value not found */
46
RS_RET_MISSING_TRAIL_QUOTE = -3004, /**< an expected trailing quote is missing */
47
RS_RET_NO_DIGIT = -3005, /**< an digit was expected, but none found (mostly parsing) */
48
RS_RET_NO_MORE_DATA = -3006, /**< insufficient data, e.g. end of string during parsing */
49
RS_RET_INVALID_IP = -3007, /**< invalid ip found where valid was expected */
50
RS_RET_OBJ_CREATION_FAILED = - 3008, /**< the creation of an object failed (no details available) */
51
RS_RET_PARAM_ERROR = -1000, /**< invalid parameter in call to function */
52
RS_RET_MISSING_INTERFACE = -1001,/**< interface version mismatch, required missing */
53
/* return states for config file processing */
54
RS_RET_NONE = -2000, /**< some value is not available - not necessarily an error */
55
RS_RET_CONFLINE_UNPROCESSED = -2001,/**< config line was not processed, pass to other module */
56
RS_RET_DISCARDMSG = -2002, /**< discard message (no error state, processing request!) */
57
RS_RET_INCOMPATIBLE = -2003, /**< function not compatible with requested feature */
58
RS_RET_NOENTRY = -2004, /**< do not create an entry for (whatever) - not necessary an error */
59
RS_RET_NO_SQL_STRING = -2005, /**< string is not suitable for use as SQL */
60
RS_RET_DISABLE_ACTION = -2006, /**< action requests that it be disabled */
61
RS_RET_SUSPENDED = -2007, /**< something was suspended, not neccesarily an error */
62
RS_RET_RQD_TPLOPT_MISSING = -2008,/**< a required template option is missing */
63
RS_RET_INVALID_VALUE = -2009,/**< some value is invalid (e.g. user-supplied data) */
64
RS_RET_INVALID_INT = -2010,/**< invalid integer */
65
RS_RET_INVALID_CMD = -2011,/**< invalid command */
66
RS_RET_VAL_OUT_OF_RANGE = -2012, /**< value out of range */
67
RS_RET_FOPEN_FAILURE = -2013, /**< failure during fopen, for example file not found - see errno */
68
RS_RET_END_OF_LINKEDLIST = -2014, /**< end of linked list, not an error, but a status */
69
RS_RET_CHAIN_NOT_PERMITTED = -2015, /**< chaining (e.g. of config command handlers) not permitted */
70
RS_RET_INVALID_PARAMS = -2016,/**< supplied parameters are invalid */
71
RS_RET_EMPTY_LIST = -2017, /**< linked list is empty */
72
RS_RET_FINISHED = -2018, /**< some opertion is finished, not an error state */
73
RS_RET_INVALID_SOURCE = -2019, /**< source (address) invalid for some reason */
74
RS_RET_ADDRESS_UNKNOWN = -2020, /**< an address is unknown - not necessarily an error */
75
RS_RET_MALICIOUS_ENTITY = -2021, /**< there is an malicious entity involved */
76
RS_RET_OK = 0 /**< operation successful */
78
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */
80
/* some helpful macros to work with srRetVals.
81
* Be sure to call the to-be-returned variable always "iRet" and
82
* the function finalizer always "finalize_it".
84
#define CHKiRet(code) if((iRet = code) != RS_RET_OK) goto finalize_it
85
/* macro below is to be used if we need our own handling, eg for cleanup */
86
#define CHKiRet_Hdlr(code) if((iRet = code) != RS_RET_OK)
87
/* macro below is used in conjunction with CHKiRet_Hdlr, else use ABORT_FINALIZE */
88
#define FINALIZE goto finalize_it;
89
#define DEFiRet rsRetVal iRet = RS_RET_OK
90
#define ABORT_FINALIZE(errCode) \
96
/** Object ID. These are for internal checking. Each
97
* object is assigned a specific ID. This is contained in
98
* all Object structs (just like C++ RTTI). We can use
99
* this field to see if we have been passed a correct ID.
100
* Other than that, there is currently no other use for
105
OIDrsFreed = -1, /**< assigned, when an object is freed. If this
106
* is seen during a method call, this is an
107
* invalid object pointer!
109
OIDrsInvalid = 0, /**< value created by calloc(), so do not use ;) */
110
/* The 0xEFCD is a debug aid. It helps us find object IDs in memory
111
* dumps (on X86, this is CDEF in the dump ;)
112
* If you are on an embedded device and you would like to save space
113
* make them 1 byte only.
115
OIDrsCStr = 0xEFCD0001,
116
OIDrsPars = 0xEFCD0002
118
typedef enum rsObjectID rsObjID;
120
/* support to set object types */
122
#define rsSETOBJTYPE(pObj, type)
123
#define rsCHECKVALIDOBJECT(x, type)
125
#define rsSETOBJTYPE(pObj, type) pObj->OID = type;
126
#define rsCHECKVALIDOBJECT(x, type) {assert(x != NULL); assert(x->OID == type);}
130
* This macro should be used to free objects.
131
* It aids in interpreting dumps during debugging.
134
#define RSFREEOBJ(x) free(x)
136
#define RSFREEOBJ(x) {(x)->OID = OIDrsFreed; free(x);}
139
/* get rid of the unhandy "unsigned char"
141
typedef unsigned char uchar;
143
/* for the time being, we do our own portability handling here. It
144
* looks like autotools either does not yet support checks for it, or
145
* I wasn't smart enough to find them ;) rgerhards, 2007-07-18
148
# define __attribute__(x) /*NOTHING*/
151
#endif /* multi-include protection */