~kroq-gar78/ubuntu/precise/rsyslog/fix-846818

« back to all changes in this revision

Viewing changes to parse.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2008-07-23 02:22:32 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080723022232-496osxty0v9vvw9g
Tags: 3.18.1-1
* New upstream release. Closes: #490445
  - List Debian in doc/rsyslog_packages.html. Closes: #488870
  - Fix compilation of imklog module on GNU/kFreeBSD. Closes: #491193
* debian/rsyslog-doc.install
  - Install the example config file. Closes: #488860
* debian/rules
  - Enable mail output plugin.
  - Make sure all directories are created by calling dh_installdirs for both
    binary-arch and binary-indep. Closes: #491459
* debian/rsyslog.install
  - Install mail output plugin (ommail.so).
* debian/control
  - Add Suggests www-browser to rsyslog-doc as the package contains mostly
    html documents.
  - Update feature list.
  - Adjust priorities, set rsyslog priority to important.

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
 *   0 means "no", 1 "yes"
236
236
 *   - bTrimLeading
237
237
 *   - bTrimTrailing
 
238
 *   - bConvLower - convert string to lower case?
238
239
 * 
239
240
 * Output:
240
241
 * ppCStr Pointer to the parsed string - must be freed by caller!
241
242
 */
242
 
rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrimLeading, int bTrimTrailing)
 
243
rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrimLeading, int bTrimTrailing, int bConvLower)
243
244
{
244
245
        DEFiRet;
245
246
        register unsigned char *pC;
246
 
        cstr_t *pCStr;
 
247
        cstr_t *pCStr = NULL;
247
248
 
248
249
        rsCHECKVALIDOBJECT(pThis, OIDrsPars);
249
250
 
254
255
 
255
256
        pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos;
256
257
 
257
 
        while(pThis->iCurrPos < rsCStrLen(pThis->pCStr)
258
 
              && *pC != cDelim) {
259
 
                if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
260
 
                        rsCStrDestruct(&pCStr);
261
 
                        FINALIZE;
262
 
                }
 
258
        while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != cDelim) {
 
259
                CHKiRet(rsCStrAppendChar(pCStr, bConvLower ? tolower(*pC) : *pC));
263
260
                ++pThis->iCurrPos;
264
261
                ++pC;
265
262
        }
271
268
        /* We got the string, now take it and see if we need to
272
269
         * remove anything at its end.
273
270
         */
274
 
        if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
275
 
                rsCStrDestruct (&pCStr);
276
 
                FINALIZE;
277
 
        }
 
271
        CHKiRet(rsCStrFinish(pCStr));
278
272
 
279
273
        if(bTrimTrailing) {
280
 
                if((iRet = rsCStrTrimTrailingWhiteSpace(pCStr)) 
281
 
                   != RS_RET_OK) {
282
 
                        rsCStrDestruct (&pCStr);
283
 
                        FINALIZE;
284
 
                }
 
274
                CHKiRet(rsCStrTrimTrailingWhiteSpace(pCStr));
285
275
        }
286
276
 
287
277
        /* done! */
288
278
        *ppCStr = pCStr;
 
279
 
289
280
finalize_it:
 
281
        if(iRet != RS_RET_OK) {
 
282
                if(pCStr != NULL)
 
283
                        rsCStrDestruct(&pCStr);
 
284
        }
 
285
 
290
286
        RETiRet;
291
287
}
292
288
 
308
304
rsRetVal parsQuotedCStr(rsParsObj *pThis, cstr_t **ppCStr)
309
305
{
310
306
        register unsigned char *pC;
311
 
        cstr_t *pCStr;
 
307
        cstr_t *pCStr = NULL;
312
308
        DEFiRet;
313
309
 
314
310
        rsCHECKVALIDOBJECT(pThis, OIDrsPars);
315
311
 
316
 
        if((iRet = parsSkipAfterChar(pThis, '"')) != RS_RET_OK)
317
 
                FINALIZE;
 
312
        CHKiRet(parsSkipAfterChar(pThis, '"'));
318
313
        pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos;
319
314
 
320
315
        /* OK, we most probably can obtain a value... */
331
326
                                 * to the output buffer (but do not rely on this,
332
327
                                 * we might later introduce other things, like \007!
333
328
                                 */
334
 
                                if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
335
 
                                        rsCStrDestruct(&pCStr);
336
 
                                        FINALIZE;
337
 
                                }
 
329
                                CHKiRet(rsCStrAppendChar(pCStr, *pC));
338
330
                        }
339
331
                } else { /* regular character */
340
 
                        if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
341
 
                                rsCStrDestruct (&pCStr);
342
 
                                FINALIZE;
343
 
                        }
 
332
                        CHKiRet(rsCStrAppendChar(pCStr, *pC));
344
333
                }
345
334
                ++pThis->iCurrPos;
346
335
                ++pC;
350
339
                ++pThis->iCurrPos; /* 'eat' trailing quote */
351
340
        } else {
352
341
                /* error - improperly quoted string! */
353
 
                rsCStrDestruct (&pCStr);
 
342
                rsCStrDestruct(&pCStr);
354
343
                ABORT_FINALIZE(RS_RET_MISSING_TRAIL_QUOTE);
355
344
        }
356
345
 
357
346
        /* We got the string, let's finish it...  */
358
 
        if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
359
 
                rsCStrDestruct (&pCStr);
360
 
                FINALIZE;
361
 
        }
 
347
        CHKiRet(rsCStrFinish(pCStr));
362
348
 
363
349
        /* done! */
364
350
        *ppCStr = pCStr;
 
351
 
365
352
finalize_it:
 
353
        if(iRet != RS_RET_OK) {
 
354
                if(pCStr != NULL)
 
355
                        rsCStrDestruct(&pCStr);
 
356
        }
 
357
 
366
358
        RETiRet;
367
359
}
368
360