~ubuntu-branches/ubuntu/karmic/rsyslog/karmic

« back to all changes in this revision

Viewing changes to runtime/vmprg.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-05-15 23:25:14 UTC
  • mfrom: (1.1.10 upstream) (3.2.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090515232514-qyfuhgicn7afwblw
Tags: 3.22.0-1
* New upstream release.
* debian/rsyslog.init
  - Pass proper return code to log_end_msg.
* debian/rsyslog.conf
  - Set $Umask to 0022 to enforce that new log files or directories are
    always created with the right permissions. Closes: #522297
* debian/patches/imudp_multiple_udp_sockets.patch
  - Fix a segfault in imudp when multiple udp listeners are configured.
    Patch cherry-picked from upstream git. Closes: #519073
* debian/patches/manpage_pidfile.patch
  - Fix rsyslogd man page to point to the correct pid file. Closes: #526658

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 */
25
25
 
26
26
#include "config.h"
 
27
#include <stdio.h>
27
28
#include <stdlib.h>
28
29
#include <assert.h>
29
30
 
30
31
#include "rsyslog.h"
31
32
#include "obj.h"
32
33
#include "vmprg.h"
 
34
#include "stringbuf.h"
33
35
 
34
36
/* static data */
35
37
DEFobjStaticHelpers
79
81
ENDobjDebugPrint(vmprg)
80
82
 
81
83
 
 
84
/* This function is similar to DebugPrint, but does not send its output to
 
85
 * the debug log but instead to a caller-provided string. The idea here is that
 
86
 * we can use this string to get a textual representation of a bytecode program. 
 
87
 * Among others, this is useful for creating testbenches, our first use case for
 
88
 * it. Here, it enables simple comparison of the resulting program to a
 
89
 * reference program by simple string compare.
 
90
 * Note that the caller must initialize the string object. We always add
 
91
 * data to it. So, it can be easily combined into a chain of methods
 
92
 * to generate the final string.
 
93
 * rgerhards, 2008-07-04
 
94
 */
 
95
static rsRetVal
 
96
Obj2Str(vmprg_t *pThis, cstr_t *pstrPrg)
 
97
{
 
98
        uchar szAddr[12];
 
99
        vmop_t *pOp;
 
100
        int i;
 
101
        int lenAddr;
 
102
        DEFiRet;
 
103
 
 
104
        ISOBJ_TYPE_assert(pThis, vmprg);
 
105
        assert(pstrPrg != NULL);
 
106
        i = 0;  /* "program counter" */
 
107
        for(pOp = pThis->vmopRoot ; pOp != NULL ; pOp = pOp->pNext) {
 
108
                lenAddr = snprintf((char*)szAddr, sizeof(szAddr), "%8.8d: ", i++);
 
109
                CHKiRet(rsCStrAppendStrWithLen(pstrPrg, szAddr, lenAddr));
 
110
                vmop.Obj2Str(pOp, pstrPrg);
 
111
        }
 
112
 
 
113
finalize_it:
 
114
        RETiRet;
 
115
}
 
116
 
 
117
 
82
118
/* add an operation (instruction) to the end of the current program. This
83
119
 * function is expected to be called while creating the program, but never
84
120
 * again after this is done and it is being executed. Results are undefined if
146
182
         * work here (if we can support an older interface version - that,
147
183
         * of course, also affects the "if" above).
148
184
         */
149
 
        //xxxpIf->oID = OBJvmprg;
150
 
 
151
185
        pIf->Construct = vmprgConstruct;
152
186
        pIf->ConstructFinalize = vmprgConstructFinalize;
153
187
        pIf->Destruct = vmprgDestruct;
154
188
        pIf->DebugPrint = vmprgDebugPrint;
 
189
        pIf->Obj2Str = Obj2Str;
155
190
        pIf->AddOperation = vmprgAddOperation;
156
191
        pIf->AddVarOperation = vmprgAddVarOperation;
157
192
finalize_it: