diff options
| author | kkadosh | 2018-02-27 16:40:00 +0000 |
|---|---|---|
| committer | jvoisin | 2018-02-27 17:40:00 +0100 |
| commit | 9e769944ff07e39f3890f192e9bb8c57a8cef54c (patch) | |
| tree | 458ec4bd3bde2cf69fc4bdb94a690fbb68508425 /src/sp_config_keywords.c | |
| parent | 55d9defebd7f6fe34bc6fa49cce61e385df21059 (diff) | |
Implements .dump() for unserialize and fix some related tests
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index d110749..c58a227 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -81,9 +81,32 @@ int parse_global_strict(char *line) { | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | int parse_unserialize(char *line) { | 83 | int parse_unserialize(char *line) { |
| 84 | return parse_enable( | 84 | bool enable = false, disable = false; |
| 85 | line, &(SNUFFLEUPAGUS_G(config).config_unserialize->enable), | 85 | sp_config_unserialize *unserialize = SNUFFLEUPAGUS_G(config).config_unserialize; |
| 86 | &(SNUFFLEUPAGUS_G(config).config_unserialize->simulation)); | 86 | |
| 87 | sp_config_functions sp_config_funcs[] = { | ||
| 88 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | ||
| 89 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | ||
| 90 | {parse_empty, SP_TOKEN_SIMULATION, &(unserialize->simulation)}, | ||
| 91 | {parse_str, SP_TOKEN_DUMP, &(unserialize->dump)}, | ||
| 92 | {0}}; | ||
| 93 | |||
| 94 | unserialize->textual_representation = estrdup(line); | ||
| 95 | |||
| 96 | int ret = parse_keywords(sp_config_funcs, line); | ||
| 97 | if (0 != ret) { | ||
| 98 | return ret; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (!(enable ^ disable)) { | ||
| 102 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu.", | ||
| 103 | sp_line_no); | ||
| 104 | return -1; | ||
| 105 | } | ||
| 106 | |||
| 107 | SNUFFLEUPAGUS_G(config).config_unserialize->enable = enable; | ||
| 108 | |||
| 109 | return ret; | ||
| 87 | } | 110 | } |
| 88 | 111 | ||
| 89 | int parse_readonly_exec(char *line) { | 112 | int parse_readonly_exec(char *line) { |
