diff options
| author | Thibault "bui" Koechlin | 2017-12-28 17:04:06 +0100 |
|---|---|---|
| committer | jvoisin | 2017-12-28 17:04:06 +0100 |
| commit | 9f5e8d12f05fb24c915a5266a1e908a75c8aed08 (patch) | |
| tree | 9160075ea943c7fd29a3923f844a0ac0d6b8b457 /src/sp_config_keywords.c | |
| parent | 62c48bf9a85e0294b7b32cea438e904e1cd50669 (diff) | |
Clang-format pass
- `clang-format --style="{BasedOnStyle: google, SortIncludes: false}" -i snuffleu*.c sp_*.c sp_*.h`
- Update the documentation accordingly
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index b3e71fe..998b692 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -108,12 +108,12 @@ int parse_cookie(char *line) { | |||
| 108 | sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); | 108 | sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); |
| 109 | 109 | ||
| 110 | sp_config_functions sp_config_funcs_cookie_encryption[] = { | 110 | sp_config_functions sp_config_funcs_cookie_encryption[] = { |
| 111 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, | 111 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, |
| 112 | {parse_regexp, SP_TOKEN_NAME_REGEXP, &(cookie->name_r)}, | 112 | {parse_regexp, SP_TOKEN_NAME_REGEXP, &(cookie->name_r)}, |
| 113 | {parse_str, SP_TOKEN_SAMESITE, &samesite}, | 113 | {parse_str, SP_TOKEN_SAMESITE, &samesite}, |
| 114 | {parse_empty, SP_TOKEN_ENCRYPT, &cookie->encrypt}, | 114 | {parse_empty, SP_TOKEN_ENCRYPT, &cookie->encrypt}, |
| 115 | {parse_empty, SP_TOKEN_SIMULATION, &cookie->simulation}, | 115 | {parse_empty, SP_TOKEN_SIMULATION, &cookie->simulation}, |
| 116 | {0}}; | 116 | {0}}; |
| 117 | 117 | ||
| 118 | ret = parse_keywords(sp_config_funcs_cookie_encryption, line); | 118 | ret = parse_keywords(sp_config_funcs_cookie_encryption, line); |
| 119 | if (0 != ret) { | 119 | if (0 != ret) { |
| @@ -122,18 +122,21 @@ int parse_cookie(char *line) { | |||
| 122 | 122 | ||
| 123 | if (cookie->encrypt) { | 123 | if (cookie->encrypt) { |
| 124 | if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)) { | 124 | if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)) { |
| 125 | sp_log_err("config", | 125 | sp_log_err( |
| 126 | "You're trying to use the cookie encryption feature" | 126 | "config", |
| 127 | "on line %zu without having set the `.cookie_env_var` option in" | 127 | "You're trying to use the cookie encryption feature" |
| 128 | "`sp.global`: please set it first.", | 128 | "on line %zu without having set the `.cookie_env_var` option in" |
| 129 | "`sp.global`: please set it first.", | ||
| 129 | sp_line_no); | 130 | sp_line_no); |
| 130 | return -1; | 131 | return -1; |
| 131 | } else if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)) { | 132 | } else if (0 == |
| 132 | sp_log_err("config", | 133 | (SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)) { |
| 133 | "You're trying to use the cookie encryption feature" | 134 | sp_log_err( |
| 134 | "on line %zu without having set the `.encryption_key` option in" | 135 | "config", |
| 135 | "`sp.global`: please set it first.", | 136 | "You're trying to use the cookie encryption feature" |
| 136 | sp_line_no); | 137 | "on line %zu without having set the `.encryption_key` option in" |
| 138 | "`sp.global`: please set it first.", | ||
| 139 | sp_line_no); | ||
| 137 | return -1; | 140 | return -1; |
| 138 | } | 141 | } |
| 139 | } else if (!samesite) { | 142 | } else if (!samesite) { |
| @@ -163,16 +166,16 @@ int parse_cookie(char *line) { | |||
| 163 | } else if (0 == strcasecmp(samesite, SP_TOKEN_SAMESITE_STRICT)) { | 166 | } else if (0 == strcasecmp(samesite, SP_TOKEN_SAMESITE_STRICT)) { |
| 164 | cookie->samesite = strict; | 167 | cookie->samesite = strict; |
| 165 | } else { | 168 | } else { |
| 166 | sp_log_err("config", | 169 | sp_log_err( |
| 167 | "%s is an invalid value to samesite (expected %s or %s) on line " | 170 | "config", |
| 168 | "%zu.", | 171 | "%s is an invalid value to samesite (expected %s or %s) on line " |
| 169 | samesite, SP_TOKEN_SAMESITE_LAX, SP_TOKEN_SAMESITE_STRICT, | 172 | "%zu.", |
| 170 | sp_line_no); | 173 | samesite, SP_TOKEN_SAMESITE_LAX, SP_TOKEN_SAMESITE_STRICT, |
| 174 | sp_line_no); | ||
| 171 | return -1; | 175 | return -1; |
| 172 | } | 176 | } |
| 173 | } | 177 | } |
| 174 | sp_list_insert(SNUFFLEUPAGUS_G(config).config_cookie->cookies, | 178 | sp_list_insert(SNUFFLEUPAGUS_G(config).config_cookie->cookies, cookie); |
| 175 | cookie); | ||
| 176 | return SUCCESS; | 179 | return SUCCESS; |
| 177 | } | 180 | } |
| 178 | 181 | ||
| @@ -235,8 +238,8 @@ int parse_disabled_functions(char *line) { | |||
| 235 | MUTUALLY_EXCLUSIVE(df->key, df->r_key, "r_key", "key"); | 238 | MUTUALLY_EXCLUSIVE(df->key, df->r_key, "r_key", "key"); |
| 236 | #undef MUTUALLY_EXCLUSIVE | 239 | #undef MUTUALLY_EXCLUSIVE |
| 237 | 240 | ||
| 238 | if (1 < ((df->r_param ? 1 : 0) + (param ? 1 : 0) + | 241 | if (1 < |
| 239 | ((-1 != df->pos) ? 1 : 0))) { | 242 | ((df->r_param ? 1 : 0) + (param ? 1 : 0) + ((-1 != df->pos) ? 1 : 0))) { |
| 240 | sp_log_err( | 243 | sp_log_err( |
| 241 | "config", | 244 | "config", |
| 242 | "Invalid configuration line: 'sp.disabled_functions%s':" | 245 | "Invalid configuration line: 'sp.disabled_functions%s':" |
| @@ -306,8 +309,8 @@ int parse_disabled_functions(char *line) { | |||
| 306 | if (param) { | 309 | if (param) { |
| 307 | df->param = parse_var(param); | 310 | df->param = parse_var(param); |
| 308 | if (!df->param) { | 311 | if (!df->param) { |
| 309 | sp_log_err("config", "Invalid value '%s' for `param` on line %zu.", | 312 | sp_log_err("config", "Invalid value '%s' for `param` on line %zu.", param, |
| 310 | param, sp_line_no); | 313 | sp_line_no); |
| 311 | return -1; | 314 | return -1; |
| 312 | } | 315 | } |
| 313 | } | 316 | } |
| @@ -316,13 +319,12 @@ int parse_disabled_functions(char *line) { | |||
| 316 | if (*var) { | 319 | if (*var) { |
| 317 | df->var = parse_var(var); | 320 | df->var = parse_var(var); |
| 318 | if (!df->var) { | 321 | if (!df->var) { |
| 319 | sp_log_err("config", "Invalid value '%s' for `var` on line %zu.", | 322 | sp_log_err("config", "Invalid value '%s' for `var` on line %zu.", var, |
| 320 | var, sp_line_no); | 323 | sp_line_no); |
| 321 | return -1; | 324 | return -1; |
| 322 | } | 325 | } |
| 323 | } else { | 326 | } else { |
| 324 | sp_log_err("config", "Empty value in `var` on line %zu.", | 327 | sp_log_err("config", "Empty value in `var` on line %zu.", sp_line_no); |
| 325 | sp_line_no); | ||
| 326 | return -1; | 328 | return -1; |
| 327 | } | 329 | } |
| 328 | } | 330 | } |
