1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
* Copyright (c) 2002-2016 Balabit
* Copyright (c) 2016 Viktor Juhasz <viktor.juhasz@balabit.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/
%type <fnum> float_between_0_and_1
%code top {
#pragma GCC diagnostic ignored "-Wswitch-default"
#include "diskq-parser.h"
}
%code {
#include "cfg-parser.h"
#include "syslog-names.h"
#include "messages.h"
#include "diskq.h"
#include "diskq-options.h"
#include "diskq-config.h"
#include <string.h>
DiskQDestPlugin *last_plugin;
DiskQueueOptions *last_options;
}
%define api.prefix {diskq_}
/* this parameter is needed in order to instruct bison to use a complete
* argument list for yylex/yyerror */
%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {LogDriverPlugin **instance}
%parse-param {gpointer arg}
/* INCLUDE_DECLS */
%token KW_DISK_BUFFER
%token KW_FLOW_CONTROL_WINDOW_SIZE
%token KW_CAPACITY_BYTES
%token KW_RELIABLE
%token KW_COMPACTION
%token KW_FLOW_CONTROL_WINDOW_BYTES
%token KW_FRONT_CACHE_SIZE
%token KW_DIR
%token KW_TRUNCATE_SIZE_RATIO
%token KW_PREALLOC
%%
start
: LL_CONTEXT_INNER_DEST dest_diskq { YYACCEPT; }
| LL_CONTEXT_OPTIONS KW_DISK_BUFFER '(' diskq_global_options ')' { YYACCEPT; }
;
dest_diskq
: KW_DISK_BUFFER
{
last_plugin = diskq_dest_plugin_new();
*instance = (LogDriverPlugin*)last_plugin;
last_options = diskq_get_options(last_plugin);
}
'(' dest_diskq_options ')' { disk_queue_options_check_plugin_settings(last_options); }
;
dest_diskq_options
: dest_diskq_option dest_diskq_options
|
;
dest_diskq_option
: KW_RELIABLE '(' yesno ')' { disk_queue_options_reliable_set(last_options, $3); }
| KW_COMPACTION '(' yesno ')' { disk_queue_options_compaction_set(last_options, $3); }
| KW_FLOW_CONTROL_WINDOW_BYTES '(' nonnegative_integer ')' { disk_queue_options_flow_control_window_bytes_set(last_options, $3); }
| KW_FLOW_CONTROL_WINDOW_SIZE '(' nonnegative_integer ')' { disk_queue_options_flow_control_window_size_set(last_options, $3); }
| KW_CAPACITY_BYTES '(' nonnegative_integer64 ')' { disk_queue_options_capacity_bytes_set(last_options, $3); }
| KW_FRONT_CACHE_SIZE '(' nonnegative_integer ')' { disk_queue_options_front_cache_size_set(last_options, $3); }
| KW_DIR '(' string ')' { disk_queue_options_set_dir(last_options, $3); free($3); }
| KW_TRUNCATE_SIZE_RATIO '(' float_between_0_and_1 ')' { disk_queue_options_set_truncate_size_ratio(last_options, $3); }
| KW_PREALLOC '(' yesno ')' { disk_queue_options_set_prealloc(last_options, $3); }
;
diskq_global_options
: diskq_global_option diskq_global_options
|
;
diskq_global_option
: KW_TRUNCATE_SIZE_RATIO '(' float_between_0_and_1 ')' { disk_queue_config_set_truncate_size_ratio(configuration, $3); }
| KW_PREALLOC '(' yesno ')' { disk_queue_config_set_prealloc(configuration, $3); }
| KW_STATS '(' diskq_global_stats_options ')'
;
diskq_global_stats_options
: diskq_global_stats_option diskq_global_stats_options
|
;
diskq_global_stats_option
: KW_FREQ '(' nonnegative_integer ')' { disk_queue_config_set_stats_freq(configuration, $3); }
;
float_between_0_and_1
: nonnegative_float { CHECK_ERROR(($1 <= 1), @1, "It cannot be bigger, than 1"); }
;
/* INCLUDE_RULES */
%%
|