summaryrefslogtreecommitdiff
path: root/src/configparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/configparser.c')
-rw-r--r--src/configparser.c179
1 files changed, 95 insertions, 84 deletions
diff --git a/src/configparser.c b/src/configparser.c
index 58a03fe..5dd2739 100644
--- a/src/configparser.c
+++ b/src/configparser.c
@@ -4,7 +4,7 @@
/* First off, code is include which follows the "include" declaration
** in the input file. */
#include <stdio.h>
-#line 5 "./configparser.y"
+#line 5 "../../src/configparser.y"
#include <assert.h>
#include <stdio.h>
@@ -24,6 +24,10 @@ static void configparser_push(config_t *ctx, data_config *dc, int isnew) {
dc->parent = ctx->current;
array_insert_unique(dc->parent->childs, (data_unset *)dc);
}
+ if (ctx->configs_stack->used > 0 && ctx->current->context_ndx == 0) {
+ fprintf(stderr, "Cannot use conditionals inside a global { ... } block\n");
+ exit(-1);
+ }
array_insert_unique(ctx->configs_stack, (data_unset *)ctx->current);
ctx->current = dc;
}
@@ -105,7 +109,7 @@ data_unset *configparser_merge_data(data_unset *op1, const data_unset *op2) {
}
-#line 109 "configparser.c"
+#line 113 "configparser.c"
/* 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.
*/
@@ -359,12 +363,14 @@ static char *yyTracePrompt = 0;
** Outputs:
** None.
*/
+#if 0
void configparserTrace(FILE *TraceFILE, char *zTracePrompt){
yyTraceFILE = TraceFILE;
yyTracePrompt = zTracePrompt;
if( yyTraceFILE==0 ) yyTracePrompt = 0;
else if( yyTracePrompt==0 ) yyTraceFILE = 0;
}
+#endif
#endif /* NDEBUG */
#ifndef NDEBUG
@@ -437,9 +443,10 @@ static const char *yyRuleName[] = {
** This function returns the symbolic name associated with a token
** value.
*/
+#if 0
const char *configparserTokenName(int tokenType){
#ifndef NDEBUG
- if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
+ if( tokenType>0 && (size_t)tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
return yyTokenName[tokenType];
}else{
return "Unknown";
@@ -448,6 +455,7 @@ const char *configparserTokenName(int tokenType){
return "";
#endif
}
+#endif
/*
** This function allocates a new parser.
@@ -512,44 +520,44 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
case 23:
case 24:
case 25:
-#line 142 "./configparser.y"
+#line 146 "../../src/configparser.y"
{ buffer_free((yypminor->yy0)); }
-#line 517 "configparser.c"
+#line 525 "configparser.c"
break;
case 35:
-#line 133 "./configparser.y"
+#line 137 "../../src/configparser.y"
{ (yypminor->yy41)->free((yypminor->yy41)); }
-#line 522 "configparser.c"
+#line 530 "configparser.c"
break;
case 36:
-#line 134 "./configparser.y"
+#line 138 "../../src/configparser.y"
{ (yypminor->yy41)->free((yypminor->yy41)); }
-#line 527 "configparser.c"
+#line 535 "configparser.c"
break;
case 37:
-#line 135 "./configparser.y"
+#line 139 "../../src/configparser.y"
{ (yypminor->yy41)->free((yypminor->yy41)); }
-#line 532 "configparser.c"
+#line 540 "configparser.c"
break;
case 39:
-#line 136 "./configparser.y"
+#line 140 "../../src/configparser.y"
{ array_free((yypminor->yy40)); }
-#line 537 "configparser.c"
+#line 545 "configparser.c"
break;
case 40:
-#line 137 "./configparser.y"
+#line 141 "../../src/configparser.y"
{ array_free((yypminor->yy40)); }
-#line 542 "configparser.c"
+#line 550 "configparser.c"
break;
case 41:
-#line 138 "./configparser.y"
+#line 142 "../../src/configparser.y"
{ buffer_free((yypminor->yy43)); }
-#line 547 "configparser.c"
+#line 555 "configparser.c"
break;
case 42:
-#line 139 "./configparser.y"
+#line 143 "../../src/configparser.y"
{ buffer_free((yypminor->yy43)); }
-#line 552 "configparser.c"
+#line 560 "configparser.c"
break;
default: break; /* If no destructor action specified: do nothing */
}
@@ -627,7 +635,7 @@ static int yy_find_shift_action(
return YY_NO_ACTION;
}
i += iLookAhead;
- if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
+ if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
#ifdef YYFALLBACK
int iFallback; /* Fallback token */
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
@@ -670,7 +678,7 @@ static int yy_find_reduce_action(
return YY_NO_ACTION;
}
i += iLookAhead;
- if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
+ if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
return yy_default[stateno];
}else{
return yy_action[i];
@@ -786,7 +794,7 @@ static void yy_reduce(
yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
if( yyTraceFILE && yyruleno>=0
- && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
+ && (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
yyRuleName[yyruleno]);
}
@@ -817,9 +825,9 @@ static void yy_reduce(
/* No destructor defined for global */
break;
case 5:
-#line 115 "./configparser.y"
+#line 119 "../../src/configparser.y"
{ yymsp[-1].minor.yy78 = NULL; }
-#line 822 "configparser.c"
+#line 830 "configparser.c"
yy_destructor(1,&yymsp[0].minor);
break;
case 6:
@@ -832,7 +840,7 @@ static void yy_reduce(
yy_destructor(1,&yymsp[0].minor);
break;
case 9:
-#line 144 "./configparser.y"
+#line 148 "../../src/configparser.y"
{
if (ctx->ok) {
buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43);
@@ -856,11 +864,11 @@ static void yy_reduce(
buffer_free(yymsp[-2].minor.yy43);
yymsp[-2].minor.yy43 = NULL;
}
-#line 859 "configparser.c"
+#line 867 "configparser.c"
yy_destructor(2,&yymsp[-1].minor);
break;
case 10:
-#line 168 "./configparser.y"
+#line 172 "../../src/configparser.y"
{
array *vars = ctx->current->value;
data_unset *du;
@@ -900,11 +908,11 @@ static void yy_reduce(
yymsp[-2].minor.yy43 = NULL;
yymsp[0].minor.yy41 = NULL;
}
-#line 903 "configparser.c"
+#line 911 "configparser.c"
yy_destructor(3,&yymsp[-1].minor);
break;
case 11:
-#line 208 "./configparser.y"
+#line 212 "../../src/configparser.y"
{
if (strchr(yymsp[0].minor.yy0->ptr, '.') == NULL) {
yygotominor.yy43 = buffer_init_string("var.");
@@ -916,10 +924,10 @@ static void yy_reduce(
yymsp[0].minor.yy0 = NULL;
}
}
-#line 919 "configparser.c"
+#line 927 "configparser.c"
break;
case 12:
-#line 220 "./configparser.y"
+#line 224 "../../src/configparser.y"
{
yygotominor.yy41 = configparser_merge_data(yymsp[-2].minor.yy41, yymsp[0].minor.yy41);
if (NULL == yygotominor.yy41) {
@@ -929,19 +937,19 @@ static void yy_reduce(
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
yymsp[0].minor.yy41 = NULL;
}
-#line 932 "configparser.c"
+#line 940 "configparser.c"
yy_destructor(5,&yymsp[-1].minor);
break;
case 13:
-#line 230 "./configparser.y"
+#line 234 "../../src/configparser.y"
{
yygotominor.yy41 = yymsp[0].minor.yy41;
yymsp[0].minor.yy41 = NULL;
}
-#line 941 "configparser.c"
+#line 949 "configparser.c"
break;
case 14:
-#line 235 "./configparser.y"
+#line 239 "../../src/configparser.y"
{
yygotominor.yy41 = NULL;
if (strncmp(yymsp[0].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) {
@@ -968,59 +976,59 @@ static void yy_reduce(
buffer_free(yymsp[0].minor.yy43);
yymsp[0].minor.yy43 = NULL;
}
-#line 971 "configparser.c"
+#line 979 "configparser.c"
break;
case 15:
-#line 262 "./configparser.y"
+#line 266 "../../src/configparser.y"
{
yygotominor.yy41 = (data_unset *)data_string_init();
buffer_copy_string_buffer(((data_string *)(yygotominor.yy41))->value, yymsp[0].minor.yy0);
buffer_free(yymsp[0].minor.yy0);
yymsp[0].minor.yy0 = NULL;
}
-#line 981 "configparser.c"
+#line 989 "configparser.c"
break;
case 16:
-#line 269 "./configparser.y"
+#line 273 "../../src/configparser.y"
{
yygotominor.yy41 = (data_unset *)data_integer_init();
((data_integer *)(yygotominor.yy41))->value = strtol(yymsp[0].minor.yy0->ptr, NULL, 10);
buffer_free(yymsp[0].minor.yy0);
yymsp[0].minor.yy0 = NULL;
}
-#line 991 "configparser.c"
+#line 999 "configparser.c"
break;
case 17:
-#line 275 "./configparser.y"
+#line 279 "../../src/configparser.y"
{
yygotominor.yy41 = (data_unset *)data_array_init();
array_free(((data_array *)(yygotominor.yy41))->value);
((data_array *)(yygotominor.yy41))->value = yymsp[0].minor.yy40;
yymsp[0].minor.yy40 = NULL;
}
-#line 1001 "configparser.c"
+#line 1009 "configparser.c"
break;
case 18:
-#line 281 "./configparser.y"
+#line 285 "../../src/configparser.y"
{
yygotominor.yy40 = array_init();
}
-#line 1008 "configparser.c"
+#line 1016 "configparser.c"
yy_destructor(8,&yymsp[-1].minor);
yy_destructor(9,&yymsp[0].minor);
break;
case 19:
-#line 284 "./configparser.y"
+#line 288 "../../src/configparser.y"
{
yygotominor.yy40 = yymsp[-1].minor.yy40;
yymsp[-1].minor.yy40 = NULL;
}
-#line 1018 "configparser.c"
+#line 1026 "configparser.c"
yy_destructor(8,&yymsp[-2].minor);
yy_destructor(9,&yymsp[0].minor);
break;
case 20:
-#line 289 "./configparser.y"
+#line 293 "../../src/configparser.y"
{
if (buffer_is_empty(yymsp[0].minor.yy41->key) ||
NULL == array_get_element(yymsp[-2].minor.yy40, yymsp[0].minor.yy41->key->ptr)) {
@@ -1037,37 +1045,37 @@ static void yy_reduce(
yygotominor.yy40 = yymsp[-2].minor.yy40;
yymsp[-2].minor.yy40 = NULL;
}
-#line 1040 "configparser.c"
+#line 1048 "configparser.c"
yy_destructor(10,&yymsp[-1].minor);
break;
case 21:
-#line 306 "./configparser.y"
+#line 310 "../../src/configparser.y"
{
yygotominor.yy40 = yymsp[-1].minor.yy40;
yymsp[-1].minor.yy40 = NULL;
}
-#line 1049 "configparser.c"
+#line 1057 "configparser.c"
yy_destructor(10,&yymsp[0].minor);
break;
case 22:
-#line 311 "./configparser.y"
+#line 315 "../../src/configparser.y"
{
yygotominor.yy40 = array_init();
array_insert_unique(yygotominor.yy40, yymsp[0].minor.yy41);
yymsp[0].minor.yy41 = NULL;
}
-#line 1059 "configparser.c"
+#line 1067 "configparser.c"
break;
case 23:
-#line 317 "./configparser.y"
+#line 321 "../../src/configparser.y"
{
yygotominor.yy41 = yymsp[0].minor.yy41;
yymsp[0].minor.yy41 = NULL;
}
-#line 1067 "configparser.c"
+#line 1075 "configparser.c"
break;
case 24:
-#line 321 "./configparser.y"
+#line 325 "../../src/configparser.y"
{
buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43);
buffer_free(yymsp[-2].minor.yy43);
@@ -1076,7 +1084,7 @@ static void yy_reduce(
yygotominor.yy41 = yymsp[0].minor.yy41;
yymsp[0].minor.yy41 = NULL;
}
-#line 1079 "configparser.c"
+#line 1087 "configparser.c"
yy_destructor(11,&yymsp[-1].minor);
break;
case 25:
@@ -1085,18 +1093,18 @@ static void yy_reduce(
case 26:
break;
case 27:
-#line 333 "./configparser.y"
+#line 337 "../../src/configparser.y"
{
data_config *dc;
dc = (data_config *)array_get_element(ctx->srv->config_context, "global");
assert(dc);
configparser_push(ctx, dc, 0);
}
-#line 1095 "configparser.c"
+#line 1103 "configparser.c"
yy_destructor(12,&yymsp[0].minor);
break;
case 28:
-#line 340 "./configparser.y"
+#line 344 "../../src/configparser.y"
{
data_config *cur;
@@ -1107,14 +1115,14 @@ static void yy_reduce(
yygotominor.yy78 = cur;
}
-#line 1110 "configparser.c"
+#line 1118 "configparser.c"
/* No destructor defined for globalstart */
yy_destructor(13,&yymsp[-2].minor);
/* No destructor defined for metalines */
yy_destructor(14,&yymsp[0].minor);
break;
case 29:
-#line 351 "./configparser.y"
+#line 355 "../../src/configparser.y"
{
assert(yymsp[-3].minor.yy78->context_ndx < yymsp[0].minor.yy78->context_ndx);
yymsp[0].minor.yy78->prev = yymsp[-3].minor.yy78;
@@ -1123,20 +1131,20 @@ static void yy_reduce(
yymsp[-3].minor.yy78 = NULL;
yymsp[0].minor.yy78 = NULL;
}
-#line 1126 "configparser.c"
+#line 1134 "configparser.c"
/* No destructor defined for eols */
yy_destructor(15,&yymsp[-1].minor);
break;
case 30:
-#line 360 "./configparser.y"
+#line 364 "../../src/configparser.y"
{
yygotominor.yy78 = yymsp[0].minor.yy78;
yymsp[0].minor.yy78 = NULL;
}
-#line 1136 "configparser.c"
+#line 1144 "configparser.c"
break;
case 31:
-#line 365 "./configparser.y"
+#line 369 "../../src/configparser.y"
{
data_config *cur;
@@ -1147,14 +1155,14 @@ static void yy_reduce(
yygotominor.yy78 = cur;
}
-#line 1150 "configparser.c"
+#line 1158 "configparser.c"
/* No destructor defined for context */
yy_destructor(13,&yymsp[-2].minor);
/* No destructor defined for metalines */
yy_destructor(14,&yymsp[0].minor);
break;
case 32:
-#line 376 "./configparser.y"
+#line 380 "../../src/configparser.y"
{
data_config *dc;
buffer *b, *rvalue, *op;
@@ -1205,6 +1213,7 @@ static void yy_reduce(
{ 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[\"user-agent\"]" ) },
+ { COMP_HTTP_LANGUAGE, CONST_STR_LEN("HTTP[\"language\"]" ) },
{ 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[\"remote-ip\"]" ) },
@@ -1295,45 +1304,45 @@ static void yy_reduce(
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
yymsp[0].minor.yy41 = NULL;
}
-#line 1298 "configparser.c"
+#line 1307 "configparser.c"
yy_destructor(16,&yymsp[-6].minor);
yy_destructor(18,&yymsp[-4].minor);
yy_destructor(19,&yymsp[-2].minor);
break;
case 33:
-#line 516 "./configparser.y"
+#line 521 "../../src/configparser.y"
{
yygotominor.yy27 = CONFIG_COND_EQ;
}
-#line 1308 "configparser.c"
+#line 1317 "configparser.c"
yy_destructor(20,&yymsp[0].minor);
break;
case 34:
-#line 519 "./configparser.y"
+#line 524 "../../src/configparser.y"
{
yygotominor.yy27 = CONFIG_COND_MATCH;
}
-#line 1316 "configparser.c"
+#line 1325 "configparser.c"
yy_destructor(21,&yymsp[0].minor);
break;
case 35:
-#line 522 "./configparser.y"
+#line 527 "../../src/configparser.y"
{
yygotominor.yy27 = CONFIG_COND_NE;
}
-#line 1324 "configparser.c"
+#line 1333 "configparser.c"
yy_destructor(22,&yymsp[0].minor);
break;
case 36:
-#line 525 "./configparser.y"
+#line 530 "../../src/configparser.y"
{
yygotominor.yy27 = CONFIG_COND_NOMATCH;
}
-#line 1332 "configparser.c"
+#line 1341 "configparser.c"
yy_destructor(23,&yymsp[0].minor);
break;
case 37:
-#line 529 "./configparser.y"
+#line 534 "../../src/configparser.y"
{
yygotominor.yy43 = NULL;
if (ctx->ok) {
@@ -1350,10 +1359,10 @@ static void yy_reduce(
yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
yymsp[0].minor.yy41 = NULL;
}
-#line 1353 "configparser.c"
+#line 1362 "configparser.c"
break;
case 38:
-#line 546 "./configparser.y"
+#line 551 "../../src/configparser.y"
{
if (ctx->ok) {
if (0 != config_parse_file(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) {
@@ -1363,11 +1372,11 @@ static void yy_reduce(
yymsp[0].minor.yy43 = NULL;
}
}
-#line 1366 "configparser.c"
+#line 1375 "configparser.c"
yy_destructor(24,&yymsp[-1].minor);
break;
case 39:
-#line 556 "./configparser.y"
+#line 561 "../../src/configparser.y"
{
if (ctx->ok) {
if (0 != config_parse_cmd(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) {
@@ -1377,7 +1386,7 @@ static void yy_reduce(
yymsp[0].minor.yy43 = NULL;
}
}
-#line 1380 "configparser.c"
+#line 1389 "configparser.c"
yy_destructor(25,&yymsp[-1].minor);
break;
};
@@ -1407,11 +1416,11 @@ static void yy_parse_failed(
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will be executed whenever the
** parser fails */
-#line 106 "./configparser.y"
+#line 110 "../../src/configparser.y"
ctx->ok = 0;
-#line 1414 "configparser.c"
+#line 1423 "configparser.c"
configparserARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
@@ -1424,6 +1433,8 @@ static void yy_syntax_error(
YYMINORTYPE yyminor /* The minor type of the error token */
){
configparserARG_FETCH;
+ UNUSED(yymajor);
+ UNUSED(yyminor);
#define TOKEN (yyminor.yy0)
configparserARG_STORE; /* Suppress warning about unused %extra_argument variable */
}