1 /* im-helper.h
2 * This file contains helper constructs that save time writing input modules. It
3 * assumes some common field names and plumbing. It is intended to be used together
4 * with module-template.h
5 *
6 * File begun on 2011-05-04 by RGerhards
7 *
8 * Copyright 2011-2016 Rainer Gerhards and Adiscon GmbH.
9 *
10 * This file is part of the rsyslog runtime library.
11 *
12 * The rsyslog runtime library is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * The rsyslog runtime library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * A copy of the GPL can be found in the file "COPYING" in this distribution.
26 * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
27 */
28 #ifndef IM_HELPER_H_INCLUDED
29 #define IM_HELPER_H_INCLUDED 1
30
31
32 /* The following function provides a complete implementation to check a
33 * ruleset and set the actual ruleset pointer. The macro assumes that
34 * standard field names are used. A functon std_checkRuleset_genErrMsg()
35 * must be defined to generate error messages in case the ruleset cannot
36 * be found.
37 */
38 static inline void std_checkRuleset_genErrMsg(modConfData_t *modConf, instanceConf_t *inst);
39 static inline rsRetVal
std_checkRuleset(modConfData_t * modConf,instanceConf_t * inst)40 std_checkRuleset(modConfData_t *modConf, instanceConf_t *inst)
41 {
42 ruleset_t *pRuleset;
43 rsRetVal localRet;
44 DEFiRet;
45
46 inst->pBindRuleset = NULL; /* assume default ruleset */
47
48 if(inst->pszBindRuleset == NULL)
49 FINALIZE;
50
51 localRet = ruleset.GetRuleset(modConf->pConf, &pRuleset, inst->pszBindRuleset);
52 if(localRet == RS_RET_NOT_FOUND) {
53 std_checkRuleset_genErrMsg(modConf, inst);
54 }
55 CHKiRet(localRet);
56 inst->pBindRuleset = pRuleset;
57
58 finalize_it:
59 RETiRet;
60 }
61
62 #endif /* #ifndef IM_HELPER_H_INCLUDED */
63