1 /* A Bison parser, made by GNU Bison 3.3.2. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37 /* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
43
44 /* Undocumented macros, especially those whose name start with YY_,
45 are private implementation details. Do not rely on them. */
46
47 /* Identify Bison output. */
48 #define YYBISON 1
49
50 /* Bison version. */
51 #define YYBISON_VERSION "3.3.2"
52
53 /* Skeleton name. */
54 #define YYSKELETON_NAME "yacc.c"
55
56 /* Pure parsers. */
57 #define YYPURE 0
58
59 /* Push parsers. */
60 #define YYPUSH 0
61
62 /* Pull parsers. */
63 #define YYPULL 1
64
65
66
67
68 /* First part of user prologue. */
69 #line 1 "configfile.y" /* yacc.c:337 */
70
71 /*
72 ** A yacc input file for the innfeed config file.
73 **
74 ** Written by James Brister <brister@vix.com>
75 **
76 ** This file contains the heart of the innfeed configuration parser, written
77 ** in yacc. It uses an external lexer generated by flex.
78 **
79 ** clang-format does not work off-the-shelf with mixed C and yacc code;
80 ** if it is run, the "%{" and "%}" lines should be commented so as not
81 ** to add extra indentation.
82 */
83
84 #include "portable/system.h"
85
86 #include "innfeed.h"
87 #include <ctype.h>
88 #include <errno.h>
89 #include <syslog.h>
90
91 #include "inn/libinn.h"
92 #include "inn/messages.h"
93
94 #include "configfile.h"
95 #include "misc.h"
96
97 /* flex does not declare yydebug as static, and uses superfluous breaks. */
98 #if defined(__llvm__) || defined(__clang__)
99 # pragma GCC diagnostic ignored "-Wmissing-variable-declarations"
100 # pragma GCC diagnostic ignored "-Wunreachable-code-break"
101 #endif
102
103 #define UNKNOWN_SCOPE_TYPE "line %d: unknown scope type: %s"
104 #define SYNTAX_ERROR "line %d: syntax error"
105
106 scope *topScope = NULL;
107 static scope *currScope = NULL;
108 char *errbuff = NULL;
109
110 static void appendName(scope *s, char *p, size_t len);
111 static char *valueScopedName(value *v);
112 static void freeValue(value *v);
113 static char *checkName(scope *s, const char *name);
114 static void addValue(scope *s, value *v);
115 static char *addScope(scope *s, const char *name, scope *val);
116 static void printScope(FILE *fp, scope *s, int indent);
117 static void printValue(FILE *fp, value *v, int indent);
118 static scope *newScope(const char *type);
119
120 /* Interface between lexer and parser. */
121 int yylex(void);
122
123 int yyerror(const char *s);
124 int yywrap(void);
125
126 int
getBool(scope * s,const char * name,int * rval,int inherit)127 getBool(scope *s, const char *name, int *rval, int inherit)
128 {
129 value *v = findValue(s, name, inherit);
130
131 if (v == NULL)
132 return 0;
133 else if (v->type != boolval)
134 return 0;
135
136 *rval = v->v.bool_val;
137 return 1;
138 }
139
140
141 int
getString(scope * s,const char * name,char ** rval,int inherit)142 getString(scope *s, const char *name, char **rval, int inherit)
143 {
144 value *v = findValue(s, name, inherit);
145
146 if (v == NULL)
147 return 0;
148 else if (v->type != stringval)
149 return 0;
150
151 *rval = xstrdup(v->v.charp_val);
152 return 1;
153 }
154
155
156 int
getReal(scope * s,const char * name,double * rval,int inherit)157 getReal(scope *s, const char *name, double *rval, int inherit)
158 {
159 value *v = findValue(s, name, inherit);
160
161 if (v == NULL)
162 return 0;
163 else if (v->type != realval)
164 return 0;
165
166 *rval = v->v.real_val;
167 return 1;
168 }
169
170 int
getInteger(scope * s,const char * name,long * rval,int inherit)171 getInteger(scope *s, const char *name, long *rval, int inherit)
172 {
173 value *v = findValue(s, name, inherit);
174
175 if (v == NULL)
176 return 0;
177 else if (v->type != intval)
178 return 0;
179
180 *rval = v->v.int_val;
181 return 1;
182 }
183
184 void
freeScopeTree(scope * s)185 freeScopeTree(scope *s)
186 {
187 int i;
188
189 if (s == NULL)
190 return;
191
192 if (s->parent == NULL && s->me != NULL) { /* top level scope */
193 free(s->me->name);
194 free(s->me);
195 }
196
197
198 for (i = 0; i < s->value_idx; i++)
199 if (s->values[i] != NULL)
200 freeValue(s->values[i]);
201
202 free(s->values);
203 free(s->scope_type);
204
205 s->parent = NULL;
206 s->values = NULL;
207
208 free(s);
209 }
210
211
212 char *
addInteger(scope * s,const char * name,long val)213 addInteger(scope *s, const char *name, long val)
214 {
215 value *v;
216 char *error;
217
218 if ((error = checkName(currScope, name)) != NULL)
219 return error;
220
221 v = (value *) xcalloc(1, sizeof(value));
222 v->name = xstrdup(name);
223 v->type = intval;
224 v->v.int_val = val;
225
226 addValue(s, v);
227
228 return NULL;
229 }
230
231 char *
addChar(scope * s,const char * name,char val)232 addChar(scope *s, const char *name, char val)
233 {
234 value *v;
235 char *error;
236
237 if ((error = checkName(currScope, name)) != NULL)
238 return error;
239
240 v = (value *) xcalloc(1, sizeof(value));
241 v->name = xstrdup(name);
242 v->type = charval;
243 v->v.char_val = val;
244
245 addValue(s, v);
246
247 return NULL;
248 }
249
250 char *
addBoolean(scope * s,const char * name,int val)251 addBoolean(scope *s, const char *name, int val)
252 {
253 value *v;
254 char *error;
255
256 if ((error = checkName(currScope, name)) != NULL)
257 return error;
258
259 v = (value *) xcalloc(1, sizeof(value));
260 v->name = xstrdup(name);
261 v->type = boolval;
262 v->v.bool_val = val;
263
264 addValue(s, v);
265
266 return NULL;
267 }
268
269 char *
addReal(scope * s,const char * name,double val)270 addReal(scope *s, const char *name, double val)
271 {
272 value *v;
273 char *error;
274
275 if ((error = checkName(currScope, name)) != NULL)
276 return error;
277
278 v = (value *) xcalloc(1, sizeof(value));
279 v->name = xstrdup(name);
280 v->type = realval;
281 v->v.real_val = val;
282
283 addValue(s, v);
284
285 return NULL;
286 }
287
288 char *
addString(scope * s,const char * name,const char * val)289 addString(scope *s, const char *name, const char *val)
290 {
291 value *v;
292 char *error;
293
294 if ((error = checkName(currScope, name)) != NULL)
295 return error;
296
297 v = (value *) xcalloc(1, sizeof(value));
298 v->name = xstrdup(name);
299 v->type = stringval;
300 v->v.charp_val = xstrdup(val);
301
302 addValue(s, v);
303
304 return NULL;
305 }
306
307 value *
findValue(scope * s,const char * name,int inherit)308 findValue(scope *s, const char *name, int inherit)
309 {
310 const char *p;
311
312 if (name == NULL || *name == '\0')
313 return NULL;
314
315 if (*name == ':')
316 return findValue(topScope, name + 1, 0);
317 else if (s == NULL)
318 return findValue(topScope, name, 0);
319 else {
320 int i;
321
322 if ((p = strchr(name, ':')) == NULL)
323 p = name + strlen(name);
324
325 for (i = 0; i < s->value_idx; i++) {
326 if (strlen(s->values[i]->name) == (size_t)(p - name)
327 && strncmp(s->values[i]->name, name, p - name) == 0) {
328 if (*p == '\0') /* last segment of name */
329 return s->values[i];
330 else if (s->values[i]->type != scopeval)
331 errbuff = xstrdup("Component not a scope");
332 else
333 return findValue(s->values[i]->v.scope_val, p + 1, 0);
334 }
335 }
336
337 /* not in this scope. Go up if inheriting values and only if no ':'
338 in name */
339 if (inherit && *p == '\0')
340 return findValue(s->parent, name, inherit);
341 }
342
343 return NULL;
344 }
345
346 /* find the scope that name belongs to. If mustExist is true then the name
347 must be a fully scoped name of a value. relative scopes start at s. */
348 scope *
findScope(scope * s,const char * name,int mustExist)349 findScope(scope *s, const char *name, int mustExist)
350 {
351 scope *p = NULL;
352 char *q;
353 int i;
354
355
356 if ((q = strchr(name, ':')) == NULL) {
357 if (!mustExist)
358 p = s;
359 else
360 for (i = 0; p == NULL && i < s->value_idx; i++)
361 if (strcmp(s->values[i]->name, name) == 0)
362 p = s;
363
364 return p;
365 } else if (*name == ':') {
366 while (s->parent != NULL)
367 s = s->parent;
368
369 return findScope(s, name + 1, mustExist);
370 } else {
371 for (i = 0; i < s->value_idx; i++)
372 if (strncmp(s->values[i]->name, name, q - name) == 0)
373 if (s->values[i]->type == scopeval)
374 return findScope(s->values[i]->v.scope_val, q + 1,
375 mustExist);
376 }
377
378 return NULL;
379 }
380
381 /****************************************************************************/
382 /* */
383 /****************************************************************************/
384
385
386 static void
appendName(scope * s,char * p,size_t len)387 appendName(scope *s, char *p, size_t len)
388 {
389 if (s == NULL)
390 return;
391 else {
392 appendName(s->parent, p, len);
393 strlcat(p, s->me->name, len);
394 strlcat(p, ":", len);
395 }
396 }
397
398 static char *
valueScopedName(value * v)399 valueScopedName(value *v)
400 {
401 scope *p = v->myscope;
402 int len = strlen(v->name);
403 char *q;
404
405 while (p != NULL) {
406 len += strlen(p->me->name) + 1;
407 p = p->parent;
408 }
409 len++;
410
411 q = xmalloc(len);
412 q[0] = '\0';
413 appendName(v->myscope, q, len);
414 strlcat(q, v->name, len);
415
416 return q;
417 }
418
419 static void
freeValue(value * v)420 freeValue(value *v)
421 {
422 free(v->name);
423 switch (v->type) {
424 case scopeval:
425 freeScopeTree(v->v.scope_val);
426 break;
427
428 case stringval:
429 free(v->v.charp_val);
430 break;
431
432 default:
433 break;
434 }
435 free(v);
436 }
437
438 static char *
checkName(scope * s,const char * name)439 checkName(scope *s, const char *name)
440 {
441 int i;
442 char *error = NULL;
443
444 if (s == NULL)
445 return NULL;
446
447 for (i = 0; i < s->value_idx; i++) {
448 char *n = NULL;
449
450 if (strcmp(name, s->values[i]->name) == 0) {
451 n = valueScopedName(s->values[i]);
452 error = concat("Two definitions of ", n, (char *) 0);
453 free(n);
454 return error;
455 }
456 }
457
458 return error;
459 }
460
461
462 static void
addValue(scope * s,value * v)463 addValue(scope *s, value *v)
464 {
465 v->myscope = s;
466
467 if (s == NULL)
468 return;
469
470 if (s->value_count == s->value_idx) {
471 if (s->values == 0) {
472 s->values = (value **) xcalloc(10, sizeof(value *));
473 s->value_count = 10;
474 } else {
475 s->value_count += 10;
476 s->values = (value **) xrealloc(s->values,
477 sizeof(value *) * s->value_count);
478 }
479 }
480
481 s->values[s->value_idx++] = v;
482 }
483
484
485 static char *
addScope(scope * s,const char * name,scope * val)486 addScope(scope *s, const char *name, scope *val)
487 {
488 value *v;
489 char *error;
490
491 if ((error = checkName(s, name)) != NULL)
492 return error;
493
494 v = (value *) xcalloc(1, sizeof(value));
495 v->name = xstrdup(name);
496 v->type = scopeval;
497 v->v.scope_val = val;
498 val->me = v;
499 val->parent = s;
500
501 addValue(s, v);
502
503 currScope = val;
504
505 return NULL;
506 }
507
508
509 static void
printScope(FILE * fp,scope * s,int indent)510 printScope(FILE *fp, scope *s, int indent)
511 {
512 int i;
513 for (i = 0; i < s->value_idx; i++)
514 printValue(fp, s->values[i], indent + 5);
515 }
516
517 static void
printValue(FILE * fp,value * v,int indent)518 printValue(FILE *fp, value *v, int indent)
519 {
520 int i;
521
522 for (i = 0; i < indent; i++)
523 fputc(' ', fp);
524
525 switch (v->type) {
526 case intval:
527 fprintf(fp, "%s : %ld # INTEGER\n", v->name, v->v.int_val);
528 break;
529
530 case stringval:
531 fprintf(fp, "%s : \"", v->name);
532 {
533 char *p = v->v.charp_val;
534 while (*p) {
535 if (*p == '"' || *p == '\\')
536 fputc('\\', fp);
537 fputc(*p, fp);
538 p++;
539 }
540 }
541 fprintf(fp, "\" # STRING\n");
542 break;
543
544 case charval:
545 fprintf(fp, "%s : %c", v->name, 047);
546 switch (v->v.char_val) {
547 case '\\':
548 fprintf(fp, "\\\\");
549 break;
550
551 default:
552 if (isprint((unsigned char) v->v.char_val))
553 fprintf(fp, "%c", v->v.char_val);
554 else
555 fprintf(fp, "\\%03o", v->v.char_val);
556 }
557 fprintf(fp, "%c # CHARACTER\n", 047);
558 break;
559
560 case realval:
561 fprintf(fp, "%s : %f # REAL\n", v->name, v->v.real_val);
562 break;
563
564 case boolval:
565 fprintf(fp, "%s : %s # BOOLEAN\n", v->name,
566 (v->v.bool_val ? "true" : "false"));
567 break;
568
569 case scopeval:
570 fprintf(fp, "%s %s { # SCOPE\n", v->v.scope_val->scope_type, v->name);
571 printScope(fp, v->v.scope_val, indent + 5);
572 for (i = 0; i < indent; i++)
573 fputc(' ', fp);
574 fprintf(fp, "}\n");
575 break;
576
577 default:
578 fprintf(fp, "UNKNOWN value type: %d\n", v->type);
579 exit(1);
580 }
581 }
582
583
584 static scope *
newScope(const char * type)585 newScope(const char *type)
586 {
587 scope *t;
588 int i;
589
590 t = (scope *) xcalloc(1, sizeof(scope));
591 t->parent = NULL;
592 t->scope_type = xstrdup(type);
593
594 for (i = 0; t->scope_type[i] != '\0'; i++)
595 t->scope_type[i] = tolower((unsigned char) t->scope_type[i]);
596
597 return t;
598 }
599
600
601 #define BAD_KEY "line %d: illegal key name: %s"
602 #define NON_ALPHA "line %d: keys must start with a letter: %s"
603
604 static char *
keyOk(const char * key)605 keyOk(const char *key)
606 {
607 const char *p = key;
608 char *rval;
609
610 if (key == NULL) {
611 rval = xmalloc(strlen("line : NULL key") + 15);
612 sprintf(rval, "line %d: NULL key", lineCount);
613 return rval;
614 } else if (*key == '\0') {
615 rval = xmalloc(strlen("line : EMPTY KEY") + 15);
616 sprintf(rval, "line %d: EMPTY KEY", lineCount);
617 return rval;
618 }
619
620 if (!isalpha((unsigned char) *p)) {
621 rval = xmalloc(strlen(NON_ALPHA) + strlen(key) + 15);
622 sprintf(rval, NON_ALPHA, lineCount, key);
623 return rval;
624 }
625
626 p++;
627 while (*p) {
628 if (!(isalnum((unsigned char) *p) || *p == '_' || *p == '-')) {
629 rval = xmalloc(strlen(BAD_KEY) + strlen(key) + 15);
630 sprintf(rval, BAD_KEY, lineCount, key);
631 return rval;
632 }
633 p++;
634 }
635
636 return NULL;
637 }
638
639 static PFIVP *funcs = NULL;
640 static void **args = NULL;
641 static int funcCount;
642 static int funcIdx;
643
644 void
configAddLoadCallback(PFIVP func,void * arg)645 configAddLoadCallback(PFIVP func, void *arg)
646 {
647 if (func == NULL)
648 return;
649
650 if (funcIdx == funcCount) {
651 funcCount += 10;
652 if (funcs == NULL) {
653 funcs = xmalloc(sizeof(PFIVP) * funcCount);
654 args = xmalloc(sizeof(void *) * funcCount);
655 } else {
656 funcs = xrealloc(funcs, sizeof(PFIVP) * funcCount);
657 args = xrealloc(args, sizeof(void *) * funcCount);
658 }
659 }
660
661 args[funcIdx] = arg;
662 funcs[funcIdx++] = func;
663 }
664
665
666 void
configRemoveLoadCallback(PFIVP func)667 configRemoveLoadCallback(PFIVP func)
668 {
669 int i, j;
670
671 for (i = 0; i < funcIdx; i++)
672 if (funcs[i] == func)
673 break;
674
675 for (j = i; j < funcIdx - 1; j++) {
676 funcs[j] = funcs[j + 1];
677 args[j] = args[j + 1];
678 }
679
680 if (funcIdx > 1 && i < funcIdx) {
681 funcs[i - 2] = funcs[i - 1];
682 args[i - 2] = args[i - 1];
683 }
684
685 if (funcIdx > 0 && i < funcIdx)
686 funcIdx--;
687 }
688
689
690 static int
doCallbacks(void)691 doCallbacks(void)
692 {
693 int i;
694 int rval = 1;
695
696 for (i = 0; i < funcIdx; i++)
697 if (funcs[i] != NULL)
698 rval = (funcs[i](args[i]) && rval);
699
700 return rval;
701 }
702
703
704 static char *key;
705 /* clang-format off */
706
707 #line 708 "y.tab.c" /* yacc.c:337 */
708 # ifndef YY_NULLPTR
709 # if defined __cplusplus
710 # if 201103L <= __cplusplus
711 # define YY_NULLPTR nullptr
712 # else
713 # define YY_NULLPTR 0
714 # endif
715 # else
716 # define YY_NULLPTR ((void*)0)
717 # endif
718 # endif
719
720 /* Enabling verbose error messages. */
721 #ifdef YYERROR_VERBOSE
722 # undef YYERROR_VERBOSE
723 # define YYERROR_VERBOSE 1
724 #else
725 # define YYERROR_VERBOSE 0
726 #endif
727
728 /* In a future release of Bison, this section will be replaced
729 by #include "y.tab.h". */
730 #ifndef YY_YY_Y_TAB_H_INCLUDED
731 # define YY_YY_Y_TAB_H_INCLUDED
732 /* Debug traces. */
733 #ifndef YYDEBUG
734 # define YYDEBUG 0
735 #endif
736 #if YYDEBUG
737 extern int yydebug;
738 #endif
739
740 /* Token type. */
741 #ifndef YYTOKENTYPE
742 # define YYTOKENTYPE
743 enum yytokentype
744 {
745 PEER = 258,
746 GROUP = 259,
747 IVAL = 260,
748 RVAL = 261,
749 NAME = 262,
750 XSTRING = 263,
751 SCOPE = 264,
752 COLON = 265,
753 LBRACE = 266,
754 RBRACE = 267,
755 TRUEBVAL = 268,
756 FALSEBVAL = 269,
757 CHAR = 270,
758 WORD = 271,
759 IP_ADDRESS = 272
760 };
761 #endif
762 /* Tokens. */
763 #define PEER 258
764 #define GROUP 259
765 #define IVAL 260
766 #define RVAL 261
767 #define NAME 262
768 #define XSTRING 263
769 #define SCOPE 264
770 #define COLON 265
771 #define LBRACE 266
772 #define RBRACE 267
773 #define TRUEBVAL 268
774 #define FALSEBVAL 269
775 #define CHAR 270
776 #define WORD 271
777 #define IP_ADDRESS 272
778
779 /* Value type. */
780 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
781
782 union YYSTYPE
783 {
784 #line 639 "configfile.y" /* yacc.c:352 */
785
786 scope *scp;
787 value *val;
788 char *name;
789 int integer;
790 double real;
791 char *string;
792 char chr;
793
794 #line 795 "y.tab.c" /* yacc.c:352 */
795 };
796
797 typedef union YYSTYPE YYSTYPE;
798 # define YYSTYPE_IS_TRIVIAL 1
799 # define YYSTYPE_IS_DECLARED 1
800 #endif
801
802
803 extern YYSTYPE yylval;
804
805 int yyparse (void);
806
807 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
808
809
810
811 #ifdef short
812 # undef short
813 #endif
814
815 #ifdef YYTYPE_UINT8
816 typedef YYTYPE_UINT8 yytype_uint8;
817 #else
818 typedef unsigned char yytype_uint8;
819 #endif
820
821 #ifdef YYTYPE_INT8
822 typedef YYTYPE_INT8 yytype_int8;
823 #else
824 typedef signed char yytype_int8;
825 #endif
826
827 #ifdef YYTYPE_UINT16
828 typedef YYTYPE_UINT16 yytype_uint16;
829 #else
830 typedef unsigned short yytype_uint16;
831 #endif
832
833 #ifdef YYTYPE_INT16
834 typedef YYTYPE_INT16 yytype_int16;
835 #else
836 typedef short yytype_int16;
837 #endif
838
839 #ifndef YYSIZE_T
840 # ifdef __SIZE_TYPE__
841 # define YYSIZE_T __SIZE_TYPE__
842 # elif defined size_t
843 # define YYSIZE_T size_t
844 # elif ! defined YYSIZE_T
845 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
846 # define YYSIZE_T size_t
847 # else
848 # define YYSIZE_T unsigned
849 # endif
850 #endif
851
852 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
853
854 #ifndef YY_
855 # if defined YYENABLE_NLS && YYENABLE_NLS
856 # if ENABLE_NLS
857 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
858 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
859 # endif
860 # endif
861 # ifndef YY_
862 # define YY_(Msgid) Msgid
863 # endif
864 #endif
865
866 #ifndef YY_ATTRIBUTE
867 # if (defined __GNUC__ \
868 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
869 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
870 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
871 # else
872 # define YY_ATTRIBUTE(Spec) /* empty */
873 # endif
874 #endif
875
876 #ifndef YY_ATTRIBUTE_PURE
877 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
878 #endif
879
880 #ifndef YY_ATTRIBUTE_UNUSED
881 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
882 #endif
883
884 /* Suppress unused-variable warnings by "using" E. */
885 #if ! defined lint || defined __GNUC__
886 # define YYUSE(E) ((void) (E))
887 #else
888 # define YYUSE(E) /* empty */
889 #endif
890
891 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
892 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
893 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
894 _Pragma ("GCC diagnostic push") \
895 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
896 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
897 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
898 _Pragma ("GCC diagnostic pop")
899 #else
900 # define YY_INITIAL_VALUE(Value) Value
901 #endif
902 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
903 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
904 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
905 #endif
906 #ifndef YY_INITIAL_VALUE
907 # define YY_INITIAL_VALUE(Value) /* Nothing. */
908 #endif
909
910
911 #if ! defined yyoverflow || YYERROR_VERBOSE
912
913 /* The parser invokes alloca or malloc; define the necessary symbols. */
914
915 # ifdef YYSTACK_USE_ALLOCA
916 # if YYSTACK_USE_ALLOCA
917 # ifdef __GNUC__
918 # define YYSTACK_ALLOC __builtin_alloca
919 # elif defined __BUILTIN_VA_ARG_INCR
920 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
921 # elif defined _AIX
922 # define YYSTACK_ALLOC __alloca
923 # elif defined _MSC_VER
924 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
925 # define alloca _alloca
926 # else
927 # define YYSTACK_ALLOC alloca
928 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
929 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
930 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
931 # ifndef EXIT_SUCCESS
932 # define EXIT_SUCCESS 0
933 # endif
934 # endif
935 # endif
936 # endif
937 # endif
938
939 # ifdef YYSTACK_ALLOC
940 /* Pacify GCC's 'empty if-body' warning. */
941 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
942 # ifndef YYSTACK_ALLOC_MAXIMUM
943 /* The OS might guarantee only one guard page at the bottom of the stack,
944 and a page size can be as small as 4096 bytes. So we cannot safely
945 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
946 to allow for a few compiler-allocated temporary stack slots. */
947 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
948 # endif
949 # else
950 # define YYSTACK_ALLOC YYMALLOC
951 # define YYSTACK_FREE YYFREE
952 # ifndef YYSTACK_ALLOC_MAXIMUM
953 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
954 # endif
955 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
956 && ! ((defined YYMALLOC || defined malloc) \
957 && (defined YYFREE || defined free)))
958 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
959 # ifndef EXIT_SUCCESS
960 # define EXIT_SUCCESS 0
961 # endif
962 # endif
963 # ifndef YYMALLOC
964 # define YYMALLOC malloc
965 # if ! defined malloc && ! defined EXIT_SUCCESS
966 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
967 # endif
968 # endif
969 # ifndef YYFREE
970 # define YYFREE free
971 # if ! defined free && ! defined EXIT_SUCCESS
972 void free (void *); /* INFRINGES ON USER NAME SPACE */
973 # endif
974 # endif
975 # endif
976 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
977
978
979 #if (! defined yyoverflow \
980 && (! defined __cplusplus \
981 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
982
983 /* A type that is properly aligned for any stack member. */
984 union yyalloc
985 {
986 yytype_int16 yyss_alloc;
987 YYSTYPE yyvs_alloc;
988 };
989
990 /* The size of the maximum gap between one aligned stack and the next. */
991 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
992
993 /* The size of an array large to enough to hold all stacks, each with
994 N elements. */
995 # define YYSTACK_BYTES(N) \
996 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
997 + YYSTACK_GAP_MAXIMUM)
998
999 # define YYCOPY_NEEDED 1
1000
1001 /* Relocate STACK from its old location to the new one. The
1002 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1003 elements in the stack, and YYPTR gives the new location of the
1004 stack. Advance YYPTR to a properly aligned location for the next
1005 stack. */
1006 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
1007 do \
1008 { \
1009 YYSIZE_T yynewbytes; \
1010 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
1011 Stack = &yyptr->Stack_alloc; \
1012 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1013 yyptr += yynewbytes / sizeof (*yyptr); \
1014 } \
1015 while (0)
1016
1017 #endif
1018
1019 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
1020 /* Copy COUNT objects from SRC to DST. The source and destination do
1021 not overlap. */
1022 # ifndef YYCOPY
1023 # if defined __GNUC__ && 1 < __GNUC__
1024 # define YYCOPY(Dst, Src, Count) \
1025 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
1026 # else
1027 # define YYCOPY(Dst, Src, Count) \
1028 do \
1029 { \
1030 YYSIZE_T yyi; \
1031 for (yyi = 0; yyi < (Count); yyi++) \
1032 (Dst)[yyi] = (Src)[yyi]; \
1033 } \
1034 while (0)
1035 # endif
1036 # endif
1037 #endif /* !YYCOPY_NEEDED */
1038
1039 /* YYFINAL -- State number of the termination state. */
1040 #define YYFINAL 3
1041 /* YYLAST -- Last index in YYTABLE. */
1042 #define YYLAST 30
1043
1044 /* YYNTOKENS -- Number of terminals. */
1045 #define YYNTOKENS 18
1046 /* YYNNTS -- Number of nonterminals. */
1047 #define YYNNTS 10
1048 /* YYNRULES -- Number of rules. */
1049 #define YYNRULES 21
1050 /* YYNSTATES -- Number of states. */
1051 #define YYNSTATES 33
1052
1053 #define YYUNDEFTOK 2
1054 #define YYMAXUTOK 272
1055
1056 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
1057 as returned by yylex, with out-of-bounds checking. */
1058 #define YYTRANSLATE(YYX) \
1059 ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1060
1061 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
1062 as returned by yylex. */
1063 static const yytype_uint8 yytranslate[] =
1064 {
1065 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1073 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1074 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1087 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1090 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1091 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1092 15, 16, 17
1093 };
1094
1095 #if YYDEBUG
1096 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1097 static const yytype_uint16 yyrline[] =
1098 {
1099 0, 667, 667, 667, 676, 678, 679, 680, 686, 686,
1100 692, 692, 698, 705, 705, 712, 718, 723, 729, 735,
1101 740, 745
1102 };
1103 #endif
1104
1105 #if YYDEBUG || YYERROR_VERBOSE || 0
1106 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1107 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1108 static const char *const yytname[] =
1109 {
1110 "$end", "error", "$undefined", "PEER", "GROUP", "IVAL", "RVAL", "NAME",
1111 "XSTRING", "SCOPE", "COLON", "LBRACE", "RBRACE", "TRUEBVAL", "FALSEBVAL",
1112 "CHAR", "WORD", "IP_ADDRESS", "$accept", "input", "$@1", "scope",
1113 "entries", "entry", "$@2", "$@3", "$@4", "value", YY_NULLPTR
1114 };
1115 #endif
1116
1117 # ifdef YYPRINT
1118 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
1119 (internal) symbol number NUM (which must be that of a token). */
1120 static const yytype_uint16 yytoknum[] =
1121 {
1122 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1123 265, 266, 267, 268, 269, 270, 271, 272
1124 };
1125 # endif
1126
1127 #define YYPACT_NINF -12
1128
1129 #define yypact_value_is_default(Yystate) \
1130 (!!((Yystate) == (-12)))
1131
1132 #define YYTABLE_NINF -5
1133
1134 #define yytable_value_is_error(Yytable_value) \
1135 0
1136
1137 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1138 STATE-NUM. */
1139 static const yytype_int8 yypact[] =
1140 {
1141 -12, 2, -12, -12, 0, -12, -11, -9, -6, -12,
1142 1, 3, 4, 8, -12, -12, -12, 14, -12, -12,
1143 -12, -12, -12, -12, -12, -12, -12, -12, -1, 5,
1144 11, -12, -12
1145 };
1146
1147 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1148 Performed when YYTABLE does not specify something else to do. Zero
1149 means the default is an error. */
1150 static const yytype_uint8 yydefact[] =
1151 {
1152 2, 0, 5, 1, 0, 7, 0, 0, 13, 6,
1153 0, 0, 0, 0, 8, 10, 12, 0, 5, 5,
1154 16, 19, 20, 17, 18, 21, 15, 14, 0, 0,
1155 0, 9, 11
1156 };
1157
1158 /* YYPGOTO[NTERM-NUM]. */
1159 static const yytype_int8 yypgoto[] =
1160 {
1161 -12, -12, -12, 6, 22, -12, -12, -12, -12, -12
1162 };
1163
1164 /* YYDEFGOTO[NTERM-NUM]. */
1165 static const yytype_int8 yydefgoto[] =
1166 {
1167 -1, 1, 2, 28, 29, 9, 18, 19, 13, 27
1168 };
1169
1170 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1171 positive, shift that token. If negative, reduce the rule whose
1172 number is the opposite. If YYTABLE_NINF, syntax error. */
1173 static const yytype_int8 yytable[] =
1174 {
1175 -3, 5, 3, 6, 7, 10, 5, 11, 6, 7,
1176 12, 31, 14, 0, 15, 16, 8, -4, 17, 20,
1177 21, 8, 22, 32, 4, 30, 0, 23, 24, 25,
1178 26
1179 };
1180
1181 static const yytype_int8 yycheck[] =
1182 {
1183 0, 1, 0, 3, 4, 16, 1, 16, 3, 4,
1184 16, 12, 11, -1, 11, 11, 16, 12, 10, 5,
1185 6, 16, 8, 12, 2, 19, -1, 13, 14, 15,
1186 16
1187 };
1188
1189 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1190 symbol of state STATE-NUM. */
1191 static const yytype_uint8 yystos[] =
1192 {
1193 0, 19, 20, 0, 22, 1, 3, 4, 16, 23,
1194 16, 16, 16, 26, 11, 11, 11, 10, 24, 25,
1195 5, 6, 8, 13, 14, 15, 16, 27, 21, 22,
1196 21, 12, 12
1197 };
1198
1199 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1200 static const yytype_uint8 yyr1[] =
1201 {
1202 0, 18, 20, 19, 21, 22, 22, 22, 24, 23,
1203 25, 23, 23, 26, 23, 27, 27, 27, 27, 27,
1204 27, 27
1205 };
1206
1207 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1208 static const yytype_uint8 yyr2[] =
1209 {
1210 0, 2, 0, 2, 1, 0, 2, 2, 0, 6,
1211 0, 6, 3, 0, 4, 1, 1, 1, 1, 1,
1212 1, 1
1213 };
1214
1215
1216 #define yyerrok (yyerrstatus = 0)
1217 #define yyclearin (yychar = YYEMPTY)
1218 #define YYEMPTY (-2)
1219 #define YYEOF 0
1220
1221 #define YYACCEPT goto yyacceptlab
1222 #define YYABORT goto yyabortlab
1223 #define YYERROR goto yyerrorlab
1224
1225
1226 #define YYRECOVERING() (!!yyerrstatus)
1227
1228 #define YYBACKUP(Token, Value) \
1229 do \
1230 if (yychar == YYEMPTY) \
1231 { \
1232 yychar = (Token); \
1233 yylval = (Value); \
1234 YYPOPSTACK (yylen); \
1235 yystate = *yyssp; \
1236 goto yybackup; \
1237 } \
1238 else \
1239 { \
1240 yyerror (YY_("syntax error: cannot back up")); \
1241 YYERROR; \
1242 } \
1243 while (0)
1244
1245 /* Error token number */
1246 #define YYTERROR 1
1247 #define YYERRCODE 256
1248
1249
1250
1251 /* Enable debugging if requested. */
1252 #if YYDEBUG
1253
1254 # ifndef YYFPRINTF
1255 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1256 # define YYFPRINTF fprintf
1257 # endif
1258
1259 # define YYDPRINTF(Args) \
1260 do { \
1261 if (yydebug) \
1262 YYFPRINTF Args; \
1263 } while (0)
1264
1265 /* This macro is provided for backward compatibility. */
1266 #ifndef YY_LOCATION_PRINT
1267 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1268 #endif
1269
1270
1271 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1272 do { \
1273 if (yydebug) \
1274 { \
1275 YYFPRINTF (stderr, "%s ", Title); \
1276 yy_symbol_print (stderr, \
1277 Type, Value); \
1278 YYFPRINTF (stderr, "\n"); \
1279 } \
1280 } while (0)
1281
1282
1283 /*-----------------------------------.
1284 | Print this symbol's value on YYO. |
1285 `-----------------------------------*/
1286
1287 static void
yy_symbol_value_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep)1288 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
1289 {
1290 FILE *yyoutput = yyo;
1291 YYUSE (yyoutput);
1292 if (!yyvaluep)
1293 return;
1294 # ifdef YYPRINT
1295 if (yytype < YYNTOKENS)
1296 YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
1297 # endif
1298 YYUSE (yytype);
1299 }
1300
1301
1302 /*---------------------------.
1303 | Print this symbol on YYO. |
1304 `---------------------------*/
1305
1306 static void
yy_symbol_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep)1307 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
1308 {
1309 YYFPRINTF (yyo, "%s %s (",
1310 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1311
1312 yy_symbol_value_print (yyo, yytype, yyvaluep);
1313 YYFPRINTF (yyo, ")");
1314 }
1315
1316 /*------------------------------------------------------------------.
1317 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1318 | TOP (included). |
1319 `------------------------------------------------------------------*/
1320
1321 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)1322 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1323 {
1324 YYFPRINTF (stderr, "Stack now");
1325 for (; yybottom <= yytop; yybottom++)
1326 {
1327 int yybot = *yybottom;
1328 YYFPRINTF (stderr, " %d", yybot);
1329 }
1330 YYFPRINTF (stderr, "\n");
1331 }
1332
1333 # define YY_STACK_PRINT(Bottom, Top) \
1334 do { \
1335 if (yydebug) \
1336 yy_stack_print ((Bottom), (Top)); \
1337 } while (0)
1338
1339
1340 /*------------------------------------------------.
1341 | Report that the YYRULE is going to be reduced. |
1342 `------------------------------------------------*/
1343
1344 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule)1345 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
1346 {
1347 unsigned long yylno = yyrline[yyrule];
1348 int yynrhs = yyr2[yyrule];
1349 int yyi;
1350 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1351 yyrule - 1, yylno);
1352 /* The symbols being reduced. */
1353 for (yyi = 0; yyi < yynrhs; yyi++)
1354 {
1355 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1356 yy_symbol_print (stderr,
1357 yystos[yyssp[yyi + 1 - yynrhs]],
1358 &yyvsp[(yyi + 1) - (yynrhs)]
1359 );
1360 YYFPRINTF (stderr, "\n");
1361 }
1362 }
1363
1364 # define YY_REDUCE_PRINT(Rule) \
1365 do { \
1366 if (yydebug) \
1367 yy_reduce_print (yyssp, yyvsp, Rule); \
1368 } while (0)
1369
1370 /* Nonzero means print parse trace. It is left uninitialized so that
1371 multiple parsers can coexist. */
1372 int yydebug;
1373 #else /* !YYDEBUG */
1374 # define YYDPRINTF(Args)
1375 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1376 # define YY_STACK_PRINT(Bottom, Top)
1377 # define YY_REDUCE_PRINT(Rule)
1378 #endif /* !YYDEBUG */
1379
1380
1381 /* YYINITDEPTH -- initial size of the parser's stacks. */
1382 #ifndef YYINITDEPTH
1383 # define YYINITDEPTH 200
1384 #endif
1385
1386 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1387 if the built-in stack extension method is used).
1388
1389 Do not make this value too large; the results are undefined if
1390 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1391 evaluated with infinite-precision integer arithmetic. */
1392
1393 #ifndef YYMAXDEPTH
1394 # define YYMAXDEPTH 10000
1395 #endif
1396
1397
1398 #if YYERROR_VERBOSE
1399
1400 # ifndef yystrlen
1401 # if defined __GLIBC__ && defined _STRING_H
1402 # define yystrlen strlen
1403 # else
1404 /* Return the length of YYSTR. */
1405 static YYSIZE_T
yystrlen(const char * yystr)1406 yystrlen (const char *yystr)
1407 {
1408 YYSIZE_T yylen;
1409 for (yylen = 0; yystr[yylen]; yylen++)
1410 continue;
1411 return yylen;
1412 }
1413 # endif
1414 # endif
1415
1416 # ifndef yystpcpy
1417 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1418 # define yystpcpy stpcpy
1419 # else
1420 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1421 YYDEST. */
1422 static char *
yystpcpy(char * yydest,const char * yysrc)1423 yystpcpy (char *yydest, const char *yysrc)
1424 {
1425 char *yyd = yydest;
1426 const char *yys = yysrc;
1427
1428 while ((*yyd++ = *yys++) != '\0')
1429 continue;
1430
1431 return yyd - 1;
1432 }
1433 # endif
1434 # endif
1435
1436 # ifndef yytnamerr
1437 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1438 quotes and backslashes, so that it's suitable for yyerror. The
1439 heuristic is that double-quoting is unnecessary unless the string
1440 contains an apostrophe, a comma, or backslash (other than
1441 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1442 null, do not copy; instead, return the length of what the result
1443 would have been. */
1444 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1445 yytnamerr (char *yyres, const char *yystr)
1446 {
1447 if (*yystr == '"')
1448 {
1449 YYSIZE_T yyn = 0;
1450 char const *yyp = yystr;
1451
1452 for (;;)
1453 switch (*++yyp)
1454 {
1455 case '\'':
1456 case ',':
1457 goto do_not_strip_quotes;
1458
1459 case '\\':
1460 if (*++yyp != '\\')
1461 goto do_not_strip_quotes;
1462 else
1463 goto append;
1464
1465 append:
1466 default:
1467 if (yyres)
1468 yyres[yyn] = *yyp;
1469 yyn++;
1470 break;
1471
1472 case '"':
1473 if (yyres)
1474 yyres[yyn] = '\0';
1475 return yyn;
1476 }
1477 do_not_strip_quotes: ;
1478 }
1479
1480 if (! yyres)
1481 return yystrlen (yystr);
1482
1483 return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
1484 }
1485 # endif
1486
1487 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1488 about the unexpected token YYTOKEN for the state stack whose top is
1489 YYSSP.
1490
1491 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1492 not large enough to hold the message. In that case, also set
1493 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1494 required number of bytes is too large to store. */
1495 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1496 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1497 yytype_int16 *yyssp, int yytoken)
1498 {
1499 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1500 YYSIZE_T yysize = yysize0;
1501 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1502 /* Internationalized format string. */
1503 const char *yyformat = YY_NULLPTR;
1504 /* Arguments of yyformat. */
1505 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1506 /* Number of reported tokens (one for the "unexpected", one per
1507 "expected"). */
1508 int yycount = 0;
1509
1510 /* There are many possibilities here to consider:
1511 - If this state is a consistent state with a default action, then
1512 the only way this function was invoked is if the default action
1513 is an error action. In that case, don't check for expected
1514 tokens because there are none.
1515 - The only way there can be no lookahead present (in yychar) is if
1516 this state is a consistent state with a default action. Thus,
1517 detecting the absence of a lookahead is sufficient to determine
1518 that there is no unexpected or expected token to report. In that
1519 case, just report a simple "syntax error".
1520 - Don't assume there isn't a lookahead just because this state is a
1521 consistent state with a default action. There might have been a
1522 previous inconsistent state, consistent state with a non-default
1523 action, or user semantic action that manipulated yychar.
1524 - Of course, the expected token list depends on states to have
1525 correct lookahead information, and it depends on the parser not
1526 to perform extra reductions after fetching a lookahead from the
1527 scanner and before detecting a syntax error. Thus, state merging
1528 (from LALR or IELR) and default reductions corrupt the expected
1529 token list. However, the list is correct for canonical LR with
1530 one exception: it will still contain any token that will not be
1531 accepted due to an error action in a later state.
1532 */
1533 if (yytoken != YYEMPTY)
1534 {
1535 int yyn = yypact[*yyssp];
1536 yyarg[yycount++] = yytname[yytoken];
1537 if (!yypact_value_is_default (yyn))
1538 {
1539 /* Start YYX at -YYN if negative to avoid negative indexes in
1540 YYCHECK. In other words, skip the first -YYN actions for
1541 this state because they are default actions. */
1542 int yyxbegin = yyn < 0 ? -yyn : 0;
1543 /* Stay within bounds of both yycheck and yytname. */
1544 int yychecklim = YYLAST - yyn + 1;
1545 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1546 int yyx;
1547
1548 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1549 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1550 && !yytable_value_is_error (yytable[yyx + yyn]))
1551 {
1552 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1553 {
1554 yycount = 1;
1555 yysize = yysize0;
1556 break;
1557 }
1558 yyarg[yycount++] = yytname[yyx];
1559 {
1560 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1561 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1562 yysize = yysize1;
1563 else
1564 return 2;
1565 }
1566 }
1567 }
1568 }
1569
1570 switch (yycount)
1571 {
1572 # define YYCASE_(N, S) \
1573 case N: \
1574 yyformat = S; \
1575 break
1576 default: /* Avoid compiler warnings. */
1577 YYCASE_(0, YY_("syntax error"));
1578 YYCASE_(1, YY_("syntax error, unexpected %s"));
1579 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1580 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1581 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1582 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1583 # undef YYCASE_
1584 }
1585
1586 {
1587 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1588 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1589 yysize = yysize1;
1590 else
1591 return 2;
1592 }
1593
1594 if (*yymsg_alloc < yysize)
1595 {
1596 *yymsg_alloc = 2 * yysize;
1597 if (! (yysize <= *yymsg_alloc
1598 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1599 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1600 return 1;
1601 }
1602
1603 /* Avoid sprintf, as that infringes on the user's name space.
1604 Don't have undefined behavior even if the translation
1605 produced a string with the wrong number of "%s"s. */
1606 {
1607 char *yyp = *yymsg;
1608 int yyi = 0;
1609 while ((*yyp = *yyformat) != '\0')
1610 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1611 {
1612 yyp += yytnamerr (yyp, yyarg[yyi++]);
1613 yyformat += 2;
1614 }
1615 else
1616 {
1617 yyp++;
1618 yyformat++;
1619 }
1620 }
1621 return 0;
1622 }
1623 #endif /* YYERROR_VERBOSE */
1624
1625 /*-----------------------------------------------.
1626 | Release the memory associated to this symbol. |
1627 `-----------------------------------------------*/
1628
1629 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1630 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1631 {
1632 YYUSE (yyvaluep);
1633 if (!yymsg)
1634 yymsg = "Deleting";
1635 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1636
1637 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1638 YYUSE (yytype);
1639 YY_IGNORE_MAYBE_UNINITIALIZED_END
1640 }
1641
1642
1643
1644
1645 /* The lookahead symbol. */
1646 int yychar;
1647
1648 /* The semantic value of the lookahead symbol. */
1649 YYSTYPE yylval;
1650 /* Number of syntax errors so far. */
1651 int yynerrs;
1652
1653
1654 /*----------.
1655 | yyparse. |
1656 `----------*/
1657
1658 int
yyparse(void)1659 yyparse (void)
1660 {
1661 int yystate;
1662 /* Number of tokens to shift before error messages enabled. */
1663 int yyerrstatus;
1664
1665 /* The stacks and their tools:
1666 'yyss': related to states.
1667 'yyvs': related to semantic values.
1668
1669 Refer to the stacks through separate pointers, to allow yyoverflow
1670 to reallocate them elsewhere. */
1671
1672 /* The state stack. */
1673 yytype_int16 yyssa[YYINITDEPTH];
1674 yytype_int16 *yyss;
1675 yytype_int16 *yyssp;
1676
1677 /* The semantic value stack. */
1678 YYSTYPE yyvsa[YYINITDEPTH];
1679 YYSTYPE *yyvs;
1680 YYSTYPE *yyvsp;
1681
1682 YYSIZE_T yystacksize;
1683
1684 int yyn;
1685 int yyresult;
1686 /* Lookahead token as an internal (translated) token number. */
1687 int yytoken = 0;
1688 /* The variables used to return semantic value and location from the
1689 action routines. */
1690 YYSTYPE yyval;
1691
1692 #if YYERROR_VERBOSE
1693 /* Buffer for error messages, and its allocated size. */
1694 char yymsgbuf[128];
1695 char *yymsg = yymsgbuf;
1696 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1697 #endif
1698
1699 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1700
1701 /* The number of symbols on the RHS of the reduced rule.
1702 Keep to zero when no symbol should be popped. */
1703 int yylen = 0;
1704
1705 yyssp = yyss = yyssa;
1706 yyvsp = yyvs = yyvsa;
1707 yystacksize = YYINITDEPTH;
1708
1709 YYDPRINTF ((stderr, "Starting parse\n"));
1710
1711 yystate = 0;
1712 yyerrstatus = 0;
1713 yynerrs = 0;
1714 yychar = YYEMPTY; /* Cause a token to be read. */
1715 goto yysetstate;
1716
1717
1718 /*------------------------------------------------------------.
1719 | yynewstate -- push a new state, which is found in yystate. |
1720 `------------------------------------------------------------*/
1721 yynewstate:
1722 /* In all cases, when you get here, the value and location stacks
1723 have just been pushed. So pushing a state here evens the stacks. */
1724 yyssp++;
1725
1726
1727 /*--------------------------------------------------------------------.
1728 | yynewstate -- set current state (the top of the stack) to yystate. |
1729 `--------------------------------------------------------------------*/
1730 yysetstate:
1731 *yyssp = (yytype_int16) yystate;
1732
1733 if (yyss + yystacksize - 1 <= yyssp)
1734 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1735 goto yyexhaustedlab;
1736 #else
1737 {
1738 /* Get the current used size of the three stacks, in elements. */
1739 YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
1740
1741 # if defined yyoverflow
1742 {
1743 /* Give user a chance to reallocate the stack. Use copies of
1744 these so that the &'s don't force the real ones into
1745 memory. */
1746 YYSTYPE *yyvs1 = yyvs;
1747 yytype_int16 *yyss1 = yyss;
1748
1749 /* Each stack pointer address is followed by the size of the
1750 data in use in that stack, in bytes. This used to be a
1751 conditional around just the two extra args, but that might
1752 be undefined if yyoverflow is a macro. */
1753 yyoverflow (YY_("memory exhausted"),
1754 &yyss1, yysize * sizeof (*yyssp),
1755 &yyvs1, yysize * sizeof (*yyvsp),
1756 &yystacksize);
1757 yyss = yyss1;
1758 yyvs = yyvs1;
1759 }
1760 # else /* defined YYSTACK_RELOCATE */
1761 /* Extend the stack our own way. */
1762 if (YYMAXDEPTH <= yystacksize)
1763 goto yyexhaustedlab;
1764 yystacksize *= 2;
1765 if (YYMAXDEPTH < yystacksize)
1766 yystacksize = YYMAXDEPTH;
1767
1768 {
1769 yytype_int16 *yyss1 = yyss;
1770 union yyalloc *yyptr =
1771 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1772 if (! yyptr)
1773 goto yyexhaustedlab;
1774 YYSTACK_RELOCATE (yyss_alloc, yyss);
1775 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1776 # undef YYSTACK_RELOCATE
1777 if (yyss1 != yyssa)
1778 YYSTACK_FREE (yyss1);
1779 }
1780 # endif
1781
1782 yyssp = yyss + yysize - 1;
1783 yyvsp = yyvs + yysize - 1;
1784
1785 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1786 (unsigned long) yystacksize));
1787
1788 if (yyss + yystacksize - 1 <= yyssp)
1789 YYABORT;
1790 }
1791 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1792
1793 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1794
1795 if (yystate == YYFINAL)
1796 YYACCEPT;
1797
1798 goto yybackup;
1799
1800
1801 /*-----------.
1802 | yybackup. |
1803 `-----------*/
1804 yybackup:
1805 /* Do appropriate processing given the current state. Read a
1806 lookahead token if we need one and don't already have one. */
1807
1808 /* First try to decide what to do without reference to lookahead token. */
1809 yyn = yypact[yystate];
1810 if (yypact_value_is_default (yyn))
1811 goto yydefault;
1812
1813 /* Not known => get a lookahead token if don't already have one. */
1814
1815 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1816 if (yychar == YYEMPTY)
1817 {
1818 YYDPRINTF ((stderr, "Reading a token: "));
1819 yychar = yylex ();
1820 }
1821
1822 if (yychar <= YYEOF)
1823 {
1824 yychar = yytoken = YYEOF;
1825 YYDPRINTF ((stderr, "Now at end of input.\n"));
1826 }
1827 else
1828 {
1829 yytoken = YYTRANSLATE (yychar);
1830 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1831 }
1832
1833 /* If the proper action on seeing token YYTOKEN is to reduce or to
1834 detect an error, take that action. */
1835 yyn += yytoken;
1836 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1837 goto yydefault;
1838 yyn = yytable[yyn];
1839 if (yyn <= 0)
1840 {
1841 if (yytable_value_is_error (yyn))
1842 goto yyerrlab;
1843 yyn = -yyn;
1844 goto yyreduce;
1845 }
1846
1847 /* Count tokens shifted since error; after three, turn off error
1848 status. */
1849 if (yyerrstatus)
1850 yyerrstatus--;
1851
1852 /* Shift the lookahead token. */
1853 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1854
1855 /* Discard the shifted token. */
1856 yychar = YYEMPTY;
1857
1858 yystate = yyn;
1859 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1860 *++yyvsp = yylval;
1861 YY_IGNORE_MAYBE_UNINITIALIZED_END
1862
1863 goto yynewstate;
1864
1865
1866 /*-----------------------------------------------------------.
1867 | yydefault -- do the default action for the current state. |
1868 `-----------------------------------------------------------*/
1869 yydefault:
1870 yyn = yydefact[yystate];
1871 if (yyn == 0)
1872 goto yyerrlab;
1873 goto yyreduce;
1874
1875
1876 /*-----------------------------.
1877 | yyreduce -- do a reduction. |
1878 `-----------------------------*/
1879 yyreduce:
1880 /* yyn is the number of a rule to reduce with. */
1881 yylen = yyr2[yyn];
1882
1883 /* If YYLEN is nonzero, implement the default value of the action:
1884 '$$ = $1'.
1885
1886 Otherwise, the following line sets YYVAL to garbage.
1887 This behavior is undocumented and Bison
1888 users should not rely upon it. Assigning to YYVAL
1889 unconditionally makes the parser a bit smaller, and it avoids a
1890 GCC warning that YYVAL may be used uninitialized. */
1891 yyval = yyvsp[1-yylen];
1892
1893
1894 YY_REDUCE_PRINT (yyn);
1895 switch (yyn)
1896 {
1897 case 2:
1898 #line 667 "configfile.y" /* yacc.c:1652 */
1899 {
1900 lineCount = 1;
1901 addScope(NULL, "", newScope(""));
1902 topScope = currScope;
1903 }
1904 #line 1905 "y.tab.c" /* yacc.c:1652 */
1905 break;
1906
1907 case 3:
1908 #line 671 "configfile.y" /* yacc.c:1652 */
1909 {
1910 if (!doCallbacks())
1911 YYABORT;
1912 }
1913 #line 1914 "y.tab.c" /* yacc.c:1652 */
1914 break;
1915
1916 case 7:
1917 #line 680 "configfile.y" /* yacc.c:1652 */
1918 {
1919 errbuff = xmalloc(strlen(SYNTAX_ERROR) + 12);
1920 sprintf(errbuff, SYNTAX_ERROR, lineCount);
1921 YYABORT;
1922 }
1923 #line 1924 "y.tab.c" /* yacc.c:1652 */
1924 break;
1925
1926 case 8:
1927 #line 686 "configfile.y" /* yacc.c:1652 */
1928 {
1929 errbuff = addScope(currScope, (yyvsp[-1].name), newScope("peer"));
1930 free((yyvsp[-1].name));
1931 if (errbuff != NULL)
1932 YYABORT;
1933 }
1934 #line 1935 "y.tab.c" /* yacc.c:1652 */
1935 break;
1936
1937 case 9:
1938 #line 691 "configfile.y" /* yacc.c:1652 */
1939 { currScope = currScope->parent; }
1940 #line 1941 "y.tab.c" /* yacc.c:1652 */
1941 break;
1942
1943 case 10:
1944 #line 692 "configfile.y" /* yacc.c:1652 */
1945 {
1946 errbuff = addScope(currScope, (yyvsp[-1].name), newScope("group"));
1947 free((yyvsp[-1].name));
1948 if (errbuff != NULL)
1949 YYABORT;
1950 }
1951 #line 1952 "y.tab.c" /* yacc.c:1652 */
1952 break;
1953
1954 case 11:
1955 #line 697 "configfile.y" /* yacc.c:1652 */
1956 { currScope = currScope->parent; }
1957 #line 1958 "y.tab.c" /* yacc.c:1652 */
1958 break;
1959
1960 case 12:
1961 #line 698 "configfile.y" /* yacc.c:1652 */
1962 {
1963 errbuff = xmalloc(strlen(UNKNOWN_SCOPE_TYPE) + 15 + strlen((yyvsp[-2].name)));
1964 sprintf(errbuff, UNKNOWN_SCOPE_TYPE, lineCount, (yyvsp[-2].name));
1965 free((yyvsp[-2].name));
1966 free((yyvsp[-1].name));
1967 YYABORT;
1968 }
1969 #line 1970 "y.tab.c" /* yacc.c:1652 */
1970 break;
1971
1972 case 13:
1973 #line 705 "configfile.y" /* yacc.c:1652 */
1974 {
1975 if ((errbuff = keyOk((yyvsp[0].name))) != NULL) {
1976 YYABORT;
1977 } else
1978 key = (yyvsp[0].name);
1979 }
1980 #line 1981 "y.tab.c" /* yacc.c:1652 */
1981 break;
1982
1983 case 15:
1984 #line 712 "configfile.y" /* yacc.c:1652 */
1985 {
1986 if ((errbuff = addString(currScope, key, (yyvsp[0].name))) != NULL)
1987 YYABORT;
1988 free(key);
1989 free((yyvsp[0].name));
1990 }
1991 #line 1992 "y.tab.c" /* yacc.c:1652 */
1992 break;
1993
1994 case 16:
1995 #line 718 "configfile.y" /* yacc.c:1652 */
1996 {
1997 if ((errbuff = addInteger(currScope, key, (yyvsp[0].integer))) != NULL)
1998 YYABORT;
1999 free(key);
2000 }
2001 #line 2002 "y.tab.c" /* yacc.c:1652 */
2002 break;
2003
2004 case 17:
2005 #line 723 "configfile.y" /* yacc.c:1652 */
2006 {
2007 if ((errbuff = addBoolean(currScope, key, 1)) != NULL)
2008 YYABORT;
2009 free(key);
2010 free((yyvsp[0].name));
2011 }
2012 #line 2013 "y.tab.c" /* yacc.c:1652 */
2013 break;
2014
2015 case 18:
2016 #line 729 "configfile.y" /* yacc.c:1652 */
2017 {
2018 if ((errbuff = addBoolean(currScope, key, 0)) != NULL)
2019 YYABORT;
2020 free(key);
2021 free((yyvsp[0].name));
2022 }
2023 #line 2024 "y.tab.c" /* yacc.c:1652 */
2024 break;
2025
2026 case 19:
2027 #line 735 "configfile.y" /* yacc.c:1652 */
2028 {
2029 if ((errbuff = addReal(currScope, key, (yyvsp[0].real))) != NULL)
2030 YYABORT;
2031 free(key);
2032 }
2033 #line 2034 "y.tab.c" /* yacc.c:1652 */
2034 break;
2035
2036 case 20:
2037 #line 740 "configfile.y" /* yacc.c:1652 */
2038 {
2039 if ((errbuff = addString(currScope, key, (yyvsp[0].string))) != NULL)
2040 YYABORT;
2041 free(key);
2042 }
2043 #line 2044 "y.tab.c" /* yacc.c:1652 */
2044 break;
2045
2046 case 21:
2047 #line 745 "configfile.y" /* yacc.c:1652 */
2048 {
2049 if ((errbuff = addChar(currScope, key, (yyvsp[0].chr))) != NULL)
2050 YYABORT;
2051 free(key);
2052 }
2053 #line 2054 "y.tab.c" /* yacc.c:1652 */
2054 break;
2055
2056
2057 #line 2058 "y.tab.c" /* yacc.c:1652 */
2058 default: break;
2059 }
2060 /* User semantic actions sometimes alter yychar, and that requires
2061 that yytoken be updated with the new translation. We take the
2062 approach of translating immediately before every use of yytoken.
2063 One alternative is translating here after every semantic action,
2064 but that translation would be missed if the semantic action invokes
2065 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2066 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2067 incorrect destructor might then be invoked immediately. In the
2068 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2069 to an incorrect destructor call or verbose syntax error message
2070 before the lookahead is translated. */
2071 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2072
2073 YYPOPSTACK (yylen);
2074 yylen = 0;
2075 YY_STACK_PRINT (yyss, yyssp);
2076
2077 *++yyvsp = yyval;
2078
2079 /* Now 'shift' the result of the reduction. Determine what state
2080 that goes to, based on the state we popped back to and the rule
2081 number reduced by. */
2082 {
2083 const int yylhs = yyr1[yyn] - YYNTOKENS;
2084 const int yyi = yypgoto[yylhs] + *yyssp;
2085 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2086 ? yytable[yyi]
2087 : yydefgoto[yylhs]);
2088 }
2089
2090 goto yynewstate;
2091
2092
2093 /*--------------------------------------.
2094 | yyerrlab -- here on detecting error. |
2095 `--------------------------------------*/
2096 yyerrlab:
2097 /* Make sure we have latest lookahead translation. See comments at
2098 user semantic actions for why this is necessary. */
2099 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2100
2101 /* If not already recovering from an error, report this error. */
2102 if (!yyerrstatus)
2103 {
2104 ++yynerrs;
2105 #if ! YYERROR_VERBOSE
2106 yyerror (YY_("syntax error"));
2107 #else
2108 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2109 yyssp, yytoken)
2110 {
2111 char const *yymsgp = YY_("syntax error");
2112 int yysyntax_error_status;
2113 yysyntax_error_status = YYSYNTAX_ERROR;
2114 if (yysyntax_error_status == 0)
2115 yymsgp = yymsg;
2116 else if (yysyntax_error_status == 1)
2117 {
2118 if (yymsg != yymsgbuf)
2119 YYSTACK_FREE (yymsg);
2120 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2121 if (!yymsg)
2122 {
2123 yymsg = yymsgbuf;
2124 yymsg_alloc = sizeof yymsgbuf;
2125 yysyntax_error_status = 2;
2126 }
2127 else
2128 {
2129 yysyntax_error_status = YYSYNTAX_ERROR;
2130 yymsgp = yymsg;
2131 }
2132 }
2133 yyerror (yymsgp);
2134 if (yysyntax_error_status == 2)
2135 goto yyexhaustedlab;
2136 }
2137 # undef YYSYNTAX_ERROR
2138 #endif
2139 }
2140
2141
2142
2143 if (yyerrstatus == 3)
2144 {
2145 /* If just tried and failed to reuse lookahead token after an
2146 error, discard it. */
2147
2148 if (yychar <= YYEOF)
2149 {
2150 /* Return failure if at end of input. */
2151 if (yychar == YYEOF)
2152 YYABORT;
2153 }
2154 else
2155 {
2156 yydestruct ("Error: discarding",
2157 yytoken, &yylval);
2158 yychar = YYEMPTY;
2159 }
2160 }
2161
2162 /* Else will try to reuse lookahead token after shifting the error
2163 token. */
2164 goto yyerrlab1;
2165
2166
2167 /*---------------------------------------------------.
2168 | yyerrorlab -- error raised explicitly by YYERROR. |
2169 `---------------------------------------------------*/
2170 yyerrorlab:
2171 /* Pacify compilers when the user code never invokes YYERROR and the
2172 label yyerrorlab therefore never appears in user code. */
2173 if (0)
2174 YYERROR;
2175
2176 /* Do not reclaim the symbols of the rule whose action triggered
2177 this YYERROR. */
2178 YYPOPSTACK (yylen);
2179 yylen = 0;
2180 YY_STACK_PRINT (yyss, yyssp);
2181 yystate = *yyssp;
2182 goto yyerrlab1;
2183
2184
2185 /*-------------------------------------------------------------.
2186 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2187 `-------------------------------------------------------------*/
2188 yyerrlab1:
2189 yyerrstatus = 3; /* Each real token shifted decrements this. */
2190
2191 for (;;)
2192 {
2193 yyn = yypact[yystate];
2194 if (!yypact_value_is_default (yyn))
2195 {
2196 yyn += YYTERROR;
2197 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2198 {
2199 yyn = yytable[yyn];
2200 if (0 < yyn)
2201 break;
2202 }
2203 }
2204
2205 /* Pop the current state because it cannot handle the error token. */
2206 if (yyssp == yyss)
2207 YYABORT;
2208
2209
2210 yydestruct ("Error: popping",
2211 yystos[yystate], yyvsp);
2212 YYPOPSTACK (1);
2213 yystate = *yyssp;
2214 YY_STACK_PRINT (yyss, yyssp);
2215 }
2216
2217 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2218 *++yyvsp = yylval;
2219 YY_IGNORE_MAYBE_UNINITIALIZED_END
2220
2221
2222 /* Shift the error token. */
2223 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2224
2225 yystate = yyn;
2226 goto yynewstate;
2227
2228
2229 /*-------------------------------------.
2230 | yyacceptlab -- YYACCEPT comes here. |
2231 `-------------------------------------*/
2232 yyacceptlab:
2233 yyresult = 0;
2234 goto yyreturn;
2235
2236
2237 /*-----------------------------------.
2238 | yyabortlab -- YYABORT comes here. |
2239 `-----------------------------------*/
2240 yyabortlab:
2241 yyresult = 1;
2242 goto yyreturn;
2243
2244
2245 #if !defined yyoverflow || YYERROR_VERBOSE
2246 /*-------------------------------------------------.
2247 | yyexhaustedlab -- memory exhaustion comes here. |
2248 `-------------------------------------------------*/
2249 yyexhaustedlab:
2250 yyerror (YY_("memory exhausted"));
2251 yyresult = 2;
2252 /* Fall through. */
2253 #endif
2254
2255
2256 /*-----------------------------------------------------.
2257 | yyreturn -- parsing is finished, return the result. |
2258 `-----------------------------------------------------*/
2259 yyreturn:
2260 if (yychar != YYEMPTY)
2261 {
2262 /* Make sure we have latest lookahead translation. See comments at
2263 user semantic actions for why this is necessary. */
2264 yytoken = YYTRANSLATE (yychar);
2265 yydestruct ("Cleanup: discarding lookahead",
2266 yytoken, &yylval);
2267 }
2268 /* Do not reclaim the symbols of the rule whose action triggered
2269 this YYABORT or YYACCEPT. */
2270 YYPOPSTACK (yylen);
2271 YY_STACK_PRINT (yyss, yyssp);
2272 while (yyssp != yyss)
2273 {
2274 yydestruct ("Cleanup: popping",
2275 yystos[*yyssp], yyvsp);
2276 YYPOPSTACK (1);
2277 }
2278 #ifndef yyoverflow
2279 if (yyss != yyssa)
2280 YYSTACK_FREE (yyss);
2281 #endif
2282 #if YYERROR_VERBOSE
2283 if (yymsg != yymsgbuf)
2284 YYSTACK_FREE (yymsg);
2285 #endif
2286 return yyresult;
2287 }
2288 #line 751 "configfile.y" /* yacc.c:1918 */
2289
2290 /* clang-format on */
2291
2292 int
yyerror(const char * s)2293 yyerror(const char *s)
2294 {
2295 #undef FMT
2296 #define FMT "line %d: %s"
2297
2298 errbuff = xmalloc(strlen(s) + strlen(FMT) + 20);
2299 sprintf(errbuff, FMT, lineCount, s);
2300
2301 return 0;
2302 }
2303
2304 int
yywrap(void)2305 yywrap(void)
2306 {
2307 return 1;
2308 }
2309
2310 extern FILE *yyin;
2311 int yydebug;
2312
2313 #define NO_INHERIT 0
2314
2315
2316 #if !defined(WANT_MAIN)
2317
2318 struct peer_table_s {
2319 char *peerName;
2320 value *peerValue;
2321 };
2322
2323 static struct peer_table_s *peerTable;
2324 static int peerTableCount;
2325 static int peerTableIdx;
2326
2327 void
configCleanup(void)2328 configCleanup(void)
2329 {
2330 int i;
2331
2332 for (i = 0; i < peerTableIdx; i++)
2333 free(peerTable[i].peerName);
2334 free(peerTable);
2335
2336 freeScopeTree(topScope);
2337 free(funcs);
2338 free(args);
2339 }
2340
2341
2342 int
buildPeerTable(FILE * fp,scope * s)2343 buildPeerTable(FILE *fp, scope *s)
2344 {
2345 int rval = 1;
2346 int i, j;
2347
2348 for (i = 0; i < s->value_idx; i++) {
2349 if (ISSCOPE(s->values[i]) && ISPEER(s->values[i])) {
2350 for (j = 0; j < peerTableIdx; j++) {
2351 if (strcmp(peerTable[j].peerName, s->values[i]->name) == 0) {
2352 logOrPrint(LOG_ERR, fp,
2353 "ME config: two peers with the same name: %s",
2354 peerTable[j].peerName);
2355 rval = 0;
2356 break;
2357 }
2358 }
2359
2360 if (j == peerTableIdx) {
2361 if (peerTableCount == peerTableIdx) {
2362 peerTableCount += 10;
2363 if (peerTable == NULL)
2364 peerTable = xmalloc(sizeof(struct peer_table_s)
2365 * peerTableCount);
2366 else
2367 peerTable =
2368 xrealloc(peerTable, sizeof(struct peer_table_s)
2369 * peerTableCount);
2370 }
2371
2372 peerTable[peerTableIdx].peerName = xstrdup(s->values[i]->name);
2373 peerTable[peerTableIdx].peerValue = s->values[i];
2374 peerTableIdx++;
2375 }
2376 } else if (ISSCOPE(s->values[i]))
2377 rval = (buildPeerTable(fp, s->values[i]->v.scope_val) && rval);
2378 }
2379
2380 return rval;
2381 }
2382
2383
2384 /* read the config file. Any errors go to errorDest if it is non-NULL,
2385 otherwise they are syslogged. If justCheck is true then return after
2386 parsing */
2387 static int inited = 0;
2388 int
readConfig(const char * file,FILE * errorDest,int justCheck,int dump)2389 readConfig(const char *file, FILE *errorDest, int justCheck, int dump)
2390 {
2391 scope *oldTop = topScope;
2392 FILE *fp;
2393 int rval;
2394
2395 if (!inited) {
2396 inited = 1;
2397 yydebug = (getenv("YYDEBUG") == NULL ? 0 : 1);
2398 if (yydebug)
2399 atexit(configCleanup);
2400 }
2401
2402 if (file == NULL || strlen(file) == 0 || !fileExistsP(file)) {
2403 logOrPrint(LOG_ERR, errorDest,
2404 "ME config aborting, no such config file: %s",
2405 file ? file : "(null)");
2406 d_printf(1, "No such config file: %s\n", file ? file : "(null)");
2407 exit(1);
2408 }
2409
2410 if ((fp = fopen(file, "r")) == NULL) {
2411 logOrPrint(LOG_ERR, errorDest, "ME config aborting fopen %s: %s", file,
2412 strerror(errno));
2413 exit(1);
2414 }
2415
2416 logOrPrint(LOG_NOTICE, errorDest, "loading %s", file);
2417
2418 yyin = fp;
2419
2420 topScope = NULL;
2421
2422 rval = yyparse();
2423
2424 fclose(fp);
2425
2426 if (rval != 0) /* failure */
2427 {
2428 freeScopeTree(topScope);
2429 if (justCheck)
2430 freeScopeTree(oldTop);
2431 else
2432 topScope = oldTop;
2433 topScope = NULL;
2434
2435 if (errbuff != NULL) {
2436 if (errorDest != NULL)
2437 fprintf(errorDest, "config file error: %s\n", errbuff);
2438 else
2439 warn("ME config file error: %s", errbuff);
2440
2441 free(errbuff);
2442 }
2443
2444 return 0;
2445 }
2446
2447 if (dump) {
2448 fprintf(errorDest ? errorDest : stderr, "Parsed config file:\n");
2449 printScope(errorDest ? errorDest : stderr, topScope, -5);
2450 fprintf(errorDest ? errorDest : stderr, "\n");
2451 }
2452
2453 if (justCheck) {
2454 freeScopeTree(topScope);
2455 freeScopeTree(oldTop);
2456
2457 topScope = NULL;
2458 } else {
2459 for (peerTableIdx--; peerTableIdx >= 0; peerTableIdx--) {
2460 free(peerTable[peerTableIdx].peerName);
2461 peerTable[peerTableIdx].peerName = NULL;
2462 peerTable[peerTableIdx].peerValue = NULL;
2463 }
2464 peerTableIdx = 0;
2465
2466 if (!buildPeerTable(errorDest, topScope))
2467 logAndExit(1, "Failed to build list of peers");
2468 }
2469
2470 return 1;
2471 }
2472
2473
2474 value *
getNextPeer(int * cookie)2475 getNextPeer(int *cookie)
2476 {
2477 value *rval;
2478
2479 if (*cookie < 0 || *cookie >= peerTableIdx)
2480 return NULL;
2481
2482 rval = peerTable[*cookie].peerValue;
2483
2484 (*cookie)++;
2485
2486 return rval;
2487 }
2488
2489
2490 value *
findPeer(const char * name)2491 findPeer(const char *name)
2492 {
2493 value *v = NULL;
2494 int i;
2495
2496 for (i = 0; i < peerTableIdx; i++)
2497 if (strcmp(peerTable[i].peerName, name) == 0) {
2498 v = peerTable[i].peerValue;
2499 break;
2500 }
2501
2502 return v;
2503 }
2504
2505 #endif
2506
2507 #if defined(WANT_MAIN)
2508 int
main(int argc,char ** argv)2509 main(int argc, char **argv)
2510 {
2511 if (yyparse())
2512 printf("parsing failed: %s\n", errbuff ? errbuff : "NONE");
2513 else {
2514 printScope(stdout, topScope, -5);
2515
2516 if (argc == 3) {
2517 # if defined(INNFEED_DEBUG)
2518 printf ("Looking for %s of type %s: ",argv[2],argv[1]) ;
2519 if (strncmp (argv[1],"int",3) == 0)
2520 {
2521 int i = 0 ;
2522
2523 if (!getInteger (topScope,argv[2],&i))
2524 printf ("wasn't found.\n") ;
2525 else
2526 printf (" %d\n",i) ;
2527 }
2528 else if (strncmp (argv[1],"real",4) == 0)
2529 {
2530 double d = 0.0 ;
2531
2532 if (!getReal (topScope,argv[2],&d))
2533 printf ("wasn't found.\n") ;
2534 else
2535 printf (" %0.5f\n",d) ;
2536 }
2537 # else
2538 value *v = findValue(topScope, argv[1], 1);
2539
2540 if (v == NULL)
2541 printf("Can't find %s\n", argv[1]);
2542 else {
2543 long ival = 987654;
2544
2545 if (getInteger(v->v.scope_val, argv[2], &ival, 1))
2546 printf("Getting %s : %ld", argv[2], ival);
2547 else
2548 printf("Name is not legal: %s\n", argv[2]);
2549 }
2550 # endif
2551 } else if (argc == 2) {
2552 value *v = findValue(topScope, argv[1], 1);
2553
2554 if (v == NULL)
2555 printf("Can't find %s\n", argv[1]);
2556 else {
2557 printf("Getting %s : ", argv[1]);
2558 printValue(stdout, v, 0);
2559 }
2560 }
2561 }
2562
2563 freeScopeTree(topScope);
2564
2565 return 0;
2566 }
2567 #endif /* defined (WANT_MAIN) */
2568