3
* Copyright 2008 Rainer Gerhards and Adiscon GmbH.
5
* This file is part of rsyslog.
7
* Rsyslog is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* Rsyslog is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
20
* A copy of the GPL can be found in the file "COPYING" in this distribution.
22
#ifndef INCLUDED_VMOP_H
23
#define INCLUDED_VMOP_H
25
#include "ctok_token.h"
27
/* machine instructions types */
28
typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc() */
30
/* for simplicity of debugging and reading dumps, we use the same IDs
31
* that the tokenizer uses where this applicable.
34
opcode_AND = ctok_AND,
35
opcode_STRADD= ctok_STRADD,
36
opcode_PLUS = ctok_PLUS,
37
opcode_MINUS = ctok_MINUS,
38
opcode_TIMES = ctok_TIMES, /* "*" */
39
opcode_DIV = ctok_DIV,
40
opcode_MOD = ctok_MOD,
41
opcode_NOT = ctok_NOT,
42
opcode_CMP_EQ = ctok_CMP_EQ, /* all compare operations must be in a row */
43
opcode_CMP_NEQ = ctok_CMP_NEQ,
44
opcode_CMP_LT = ctok_CMP_LT,
45
opcode_CMP_GT = ctok_CMP_GT,
46
opcode_CMP_LTEQ = ctok_CMP_LTEQ,
47
opcode_CMP_CONTAINS = ctok_CMP_CONTAINS,
48
opcode_CMP_STARTSWITH = ctok_CMP_STARTSWITH,
49
opcode_CMP_CONTAINSI = ctok_CMP_CONTAINSI,
50
opcode_CMP_STARTSWITHI = ctok_CMP_STARTSWITHI,
51
opcode_CMP_GTEQ = ctok_CMP_GTEQ, /* end compare operations */
52
/* here we start our own codes */
53
opcode_POP = 1000, /* requires var operand to receive result */
54
opcode_PUSHSYSVAR = 1001, /* requires var operand */
55
opcode_PUSHMSGVAR = 1002, /* requires var operand */
56
opcode_PUSHCONSTANT = 1003, /* requires var operand */
57
opcode_UNARY_MINUS = 1010,
58
opcode_END_PROG = 1011
63
typedef struct vmop_s {
64
BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */
68
/* TODO: add function pointer */
70
struct vmop_s *pNext; /* next operation or NULL, if end of program (logically this belongs to vmprg) */
75
BEGINinterface(vmop) /* name must also be changed in ENDinterface macro! */
76
INTERFACEObjDebugPrint(vmop);
77
rsRetVal (*Construct)(vmop_t **ppThis);
78
rsRetVal (*ConstructFinalize)(vmop_t __attribute__((unused)) *pThis);
79
rsRetVal (*Destruct)(vmop_t **ppThis);
80
rsRetVal (*SetOpcode)(vmop_t *pThis, opcode_t opcode);
81
rsRetVal (*SetVar)(vmop_t *pThis, var_t *pVar);
82
rsRetVal (*Opcode2Str)(vmop_t *pThis, uchar **ppName);
84
#define vmopCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */
86
/* the remaining prototypes */
89
#endif /* #ifndef INCLUDED_VMOP_H */