version 1.1.1.2, 2014/06/15 20:20:06
|
version 1.1.1.3, 2016/11/02 10:35:00
|
Line 3
|
Line 3
|
*/ |
*/ |
/* First off, code is include which follows the "include" declaration |
/* First off, code is include which follows the "include" declaration |
** in the input file. */ |
** in the input file. */ |
|
#include "first.h" |
#include <stdio.h> |
#include <stdio.h> |
#line 5 "../../src/configparser.y" |
#line 5 "../../src/configparser.y" |
|
|
|
#include "first.h" |
#include "configfile.h" |
#include "configfile.h" |
#include "buffer.h" |
#include "buffer.h" |
#include "array.h" |
#include "array.h" |
|
#include "request.h" /* http_request_host_normalize() */ |
|
|
#include <assert.h> |
#include <assert.h> |
|
#include <ctype.h> |
|
#include <errno.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
|
Line 20 static void configparser_push(config_t *ctx, data_conf
|
Line 25 static void configparser_push(config_t *ctx, data_conf
|
force_assert(dc->context_ndx > ctx->current->context_ndx); |
force_assert(dc->context_ndx > ctx->current->context_ndx); |
array_insert_unique(ctx->all_configs, (data_unset *)dc); |
array_insert_unique(ctx->all_configs, (data_unset *)dc); |
dc->parent = ctx->current; |
dc->parent = ctx->current; |
array_insert_unique(dc->parent->childs, (data_unset *)dc); | vector_config_weak_push(&dc->parent->children, dc); |
} |
} |
if (ctx->configs_stack->used > 0 && ctx->current->context_ndx == 0) { | if (ctx->configs_stack.used > 0 && ctx->current->context_ndx == 0) { |
fprintf(stderr, "Cannot use conditionals inside a global { ... } block\n"); |
fprintf(stderr, "Cannot use conditionals inside a global { ... } block\n"); |
exit(-1); |
exit(-1); |
} |
} |
array_insert_unique(ctx->configs_stack, (data_unset *)ctx->current); | vector_config_weak_push(&ctx->configs_stack, ctx->current); |
ctx->current = dc; |
ctx->current = dc; |
} |
} |
|
|
static data_config *configparser_pop(config_t *ctx) { |
static data_config *configparser_pop(config_t *ctx) { |
data_config *old = ctx->current; |
data_config *old = ctx->current; |
ctx->current = (data_config *) array_pop(ctx->configs_stack); | ctx->current = vector_config_weak_pop(&ctx->configs_stack); |
return old; |
return old; |
} |
} |
|
|
Line 64 data_unset *configparser_merge_data(data_unset *op1, c
|
Line 69 data_unset *configparser_merge_data(data_unset *op1, c
|
if (op1->type != op2->type) { |
if (op1->type != op2->type) { |
if (op1->type == TYPE_STRING && op2->type == TYPE_INTEGER) { |
if (op1->type == TYPE_STRING && op2->type == TYPE_INTEGER) { |
data_string *ds = (data_string *)op1; |
data_string *ds = (data_string *)op1; |
buffer_append_long(ds->value, ((data_integer*)op2)->value); | buffer_append_int(ds->value, ((data_integer*)op2)->value); |
return op1; |
return op1; |
} else if (op1->type == TYPE_INTEGER && op2->type == TYPE_STRING) { |
} else if (op1->type == TYPE_INTEGER && op2->type == TYPE_STRING) { |
data_string *ds = data_string_init(); |
data_string *ds = data_string_init(); |
buffer_append_long(ds->value, ((data_integer*)op1)->value); | buffer_append_int(ds->value, ((data_integer*)op1)->value); |
buffer_append_string_buffer(ds->value, ((data_string*)op2)->value); |
buffer_append_string_buffer(ds->value, ((data_string*)op2)->value); |
op1->free(op1); |
op1->free(op1); |
return (data_unset *)ds; |
return (data_unset *)ds; |
} else { |
} else { |
fprintf(stderr, "data type mismatch, cannot merge\n"); |
fprintf(stderr, "data type mismatch, cannot merge\n"); |
|
op1->free(op1); |
return NULL; |
return NULL; |
} |
} |
} |
} |
Line 94 data_unset *configparser_merge_data(data_unset *op1, c
|
Line 100 data_unset *configparser_merge_data(data_unset *op1, c
|
for (i = 0; i < src->used; i ++) { |
for (i = 0; i < src->used; i ++) { |
du = (data_unset *)src->data[i]; |
du = (data_unset *)src->data[i]; |
if (du) { |
if (du) { |
array_insert_unique(dst, du->copy(du)); | if (du->is_index_key || buffer_is_empty(du->key) || !array_get_element(dst, du->key->ptr)) { |
| array_insert_unique(dst, du->copy(du)); |
| } else { |
| fprintf(stderr, "Duplicate array-key '%s'\n", du->key->ptr); |
| op1->free(op1); |
| return NULL; |
| } |
} |
} |
} |
} |
break; |
break; |
Line 106 data_unset *configparser_merge_data(data_unset *op1, c
|
Line 118 data_unset *configparser_merge_data(data_unset *op1, c
|
return op1; |
return op1; |
} |
} |
|
|
|
static int configparser_remoteip_normalize_compat(buffer *rvalue) { |
|
/* $HTTP["remoteip"] IPv6 accepted with or without '[]' for config compat |
|
* http_request_host_normalize() expects IPv6 with '[]', |
|
* and config processing at runtime expects COMP_HTTP_REMOTE_IP |
|
* compared without '[]', so strip '[]' after normalization */ |
|
buffer *b = buffer_init(); |
|
int rc; |
|
|
#line 111 "configparser.c" | if (rvalue->ptr[0] != '[') { |
| buffer_append_string_len(b, CONST_STR_LEN("[")); |
| buffer_append_string_buffer(b, rvalue); |
| buffer_append_string_len(b, CONST_STR_LEN("]")); |
| } else { |
| buffer_append_string_buffer(b, rvalue); |
| } |
| |
| rc = http_request_host_normalize(b); |
| |
| if (0 == rc) { |
| /* remove surrounding '[]' */ |
| size_t blen = buffer_string_length(b); |
| if (blen > 1) buffer_copy_string_len(rvalue, b->ptr+1, blen-2); |
| } |
| |
| buffer_free(b); |
| return rc; |
| } |
| |
| |
| #line 151 "configparser.c" |
/* Next is all token values, in a form suitable for use by makeheaders. |
/* Next is all token values, in a form suitable for use by makeheaders. |
** This section will be null unless lemon is run with the -m switch. |
** This section will be null unless lemon is run with the -m switch. |
*/ |
*/ |
Line 518 static void yy_destructor(YYCODETYPE yymajor, YYMINORT
|
Line 558 static void yy_destructor(YYCODETYPE yymajor, YYMINORT
|
case 23: |
case 23: |
case 24: |
case 24: |
case 25: |
case 25: |
#line 144 "../../src/configparser.y" | #line 182 "../../src/configparser.y" |
{ buffer_free((yypminor->yy0)); } |
{ buffer_free((yypminor->yy0)); } |
#line 523 "configparser.c" | #line 563 "configparser.c" |
break; |
break; |
case 35: |
case 35: |
#line 135 "../../src/configparser.y" | #line 173 "../../src/configparser.y" |
{ (yypminor->yy41)->free((yypminor->yy41)); } | { if ((yypminor->yy41)) (yypminor->yy41)->free((yypminor->yy41)); } |
#line 528 "configparser.c" | #line 568 "configparser.c" |
break; |
break; |
case 36: |
case 36: |
#line 136 "../../src/configparser.y" | #line 174 "../../src/configparser.y" |
{ (yypminor->yy41)->free((yypminor->yy41)); } | { if ((yypminor->yy41)) (yypminor->yy41)->free((yypminor->yy41)); } |
#line 533 "configparser.c" | #line 573 "configparser.c" |
break; |
break; |
case 37: |
case 37: |
#line 137 "../../src/configparser.y" | #line 175 "../../src/configparser.y" |
{ (yypminor->yy41)->free((yypminor->yy41)); } | { if ((yypminor->yy41)) (yypminor->yy41)->free((yypminor->yy41)); } |
#line 538 "configparser.c" | #line 578 "configparser.c" |
break; |
break; |
case 39: |
case 39: |
#line 138 "../../src/configparser.y" | #line 176 "../../src/configparser.y" |
{ array_free((yypminor->yy40)); } |
{ array_free((yypminor->yy40)); } |
#line 543 "configparser.c" | #line 583 "configparser.c" |
break; |
break; |
case 40: |
case 40: |
#line 139 "../../src/configparser.y" | #line 177 "../../src/configparser.y" |
{ array_free((yypminor->yy40)); } |
{ array_free((yypminor->yy40)); } |
#line 548 "configparser.c" | #line 588 "configparser.c" |
break; |
break; |
case 41: |
case 41: |
#line 140 "../../src/configparser.y" | #line 178 "../../src/configparser.y" |
{ buffer_free((yypminor->yy43)); } |
{ buffer_free((yypminor->yy43)); } |
#line 553 "configparser.c" | #line 593 "configparser.c" |
break; |
break; |
case 42: |
case 42: |
#line 141 "../../src/configparser.y" | #line 179 "../../src/configparser.y" |
{ buffer_free((yypminor->yy43)); } |
{ buffer_free((yypminor->yy43)); } |
#line 558 "configparser.c" | #line 598 "configparser.c" |
break; |
break; |
default: break; /* If no destructor action specified: do nothing */ |
default: break; /* If no destructor action specified: do nothing */ |
} |
} |
Line 571 static void yy_destructor(YYCODETYPE yymajor, YYMINORT
|
Line 611 static void yy_destructor(YYCODETYPE yymajor, YYMINORT
|
*/ |
*/ |
static int yy_pop_parser_stack(yyParser *pParser){ |
static int yy_pop_parser_stack(yyParser *pParser){ |
YYCODETYPE yymajor; |
YYCODETYPE yymajor; |
yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; | yyStackEntry *yytos; |
|
|
if( pParser->yyidx<0 ) return 0; |
if( pParser->yyidx<0 ) return 0; |
|
yytos = &pParser->yystack[pParser->yyidx]; |
#ifndef NDEBUG |
#ifndef NDEBUG |
if( yyTraceFILE && pParser->yyidx>=0 ){ |
if( yyTraceFILE && pParser->yyidx>=0 ){ |
fprintf(yyTraceFILE,"%sPopping %s\n", |
fprintf(yyTraceFILE,"%sPopping %s\n", |
Line 791 static void yy_reduce(
|
Line 832 static void yy_reduce(
|
configparserARG_FETCH; |
configparserARG_FETCH; |
yymsp = &yypParser->yystack[yypParser->yyidx]; |
yymsp = &yypParser->yystack[yypParser->yyidx]; |
#ifndef NDEBUG |
#ifndef NDEBUG |
if( yyTraceFILE && yyruleno>=0 | if( yyTraceFILE ) { |
| if (yyruleno>=0 |
&& (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ |
&& (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ |
fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, | fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
yyRuleName[yyruleno]); | yyRuleName[yyruleno]); |
| } else { |
| return; /*(should not happen)*/ |
| } |
} |
} |
#endif /* NDEBUG */ |
#endif /* NDEBUG */ |
|
|
Line 823 static void yy_reduce(
|
Line 868 static void yy_reduce(
|
/* No destructor defined for global */ |
/* No destructor defined for global */ |
break; |
break; |
case 5: |
case 5: |
#line 117 "../../src/configparser.y" | #line 156 "../../src/configparser.y" |
{ yymsp[-1].minor.yy78 = NULL; } |
{ yymsp[-1].minor.yy78 = NULL; } |
#line 828 "configparser.c" | #line 873 "configparser.c" |
yy_destructor(1,&yymsp[0].minor); |
yy_destructor(1,&yymsp[0].minor); |
break; |
break; |
case 6: |
case 6: |
Line 838 static void yy_reduce(
|
Line 883 static void yy_reduce(
|
yy_destructor(1,&yymsp[0].minor); |
yy_destructor(1,&yymsp[0].minor); |
break; |
break; |
case 9: |
case 9: |
#line 146 "../../src/configparser.y" | #line 184 "../../src/configparser.y" |
{ |
{ |
if (ctx->ok) { |
if (ctx->ok) { |
buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); | buffer_copy_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); |
if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { |
if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { |
fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n", |
fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n", |
ctx->current->context_ndx, |
ctx->current->context_ndx, |
Line 862 static void yy_reduce(
|
Line 907 static void yy_reduce(
|
buffer_free(yymsp[-2].minor.yy43); |
buffer_free(yymsp[-2].minor.yy43); |
yymsp[-2].minor.yy43 = NULL; |
yymsp[-2].minor.yy43 = NULL; |
} |
} |
#line 865 "configparser.c" | #line 910 "configparser.c" |
yy_destructor(2,&yymsp[-1].minor); |
yy_destructor(2,&yymsp[-1].minor); |
break; |
break; |
case 10: |
case 10: |
#line 170 "../../src/configparser.y" | #line 208 "../../src/configparser.y" |
{ |
{ |
array *vars = ctx->current->value; | if (ctx->ok) { |
data_unset *du; | array *vars = ctx->current->value; |
| data_unset *du; |
|
|
if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { | if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { |
fprintf(stderr, "Appending env variable is not supported in conditional %d %s: %s\n", | fprintf(stderr, "Appending env variable is not supported in conditional %d %s: %s\n", |
ctx->current->context_ndx, | ctx->current->context_ndx, |
ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr); | ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr); |
ctx->ok = 0; | |
} else if (NULL != (du = array_get_element(vars, yymsp[-2].minor.yy43->ptr))) { | |
/* exists in current block */ | |
du = configparser_merge_data(du, yymsp[0].minor.yy41); | |
if (NULL == du) { | |
ctx->ok = 0; |
ctx->ok = 0; |
|
} else if (NULL != (du = array_extract_element(vars, yymsp[-2].minor.yy43->ptr)) || NULL != (du = configparser_get_variable(ctx, yymsp[-2].minor.yy43))) { |
|
du = configparser_merge_data(du, yymsp[0].minor.yy41); |
|
if (NULL == du) { |
|
ctx->ok = 0; |
|
} |
|
else { |
|
buffer_copy_buffer(du->key, yymsp[-2].minor.yy43); |
|
array_insert_unique(ctx->current->value, du); |
|
} |
|
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
|
} else { |
|
buffer_copy_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); |
|
array_insert_unique(ctx->current->value, yymsp[0].minor.yy41); |
} |
} |
else { | buffer_free(yymsp[-2].minor.yy43); |
buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43); | yymsp[-2].minor.yy43 = NULL; |
array_replace(vars, du); | yymsp[0].minor.yy41 = NULL; |
} | |
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); | |
} else if (NULL != (du = configparser_get_variable(ctx, yymsp[-2].minor.yy43))) { | |
du = configparser_merge_data(du, yymsp[0].minor.yy41); | |
if (NULL == du) { | |
ctx->ok = 0; | |
} | |
else { | |
buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43); | |
array_insert_unique(ctx->current->value, du); | |
} | |
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); | |
} else { | |
buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); | |
array_insert_unique(ctx->current->value, yymsp[0].minor.yy41); | |
} |
} |
buffer_free(yymsp[-2].minor.yy43); |
|
yymsp[-2].minor.yy43 = NULL; |
|
yymsp[0].minor.yy41 = NULL; |
|
} |
} |
#line 908 "configparser.c" | #line 944 "configparser.c" |
yy_destructor(3,&yymsp[-1].minor); |
yy_destructor(3,&yymsp[-1].minor); |
break; |
break; |
case 11: |
case 11: |
#line 209 "../../src/configparser.y" | #line 238 "../../src/configparser.y" |
{ |
{ |
if (strchr(yymsp[0].minor.yy0->ptr, '.') == NULL) { |
if (strchr(yymsp[0].minor.yy0->ptr, '.') == NULL) { |
yygotominor.yy43 = buffer_init_string("var."); |
yygotominor.yy43 = buffer_init_string("var."); |
Line 921 static void yy_reduce(
|
Line 957 static void yy_reduce(
|
yymsp[0].minor.yy0 = NULL; |
yymsp[0].minor.yy0 = NULL; |
} |
} |
} |
} |
#line 924 "configparser.c" | #line 960 "configparser.c" |
break; |
break; |
case 12: |
case 12: |
#line 221 "../../src/configparser.y" | #line 250 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = configparser_merge_data(yymsp[-2].minor.yy41, yymsp[0].minor.yy41); | yygotominor.yy41 = NULL; |
if (NULL == yygotominor.yy41) { | if (ctx->ok) { |
ctx->ok = 0; | yygotominor.yy41 = configparser_merge_data(yymsp[-2].minor.yy41, yymsp[0].minor.yy41); |
| if (NULL == yygotominor.yy41) { |
| ctx->ok = 0; |
| } |
| yymsp[-2].minor.yy41 = NULL; |
| yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
| yymsp[0].minor.yy41 = NULL; |
} |
} |
yymsp[-2].minor.yy41 = NULL; |
|
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
|
yymsp[0].minor.yy41 = NULL; |
|
} |
} |
#line 937 "configparser.c" | #line 976 "configparser.c" |
yy_destructor(5,&yymsp[-1].minor); |
yy_destructor(5,&yymsp[-1].minor); |
break; |
break; |
case 13: |
case 13: |
#line 231 "../../src/configparser.y" | #line 263 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = yymsp[0].minor.yy41; |
yygotominor.yy41 = yymsp[0].minor.yy41; |
yymsp[0].minor.yy41 = NULL; |
yymsp[0].minor.yy41 = NULL; |
} |
} |
#line 946 "configparser.c" | #line 985 "configparser.c" |
break; |
break; |
case 14: |
case 14: |
#line 236 "../../src/configparser.y" | #line 268 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = NULL; |
yygotominor.yy41 = NULL; |
if (strncmp(yymsp[0].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { | if (ctx->ok) { |
char *env; | if (strncmp(yymsp[0].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { |
| char *env; |
|
|
if (NULL != (env = getenv(yymsp[0].minor.yy43->ptr + 4))) { | if (NULL != (env = getenv(yymsp[0].minor.yy43->ptr + 4))) { |
data_string *ds; | data_string *ds; |
ds = data_string_init(); | ds = data_string_init(); |
buffer_append_string(ds->value, env); | buffer_append_string(ds->value, env); |
yygotominor.yy41 = (data_unset *)ds; | yygotominor.yy41 = (data_unset *)ds; |
} | } |
else { | else { |
fprintf(stderr, "Undefined env variable: %s\n", yymsp[0].minor.yy43->ptr + 4); | fprintf(stderr, "Undefined env variable: %s\n", yymsp[0].minor.yy43->ptr + 4); |
| ctx->ok = 0; |
| } |
| } else if (NULL == (yygotominor.yy41 = configparser_get_variable(ctx, yymsp[0].minor.yy43))) { |
| fprintf(stderr, "Undefined config variable: %s\n", yymsp[0].minor.yy43->ptr); |
ctx->ok = 0; |
ctx->ok = 0; |
} |
} |
} else if (NULL == (yygotominor.yy41 = configparser_get_variable(ctx, yymsp[0].minor.yy43))) { | buffer_free(yymsp[0].minor.yy43); |
fprintf(stderr, "Undefined config variable: %s\n", yymsp[0].minor.yy43->ptr); | yymsp[0].minor.yy43 = NULL; |
ctx->ok = 0; | |
} |
} |
if (!yygotominor.yy41) { |
|
/* make a dummy so it won't crash */ |
|
yygotominor.yy41 = (data_unset *)data_string_init(); |
|
} |
|
buffer_free(yymsp[0].minor.yy43); |
|
yymsp[0].minor.yy43 = NULL; |
|
} |
} |
#line 976 "configparser.c" | #line 1013 "configparser.c" |
break; |
break; |
case 15: |
case 15: |
#line 263 "../../src/configparser.y" | #line 293 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = (data_unset *)data_string_init(); |
yygotominor.yy41 = (data_unset *)data_string_init(); |
buffer_copy_string_buffer(((data_string *)(yygotominor.yy41))->value, yymsp[0].minor.yy0); | buffer_copy_buffer(((data_string *)(yygotominor.yy41))->value, yymsp[0].minor.yy0); |
buffer_free(yymsp[0].minor.yy0); |
buffer_free(yymsp[0].minor.yy0); |
yymsp[0].minor.yy0 = NULL; |
yymsp[0].minor.yy0 = NULL; |
} |
} |
#line 986 "configparser.c" | #line 1023 "configparser.c" |
break; |
break; |
case 16: |
case 16: |
#line 270 "../../src/configparser.y" | #line 300 "../../src/configparser.y" |
{ |
{ |
|
char *endptr; |
yygotominor.yy41 = (data_unset *)data_integer_init(); |
yygotominor.yy41 = (data_unset *)data_integer_init(); |
((data_integer *)(yygotominor.yy41))->value = strtol(yymsp[0].minor.yy0->ptr, NULL, 10); | errno = 0; |
| ((data_integer *)(yygotominor.yy41))->value = strtol(yymsp[0].minor.yy0->ptr, &endptr, 10); |
| /* skip trailing whitespace */ |
| if (endptr != yymsp[0].minor.yy0->ptr) while (isspace(*endptr)) endptr++; |
| if (0 != errno || *endptr != '\0') { |
| fprintf(stderr, "error parsing number: '%s'\n", yymsp[0].minor.yy0->ptr); |
| ctx->ok = 0; |
| } |
buffer_free(yymsp[0].minor.yy0); |
buffer_free(yymsp[0].minor.yy0); |
yymsp[0].minor.yy0 = NULL; |
yymsp[0].minor.yy0 = NULL; |
} |
} |
#line 996 "configparser.c" | #line 1041 "configparser.c" |
break; |
break; |
case 17: |
case 17: |
#line 276 "../../src/configparser.y" | #line 314 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = (data_unset *)data_array_init(); |
yygotominor.yy41 = (data_unset *)data_array_init(); |
array_free(((data_array *)(yygotominor.yy41))->value); |
array_free(((data_array *)(yygotominor.yy41))->value); |
((data_array *)(yygotominor.yy41))->value = yymsp[0].minor.yy40; |
((data_array *)(yygotominor.yy41))->value = yymsp[0].minor.yy40; |
yymsp[0].minor.yy40 = NULL; |
yymsp[0].minor.yy40 = NULL; |
} |
} |
#line 1006 "configparser.c" | #line 1051 "configparser.c" |
break; |
break; |
case 18: |
case 18: |
#line 282 "../../src/configparser.y" | #line 320 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy40 = array_init(); |
yygotominor.yy40 = array_init(); |
} |
} |
#line 1013 "configparser.c" | #line 1058 "configparser.c" |
yy_destructor(8,&yymsp[-1].minor); |
yy_destructor(8,&yymsp[-1].minor); |
yy_destructor(9,&yymsp[0].minor); |
yy_destructor(9,&yymsp[0].minor); |
break; |
break; |
case 19: |
case 19: |
#line 285 "../../src/configparser.y" | #line 323 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy40 = yymsp[-1].minor.yy40; |
yygotominor.yy40 = yymsp[-1].minor.yy40; |
yymsp[-1].minor.yy40 = NULL; |
yymsp[-1].minor.yy40 = NULL; |
} |
} |
#line 1023 "configparser.c" | #line 1068 "configparser.c" |
yy_destructor(8,&yymsp[-2].minor); |
yy_destructor(8,&yymsp[-2].minor); |
yy_destructor(9,&yymsp[0].minor); |
yy_destructor(9,&yymsp[0].minor); |
break; |
break; |
case 20: |
case 20: |
#line 290 "../../src/configparser.y" | #line 328 "../../src/configparser.y" |
{ |
{ |
if (buffer_is_empty(yymsp[0].minor.yy41->key) || | yygotominor.yy40 = NULL; |
NULL == array_get_element(yymsp[-2].minor.yy40, yymsp[0].minor.yy41->key->ptr)) { | if (ctx->ok) { |
array_insert_unique(yymsp[-2].minor.yy40, yymsp[0].minor.yy41); | if (buffer_is_empty(yymsp[0].minor.yy41->key) || |
yymsp[0].minor.yy41 = NULL; | NULL == array_get_element(yymsp[-2].minor.yy40, yymsp[0].minor.yy41->key->ptr)) { |
} else { | array_insert_unique(yymsp[-2].minor.yy40, yymsp[0].minor.yy41); |
fprintf(stderr, "Duplicate array-key: %s\n", | yymsp[0].minor.yy41 = NULL; |
yymsp[0].minor.yy41->key->ptr); | } else { |
ctx->ok = 0; | fprintf(stderr, "Error: duplicate array-key: %s. Please get rid of the duplicate entry.\n", |
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); | yymsp[0].minor.yy41->key->ptr); |
yymsp[0].minor.yy41 = NULL; | ctx->ok = 0; |
} | yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
| yymsp[0].minor.yy41 = NULL; |
| } |
|
|
yygotominor.yy40 = yymsp[-2].minor.yy40; | yygotominor.yy40 = yymsp[-2].minor.yy40; |
yymsp[-2].minor.yy40 = NULL; | yymsp[-2].minor.yy40 = NULL; |
| } |
} |
} |
#line 1045 "configparser.c" | #line 1093 "configparser.c" |
yy_destructor(10,&yymsp[-1].minor); |
yy_destructor(10,&yymsp[-1].minor); |
break; |
break; |
case 21: |
case 21: |
#line 307 "../../src/configparser.y" | #line 348 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy40 = yymsp[-1].minor.yy40; |
yygotominor.yy40 = yymsp[-1].minor.yy40; |
yymsp[-1].minor.yy40 = NULL; |
yymsp[-1].minor.yy40 = NULL; |
} |
} |
#line 1054 "configparser.c" | #line 1102 "configparser.c" |
yy_destructor(10,&yymsp[0].minor); |
yy_destructor(10,&yymsp[0].minor); |
break; |
break; |
case 22: |
case 22: |
#line 312 "../../src/configparser.y" | #line 353 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy40 = array_init(); | yygotominor.yy40 = NULL; |
array_insert_unique(yygotominor.yy40, yymsp[0].minor.yy41); | if (ctx->ok) { |
yymsp[0].minor.yy41 = NULL; | yygotominor.yy40 = array_init(); |
| array_insert_unique(yygotominor.yy40, yymsp[0].minor.yy41); |
| yymsp[0].minor.yy41 = NULL; |
| } |
} |
} |
#line 1064 "configparser.c" | #line 1115 "configparser.c" |
break; |
break; |
case 23: |
case 23: |
#line 318 "../../src/configparser.y" | #line 362 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy41 = yymsp[0].minor.yy41; |
yygotominor.yy41 = yymsp[0].minor.yy41; |
yymsp[0].minor.yy41 = NULL; |
yymsp[0].minor.yy41 = NULL; |
} |
} |
#line 1072 "configparser.c" | #line 1123 "configparser.c" |
break; |
break; |
case 24: |
case 24: |
#line 322 "../../src/configparser.y" | #line 366 "../../src/configparser.y" |
{ |
{ |
buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); | yygotominor.yy41 = NULL; |
buffer_free(yymsp[-2].minor.yy43); | if (ctx->ok) { |
yymsp[-2].minor.yy43 = NULL; | buffer_copy_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); |
| buffer_free(yymsp[-2].minor.yy43); |
| yymsp[-2].minor.yy43 = NULL; |
|
|
yygotominor.yy41 = yymsp[0].minor.yy41; | yygotominor.yy41 = yymsp[0].minor.yy41; |
yymsp[0].minor.yy41 = NULL; | yymsp[0].minor.yy41 = NULL; |
| } |
} |
} |
#line 1084 "configparser.c" | #line 1138 "configparser.c" |
yy_destructor(11,&yymsp[-1].minor); |
yy_destructor(11,&yymsp[-1].minor); |
break; |
break; |
case 25: |
case 25: |
Line 1090 static void yy_reduce(
|
Line 1144 static void yy_reduce(
|
case 26: |
case 26: |
break; |
break; |
case 27: |
case 27: |
#line 334 "../../src/configparser.y" | #line 381 "../../src/configparser.y" |
{ |
{ |
data_config *dc; |
data_config *dc; |
dc = (data_config *)array_get_element(ctx->srv->config_context, "global"); |
dc = (data_config *)array_get_element(ctx->srv->config_context, "global"); |
force_assert(dc); |
force_assert(dc); |
configparser_push(ctx, dc, 0); |
configparser_push(ctx, dc, 0); |
} |
} |
#line 1100 "configparser.c" | #line 1154 "configparser.c" |
yy_destructor(12,&yymsp[0].minor); |
yy_destructor(12,&yymsp[0].minor); |
break; |
break; |
case 28: |
case 28: |
#line 341 "../../src/configparser.y" | #line 388 "../../src/configparser.y" |
{ |
{ |
data_config *cur; | force_assert(ctx->current); |
| |
cur = ctx->current; | |
configparser_pop(ctx); |
configparser_pop(ctx); |
| force_assert(ctx->current); |
force_assert(cur && ctx->current); | |
| |
yygotominor.yy78 = cur; | |
} |
} |
#line 1115 "configparser.c" | #line 1164 "configparser.c" |
/* No destructor defined for globalstart */ |
/* No destructor defined for globalstart */ |
yy_destructor(13,&yymsp[-2].minor); |
yy_destructor(13,&yymsp[-2].minor); |
/* No destructor defined for metalines */ |
/* No destructor defined for metalines */ |
yy_destructor(14,&yymsp[0].minor); |
yy_destructor(14,&yymsp[0].minor); |
break; |
break; |
case 29: |
case 29: |
#line 352 "../../src/configparser.y" | #line 394 "../../src/configparser.y" |
{ |
{ |
if (yymsp[-3].minor.yy78->context_ndx >= yymsp[0].minor.yy78->context_ndx) { | yygotominor.yy78 = NULL; |
fprintf(stderr, "unreachable else condition\n"); | if (ctx->ok) { |
ctx->ok = 0; | if (yymsp[-3].minor.yy78->context_ndx >= yymsp[0].minor.yy78->context_ndx) { |
| fprintf(stderr, "unreachable else condition\n"); |
| ctx->ok = 0; |
| } |
| yymsp[0].minor.yy78->prev = yymsp[-3].minor.yy78; |
| yymsp[-3].minor.yy78->next = yymsp[0].minor.yy78; |
| yygotominor.yy78 = yymsp[0].minor.yy78; |
| yymsp[-3].minor.yy78 = NULL; |
| yymsp[0].minor.yy78 = NULL; |
} |
} |
yymsp[0].minor.yy78->prev = yymsp[-3].minor.yy78; |
|
yymsp[-3].minor.yy78->next = yymsp[0].minor.yy78; |
|
yygotominor.yy78 = yymsp[0].minor.yy78; |
|
yymsp[-3].minor.yy78 = NULL; |
|
yymsp[0].minor.yy78 = NULL; |
|
} |
} |
#line 1134 "configparser.c" | #line 1186 "configparser.c" |
/* No destructor defined for eols */ |
/* No destructor defined for eols */ |
yy_destructor(15,&yymsp[-1].minor); |
yy_destructor(15,&yymsp[-1].minor); |
break; |
break; |
case 30: |
case 30: |
#line 364 "../../src/configparser.y" | #line 409 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy78 = yymsp[0].minor.yy78; |
yygotominor.yy78 = yymsp[0].minor.yy78; |
yymsp[0].minor.yy78 = NULL; |
yymsp[0].minor.yy78 = NULL; |
} |
} |
#line 1144 "configparser.c" | #line 1196 "configparser.c" |
break; |
break; |
case 31: |
case 31: |
#line 369 "../../src/configparser.y" | #line 414 "../../src/configparser.y" |
{ |
{ |
data_config *cur; | yygotominor.yy78 = NULL; |
| if (ctx->ok) { |
| data_config *cur; |
|
|
cur = ctx->current; | cur = ctx->current; |
configparser_pop(ctx); | configparser_pop(ctx); |
|
|
force_assert(cur && ctx->current); | force_assert(cur && ctx->current); |
|
|
yygotominor.yy78 = cur; | yygotominor.yy78 = cur; |
| } |
} |
} |
#line 1158 "configparser.c" | #line 1213 "configparser.c" |
/* No destructor defined for context */ |
/* No destructor defined for context */ |
yy_destructor(13,&yymsp[-2].minor); |
yy_destructor(13,&yymsp[-2].minor); |
/* No destructor defined for metalines */ |
/* No destructor defined for metalines */ |
yy_destructor(14,&yymsp[0].minor); |
yy_destructor(14,&yymsp[0].minor); |
break; |
break; |
case 32: |
case 32: |
#line 380 "../../src/configparser.y" | #line 428 "../../src/configparser.y" |
{ |
{ |
data_config *dc; |
data_config *dc; |
buffer *b, *rvalue, *op; |
buffer *b, *rvalue, *op; |
Line 1172 static void yy_reduce(
|
Line 1227 static void yy_reduce(
|
ctx->ok = 0; |
ctx->ok = 0; |
} |
} |
|
|
switch(yymsp[-1].minor.yy27) { | if (ctx->ok) { |
case CONFIG_COND_NE: | switch(yymsp[-1].minor.yy27) { |
op = buffer_init_string("!="); | case CONFIG_COND_NE: |
break; | op = buffer_init_string("!="); |
case CONFIG_COND_EQ: | break; |
op = buffer_init_string("=="); | case CONFIG_COND_EQ: |
break; | op = buffer_init_string("=="); |
case CONFIG_COND_NOMATCH: | break; |
op = buffer_init_string("!~"); | case CONFIG_COND_NOMATCH: |
break; | op = buffer_init_string("!~"); |
case CONFIG_COND_MATCH: | break; |
op = buffer_init_string("=~"); | case CONFIG_COND_MATCH: |
break; | op = buffer_init_string("=~"); |
default: | break; |
force_assert(0); | default: |
return; | force_assert(0); |
} | return; /* unreachable */ |
| } |
|
|
b = buffer_init(); | b = buffer_init(); |
buffer_copy_string_buffer(b, ctx->current->key); | buffer_copy_buffer(b, ctx->current->key); |
buffer_append_string(b, "/"); | buffer_append_string(b, "/"); |
buffer_append_string_buffer(b, yymsp[-5].minor.yy0); | buffer_append_string_buffer(b, yymsp[-5].minor.yy0); |
buffer_append_string_buffer(b, yymsp[-3].minor.yy43); | buffer_append_string_buffer(b, yymsp[-3].minor.yy43); |
buffer_append_string_buffer(b, op); | buffer_append_string_buffer(b, op); |
rvalue = ((data_string*)yymsp[0].minor.yy41)->value; | rvalue = ((data_string*)yymsp[0].minor.yy41)->value; |
buffer_append_string_buffer(b, rvalue); | buffer_append_string_buffer(b, rvalue); |
|
|
if (NULL != (dc = (data_config *)array_get_element(ctx->all_configs, b->ptr))) { | if (NULL != (dc = (data_config *)array_get_element(ctx->all_configs, b->ptr))) { |
configparser_push(ctx, dc, 0); | configparser_push(ctx, dc, 0); |
} else { | } else { |
struct { | static const struct { |
comp_key_t comp; | comp_key_t comp; |
char *comp_key; | char *comp_key; |
size_t len; | size_t len; |
} comps[] = { | } comps[] = { |
{ COMP_SERVER_SOCKET, CONST_STR_LEN("SERVER[\"socket\"]" ) }, | { COMP_SERVER_SOCKET, CONST_STR_LEN("SERVER[\"socket\"]" ) }, |
{ COMP_HTTP_URL, CONST_STR_LEN("HTTP[\"url\"]" ) }, | { COMP_HTTP_URL, CONST_STR_LEN("HTTP[\"url\"]" ) }, |
{ COMP_HTTP_HOST, CONST_STR_LEN("HTTP[\"host\"]" ) }, | { COMP_HTTP_HOST, CONST_STR_LEN("HTTP[\"host\"]" ) }, |
{ COMP_HTTP_REFERER, CONST_STR_LEN("HTTP[\"referer\"]" ) }, | { COMP_HTTP_REFERER, CONST_STR_LEN("HTTP[\"referer\"]" ) }, |
{ COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"useragent\"]" ) }, | { COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"useragent\"]" ) }, |
{ COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"user-agent\"]" ) }, | { COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"user-agent\"]" ) }, |
{ COMP_HTTP_LANGUAGE, CONST_STR_LEN("HTTP[\"language\"]" ) }, | { COMP_HTTP_LANGUAGE, CONST_STR_LEN("HTTP[\"language\"]" ) }, |
{ COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) }, | { COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) }, |
{ COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) }, | { COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) }, |
{ COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remote-ip\"]" ) }, | { COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remote-ip\"]" ) }, |
{ COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"querystring\"]") }, | { COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"querystring\"]") }, |
{ COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"query-string\"]") }, | { COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"query-string\"]") }, |
{ COMP_HTTP_REQUEST_METHOD, CONST_STR_LEN("HTTP[\"request-method\"]") }, | { COMP_HTTP_REQUEST_METHOD, CONST_STR_LEN("HTTP[\"request-method\"]") }, |
{ COMP_HTTP_SCHEME, CONST_STR_LEN("HTTP[\"scheme\"]" ) }, | { COMP_HTTP_SCHEME, CONST_STR_LEN("HTTP[\"scheme\"]" ) }, |
{ COMP_UNSET, NULL, 0 }, | { COMP_UNSET, NULL, 0 }, |
}; | }; |
size_t i; | size_t i; |
|
|
dc = data_config_init(); | dc = data_config_init(); |
|
|
buffer_copy_string_buffer(dc->key, b); | buffer_copy_buffer(dc->key, b); |
buffer_copy_string_buffer(dc->op, op); | buffer_copy_buffer(dc->op, op); |
buffer_copy_string_buffer(dc->comp_key, yymsp[-5].minor.yy0); | buffer_copy_buffer(dc->comp_key, yymsp[-5].minor.yy0); |
buffer_append_string_len(dc->comp_key, CONST_STR_LEN("[\"")); | buffer_append_string_len(dc->comp_key, CONST_STR_LEN("[\"")); |
buffer_append_string_buffer(dc->comp_key, yymsp[-3].minor.yy43); | buffer_append_string_buffer(dc->comp_key, yymsp[-3].minor.yy43); |
buffer_append_string_len(dc->comp_key, CONST_STR_LEN("\"]")); | buffer_append_string_len(dc->comp_key, CONST_STR_LEN("\"]")); |
dc->cond = yymsp[-1].minor.yy27; | dc->cond = yymsp[-1].minor.yy27; |
|
|
for (i = 0; comps[i].comp_key; i ++) { | for (i = 0; comps[i].comp_key; i ++) { |
if (buffer_is_equal_string( | if (buffer_is_equal_string( |
dc->comp_key, comps[i].comp_key, comps[i].len)) { | dc->comp_key, comps[i].comp_key, comps[i].len)) { |
dc->comp = comps[i].comp; | dc->comp = comps[i].comp; |
break; | break; |
| } |
} |
} |
} | if (COMP_UNSET == dc->comp) { |
if (COMP_UNSET == dc->comp) { | fprintf(stderr, "error comp_key %s", dc->comp_key->ptr); |
fprintf(stderr, "error comp_key %s", dc->comp_key->ptr); | ctx->ok = 0; |
ctx->ok = 0; | } |
} | else if (COMP_HTTP_REMOTE_IP == dc->comp |
| && (dc->cond == CONFIG_COND_EQ || dc->cond == CONFIG_COND_NE)) { |
| char * const slash = strchr(rvalue->ptr, '/'); /* CIDR mask */ |
| char * const colon = strchr(rvalue->ptr, ':'); /* IPv6 */ |
| if (NULL != slash && slash == rvalue->ptr){/*(skip AF_UNIX /path/file)*/ |
| } |
| else if (NULL != slash) { |
| char *nptr; |
| const unsigned long nm_bits = strtoul(slash + 1, &nptr, 10); |
| if (*nptr || 0 == nm_bits || nm_bits > (NULL != colon ? 128 : 32)) { |
| /*(also rejects (slash+1 == nptr) which results in nm_bits = 0)*/ |
| fprintf(stderr, "invalid or missing netmask: %s\n", rvalue->ptr); |
| ctx->ok = 0; |
| } |
| else { |
| int rc; |
| buffer_string_set_length(rvalue, (size_t)(slash - rvalue->ptr)); /*(truncate)*/ |
| rc = (NULL == colon) |
| ? http_request_host_normalize(rvalue) |
| : configparser_remoteip_normalize_compat(rvalue); |
| buffer_append_string_len(rvalue, CONST_STR_LEN("/")); |
| buffer_append_int(rvalue, (int)nm_bits); |
| if (0 != rc) { |
| fprintf(stderr, "invalid IP addr: %s\n", rvalue->ptr); |
| ctx->ok = 0; |
| } |
| } |
| } |
| else { |
| int rc = (NULL == colon) |
| ? http_request_host_normalize(rvalue) |
| : configparser_remoteip_normalize_compat(rvalue); |
| if (0 != rc) { |
| fprintf(stderr, "invalid IP addr: %s\n", rvalue->ptr); |
| ctx->ok = 0; |
| } |
| } |
| } |
| else if (COMP_SERVER_SOCKET == dc->comp) { |
| /*(redundant with parsing in network.c; not actually required here)*/ |
| if (rvalue->ptr[0] != ':' /*(network.c special-cases ":" and "[]")*/ |
| && !(rvalue->ptr[0] == '[' && rvalue->ptr[1] == ']')) { |
| if (http_request_host_normalize(rvalue)) { |
| fprintf(stderr, "invalid IP addr: %s\n", rvalue->ptr); |
| ctx->ok = 0; |
| } |
| } |
| } |
| else if (COMP_HTTP_HOST == dc->comp) { |
| if (dc->cond == CONFIG_COND_EQ || dc->cond == CONFIG_COND_NE) { |
| if (http_request_host_normalize(rvalue)) { |
| fprintf(stderr, "invalid IP addr: %s\n", rvalue->ptr); |
| ctx->ok = 0; |
| } |
| } |
| } |
|
|
switch(yymsp[-1].minor.yy27) { | if (ctx->ok) switch(yymsp[-1].minor.yy27) { |
case CONFIG_COND_NE: | case CONFIG_COND_NE: |
case CONFIG_COND_EQ: | case CONFIG_COND_EQ: |
dc->string = buffer_init_buffer(rvalue); | dc->string = buffer_init_buffer(rvalue); |
break; | break; |
case CONFIG_COND_NOMATCH: | case CONFIG_COND_NOMATCH: |
case CONFIG_COND_MATCH: { | case CONFIG_COND_MATCH: { |
#ifdef HAVE_PCRE_H |
#ifdef HAVE_PCRE_H |
const char *errptr; | const char *errptr; |
int erroff, captures; | int erroff, captures; |
|
|
if (NULL == (dc->regex = | if (NULL == (dc->regex = |
pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) { | pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) { |
dc->string = buffer_init_string(errptr); | dc->string = buffer_init_string(errptr); |
dc->cond = CONFIG_COND_UNSET; | dc->cond = CONFIG_COND_UNSET; |
|
|
fprintf(stderr, "parsing regex failed: %s -> %s at offset %d\n", | fprintf(stderr, "parsing regex failed: %s -> %s at offset %d\n", |
rvalue->ptr, errptr, erroff); | rvalue->ptr, errptr, erroff); |
|
|
|
ctx->ok = 0; |
|
} else if (NULL == (dc->regex_study = |
|
pcre_study(dc->regex, 0, &errptr)) && |
|
errptr != NULL) { |
|
fprintf(stderr, "studying regex failed: %s -> %s\n", |
|
rvalue->ptr, errptr); |
|
ctx->ok = 0; |
|
} else if (0 != (pcre_fullinfo(dc->regex, dc->regex_study, PCRE_INFO_CAPTURECOUNT, &captures))) { |
|
fprintf(stderr, "getting capture count for regex failed: %s\n", |
|
rvalue->ptr); |
|
ctx->ok = 0; |
|
} else if (captures > 9) { |
|
fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n", |
|
rvalue->ptr); |
|
ctx->ok = 0; |
|
} else { |
|
dc->string = buffer_init_buffer(rvalue); |
|
} |
|
#else |
|
fprintf(stderr, "can't handle '$%s[%s] =~ ...' as you compiled without pcre support. \n" |
|
"(perhaps just a missing pcre-devel package ?) \n", |
|
yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); |
ctx->ok = 0; |
ctx->ok = 0; |
} else if (NULL == (dc->regex_study = | #endif |
pcre_study(dc->regex, 0, &errptr)) && | break; |
errptr != NULL) { | } |
fprintf(stderr, "studying regex failed: %s -> %s\n", | |
rvalue->ptr, errptr); | default: |
| fprintf(stderr, "unknown condition for $%s[%s]\n", |
| yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); |
ctx->ok = 0; |
ctx->ok = 0; |
} else if (0 != (pcre_fullinfo(dc->regex, dc->regex_study, PCRE_INFO_CAPTURECOUNT, &captures))) { | break; |
fprintf(stderr, "getting capture count for regex failed: %s\n", | } |
rvalue->ptr); | |
ctx->ok = 0; | if (ctx->ok) { |
} else if (captures > 9) { | configparser_push(ctx, dc, 1); |
fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n", | |
rvalue->ptr); | |
ctx->ok = 0; | |
} else { |
} else { |
dc->string = buffer_init_buffer(rvalue); | dc->free((data_unset*) dc); |
} |
} |
#else |
|
fprintf(stderr, "can't handle '$%s[%s] =~ ...' as you compiled without pcre support. \n" |
|
"(perhaps just a missing pcre-devel package ?) \n", |
|
yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); |
|
ctx->ok = 0; |
|
#endif |
|
break; |
|
} |
} |
|
|
default: | buffer_free(b); |
fprintf(stderr, "unknown condition for $%s[%s]\n", | buffer_free(op); |
yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); | buffer_free(yymsp[-5].minor.yy0); |
ctx->ok = 0; | yymsp[-5].minor.yy0 = NULL; |
break; | buffer_free(yymsp[-3].minor.yy43); |
} | yymsp[-3].minor.yy43 = NULL; |
| yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
configparser_push(ctx, dc, 1); | yymsp[0].minor.yy41 = NULL; |
} |
} |
|
|
buffer_free(b); |
|
buffer_free(op); |
|
buffer_free(yymsp[-5].minor.yy0); |
|
yymsp[-5].minor.yy0 = NULL; |
|
buffer_free(yymsp[-3].minor.yy43); |
|
yymsp[-3].minor.yy43 = NULL; |
|
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
|
yymsp[0].minor.yy41 = NULL; |
|
} |
} |
#line 1315 "configparser.c" | #line 1432 "configparser.c" |
yy_destructor(16,&yymsp[-6].minor); |
yy_destructor(16,&yymsp[-6].minor); |
yy_destructor(18,&yymsp[-4].minor); |
yy_destructor(18,&yymsp[-4].minor); |
yy_destructor(19,&yymsp[-2].minor); |
yy_destructor(19,&yymsp[-2].minor); |
break; |
break; |
case 33: |
case 33: |
#line 529 "../../src/configparser.y" | #line 639 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy27 = CONFIG_COND_EQ; |
yygotominor.yy27 = CONFIG_COND_EQ; |
} |
} |
#line 1325 "configparser.c" | #line 1442 "configparser.c" |
yy_destructor(20,&yymsp[0].minor); |
yy_destructor(20,&yymsp[0].minor); |
break; |
break; |
case 34: |
case 34: |
#line 532 "../../src/configparser.y" | #line 642 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy27 = CONFIG_COND_MATCH; |
yygotominor.yy27 = CONFIG_COND_MATCH; |
} |
} |
#line 1333 "configparser.c" | #line 1450 "configparser.c" |
yy_destructor(21,&yymsp[0].minor); |
yy_destructor(21,&yymsp[0].minor); |
break; |
break; |
case 35: |
case 35: |
#line 535 "../../src/configparser.y" | #line 645 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy27 = CONFIG_COND_NE; |
yygotominor.yy27 = CONFIG_COND_NE; |
} |
} |
#line 1341 "configparser.c" | #line 1458 "configparser.c" |
yy_destructor(22,&yymsp[0].minor); |
yy_destructor(22,&yymsp[0].minor); |
break; |
break; |
case 36: |
case 36: |
#line 538 "../../src/configparser.y" | #line 648 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy27 = CONFIG_COND_NOMATCH; |
yygotominor.yy27 = CONFIG_COND_NOMATCH; |
} |
} |
#line 1349 "configparser.c" | #line 1466 "configparser.c" |
yy_destructor(23,&yymsp[0].minor); |
yy_destructor(23,&yymsp[0].minor); |
break; |
break; |
case 37: |
case 37: |
#line 542 "../../src/configparser.y" | #line 652 "../../src/configparser.y" |
{ |
{ |
yygotominor.yy43 = NULL; |
yygotominor.yy43 = NULL; |
if (ctx->ok) { |
if (ctx->ok) { |
Line 1358 static void yy_reduce(
|
Line 1475 static void yy_reduce(
|
yygotominor.yy43 = buffer_init_buffer(((data_string*)yymsp[0].minor.yy41)->value); |
yygotominor.yy43 = buffer_init_buffer(((data_string*)yymsp[0].minor.yy41)->value); |
} else if (yymsp[0].minor.yy41->type == TYPE_INTEGER) { |
} else if (yymsp[0].minor.yy41->type == TYPE_INTEGER) { |
yygotominor.yy43 = buffer_init(); |
yygotominor.yy43 = buffer_init(); |
buffer_copy_long(yygotominor.yy43, ((data_integer *)yymsp[0].minor.yy41)->value); | buffer_copy_int(yygotominor.yy43, ((data_integer *)yymsp[0].minor.yy41)->value); |
} else { |
} else { |
fprintf(stderr, "operand must be string"); |
fprintf(stderr, "operand must be string"); |
ctx->ok = 0; |
ctx->ok = 0; |
Line 1367 static void yy_reduce(
|
Line 1484 static void yy_reduce(
|
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); |
yymsp[0].minor.yy41 = NULL; |
yymsp[0].minor.yy41 = NULL; |
} |
} |
#line 1370 "configparser.c" | #line 1487 "configparser.c" |
break; |
break; |
case 38: |
case 38: |
#line 559 "../../src/configparser.y" | #line 669 "../../src/configparser.y" |
{ |
{ |
if (ctx->ok) { |
if (ctx->ok) { |
if (0 != config_parse_file(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { |
if (0 != config_parse_file(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { |
Line 1380 static void yy_reduce(
|
Line 1497 static void yy_reduce(
|
yymsp[0].minor.yy43 = NULL; |
yymsp[0].minor.yy43 = NULL; |
} |
} |
} |
} |
#line 1383 "configparser.c" | #line 1500 "configparser.c" |
yy_destructor(24,&yymsp[-1].minor); |
yy_destructor(24,&yymsp[-1].minor); |
break; |
break; |
case 39: |
case 39: |
#line 569 "../../src/configparser.y" | #line 679 "../../src/configparser.y" |
{ |
{ |
if (ctx->ok) { |
if (ctx->ok) { |
if (0 != config_parse_cmd(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { |
if (0 != config_parse_cmd(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { |
Line 1394 static void yy_reduce(
|
Line 1511 static void yy_reduce(
|
yymsp[0].minor.yy43 = NULL; |
yymsp[0].minor.yy43 = NULL; |
} |
} |
} |
} |
#line 1397 "configparser.c" | #line 1514 "configparser.c" |
yy_destructor(25,&yymsp[-1].minor); |
yy_destructor(25,&yymsp[-1].minor); |
break; |
break; |
}; |
}; |
Line 1424 static void yy_parse_failed(
|
Line 1541 static void yy_parse_failed(
|
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
/* Here code is inserted which will be executed whenever the |
/* Here code is inserted which will be executed whenever the |
** parser fails */ |
** parser fails */ |
#line 108 "../../src/configparser.y" | #line 147 "../../src/configparser.y" |
|
|
ctx->ok = 0; |
ctx->ok = 0; |
|
|
#line 1431 "configparser.c" | #line 1548 "configparser.c" |
configparserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
configparserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
} |
} |
|
|