1 /* The ruleset object. 2 * 3 * This implements rulesets within rsyslog. 4 * 5 * Copyright 2009-2021 Rainer Gerhards and Adiscon GmbH. 6 * 7 * This file is part of the rsyslog runtime library. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * -or- 15 * see COPYING.ASL20 in the source distribution 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 */ 23 #ifndef INCLUDED_RULESET_H 24 #define INCLUDED_RULESET_H 25 26 #include "queue.h" 27 #include "linkedlist.h" 28 #include "rsconf.h" 29 30 /* the ruleset object */ 31 struct ruleset_s { 32 BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ 33 uchar *pszName; /* name of our ruleset */ 34 qqueue_t *pQueue; /* "main" message queue, if the ruleset has its own (else NULL) */ 35 struct cnfstmt *root; 36 struct cnfstmt *last; 37 parserList_t *pParserLst;/* list of parsers to use for this ruleset */ 38 }; 39 40 /* interfaces */ 41 BEGINinterface(ruleset) /* name must also be changed in ENDinterface macro! */ 42 INTERFACEObjDebugPrint(ruleset); 43 rsRetVal (*DebugPrintAll)(rsconf_t *conf); 44 rsRetVal (*Construct)(ruleset_t **ppThis); 45 rsRetVal (*ConstructFinalize)(rsconf_t *conf, ruleset_t __attribute__((unused)) *pThis); 46 rsRetVal (*Destruct)(ruleset_t **ppThis); 47 rsRetVal (*DestructAllActions)(rsconf_t *conf); 48 rsRetVal (*SetName)(ruleset_t *pThis, uchar *pszName); 49 rsRetVal (*ProcessBatch)(batch_t*, wti_t *); 50 rsRetVal (*GetRuleset)(rsconf_t *conf, ruleset_t **ppThis, uchar*); 51 rsRetVal (*SetDefaultRuleset)(rsconf_t *conf, uchar*); 52 rsRetVal (*SetCurrRuleset)(rsconf_t *conf, uchar*); 53 ruleset_t* (*GetCurrent)(rsconf_t *conf); 54 qqueue_t* (*GetRulesetQueue)(ruleset_t*); 55 /* v3, 2009-11-04 */ 56 parserList_t* (*GetParserList)(rsconf_t *conf, smsg_t *); 57 /* v5, 2011-04-19 58 * added support for the rsconf object -- fundamental change 59 * v6, 2011-07-15 60 * removed conf ptr from SetName, AddRule as the flex/bison based 61 * system uses globals in any case. 62 */ 63 /* v7, 2012-09-04 */ 64 /* AddRule() removed */ 65 /*TODO:REMOVE*/rsRetVal (*IterateAllActions)(rsconf_t *conf, rsRetVal (*pFunc)(void*, void*), void* pParam); 66 void (*AddScript)(ruleset_t *pThis, struct cnfstmt *script); 67 /* v8: changed processBatch interface */ 68 ENDinterface(ruleset) 69 #define rulesetCURR_IF_VERSION 8 /* increment whenever you change the interface structure! */ 70 71 72 /* prototypes */ 73 PROTOTYPEObj(ruleset); 74 75 /* TODO: remove these -- currently done dirty for config file 76 * redo -- rgerhards, 2011-04-19 77 * rgerhards, 2012-04-19: actually, it may be way cooler not to remove 78 * them and use plain c-style conventions at least inside core objects. 79 */ 80 rsRetVal rulesetDestructForLinkedList(void *pData); 81 rsRetVal rulesetKeyDestruct(void __attribute__((unused)) *pData); 82 83 /* Get name associated to ruleset. This function cannot fail (except, 84 * of course, if previously something went really wrong). Returned 85 * pointer is read-only. 86 * rgerhards, 2012-04-18 87 */ 88 #define rulesetGetName(pRuleset) ((pRuleset)->pszName) 89 90 /* returns 1 if the ruleset has a queue associated, 0 if not */ 91 #define rulesetHasQueue(pRuleset) ( ((pRuleset)->pQueue != NULL) \ 92 && ((pRuleset)->pQueue->qType != QUEUETYPE_DIRECT) ? 1 : 0 ) 93 94 95 /* we will most probably convert this module back to traditional C 96 * calling sequence, so here we go... 97 */ 98 rsRetVal rulesetGetRuleset(rsconf_t *conf, ruleset_t **ppRuleset, uchar *pszName); 99 rsRetVal rulesetOptimizeAll(rsconf_t *conf); 100 rsRetVal rulesetProcessCnf(struct cnfobj *o); 101 rsRetVal activateRulesetQueues(void); 102 103 /* Set a current rule set to already-known pointer */ 104 #define rulesetSetCurrRulesetPtr(pRuleset) (loadConf->rulesets.pCurr = (pRuleset)) 105 106 #endif /* #ifndef INCLUDED_RULESET_H */ 107