~ubuntu-branches/ubuntu/lucid/rsyslog/lucid-updates

« back to all changes in this revision

Viewing changes to runtime/expr.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-06-23 12:12:43 UTC
  • mfrom: (1.1.11 upstream) (3.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20090623121243-d2fejarzidywnn17
Tags: 4.2.0-1
* New upstream release of the now stable v4 branch.
  - Fix warnings when /etc/rsyslog.d/ is empty. Closes: #530228
* debian/patches/imudp_multiple_udp_sockets.patch
  - Removed, merged upstream.
* debian/rsyslog.default
  - Set default compat mode to '4'.
* debian/rsyslog.logcheck.ignore.server
  - Update logcheck rules files to also ignore rsyslogd and imklog stop
    messages.
* debian/control
  - Bump Standards-Version to 3.8.2. No further changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 * rgerhards, 2008-02-19
56
56
 */
57
57
 
58
 
/* forward definiton - thanks to recursive ABNF, we can not avoid at least one ;) */
 
58
/* forward definition - thanks to recursive ABNF, we can not avoid at least one ;) */
59
59
static rsRetVal expr(expr_t *pThis, ctok_t *tok);
60
60
 
61
61
 
62
62
static rsRetVal
 
63
function(expr_t *pThis, ctok_t *tok)
 
64
{
 
65
        DEFiRet;
 
66
        ctok_token_t *pToken = NULL;
 
67
        int iNumArgs = 0;
 
68
        var_t *pVar;
 
69
 
 
70
        ISOBJ_TYPE_assert(pThis, expr);
 
71
        ISOBJ_TYPE_assert(tok, ctok);
 
72
 
 
73
        CHKiRet(ctok.GetToken(tok, &pToken));
 
74
        /* note: pToken is destructed in finalize_it */
 
75
 
 
76
        if(pToken->tok == ctok_LPAREN) {
 
77
                CHKiRet(ctok_token.Destruct(&pToken)); /* token processed, "eat" it */
 
78
                CHKiRet(ctok.GetToken(tok, &pToken)); /* get next one */
 
79
        } else
 
80
                ABORT_FINALIZE(RS_RET_FUNC_NO_LPAREN);
 
81
 
 
82
        /* we first push all the params on the stack. Then we call the function */
 
83
        while(pToken->tok != ctok_RPAREN) { 
 
84
                ++iNumArgs;
 
85
                CHKiRet(ctok.UngetToken(tok, pToken)); /* not for us, so let others process it */
 
86
                CHKiRet(expr(pThis, tok));
 
87
                CHKiRet(ctok.GetToken(tok, &pToken)); /* get next one, needed for while() check */
 
88
                if(pToken->tok == ctok_COMMA) {
 
89
                        CHKiRet(ctok_token.Destruct(&pToken)); /* token processed, "eat" it */
 
90
                        CHKiRet(ctok.GetToken(tok, &pToken)); /* get next one */
 
91
                        if(pToken->tok == ctok_RPAREN) {
 
92
                                ABORT_FINALIZE(RS_RET_FUNC_MISSING_EXPR);
 
93
                        }
 
94
                }
 
95
        }
 
96
 
 
97
 
 
98
        /* now push number of arguments - this must be on top of the stack */
 
99
        CHKiRet(var.Construct(&pVar));
 
100
        CHKiRet(var.ConstructFinalize(pVar));
 
101
        CHKiRet(var.SetNumber(pVar, iNumArgs));
 
102
        CHKiRet(vmprg.AddVarOperation(pThis->pVmprg, opcode_PUSHCONSTANT, pVar)); /* add to program */
 
103
 
 
104
 
 
105
finalize_it:
 
106
        if(pToken != NULL) {
 
107
                ctok_token.Destruct(&pToken); /* "eat" processed token */
 
108
        }
 
109
 
 
110
        RETiRet;
 
111
}
 
112
 
 
113
 
 
114
static rsRetVal
63
115
terminal(expr_t *pThis, ctok_t *tok)
64
116
{
65
117
        DEFiRet;
85
137
                        break;
86
138
                case ctok_FUNCTION:
87
139
                        dbgoprint((obj_t*) pThis, "function\n");
88
 
                        /* TODO: vm: call - well, need to implement that first */
89
 
                        ABORT_FINALIZE(RS_RET_NOT_IMPLEMENTED);
 
140
                        CHKiRet(function(pThis, tok)); /* this creates the stack call frame */
 
141
                        /* ... but we place the call instruction onto the stack ourselfs (because
 
142
                         * we have all relevant information)
 
143
                         */
 
144
                        CHKiRet(ctok_token.UnlinkVar(pToken, &pVar));
 
145
                        CHKiRet(vmprg.AddVarOperation(pThis->pVmprg, opcode_FUNC_CALL, pVar)); /* add to program */
90
146
                        break;
91
147
                case ctok_MSGVAR:
92
148
                        dbgoprint((obj_t*) pThis, "MSGVAR\n");
406
462
 */
407
463
BEGINObjClassInit(expr, 1, OBJ_IS_CORE_MODULE) /* class, version */
408
464
        /* request objects we use */
 
465
        CHKiRet(objUse(var, CORE_COMPONENT));
409
466
        CHKiRet(objUse(vmprg, CORE_COMPONENT));
410
467
        CHKiRet(objUse(var, CORE_COMPONENT));
411
468
        CHKiRet(objUse(ctok_token, CORE_COMPONENT));