diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 18:54:20 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 18:54:20 +0000 |
commit | 44bb5af7ccef417a1d088527fc02af5f0e8d3dc5 (patch) | |
tree | 6a28892a1253b4f199a4f55c64b1a65fbdd38386 | |
parent | fa150f43db5f9673a5b9dfb0727767eca60e4453 (diff) | |
download | rsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.tar.gz rsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.tar.xz rsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.zip |
begun expr compile process, first steps done
-rw-r--r-- | ctok_token.c | 18 | ||||
-rw-r--r-- | ctok_token.h | 1 | ||||
-rw-r--r-- | doc/professional_support.html | 56 | ||||
-rw-r--r-- | expr.c | 11 | ||||
-rw-r--r-- | var.c | 49 | ||||
-rw-r--r-- | var.h | 6 | ||||
-rw-r--r-- | vmop.c | 87 | ||||
-rw-r--r-- | vmop.h | 8 |
8 files changed, 212 insertions, 24 deletions
diff --git a/ctok_token.c b/ctok_token.c index 7e768f37..a0f6b18d 100644 --- a/ctok_token.c +++ b/ctok_token.c @@ -61,6 +61,24 @@ CODESTARTobjDestruct(ctok_token) ENDobjDestruct(ctok_token) +/* get the rsCStrObj from the token, but do not destruct it. This is meant to + * be used by a caller who passes on the string to some other function. The + * caller is responsible for destructing it. + * rgerhards, 2008-02-20 + */ +rsRetVal +ctok_tokenUnlinkCStr(ctok_token_t *pThis, rsCStrObj **ppCStr) +{ + DEFiRet; + + ISOBJ_TYPE_assert(pThis, ctok_token); + ASSERT(ppCStr != NULL); + + *ppCStr = pThis->pstrVal; + pThis->pstrVal = NULL; + + RETiRet; +} BEGINObjClassInit(ctok_token, 1) /* class, version */ OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, ctok_tokenConstructFinalize); diff --git a/ctok_token.h b/ctok_token.h index 66be42b6..b7d3cf19 100644 --- a/ctok_token.h +++ b/ctok_token.h @@ -73,6 +73,7 @@ typedef struct { rsRetVal ctok_tokenConstruct(ctok_token_t **ppThis); rsRetVal ctok_tokenConstructFinalize(ctok_token_t __attribute__((unused)) *pThis); rsRetVal ctok_tokenDestruct(ctok_token_t **ppThis); +rsRetVal ctok_tokenUnlinkCStr(ctok_token_t *pThis, rsCStrObj **ppCStr); PROTOTYPEObjClassInit(ctok_token); #endif /* #ifndef INCLUDED_CTOK_TOKEN_H */ diff --git a/doc/professional_support.html b/doc/professional_support.html index dc9742b2..6d7db1ac 100644 --- a/doc/professional_support.html +++ b/doc/professional_support.html @@ -7,25 +7,45 @@ <h1>Professional Support for Rsyslog</h1> <p>Professional Support is offered by <a href="http://www.adiscon.com">Adiscon</a>, the company that sponsored rsyslog development. For details, please contact <a href="mailto:info%40adiscon.com">Adiscon Sales</a>.</p> - -<p><h3><u>EMail Support Service</u></h3> - -Price: 99.00 USD -<br>Duration: 180 days -<br>Support level: 8x5 - -<p>Purchase rsyslog support directly from the source. This contract provides priority email support. It is a great option if you need to provide proof of software support in your organization. This contract provides - unlimited email support tickets during validity - fixes for current AND PAST rsyslog releases - advise on how to implement rsyslog in the best possible way Under this contract, fixes for old rsyslog releases will be provided / created, provided that it is possible to do that with the code base in question. Phone support is not included. This agreement is governed under German law.</p> - - -<p><h3><u>Custom-Written Config File</u></h3> - +<p></p> +<h3><u>EMail Support Service</u></h3> +Price: 99.00 USD <br> +Duration: 180 days +<br> +Support level: 8x5 +<p>Purchase rsyslog support directly from the source. This +contract provides priority email support. It is a great option if you +need to provide proof of software support in your organization. This +contract provides</p> +<ul> +<li>unlimited email support tickets during validity +</li><li><span style="font-weight: bold;">fixes for</span> +current and <span style="font-weight: bold;">past rsyslog +releases</span> +</li><li>advise on how to implement rsyslog in the best possible way. +</li></ul> +<p>Under this contract, fixes for old rsyslog releases will be +provided / created, provided that it is possible to do that with the +code base in question. Phone support is not included.</p><h3><u>Custom-Written Config File</u></h3> Price: 29.00 USD -<br>Duration: N/A -<br>Support level: 8x5 - -<p>Creating rsyslog config files is easy - but if you would like to have that extra feature and have no time to do it, this service is for you. Important: BEFORE you purchase this service, contact us and inquire (via info@adiscon.com) whether or not your desired result can be achieved via rsyslog. Once this is clear, order the service and we will ship a custom-made configuration file within 5 working days (at latest, most often much faster). For security reasons, we will not put passwords into the configuration file, but will place easy to read comments in the places where you need to put them in. The agreement is governed under German law. You may also purchase this service if you would like to have your own configuration file reviewed, e.g. for auditing purposes.</p> - - +<br> +Duration: N/A +<br> +Support level: 8x5 +<p>Creating rsyslog config files is easy - but if you would like +to have that extra feature and have no time to do it, this service is +for you. Important: BEFORE you purchase this service, contact us and +inquire (via <a href="mailto:info%40adiscon.com">info@adiscon.com</a>) +whether or not your desired result can be achieved via rsyslog. Once +this is clear, order the service and we will ship a custom-made +configuration file within 5 working days (at latest, most often much +faster). For security reasons, we will not put passwords into the +configuration file, but will place easy to read comments in the places +where you need to put them in. The agreement is governed under German +law. You may also purchase this service if you would like to have your +own configuration file reviewed, e.g. for auditing purposes.</p><br><p>All agreements are +governed under German law. +</p><p></p> <p>[<a href="manual.html">manual index</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p> <p><font size="2">This documentation is part of the <a href="http://www.rsyslog.com/">rsyslog</a> @@ -59,6 +59,8 @@ terminal(expr_t *pThis, ctok_t *ctok) { DEFiRet; ctok_token_t *pToken; + var_t *pVar; + rsCStrObj *pCStr; ISOBJ_TYPE_assert(pThis, expr); ISOBJ_TYPE_assert(ctok, ctok); @@ -67,11 +69,17 @@ terminal(expr_t *pThis, ctok_t *ctok) switch(pToken->tok) { case ctok_SIMPSTR: + CHKiRet(varConstruct(&pVar)); + CHKiRet(varConstructFinalize(pVar)); + CHKiRet(ctok_tokenUnlinkCStr(pToken, &pCStr)); + CHKiRet(varSetString(pVar, pCStr)); dbgoprint((obj_t*) pThis, "simpstr\n"); + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_PUSHCONSTANT, pVar)); /* add to program */ // push val break; case ctok_NUMBER: dbgoprint((obj_t*) pThis, "number\n"); + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_PUSHCONSTANT, NULL)); /* add to program */ // push val break; case ctok_FUNCTION: @@ -81,10 +89,12 @@ terminal(expr_t *pThis, ctok_t *ctok) break; case ctok_MSGVAR: dbgoprint((obj_t*) pThis, "MSGVAR\n"); + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_PUSHMSGVAR, NULL)); /* add to program */ // push val break; case ctok_SYSVAR: dbgoprint((obj_t*) pThis, "SYSVAR\n"); + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_PUSHSYSVAR, NULL)); /* add to program */ // push val break; case ctok_LPAREN: @@ -96,7 +106,6 @@ terminal(expr_t *pThis, ctok_t *ctok) ABORT_FINALIZE(RS_RET_SYNTAX_ERROR); CHKiRet(ctok_tokenDestruct(&pToken)); /* "eat" processed token */ dbgoprint((obj_t*) pThis, "end expr, rparen eaten\n"); - /* fill structure */ break; default: dbgoprint((obj_t*) pThis, "invalid token %d\n", pToken->tok); @@ -71,12 +71,61 @@ CODESTARTobjDestruct(var) ENDobjDestruct(var) +/* DebugPrint support for the var object */ +BEGINobjDebugPrint(var) /* be sure to specify the object type also in END and CODESTART macros! */ +CODESTARTobjDebugPrint(var) + switch(pThis->varType) { + case VARTYPE_CSTR: + dbgoprint((obj_t*) pThis, "type: cstr, val '%s'\n", rsCStrGetSzStr(pThis->val.vpCStr)); + break; + default: + dbgoprint((obj_t*) pThis, "type %d currently not suppored in debug output\n", pThis->varType); + break; + } +ENDobjDebugPrint(var) + + +/* free the current values (destructs objects if necessary) + */ +static rsRetVal +varUnsetValues(var_t *pThis) +{ + DEFiRet; + + ISOBJ_TYPE_assert(pThis, var); + if(pThis->varType == VARTYPE_CSTR) + rsCStrDestruct(&pThis->val.vpCStr); + + pThis->varType = VARTYPE_NONE; + + RETiRet; +} + + +/* set a string value + */ +rsRetVal +varSetString(var_t *pThis, rsCStrObj *pCStr) +{ + DEFiRet; + + ISOBJ_TYPE_assert(pThis, var); + + CHKiRet(varUnsetValues(pThis)); + pThis->varType = VARTYPE_CSTR; + pThis->val.vpCStr = pCStr; + +finalize_it: + RETiRet; +} + /* Initialize the var class. Must be called as the very first method * before anything else is called inside this class. * rgerhards, 2008-02-19 */ BEGINObjClassInit(var, 1) /* class, version */ + OBJSetMethodHandler(objMethod_DEBUGPRINT, varDebugPrint); OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, varConstructFinalize); ENDObjClassInit(var) @@ -22,9 +22,11 @@ #ifndef INCLUDED_VAR_H #define INCLUDED_VAR_H +#include "stringbuf.h" /* data types */ -typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc() */ +typedef enum { + VARTYPE_NONE = 0, /* currently no value set */ VARTYPE_PSZ = 1, VARTYPE_SHORT = 2, VARTYPE_INT = 3, @@ -53,6 +55,8 @@ typedef struct var_s { rsRetVal varConstruct(var_t **ppThis); rsRetVal varConstructFinalize(var_t __attribute__((unused)) *pThis); rsRetVal varDestruct(var_t **ppThis); +rsRetVal varSetString(var_t *pThis, rsCStrObj *pCStr); PROTOTYPEObjClassInit(var); +PROTOTYPEObjDebugPrint(var); #endif /* #ifndef INCLUDED_VAR_H */ @@ -58,10 +58,15 @@ CODESTARTobjDestruct(vmop) ENDobjDestruct(vmop) -/* destructor for the vmop object */ +/* DebugPrint support for the vmop object */ BEGINobjDebugPrint(vmop) /* be sure to specify the object type also in END and CODESTART macros! */ + uchar *pOpcodeName; CODESTARTobjDebugPrint(vmop) - dbgoprint((obj_t*) pThis, "operation: %d, next %p\n", (int) pThis->opcode, pThis->pNext); + vmopOpcode2Str(pThis, &pOpcodeName); + dbgoprint((obj_t*) pThis, "opcode: %d\t(%s), next %p, var in next line\n", (int) pThis->opcode, pOpcodeName, + pThis->pNext); + if(pThis->operand.pVar != NULL) + varDebugPrint(pThis->operand.pVar); ENDobjDebugPrint(vmop) @@ -92,6 +97,84 @@ vmopSetOpcode(vmop_t *pThis, opcode_t opcode) } +/* a way to turn an opcode into a readable string + */ +rsRetVal +vmopOpcode2Str(vmop_t *pThis, uchar **ppName) +{ + DEFiRet; + ISOBJ_TYPE_assert(pThis, vmop); + + switch(pThis->opcode) { + case opcode_OR: + *ppName = (uchar*) "or"; + break; + case opcode_AND: + *ppName = (uchar*) "and"; + break; + case opcode_PLUS: + *ppName = (uchar*) "+"; + break; + case opcode_MINUS: + *ppName = (uchar*) "-"; + break; + case opcode_TIMES: + *ppName = (uchar*) "*"; + break; + case opcode_DIV: + *ppName = (uchar*) "/"; + break; + case opcode_MOD: + *ppName = (uchar*) "%"; + break; + case opcode_NOT: + *ppName = (uchar*) "not"; + break; + case opcode_CMP_EQ: + *ppName = (uchar*) "=="; + break; + case opcode_CMP_NEQ: + *ppName = (uchar*) "!="; + break; + case opcode_CMP_LT: + *ppName = (uchar*) "<"; + break; + case opcode_CMP_GT: + *ppName = (uchar*) ">"; + break; + case opcode_CMP_LTEQ: + *ppName = (uchar*) "<="; + break; + case opcode_CMP_CONTAINS: + *ppName = (uchar*) "contains"; + break; + case opcode_CMP_STARTSWITH: + *ppName = (uchar*) "startswith"; + break; + case opcode_CMP_GTEQ: + *ppName = (uchar*) ">="; + break; + case opcode_PUSHSYSVAR: + *ppName = (uchar*) "PUSHSYSVAR"; + break; + case opcode_PUSHMSGVAR: + *ppName = (uchar*) "PUSHMSGVAR"; + break; + case opcode_PUSHCONSTANT: + *ppName = (uchar*) "PUSHCONSTANT"; + break; + case opcode_POP: + *ppName = (uchar*) ""; + break; + default: + *ppName = (uchar*) "INVALID opcode"; + break; + } + + RETiRet; +} + + /* Initialize the vmop class. Must be called as the very first method * before anything else is called inside this class. * rgerhards, 2008-02-19 @@ -47,10 +47,13 @@ typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc( opcode_CMP_STARTSWITH = ctok_CMP_STARTSWITH, opcode_CMP_GTEQ = ctok_CMP_GTEQ, /* end compare operations */ /* here we start our own codes */ - opcode_PUSH = 1000, /* requires var operand */ - opcode_POP = 1001, /* requires var operand to receive result */ + opcode_POP = 1000, /* requires var operand to receive result */ + opcode_PUSHSYSVAR = 1001, /* requires var operand */ + opcode_PUSHMSGVAR = 1002, /* requires var operand */ + opcode_PUSHCONSTANT = 1003, /* requires var operand */ } opcode_t; + /* the vmop object */ typedef struct vmop_s { BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ @@ -69,6 +72,7 @@ rsRetVal vmopConstructFinalize(vmop_t __attribute__((unused)) *pThis); rsRetVal vmopDestruct(vmop_t **ppThis); rsRetVal vmopSetOpcode(vmop_t *pThis, opcode_t opcode); rsRetVal vmopSetVar(vmop_t *pThis, var_t *pVar); +rsRetVal vmopOpcode2Str(vmop_t *pThis, uchar **ppName); PROTOTYPEObjClassInit(vmop); PROTOTYPEObjDebugPrint(vmop); |