~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/dummy/dummy-grammar.y

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include "cfg-parser.h"
33
33
#include "dummy-grammar.h"
 
34
#include "plugin.h"
 
35
 
 
36
extern LogDriver *last_driver;
34
37
 
35
38
}
36
39
 
37
40
%name-prefix "dummy_"
38
41
%lex-param {CfgLexer *lexer}
39
42
%parse-param {CfgLexer *lexer}
40
 
%parse-param {DummyDestDriver **dummy_dd_instance}
 
43
%parse-param {LogDriver **instance}
 
44
%parse-param {gpointer arg}
41
45
 
42
46
 
43
47
 
76
80
          {                                                             \
77
81
            gchar __buf[256];                                           \
78
82
            g_snprintf(__buf, sizeof(__buf), errorfmt ? errorfmt : "x", ## __VA_ARGS__); \
79
 
            yyerror(& (token), lexer, NULL, __buf);                     \
 
83
            yyerror(& (token), lexer, NULL, NULL, __buf);               \
80
84
          }                                                             \
81
85
        YYERROR;                                                        \
82
86
      }                                                                 \
102
106
%token LL_CONTEXT_PRAGMA              11
103
107
%token LL_CONTEXT_FORMAT              12
104
108
%token LL_CONTEXT_TEMPLATE_FUNC       13
 
109
%token LL_CONTEXT_INNER_DEST          14
 
110
%token LL_CONTEXT_INNER_SRC           15
105
111
 
106
112
/* statements */
107
113
%token KW_SOURCE                      10000
136
142
 
137
143
%token KW_SYSLOG                      10060
138
144
 
139
 
 
140
145
/* option items */
141
146
%token KW_MARK_FREQ                   10071
142
147
%token KW_STATS_FREQ                  10072
180
185
%token KW_HOST_OVERRIDE               10166
181
186
 
182
187
%token KW_THROTTLE                    10170
 
188
%token KW_THREADED                    10171
183
189
 
184
190
/* log statement options */
185
191
%token KW_FLAGS                       10190
264
270
%token LL_EOL                         10428
265
271
%token LL_ERROR                       10429
266
272
 
 
273
/* value pairs */
 
274
%token KW_VALUE_PAIRS                 10500
 
275
%token KW_SELECT                      10501
 
276
%token KW_EXCLUDE                     10502
 
277
%token KW_PAIR                        10503
 
278
%token KW_KEY                         10504
 
279
%token KW_SCOPE                       10505
 
280
 
 
281
 
 
282
%type   <ptr> value_pair_option
267
283
 
268
284
%type   <num> yesno
269
285
%type   <num> dnsmode
286
302
start
287
303
        : LL_CONTEXT_DESTINATION KW_DUMMY
288
304
          {
289
 
            *dummy_dd_instance = dummy_dd_new();
 
305
            last_driver = *instance = dummy_dd_new();
290
306
          }
291
307
          '(' dummy_options ')'         { YYACCEPT; }
292
308
        ;
297
313
        ;
298
314
 
299
315
dummy_option
300
 
        : KW_DUMMY_OPT '(' yesno ')'    { (*dummy_dd_instance)->opt = $3; };
 
316
        : KW_DUMMY_OPT '(' yesno ')'    { ((DummyDestDriver *)last_driver)->opt = $3; };
 
317
        | dest_driver_option
301
318
        ;
302
319
 
303
320
 
362
379
        ;
363
380
 
364
381
 
 
382
/* LogSource related options */
 
383
source_option
 
384
        /* NOTE: plugins need to set "last_source_options" in order to incorporate this rule in their grammar */
 
385
        : KW_LOG_IW_SIZE '(' LL_NUMBER ')'      { last_source_options->init_window_size = $3; }
 
386
        | KW_CHAIN_HOSTNAMES '(' yesno ')'      { last_source_options->chain_hostnames = $3; }
 
387
        | KW_NORMALIZE_HOSTNAMES '(' yesno ')'  { last_source_options->normalize_hostnames = $3; }
 
388
        | KW_KEEP_HOSTNAME '(' yesno ')'        { last_source_options->keep_hostname = $3; }
 
389
        | KW_USE_FQDN '(' yesno ')'             { last_source_options->use_fqdn = $3; }
 
390
        | KW_USE_DNS '(' dnsmode ')'            { last_source_options->use_dns = $3; }
 
391
        | KW_DNS_CACHE '(' yesno ')'            { last_source_options->use_dns_cache = $3; }
 
392
        | KW_PROGRAM_OVERRIDE '(' string ')'    { last_source_options->program_override = g_strdup($3); free($3); }
 
393
        | KW_HOST_OVERRIDE '(' string ')'       { last_source_options->host_override = g_strdup($3); free($3); }
 
394
        | KW_LOG_PREFIX '(' string ')'          { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_source_options->program_override = g_strdup($3); free($3); }
 
395
        | KW_KEEP_TIMESTAMP '(' yesno ')'       { last_source_options->keep_timestamp = $3; }
 
396
        | KW_TAGS '(' string_list ')'           { log_source_options_set_tags(last_source_options, $3); }
 
397
        ;
 
398
 
 
399
 
365
400
source_reader_options
366
401
        : source_reader_option source_reader_options
367
402
        |
368
403
        ;
369
404
 
 
405
/* LogReader related options, inherits from LogSource */
370
406
source_reader_option
371
 
        : KW_LOG_IW_SIZE '(' LL_NUMBER ')'              { last_reader_options->super.init_window_size = $3; }
372
 
        | KW_CHAIN_HOSTNAMES '(' yesno ')'      { last_reader_options->super.chain_hostnames = $3; }
373
 
        | KW_NORMALIZE_HOSTNAMES '(' yesno ')'  { last_reader_options->super.normalize_hostnames = $3; }
374
 
        | KW_KEEP_HOSTNAME '(' yesno ')'        { last_reader_options->super.keep_hostname = $3; }
375
 
        | KW_USE_FQDN '(' yesno ')'             { last_reader_options->super.use_fqdn = $3; }
376
 
        | KW_USE_DNS '(' dnsmode ')'            { last_reader_options->super.use_dns = $3; }
377
 
        | KW_DNS_CACHE '(' yesno ')'            { last_reader_options->super.use_dns_cache = $3; }
378
 
        | KW_PROGRAM_OVERRIDE '(' string ')'    { last_reader_options->super.program_override = g_strdup($3); free($3); }
379
 
        | KW_HOST_OVERRIDE '(' string ')'       { last_reader_options->super.host_override = g_strdup($3); free($3); }
380
 
        | KW_LOG_PREFIX '(' string ')'          { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_reader_options->super.program_override = g_strdup($3); free($3); }
381
 
        | KW_TIME_ZONE '(' string ')'           { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
 
407
        /* NOTE: plugins need to set "last_reader_options" in order to incorporate this rule in their grammar */
 
408
 
 
409
        : KW_TIME_ZONE '(' string ')'           { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
382
410
        | KW_CHECK_HOSTNAME '(' yesno ')'       { last_reader_options->check_hostname = $3; }
383
411
        | KW_FLAGS '(' source_reader_option_flags ')'
384
412
        | KW_LOG_MSG_SIZE '(' LL_NUMBER ')'     { last_reader_options->msg_size = $3; }
385
413
        | KW_LOG_FETCH_LIMIT '(' LL_NUMBER ')'  { last_reader_options->fetch_limit = $3; }
386
414
        | KW_PAD_SIZE '(' LL_NUMBER ')'         { last_reader_options->padding = $3; }
387
 
        | KW_KEEP_TIMESTAMP '(' yesno ')'       { last_reader_options->super.keep_timestamp = $3; }
388
415
        | KW_ENCODING '(' string ')'            { last_reader_options->text_encoding = g_strdup($3); free($3); }
389
 
        | KW_TAGS '(' string_list ')'           { log_reader_options_set_tags(last_reader_options, $3); }
390
416
        | KW_FORMAT '(' string ')'              { last_reader_options->parse_options.format = g_strdup($3); free($3); }
391
417
        | KW_DEFAULT_LEVEL '(' level_string ')'
392
418
          {
400
426
              last_reader_options->parse_options.default_pri = LOG_NOTICE;
401
427
            last_reader_options->parse_options.default_pri = (last_reader_options->parse_options.default_pri & 7) | $3;
402
428
          }
 
429
        | { last_source_options = &last_reader_options->super; } source_option
403
430
        ;
404
431
 
405
432
source_reader_option_flags
406
433
        : string source_reader_option_flags     { CHECK_ERROR(log_reader_options_process_flag(last_reader_options, $1), @1, "Unknown flag %s", $1); free($1); }
 
434
        | KW_CHECK_HOSTNAME source_reader_option_flags     { log_reader_options_process_flag(last_reader_options, "check-hostname"); }
407
435
        |
408
436
        ;
409
437
 
 
438
dest_driver_option
 
439
        /* NOTE: plugins need to set "last_driver" in order to incorporate this rule in their grammar */
 
440
 
 
441
        : KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'    { ((LogDestDriver *) last_driver)->log_fifo_size = $3; }
 
442
        | KW_THROTTLE '(' LL_NUMBER ')'         { ((LogDestDriver *) last_driver)->throttle = $3; }
 
443
        | LL_IDENTIFIER
 
444
          {
 
445
            Plugin *p;
 
446
            gint context = LL_CONTEXT_INNER_DEST;
 
447
            gpointer value;
 
448
 
 
449
            p = plugin_find(configuration, context, $1);
 
450
            CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1);
 
451
 
 
452
            value = plugin_parse_config(p, configuration, &@1, last_driver);
 
453
 
 
454
            free($1);
 
455
            if (!value)
 
456
              {
 
457
                YYERROR;
 
458
              }
 
459
            log_driver_add_plugin(last_driver, (LogDriverPlugin *) value);
 
460
          }
 
461
        ;
 
462
 
410
463
dest_writer_options
411
464
        : dest_writer_option dest_writer_options
412
465
        |
413
466
        ;
414
467
 
415
468
dest_writer_option
 
469
        /* NOTE: plugins need to set "last_writer_options" in order to incorporate this rule in their grammar */
 
470
 
416
471
        : KW_FLAGS '(' dest_writer_options_flags ')' { last_writer_options->options = $3; }
417
 
        | KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'    { last_writer_options->mem_fifo_size = $3; }
418
472
        | KW_FLUSH_LINES '(' LL_NUMBER ')'              { last_writer_options->flush_lines = $3; }
419
473
        | KW_FLUSH_TIMEOUT '(' LL_NUMBER ')'    { last_writer_options->flush_timeout = $3; }
420
474
        | KW_SUPPRESS '(' LL_NUMBER ')'            { last_writer_options->suppress = $3; }
421
475
        | KW_TEMPLATE '(' string ')'            {
422
476
                                                  GError *error = NULL;
423
477
 
424
 
                                                  last_writer_options->template = cfg_check_inline_template(configuration, $3);
425
 
                                                  CHECK_ERROR(log_template_compile(last_writer_options->template, &error), @3, "Error compiling template (%s)", error->message);
 
478
                                                  last_writer_options->template = cfg_check_inline_template(configuration, $3, &error);
 
479
                                                  CHECK_ERROR(last_writer_options->template != NULL, @3, "Error compiling template (%s)", error->message);
426
480
                                                  free($3);
427
481
                                                }
428
482
        | KW_TEMPLATE_ESCAPE '(' yesno ')'      { log_writer_options_set_template_escape(last_writer_options, $3); }
429
483
        | KW_TIME_ZONE '(' string ')'           { last_writer_options->template_options.time_zone[LTZ_SEND] = g_strdup($3); free($3); }
430
484
        | KW_TS_FORMAT '(' string ')'           { last_writer_options->template_options.ts_format = cfg_ts_format_value($3); free($3); }
431
485
        | KW_FRAC_DIGITS '(' LL_NUMBER ')'      { last_writer_options->template_options.frac_digits = $3; }
432
 
        | KW_THROTTLE '(' LL_NUMBER ')'         { last_writer_options->throttle = $3; }
 
486
        | KW_PAD_SIZE '(' LL_NUMBER ')'         { last_writer_options->padding = $3; }
433
487
        ;
434
488
 
435
489
dest_writer_options_flags
437
491
        |                                       { $$ = 0; }
438
492
        ;
439
493
 
 
494
value_pair_option
 
495
        : KW_VALUE_PAIRS
 
496
          { last_value_pairs = value_pairs_new(); }
 
497
          '(' vp_options ')'
 
498
          { $$ = last_value_pairs; }
 
499
        ;
 
500
 
 
501
vp_options
 
502
        : vp_option vp_options
 
503
        |
 
504
        ;
 
505
 
 
506
vp_option
 
507
        : KW_PAIR '(' string ':' string ')'      { value_pairs_add_pair(last_value_pairs, configuration, $3, $5); free($3); free($5); }
 
508
        | KW_PAIR '(' string string ')'          { value_pairs_add_pair(last_value_pairs, configuration, $3, $4); free($3); free($4); }
 
509
        | KW_KEY '(' string ')'             {
 
510
                gchar *k = g_strconcat("$", $3, NULL);
 
511
                value_pairs_add_pair(last_value_pairs, configuration, $3, k);
 
512
                g_free(k);
 
513
                free($3);
 
514
          }
 
515
        | KW_EXCLUDE '(' string ')'              { value_pairs_add_exclude_glob(last_value_pairs, $3); free($3); }
 
516
        | KW_SCOPE '(' vp_scope_list ')'
 
517
        ;
 
518
 
 
519
vp_scope_list
 
520
        : string vp_scope_list              { value_pairs_add_scope(last_value_pairs, $1); free($1); }
 
521
        |
 
522
        ;
 
523
 
440
524
 
441
525
%%