32
32
#include "cfg-parser.h"
33
33
#include "dummy-grammar.h"
36
extern LogDriver *last_driver;
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}
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); \
382
/* LogSource related options */
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); }
365
400
source_reader_options
366
401
: source_reader_option source_reader_options
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 */
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 ')'
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;
429
| { last_source_options = &last_reader_options->super; } source_option
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"); }
439
/* NOTE: plugins need to set "last_driver" in order to incorporate this rule in their grammar */
441
: KW_LOG_FIFO_SIZE '(' LL_NUMBER ')' { ((LogDestDriver *) last_driver)->log_fifo_size = $3; }
442
| KW_THROTTLE '(' LL_NUMBER ')' { ((LogDestDriver *) last_driver)->throttle = $3; }
446
gint context = LL_CONTEXT_INNER_DEST;
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);
452
value = plugin_parse_config(p, configuration, &@1, last_driver);
459
log_driver_add_plugin(last_driver, (LogDriverPlugin *) value);
410
463
dest_writer_options
411
464
: dest_writer_option dest_writer_options
415
468
dest_writer_option
469
/* NOTE: plugins need to set "last_writer_options" in order to incorporate this rule in their grammar */
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;
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);
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; }
435
489
dest_writer_options_flags
496
{ last_value_pairs = value_pairs_new(); }
498
{ $$ = last_value_pairs; }
502
: vp_option vp_options
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);
515
| KW_EXCLUDE '(' string ')' { value_pairs_add_exclude_glob(last_value_pairs, $3); free($3); }
516
| KW_SCOPE '(' vp_scope_list ')'
520
: string vp_scope_list { value_pairs_add_scope(last_value_pairs, $1); free($1); }