]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ofed/libsdp/src/config_parser.c
MFV r323531: 8521 nvlist memory leak in get_clones_stat() and spa_load_best()
[FreeBSD/FreeBSD.git] / contrib / ofed / libsdp / src / config_parser.c
1 /* A Bison parser, made by GNU Bison 2.3.  */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6    Free Software Foundation, 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 2, or (at your option)
11    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, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110-1301, USA.  */
22
23 /* As a special exception, you may create a larger work that contains
24    part or all of the Bison parser skeleton and distribute that work
25    under terms of your choice, so long as that work isn't itself a
26    parser generator using the skeleton or a modified version thereof
27    as a parser skeleton.  Alternatively, if you modify or redistribute
28    the parser skeleton itself, you may (at your option) remove this
29    special exception, which will cause the skeleton and the resulting
30    Bison output files to be licensed under the GNU General Public
31    License without this special exception.
32
33    This special exception was added by the Free Software Foundation in
34    version 2.2 of Bison.  */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37    simplifying the original so-called "semantic" parser.  */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40    infringing on user name space.  This should be done even for local
41    variables, as they might otherwise be expanded by user macros.
42    There are some unavoidable exceptions within include files to
43    define necessary library symbols; they are noted "INFRINGES ON
44    USER NAME SPACE" below.  */
45
46 /* Identify Bison output.  */
47 #define YYBISON 1
48
49 /* Bison version.  */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name.  */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers.  */
56 #define YYPURE 0
57
58 /* Using locations.  */
59 #define YYLSP_NEEDED 0
60
61 /* Substitute the variable and function names.  */
62 #define yyparse libsdp_yyparse
63 #define yylex   libsdp_yylex
64 #define yyerror libsdp_yyerror
65 #define yylval  libsdp_yylval
66 #define yychar  libsdp_yychar
67 #define yydebug libsdp_yydebug
68 #define yynerrs libsdp_yynerrs
69
70
71 /* Tokens.  */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74    /* Put the tokens into the symbol table, so that GDB and other debuggers
75       know about them.  */
76    enum yytokentype {
77      USE = 258,
78      CLIENT = 259,
79      SERVER = 260,
80      TCP = 261,
81      SDP = 262,
82      BOTH = 263,
83      INT = 264,
84      LOG = 265,
85      DEST = 266,
86      STDERR = 267,
87      SYSLOG = 268,
88      FILENAME = 269,
89      NAME = 270,
90      LEVEL = 271,
91      LINE = 272,
92      SUBNET = 273
93    };
94 #endif
95 /* Tokens.  */
96 #define USE 258
97 #define CLIENT 259
98 #define SERVER 260
99 #define TCP 261
100 #define SDP 262
101 #define BOTH 263
102 #define INT 264
103 #define LOG 265
104 #define DEST 266
105 #define STDERR 267
106 #define SYSLOG 268
107 #define FILENAME 269
108 #define NAME 270
109 #define LEVEL 271
110 #define LINE 272
111 #define SUBNET 273
112
113
114
115
116 /* Copy the first part of user declarations.  */
117 #line 39 "./config_parser.y"
118
119
120 /* header section */
121 #include <stdlib.h>
122 #include <stdio.h>
123 #include <string.h>
124 #include "libsdp.h"
125 #include <sys/socket.h>
126 #include <netinet/in.h>
127 #include <arpa/inet.h>
128
129 #define YYERROR_VERBOSE 1
130
131 extern int yyerror(char *msg);
132 extern int yylex(void);
133 static int parse_err = 0;
134
135 struct use_family_rule *__sdp_clients_family_rules_head = NULL;
136 struct use_family_rule *__sdp_clients_family_rules_tail = NULL;
137 struct use_family_rule *__sdp_servers_family_rules_head = NULL;
138 struct use_family_rule *__sdp_servers_family_rules_tail = NULL;
139
140 /* some globals to store intermidiate parser state */
141 static struct use_family_rule __sdp_rule;
142 static int current_role = 0;
143
144 int __sdp_config_empty(
145                        void
146                        )
147 {
148   return ( (__sdp_clients_family_rules_head == NULL) &&
149            (__sdp_servers_family_rules_head == NULL) );
150 }
151
152 static void __sdp_set_ip_addr(char *addr)
153 {
154         int rc;
155         char *addrlen;
156         struct sockaddr_in *addr4 = (struct sockaddr_in *)(&__sdp_rule.ip);
157         struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)(&__sdp_rule.ip);
158         int prefixlen = 0;
159
160         addrlen = strrchr(addr, '/');
161         if (addrlen) {
162                 prefixlen = atoi(addrlen + 1);
163                 *addrlen = '\0';
164         }
165
166         rc = inet_pton(AF_INET, addr, &addr4->sin_addr);
167         if (rc > 0) {
168                 addr4->sin_family = AF_INET;
169                 __sdp_rule.prefixlen = prefixlen ?: 32;
170                 return;
171         }
172
173         rc = inet_pton(AF_INET6, addr, &addr6->sin6_addr);
174         if (rc > 0) {
175                 addr6->sin6_family = AF_INET6;
176                 __sdp_rule.prefixlen = prefixlen ?: 128;
177                 return;
178         }
179
180         parse_err = 1;
181         yyerror("provided address is not legal");
182 }
183
184 static const char *addr2str(struct sockaddr_storage *src)
185 {
186         static char dst[INET6_ADDRSTRLEN];
187         int af = src->ss_family;
188         const struct sockaddr_in *addr4 = (const struct sockaddr_in *)src;
189         const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)src;
190
191         if (af == AF_INET6)
192                 return inet_ntop(af, &addr6->sin6_addr, dst, INET6_ADDRSTRLEN);
193
194         return inet_ntop(af, &addr4->sin_addr, dst, INET6_ADDRSTRLEN);
195 }
196
197 static void __sdp_set_prog_name_expr(char *prog_name_expr)
198 {
199   __sdp_rule.prog_name_expr = strdup(prog_name_expr);
200   if (!__sdp_rule.prog_name_expr) {
201     yyerror("fail to allocate program name expression");    
202   }
203 }
204
205 static char *__sdp_get_role_str(int role)
206 {
207   if (role == 1) return("server");
208   if (role == 2) return("client");
209   return("unknown role");
210 }
211
212 extern int __sdp_min_level;
213
214 /* dump the current state in readable format */
215 static void  __sdp_dump_config_state() {
216   char buf[1024];
217   sprintf(buf, "CONFIG: use %s %s %s", 
218           __sdp_get_family_str(__sdp_rule.target_family), 
219           __sdp_get_role_str( current_role ),
220           __sdp_rule.prog_name_expr);
221   if (__sdp_rule.match_by_addr) {
222       sprintf(buf+strlen(buf), " %s/%d", 
223               addr2str(&__sdp_rule.ip), __sdp_rule.prefixlen);
224   } else {
225     sprintf(buf+strlen(buf), " *");
226   }
227   if (__sdp_rule.match_by_port) {
228     sprintf(buf+strlen(buf), ":%d",__sdp_rule.sport);
229     if (__sdp_rule.eport > __sdp_rule.sport) 
230       sprintf(buf+strlen(buf), "-%d",__sdp_rule.eport);
231   }
232   else
233     sprintf(buf+strlen(buf), ":*");
234   sprintf(buf+strlen(buf), "\n");
235   __sdp_log(1, buf);
236 }
237
238 /* use the above state for making a new rule */
239 static void __sdp_add_rule() {
240   struct use_family_rule **p_tail, **p_head, *rule;
241
242   if (__sdp_min_level <= 1) __sdp_dump_config_state();
243   if ( current_role == 1 ) {
244     p_tail = &__sdp_servers_family_rules_tail;
245     p_head = &__sdp_servers_family_rules_head;
246   } else if ( current_role == 2 ) {
247     p_tail = &__sdp_clients_family_rules_tail;
248     p_head = &__sdp_clients_family_rules_head;
249   } else {
250     yyerror("ignoring unknown role");
251     parse_err = 1;
252     return;
253   }
254
255   rule = (struct use_family_rule *)malloc(sizeof(*rule));
256   if (!rule) {
257     yyerror("fail to allocate new rule");
258     parse_err = 1;
259     return;
260   }
261
262   memset(rule, 0, sizeof(*rule));
263   *rule = __sdp_rule;
264   rule->prev = *p_tail;
265   if (!(*p_head)) {
266     *p_head = rule;
267   } else {
268     (*p_tail)->next = rule;
269   } /* if */
270   *p_tail = rule;
271 }
272
273
274
275 /* Enabling traces.  */
276 #ifndef YYDEBUG
277 # define YYDEBUG 1
278 #endif
279
280 /* Enabling verbose error messages.  */
281 #ifdef YYERROR_VERBOSE
282 # undef YYERROR_VERBOSE
283 # define YYERROR_VERBOSE 1
284 #else
285 # define YYERROR_VERBOSE 1
286 #endif
287
288 /* Enabling the token table.  */
289 #ifndef YYTOKEN_TABLE
290 # define YYTOKEN_TABLE 0
291 #endif
292
293 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
294 typedef union YYSTYPE
295 #line 197 "./config_parser.y"
296 {
297   int        ival;
298   char      *sval;
299 }
300 /* Line 193 of yacc.c.  */
301 #line 302 "y.tab.c"
302         YYSTYPE;
303 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
304 # define YYSTYPE_IS_DECLARED 1
305 # define YYSTYPE_IS_TRIVIAL 1
306 #endif
307
308
309
310 /* Copy the second part of user declarations.  */
311 #line 223 "./config_parser.y"
312
313   long __sdp_config_line_num;
314
315
316 /* Line 216 of yacc.c.  */
317 #line 318 "y.tab.c"
318
319 #ifdef short
320 # undef short
321 #endif
322
323 #ifdef YYTYPE_UINT8
324 typedef YYTYPE_UINT8 yytype_uint8;
325 #else
326 typedef unsigned char yytype_uint8;
327 #endif
328
329 #ifdef YYTYPE_INT8
330 typedef YYTYPE_INT8 yytype_int8;
331 #elif (defined __STDC__ || defined __C99__FUNC__ \
332      || defined __cplusplus || defined _MSC_VER)
333 typedef signed char yytype_int8;
334 #else
335 typedef short int yytype_int8;
336 #endif
337
338 #ifdef YYTYPE_UINT16
339 typedef YYTYPE_UINT16 yytype_uint16;
340 #else
341 typedef unsigned short int yytype_uint16;
342 #endif
343
344 #ifdef YYTYPE_INT16
345 typedef YYTYPE_INT16 yytype_int16;
346 #else
347 typedef short int yytype_int16;
348 #endif
349
350 #ifndef YYSIZE_T
351 # ifdef __SIZE_TYPE__
352 #  define YYSIZE_T __SIZE_TYPE__
353 # elif defined size_t
354 #  define YYSIZE_T size_t
355 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
356      || defined __cplusplus || defined _MSC_VER)
357 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
358 #  define YYSIZE_T size_t
359 # else
360 #  define YYSIZE_T unsigned int
361 # endif
362 #endif
363
364 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
365
366 #ifndef YY_
367 # if YYENABLE_NLS
368 #  if ENABLE_NLS
369 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
370 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
371 #  endif
372 # endif
373 # ifndef YY_
374 #  define YY_(msgid) msgid
375 # endif
376 #endif
377
378 /* Suppress unused-variable warnings by "using" E.  */
379 #if ! defined lint || defined __GNUC__
380 # define YYUSE(e) ((void) (e))
381 #else
382 # define YYUSE(e) /* empty */
383 #endif
384
385 /* Identity function, used to suppress warnings about constant conditions.  */
386 #ifndef lint
387 # define YYID(n) (n)
388 #else
389 #if (defined __STDC__ || defined __C99__FUNC__ \
390      || defined __cplusplus || defined _MSC_VER)
391 static int
392 YYID (int i)
393 #else
394 static int
395 YYID (i)
396     int i;
397 #endif
398 {
399   return i;
400 }
401 #endif
402
403 #if ! defined yyoverflow || YYERROR_VERBOSE
404
405 /* The parser invokes alloca or malloc; define the necessary symbols.  */
406
407 # ifdef YYSTACK_USE_ALLOCA
408 #  if YYSTACK_USE_ALLOCA
409 #   ifdef __GNUC__
410 #    define YYSTACK_ALLOC __builtin_alloca
411 #   elif defined __BUILTIN_VA_ARG_INCR
412 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
413 #   elif defined _AIX
414 #    define YYSTACK_ALLOC __alloca
415 #   elif defined _MSC_VER
416 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
417 #    define alloca _alloca
418 #   else
419 #    define YYSTACK_ALLOC alloca
420 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
421      || defined __cplusplus || defined _MSC_VER)
422 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
423 #     ifndef _STDLIB_H
424 #      define _STDLIB_H 1
425 #     endif
426 #    endif
427 #   endif
428 #  endif
429 # endif
430
431 # ifdef YYSTACK_ALLOC
432    /* Pacify GCC's `empty if-body' warning.  */
433 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
434 #  ifndef YYSTACK_ALLOC_MAXIMUM
435     /* The OS might guarantee only one guard page at the bottom of the stack,
436        and a page size can be as small as 4096 bytes.  So we cannot safely
437        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
438        to allow for a few compiler-allocated temporary stack slots.  */
439 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
440 #  endif
441 # else
442 #  define YYSTACK_ALLOC YYMALLOC
443 #  define YYSTACK_FREE YYFREE
444 #  ifndef YYSTACK_ALLOC_MAXIMUM
445 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
446 #  endif
447 #  if (defined __cplusplus && ! defined _STDLIB_H \
448        && ! ((defined YYMALLOC || defined malloc) \
449              && (defined YYFREE || defined free)))
450 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
451 #   ifndef _STDLIB_H
452 #    define _STDLIB_H 1
453 #   endif
454 #  endif
455 #  ifndef YYMALLOC
456 #   define YYMALLOC malloc
457 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
458      || defined __cplusplus || defined _MSC_VER)
459 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
460 #   endif
461 #  endif
462 #  ifndef YYFREE
463 #   define YYFREE free
464 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
465      || defined __cplusplus || defined _MSC_VER)
466 void free (void *); /* INFRINGES ON USER NAME SPACE */
467 #   endif
468 #  endif
469 # endif
470 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
471
472
473 #if (! defined yyoverflow \
474      && (! defined __cplusplus \
475          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
476
477 /* A type that is properly aligned for any stack member.  */
478 union yyalloc
479 {
480   yytype_int16 yyss;
481   YYSTYPE yyvs;
482   };
483
484 /* The size of the maximum gap between one aligned stack and the next.  */
485 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
486
487 /* The size of an array large to enough to hold all stacks, each with
488    N elements.  */
489 # define YYSTACK_BYTES(N) \
490      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
491       + YYSTACK_GAP_MAXIMUM)
492
493 /* Copy COUNT objects from FROM to TO.  The source and destination do
494    not overlap.  */
495 # ifndef YYCOPY
496 #  if defined __GNUC__ && 1 < __GNUC__
497 #   define YYCOPY(To, From, Count) \
498       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
499 #  else
500 #   define YYCOPY(To, From, Count)              \
501       do                                        \
502         {                                       \
503           YYSIZE_T yyi;                         \
504           for (yyi = 0; yyi < (Count); yyi++)   \
505             (To)[yyi] = (From)[yyi];            \
506         }                                       \
507       while (YYID (0))
508 #  endif
509 # endif
510
511 /* Relocate STACK from its old location to the new one.  The
512    local variables YYSIZE and YYSTACKSIZE give the old and new number of
513    elements in the stack, and YYPTR gives the new location of the
514    stack.  Advance YYPTR to a properly aligned location for the next
515    stack.  */
516 # define YYSTACK_RELOCATE(Stack)                                        \
517     do                                                                  \
518       {                                                                 \
519         YYSIZE_T yynewbytes;                                            \
520         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
521         Stack = &yyptr->Stack;                                          \
522         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
523         yyptr += yynewbytes / sizeof (*yyptr);                          \
524       }                                                                 \
525     while (YYID (0))
526
527 #endif
528
529 /* YYFINAL -- State number of the termination state.  */
530 #define YYFINAL  7
531 /* YYLAST -- Last index in YYTABLE.  */
532 #define YYLAST   31
533
534 /* YYNTOKENS -- Number of terminals.  */
535 #define YYNTOKENS  22
536 /* YYNNTS -- Number of nonterminals.  */
537 #define YYNNTS  16
538 /* YYNRULES -- Number of rules.  */
539 #define YYNRULES  31
540 /* YYNRULES -- Number of states.  */
541 #define YYNSTATES  44
542
543 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
544 #define YYUNDEFTOK  2
545 #define YYMAXUTOK   273
546
547 #define YYTRANSLATE(YYX)                                                \
548   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
549
550 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
551 static const yytype_uint8 yytranslate[] =
552 {
553        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
554        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
555        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
556        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
557        2,     2,    20,     2,     2,    21,     2,     2,     2,     2,
558        2,     2,     2,     2,     2,     2,     2,     2,    19,     2,
559        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
560        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
561        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
562        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
563        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
564        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
565        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
566        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
567        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
568        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
569        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
570        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
571        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
572        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
574        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
579        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
580       15,    16,    17,    18
581 };
582
583 #if YYDEBUG
584 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
585    YYRHS.  */
586 static const yytype_uint8 yyprhs[] =
587 {
588        0,     0,     3,     5,     8,     9,    11,    14,    15,    18,
589       20,    22,    26,    27,    30,    33,    36,    39,    43,    46,
590       55,    57,    59,    61,    63,    65,    67,    69,    71,    73,
591       75,    79
592 };
593
594 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
595 static const yytype_int8 yyrhs[] =
596 {
597       25,     0,    -1,    17,    -1,    23,    17,    -1,    -1,    23,
598       -1,    24,    26,    -1,    -1,    26,    27,    -1,    28,    -1,
599       32,    -1,    10,    29,    23,    -1,    -1,    29,    30,    -1,
600       29,    31,    -1,    11,    12,    -1,    11,    13,    -1,    11,
601       14,    15,    -1,    16,     9,    -1,     3,    33,    34,    35,
602       36,    19,    37,    23,    -1,     6,    -1,     7,    -1,     8,
603       -1,     5,    -1,     4,    -1,    15,    -1,    20,    -1,    18,
604       -1,    20,    -1,     9,    -1,     9,    21,     9,    -1,    20,
605       -1
606 };
607
608 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
609 static const yytype_uint16 yyrline[] =
610 {
611        0,   229,   229,   230,   232,   233,   236,   239,   240,   244,
612      245,   249,   252,   253,   254,   258,   259,   260,   264,   268,
613      272,   273,   274,   278,   279,   283,   284,   288,   289,   293,
614      294,   295
615 };
616 #endif
617
618 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
619 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
620    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
621 static const char *const yytname[] =
622 {
623   "$end", "error", "$undefined", "\"use\"", "\"client or connect\"",
624   "\"server or listen\"", "\"tcp\"", "\"sdp\"", "\"both\"",
625   "\"integer value\"", "\"log statement\"", "\"destination\"",
626   "\"stderr\"", "\"syslog\"", "\"file\"", "\"a name\"", "\"min-level\"",
627   "\"new line\"", "\"ip address\"", "':'", "'*'", "'-'", "$accept", "NL",
628   "ONL", "config", "statements", "statement", "log_statement", "log_opts",
629   "log_dest", "verbosity", "socket_statement", "family", "role", "program",
630   "address", "ports", 0
631 };
632 #endif
633
634 # ifdef YYPRINT
635 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
636    token YYLEX-NUM.  */
637 static const yytype_uint16 yytoknum[] =
638 {
639        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
640      265,   266,   267,   268,   269,   270,   271,   272,   273,    58,
641       42,    45
642 };
643 # endif
644
645 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
646 static const yytype_uint8 yyr1[] =
647 {
648        0,    22,    23,    23,    24,    24,    25,    26,    26,    27,
649       27,    28,    29,    29,    29,    30,    30,    30,    31,    32,
650       33,    33,    33,    34,    34,    35,    35,    36,    36,    37,
651       37,    37
652 };
653
654 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
655 static const yytype_uint8 yyr2[] =
656 {
657        0,     2,     1,     2,     0,     1,     2,     0,     2,     1,
658        1,     3,     0,     2,     2,     2,     2,     3,     2,     8,
659        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
660        3,     1
661 };
662
663 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
664    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
665    means the default is an error.  */
666 static const yytype_uint8 yydefact[] =
667 {
668        4,     2,     5,     7,     0,     3,     6,     1,     0,    12,
669        8,     9,    10,    20,    21,    22,     0,     0,    24,    23,
670        0,     0,     0,    11,    13,    14,    25,    26,     0,    15,
671       16,     0,    18,    27,    28,     0,    17,     0,    29,    31,
672        0,     0,    19,    30
673 };
674
675 /* YYDEFGOTO[NTERM-NUM].  */
676 static const yytype_int8 yydefgoto[] =
677 {
678       -1,     2,     3,     4,     6,    10,    11,    17,    24,    25,
679       12,    16,    20,    28,    35,    40
680 };
681
682 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
683    STATE-NUM.  */
684 #define YYPACT_NINF -18
685 static const yytype_int8 yypact[] =
686 {
687      -10,   -18,     5,   -18,    21,   -18,    -1,   -18,     7,   -18,
688      -18,   -18,   -18,   -18,   -18,   -18,    15,    -6,   -18,   -18,
689      -12,     4,    16,     5,   -18,   -18,   -18,   -18,   -14,   -18,
690      -18,     9,   -18,   -18,   -18,     8,   -18,    -8,    10,   -18,
691      -10,    17,     5,   -18
692 };
693
694 /* YYPGOTO[NTERM-NUM].  */
695 static const yytype_int8 yypgoto[] =
696 {
697      -18,   -17,   -18,   -18,   -18,   -18,   -18,   -18,   -18,   -18,
698      -18,   -18,   -18,   -18,   -18,   -18
699 };
700
701 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
702    positive, shift that token.  If negative, reduce the rule which
703    number is the opposite.  If zero, do what YYDEFACT says.
704    If YYTABLE_NINF, syntax error.  */
705 #define YYTABLE_NINF -1
706 static const yytype_uint8 yytable[] =
707 {
708       23,    38,     8,    26,    33,    21,    34,     1,    27,     9,
709       22,     1,    39,    13,    14,    15,    29,    30,    31,    18,
710       19,     7,     5,    42,    36,    32,    43,    37,     0,     0,
711        0,    41
712 };
713
714 static const yytype_int8 yycheck[] =
715 {
716       17,     9,     3,    15,    18,    11,    20,    17,    20,    10,
717       16,    17,    20,     6,     7,     8,    12,    13,    14,     4,
718        5,     0,    17,    40,    15,     9,     9,    19,    -1,    -1,
719       -1,    21
720 };
721
722 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
723    symbol of state STATE-NUM.  */
724 static const yytype_uint8 yystos[] =
725 {
726        0,    17,    23,    24,    25,    17,    26,     0,     3,    10,
727       27,    28,    32,     6,     7,     8,    33,    29,     4,     5,
728       34,    11,    16,    23,    30,    31,    15,    20,    35,    12,
729       13,    14,     9,    18,    20,    36,    15,    19,     9,    20,
730       37,    21,    23,     9
731 };
732
733 #define yyerrok         (yyerrstatus = 0)
734 #define yyclearin       (yychar = YYEMPTY)
735 #define YYEMPTY         (-2)
736 #define YYEOF           0
737
738 #define YYACCEPT        goto yyacceptlab
739 #define YYABORT         goto yyabortlab
740 #define YYERROR         goto yyerrorlab
741
742
743 /* Like YYERROR except do call yyerror.  This remains here temporarily
744    to ease the transition to the new meaning of YYERROR, for GCC.
745    Once GCC version 2 has supplanted version 1, this can go.  */
746
747 #define YYFAIL          goto yyerrlab
748
749 #define YYRECOVERING()  (!!yyerrstatus)
750
751 #define YYBACKUP(Token, Value)                                  \
752 do                                                              \
753   if (yychar == YYEMPTY && yylen == 1)                          \
754     {                                                           \
755       yychar = (Token);                                         \
756       yylval = (Value);                                         \
757       yytoken = YYTRANSLATE (yychar);                           \
758       YYPOPSTACK (1);                                           \
759       goto yybackup;                                            \
760     }                                                           \
761   else                                                          \
762     {                                                           \
763       yyerror (YY_("syntax error: cannot back up")); \
764       YYERROR;                                                  \
765     }                                                           \
766 while (YYID (0))
767
768
769 #define YYTERROR        1
770 #define YYERRCODE       256
771
772
773 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
774    If N is 0, then set CURRENT to the empty location which ends
775    the previous symbol: RHS[0] (always defined).  */
776
777 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
778 #ifndef YYLLOC_DEFAULT
779 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
780     do                                                                  \
781       if (YYID (N))                                                    \
782         {                                                               \
783           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
784           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
785           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
786           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
787         }                                                               \
788       else                                                              \
789         {                                                               \
790           (Current).first_line   = (Current).last_line   =              \
791             YYRHSLOC (Rhs, 0).last_line;                                \
792           (Current).first_column = (Current).last_column =              \
793             YYRHSLOC (Rhs, 0).last_column;                              \
794         }                                                               \
795     while (YYID (0))
796 #endif
797
798
799 /* YY_LOCATION_PRINT -- Print the location on the stream.
800    This macro was not mandated originally: define only if we know
801    we won't break user code: when these are the locations we know.  */
802
803 #ifndef YY_LOCATION_PRINT
804 # if YYLTYPE_IS_TRIVIAL
805 #  define YY_LOCATION_PRINT(File, Loc)                  \
806      fprintf (File, "%d.%d-%d.%d",                      \
807               (Loc).first_line, (Loc).first_column,     \
808               (Loc).last_line,  (Loc).last_column)
809 # else
810 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
811 # endif
812 #endif
813
814
815 /* YYLEX -- calling `yylex' with the right arguments.  */
816
817 #ifdef YYLEX_PARAM
818 # define YYLEX yylex (YYLEX_PARAM)
819 #else
820 # define YYLEX yylex ()
821 #endif
822
823 /* Enable debugging if requested.  */
824 #if YYDEBUG
825
826 # ifndef YYFPRINTF
827 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
828 #  define YYFPRINTF fprintf
829 # endif
830
831 # define YYDPRINTF(Args)                        \
832 do {                                            \
833   if (yydebug)                                  \
834     YYFPRINTF Args;                             \
835 } while (YYID (0))
836
837 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
838 do {                                                                      \
839   if (yydebug)                                                            \
840     {                                                                     \
841       YYFPRINTF (stderr, "%s ", Title);                                   \
842       yy_symbol_print (stderr,                                            \
843                   Type, Value); \
844       YYFPRINTF (stderr, "\n");                                           \
845     }                                                                     \
846 } while (YYID (0))
847
848
849 /*--------------------------------.
850 | Print this symbol on YYOUTPUT.  |
851 `--------------------------------*/
852
853 /*ARGSUSED*/
854 #if (defined __STDC__ || defined __C99__FUNC__ \
855      || defined __cplusplus || defined _MSC_VER)
856 static void
857 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
858 #else
859 static void
860 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
861     FILE *yyoutput;
862     int yytype;
863     YYSTYPE const * const yyvaluep;
864 #endif
865 {
866   if (!yyvaluep)
867     return;
868 # ifdef YYPRINT
869   if (yytype < YYNTOKENS)
870     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
871 # else
872   YYUSE (yyoutput);
873 # endif
874   switch (yytype)
875     {
876       default:
877         break;
878     }
879 }
880
881
882 /*--------------------------------.
883 | Print this symbol on YYOUTPUT.  |
884 `--------------------------------*/
885
886 #if (defined __STDC__ || defined __C99__FUNC__ \
887      || defined __cplusplus || defined _MSC_VER)
888 static void
889 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
890 #else
891 static void
892 yy_symbol_print (yyoutput, yytype, yyvaluep)
893     FILE *yyoutput;
894     int yytype;
895     YYSTYPE const * const yyvaluep;
896 #endif
897 {
898   if (yytype < YYNTOKENS)
899     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
900   else
901     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
902
903   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
904   YYFPRINTF (yyoutput, ")");
905 }
906
907 /*------------------------------------------------------------------.
908 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
909 | TOP (included).                                                   |
910 `------------------------------------------------------------------*/
911
912 #if (defined __STDC__ || defined __C99__FUNC__ \
913      || defined __cplusplus || defined _MSC_VER)
914 static void
915 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
916 #else
917 static void
918 yy_stack_print (bottom, top)
919     yytype_int16 *bottom;
920     yytype_int16 *top;
921 #endif
922 {
923   YYFPRINTF (stderr, "Stack now");
924   for (; bottom <= top; ++bottom)
925     YYFPRINTF (stderr, " %d", *bottom);
926   YYFPRINTF (stderr, "\n");
927 }
928
929 # define YY_STACK_PRINT(Bottom, Top)                            \
930 do {                                                            \
931   if (yydebug)                                                  \
932     yy_stack_print ((Bottom), (Top));                           \
933 } while (YYID (0))
934
935
936 /*------------------------------------------------.
937 | Report that the YYRULE is going to be reduced.  |
938 `------------------------------------------------*/
939
940 #if (defined __STDC__ || defined __C99__FUNC__ \
941      || defined __cplusplus || defined _MSC_VER)
942 static void
943 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
944 #else
945 static void
946 yy_reduce_print (yyvsp, yyrule)
947     YYSTYPE *yyvsp;
948     int yyrule;
949 #endif
950 {
951   int yynrhs = yyr2[yyrule];
952   int yyi;
953   unsigned long int yylno = yyrline[yyrule];
954   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
955              yyrule - 1, yylno);
956   /* The symbols being reduced.  */
957   for (yyi = 0; yyi < yynrhs; yyi++)
958     {
959       fprintf (stderr, "   $%d = ", yyi + 1);
960       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
961                        &(yyvsp[(yyi + 1) - (yynrhs)])
962                                        );
963       fprintf (stderr, "\n");
964     }
965 }
966
967 # define YY_REDUCE_PRINT(Rule)          \
968 do {                                    \
969   if (yydebug)                          \
970     yy_reduce_print (yyvsp, Rule); \
971 } while (YYID (0))
972
973 /* Nonzero means print parse trace.  It is left uninitialized so that
974    multiple parsers can coexist.  */
975 int yydebug;
976 #else /* !YYDEBUG */
977 # define YYDPRINTF(Args)
978 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
979 # define YY_STACK_PRINT(Bottom, Top)
980 # define YY_REDUCE_PRINT(Rule)
981 #endif /* !YYDEBUG */
982
983
984 /* YYINITDEPTH -- initial size of the parser's stacks.  */
985 #ifndef YYINITDEPTH
986 # define YYINITDEPTH 200
987 #endif
988
989 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
990    if the built-in stack extension method is used).
991
992    Do not make this value too large; the results are undefined if
993    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
994    evaluated with infinite-precision integer arithmetic.  */
995
996 #ifndef YYMAXDEPTH
997 # define YYMAXDEPTH 10000
998 #endif
999
1000 \f
1001
1002 #if YYERROR_VERBOSE
1003
1004 # ifndef yystrlen
1005 #  if defined __GLIBC__ && defined _STRING_H
1006 #   define yystrlen strlen
1007 #  else
1008 /* Return the length of YYSTR.  */
1009 #if (defined __STDC__ || defined __C99__FUNC__ \
1010      || defined __cplusplus || defined _MSC_VER)
1011 static YYSIZE_T
1012 yystrlen (const char *yystr)
1013 #else
1014 static YYSIZE_T
1015 yystrlen (yystr)
1016     const char *yystr;
1017 #endif
1018 {
1019   YYSIZE_T yylen;
1020   for (yylen = 0; yystr[yylen]; yylen++)
1021     continue;
1022   return yylen;
1023 }
1024 #  endif
1025 # endif
1026
1027 # ifndef yystpcpy
1028 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1029 #   define yystpcpy stpcpy
1030 #  else
1031 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1032    YYDEST.  */
1033 #if (defined __STDC__ || defined __C99__FUNC__ \
1034      || defined __cplusplus || defined _MSC_VER)
1035 static char *
1036 yystpcpy (char *yydest, const char *yysrc)
1037 #else
1038 static char *
1039 yystpcpy (yydest, yysrc)
1040     char *yydest;
1041     const char *yysrc;
1042 #endif
1043 {
1044   char *yyd = yydest;
1045   const char *yys = yysrc;
1046
1047   while ((*yyd++ = *yys++) != '\0')
1048     continue;
1049
1050   return yyd - 1;
1051 }
1052 #  endif
1053 # endif
1054
1055 # ifndef yytnamerr
1056 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1057    quotes and backslashes, so that it's suitable for yyerror.  The
1058    heuristic is that double-quoting is unnecessary unless the string
1059    contains an apostrophe, a comma, or backslash (other than
1060    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1061    null, do not copy; instead, return the length of what the result
1062    would have been.  */
1063 static YYSIZE_T
1064 yytnamerr (char *yyres, const char *yystr)
1065 {
1066   if (*yystr == '"')
1067     {
1068       YYSIZE_T yyn = 0;
1069       char const *yyp = yystr;
1070
1071       for (;;)
1072         switch (*++yyp)
1073           {
1074           case '\'':
1075           case ',':
1076             goto do_not_strip_quotes;
1077
1078           case '\\':
1079             if (*++yyp != '\\')
1080               goto do_not_strip_quotes;
1081             /* Fall through.  */
1082           default:
1083             if (yyres)
1084               yyres[yyn] = *yyp;
1085             yyn++;
1086             break;
1087
1088           case '"':
1089             if (yyres)
1090               yyres[yyn] = '\0';
1091             return yyn;
1092           }
1093     do_not_strip_quotes: ;
1094     }
1095
1096   if (! yyres)
1097     return yystrlen (yystr);
1098
1099   return yystpcpy (yyres, yystr) - yyres;
1100 }
1101 # endif
1102
1103 /* Copy into YYRESULT an error message about the unexpected token
1104    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1105    including the terminating null byte.  If YYRESULT is null, do not
1106    copy anything; just return the number of bytes that would be
1107    copied.  As a special case, return 0 if an ordinary "syntax error"
1108    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1109    size calculation.  */
1110 static YYSIZE_T
1111 yysyntax_error (char *yyresult, int yystate, int yychar)
1112 {
1113   int yyn = yypact[yystate];
1114
1115   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1116     return 0;
1117   else
1118     {
1119       int yytype = YYTRANSLATE (yychar);
1120       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1121       YYSIZE_T yysize = yysize0;
1122       YYSIZE_T yysize1;
1123       int yysize_overflow = 0;
1124       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1125       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1126       int yyx;
1127
1128 # if 0
1129       /* This is so xgettext sees the translatable formats that are
1130          constructed on the fly.  */
1131       YY_("syntax error, unexpected %s");
1132       YY_("syntax error, unexpected %s, expecting %s");
1133       YY_("syntax error, unexpected %s, expecting %s or %s");
1134       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1135       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1136 # endif
1137       char *yyfmt;
1138       char const *yyf;
1139       static char const yyunexpected[] = "syntax error, unexpected %s";
1140       static char const yyexpecting[] = ", expecting %s";
1141       static char const yyor[] = " or %s";
1142       char yyformat[sizeof yyunexpected
1143                     + sizeof yyexpecting - 1
1144                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1145                        * (sizeof yyor - 1))];
1146       char const *yyprefix = yyexpecting;
1147
1148       /* Start YYX at -YYN if negative to avoid negative indexes in
1149          YYCHECK.  */
1150       int yyxbegin = yyn < 0 ? -yyn : 0;
1151
1152       /* Stay within bounds of both yycheck and yytname.  */
1153       int yychecklim = YYLAST - yyn + 1;
1154       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1155       int yycount = 1;
1156
1157       yyarg[0] = yytname[yytype];
1158       yyfmt = yystpcpy (yyformat, yyunexpected);
1159
1160       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1161         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1162           {
1163             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1164               {
1165                 yycount = 1;
1166                 yysize = yysize0;
1167                 yyformat[sizeof yyunexpected - 1] = '\0';
1168                 break;
1169               }
1170             yyarg[yycount++] = yytname[yyx];
1171             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1172             yysize_overflow |= (yysize1 < yysize);
1173             yysize = yysize1;
1174             yyfmt = yystpcpy (yyfmt, yyprefix);
1175             yyprefix = yyor;
1176           }
1177
1178       yyf = YY_(yyformat);
1179       yysize1 = yysize + yystrlen (yyf);
1180       yysize_overflow |= (yysize1 < yysize);
1181       yysize = yysize1;
1182
1183       if (yysize_overflow)
1184         return YYSIZE_MAXIMUM;
1185
1186       if (yyresult)
1187         {
1188           /* Avoid sprintf, as that infringes on the user's name space.
1189              Don't have undefined behavior even if the translation
1190              produced a string with the wrong number of "%s"s.  */
1191           char *yyp = yyresult;
1192           int yyi = 0;
1193           while ((*yyp = *yyf) != '\0')
1194             {
1195               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1196                 {
1197                   yyp += yytnamerr (yyp, yyarg[yyi++]);
1198                   yyf += 2;
1199                 }
1200               else
1201                 {
1202                   yyp++;
1203                   yyf++;
1204                 }
1205             }
1206         }
1207       return yysize;
1208     }
1209 }
1210 #endif /* YYERROR_VERBOSE */
1211 \f
1212
1213 /*-----------------------------------------------.
1214 | Release the memory associated to this symbol.  |
1215 `-----------------------------------------------*/
1216
1217 /*ARGSUSED*/
1218 #if (defined __STDC__ || defined __C99__FUNC__ \
1219      || defined __cplusplus || defined _MSC_VER)
1220 static void
1221 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1222 #else
1223 static void
1224 yydestruct (yymsg, yytype, yyvaluep)
1225     const char *yymsg;
1226     int yytype;
1227     YYSTYPE *yyvaluep;
1228 #endif
1229 {
1230   YYUSE (yyvaluep);
1231
1232   if (!yymsg)
1233     yymsg = "Deleting";
1234   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1235
1236   switch (yytype)
1237     {
1238
1239       default:
1240         break;
1241     }
1242 }
1243 \f
1244
1245 /* Prevent warnings from -Wmissing-prototypes.  */
1246
1247 #ifdef YYPARSE_PARAM
1248 #if defined __STDC__ || defined __cplusplus
1249 int yyparse (void *YYPARSE_PARAM);
1250 #else
1251 int yyparse ();
1252 #endif
1253 #else /* ! YYPARSE_PARAM */
1254 #if defined __STDC__ || defined __cplusplus
1255 int yyparse (void);
1256 #else
1257 int yyparse ();
1258 #endif
1259 #endif /* ! YYPARSE_PARAM */
1260
1261
1262
1263 /* The look-ahead symbol.  */
1264 int yychar;
1265
1266 /* The semantic value of the look-ahead symbol.  */
1267 YYSTYPE yylval;
1268
1269 /* Number of syntax errors so far.  */
1270 int yynerrs;
1271
1272
1273
1274 /*----------.
1275 | yyparse.  |
1276 `----------*/
1277
1278 #ifdef YYPARSE_PARAM
1279 #if (defined __STDC__ || defined __C99__FUNC__ \
1280      || defined __cplusplus || defined _MSC_VER)
1281 int
1282 yyparse (void *YYPARSE_PARAM)
1283 #else
1284 int
1285 yyparse (YYPARSE_PARAM)
1286     void *YYPARSE_PARAM;
1287 #endif
1288 #else /* ! YYPARSE_PARAM */
1289 #if (defined __STDC__ || defined __C99__FUNC__ \
1290      || defined __cplusplus || defined _MSC_VER)
1291 int
1292 yyparse (void)
1293 #else
1294 int
1295 yyparse ()
1296
1297 #endif
1298 #endif
1299 {
1300   
1301   int yystate;
1302   int yyn;
1303   int yyresult;
1304   /* Number of tokens to shift before error messages enabled.  */
1305   int yyerrstatus;
1306   /* Look-ahead token as an internal (translated) token number.  */
1307   int yytoken = 0;
1308 #if YYERROR_VERBOSE
1309   /* Buffer for error messages, and its allocated size.  */
1310   char yymsgbuf[128];
1311   char *yymsg = yymsgbuf;
1312   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1313 #endif
1314
1315   /* Three stacks and their tools:
1316      `yyss': related to states,
1317      `yyvs': related to semantic values,
1318      `yyls': related to locations.
1319
1320      Refer to the stacks thru separate pointers, to allow yyoverflow
1321      to reallocate them elsewhere.  */
1322
1323   /* The state stack.  */
1324   yytype_int16 yyssa[YYINITDEPTH];
1325   yytype_int16 *yyss = yyssa;
1326   yytype_int16 *yyssp;
1327
1328   /* The semantic value stack.  */
1329   YYSTYPE yyvsa[YYINITDEPTH];
1330   YYSTYPE *yyvs = yyvsa;
1331   YYSTYPE *yyvsp;
1332
1333
1334
1335 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1336
1337   YYSIZE_T yystacksize = YYINITDEPTH;
1338
1339   /* The variables used to return semantic value and location from the
1340      action routines.  */
1341   YYSTYPE yyval;
1342
1343
1344   /* The number of symbols on the RHS of the reduced rule.
1345      Keep to zero when no symbol should be popped.  */
1346   int yylen = 0;
1347
1348   YYDPRINTF ((stderr, "Starting parse\n"));
1349
1350   yystate = 0;
1351   yyerrstatus = 0;
1352   yynerrs = 0;
1353   yychar = YYEMPTY;             /* Cause a token to be read.  */
1354
1355   /* Initialize stack pointers.
1356      Waste one element of value and location stack
1357      so that they stay on the same level as the state stack.
1358      The wasted elements are never initialized.  */
1359
1360   yyssp = yyss;
1361   yyvsp = yyvs;
1362
1363   goto yysetstate;
1364
1365 /*------------------------------------------------------------.
1366 | yynewstate -- Push a new state, which is found in yystate.  |
1367 `------------------------------------------------------------*/
1368  yynewstate:
1369   /* In all cases, when you get here, the value and location stacks
1370      have just been pushed.  So pushing a state here evens the stacks.  */
1371   yyssp++;
1372
1373  yysetstate:
1374   *yyssp = yystate;
1375
1376   if (yyss + yystacksize - 1 <= yyssp)
1377     {
1378       /* Get the current used size of the three stacks, in elements.  */
1379       YYSIZE_T yysize = yyssp - yyss + 1;
1380
1381 #ifdef yyoverflow
1382       {
1383         /* Give user a chance to reallocate the stack.  Use copies of
1384            these so that the &'s don't force the real ones into
1385            memory.  */
1386         YYSTYPE *yyvs1 = yyvs;
1387         yytype_int16 *yyss1 = yyss;
1388
1389
1390         /* Each stack pointer address is followed by the size of the
1391            data in use in that stack, in bytes.  This used to be a
1392            conditional around just the two extra args, but that might
1393            be undefined if yyoverflow is a macro.  */
1394         yyoverflow (YY_("memory exhausted"),
1395                     &yyss1, yysize * sizeof (*yyssp),
1396                     &yyvs1, yysize * sizeof (*yyvsp),
1397
1398                     &yystacksize);
1399
1400         yyss = yyss1;
1401         yyvs = yyvs1;
1402       }
1403 #else /* no yyoverflow */
1404 # ifndef YYSTACK_RELOCATE
1405       goto yyexhaustedlab;
1406 # else
1407       /* Extend the stack our own way.  */
1408       if (YYMAXDEPTH <= yystacksize)
1409         goto yyexhaustedlab;
1410       yystacksize *= 2;
1411       if (YYMAXDEPTH < yystacksize)
1412         yystacksize = YYMAXDEPTH;
1413
1414       {
1415         yytype_int16 *yyss1 = yyss;
1416         union yyalloc *yyptr =
1417           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1418         if (! yyptr)
1419           goto yyexhaustedlab;
1420         YYSTACK_RELOCATE (yyss);
1421         YYSTACK_RELOCATE (yyvs);
1422
1423 #  undef YYSTACK_RELOCATE
1424         if (yyss1 != yyssa)
1425           YYSTACK_FREE (yyss1);
1426       }
1427 # endif
1428 #endif /* no yyoverflow */
1429
1430       yyssp = yyss + yysize - 1;
1431       yyvsp = yyvs + yysize - 1;
1432
1433
1434       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1435                   (unsigned long int) yystacksize));
1436
1437       if (yyss + yystacksize - 1 <= yyssp)
1438         YYABORT;
1439     }
1440
1441   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1442
1443   goto yybackup;
1444
1445 /*-----------.
1446 | yybackup.  |
1447 `-----------*/
1448 yybackup:
1449
1450   /* Do appropriate processing given the current state.  Read a
1451      look-ahead token if we need one and don't already have one.  */
1452
1453   /* First try to decide what to do without reference to look-ahead token.  */
1454   yyn = yypact[yystate];
1455   if (yyn == YYPACT_NINF)
1456     goto yydefault;
1457
1458   /* Not known => get a look-ahead token if don't already have one.  */
1459
1460   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1461   if (yychar == YYEMPTY)
1462     {
1463       YYDPRINTF ((stderr, "Reading a token: "));
1464       yychar = YYLEX;
1465     }
1466
1467   if (yychar <= YYEOF)
1468     {
1469       yychar = yytoken = YYEOF;
1470       YYDPRINTF ((stderr, "Now at end of input.\n"));
1471     }
1472   else
1473     {
1474       yytoken = YYTRANSLATE (yychar);
1475       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1476     }
1477
1478   /* If the proper action on seeing token YYTOKEN is to reduce or to
1479      detect an error, take that action.  */
1480   yyn += yytoken;
1481   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1482     goto yydefault;
1483   yyn = yytable[yyn];
1484   if (yyn <= 0)
1485     {
1486       if (yyn == 0 || yyn == YYTABLE_NINF)
1487         goto yyerrlab;
1488       yyn = -yyn;
1489       goto yyreduce;
1490     }
1491
1492   if (yyn == YYFINAL)
1493     YYACCEPT;
1494
1495   /* Count tokens shifted since error; after three, turn off error
1496      status.  */
1497   if (yyerrstatus)
1498     yyerrstatus--;
1499
1500   /* Shift the look-ahead token.  */
1501   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1502
1503   /* Discard the shifted token unless it is eof.  */
1504   if (yychar != YYEOF)
1505     yychar = YYEMPTY;
1506
1507   yystate = yyn;
1508   *++yyvsp = yylval;
1509
1510   goto yynewstate;
1511
1512
1513 /*-----------------------------------------------------------.
1514 | yydefault -- do the default action for the current state.  |
1515 `-----------------------------------------------------------*/
1516 yydefault:
1517   yyn = yydefact[yystate];
1518   if (yyn == 0)
1519     goto yyerrlab;
1520   goto yyreduce;
1521
1522
1523 /*-----------------------------.
1524 | yyreduce -- Do a reduction.  |
1525 `-----------------------------*/
1526 yyreduce:
1527   /* yyn is the number of a rule to reduce with.  */
1528   yylen = yyr2[yyn];
1529
1530   /* If YYLEN is nonzero, implement the default value of the action:
1531      `$$ = $1'.
1532
1533      Otherwise, the following line sets YYVAL to garbage.
1534      This behavior is undocumented and Bison
1535      users should not rely upon it.  Assigning to YYVAL
1536      unconditionally makes the parser a bit smaller, and it avoids a
1537      GCC warning that YYVAL may be used uninitialized.  */
1538   yyval = yyvsp[1-yylen];
1539
1540
1541   YY_REDUCE_PRINT (yyn);
1542   switch (yyn)
1543     {
1544         case 15:
1545 #line 258 "./config_parser.y"
1546     { __sdp_log_set_log_stderr(); }
1547     break;
1548
1549   case 16:
1550 #line 259 "./config_parser.y"
1551     { __sdp_log_set_log_syslog(); }
1552     break;
1553
1554   case 17:
1555 #line 260 "./config_parser.y"
1556     { __sdp_log_set_log_file((yyvsp[(3) - (3)].sval)); }
1557     break;
1558
1559   case 18:
1560 #line 264 "./config_parser.y"
1561     { __sdp_log_set_min_level((yyvsp[(2) - (2)].ival)); }
1562     break;
1563
1564   case 19:
1565 #line 268 "./config_parser.y"
1566     { __sdp_add_rule(); }
1567     break;
1568
1569   case 20:
1570 #line 272 "./config_parser.y"
1571     { __sdp_rule.target_family = USE_TCP; }
1572     break;
1573
1574   case 21:
1575 #line 273 "./config_parser.y"
1576     { __sdp_rule.target_family = USE_SDP; }
1577     break;
1578
1579   case 22:
1580 #line 274 "./config_parser.y"
1581     { __sdp_rule.target_family = USE_BOTH; }
1582     break;
1583
1584   case 23:
1585 #line 278 "./config_parser.y"
1586     { current_role = 1; }
1587     break;
1588
1589   case 24:
1590 #line 279 "./config_parser.y"
1591     { current_role = 2; }
1592     break;
1593
1594   case 25:
1595 #line 283 "./config_parser.y"
1596     { __sdp_set_prog_name_expr((yyvsp[(1) - (1)].sval)); }
1597     break;
1598
1599   case 26:
1600 #line 284 "./config_parser.y"
1601     { __sdp_set_prog_name_expr("*"); }
1602     break;
1603
1604   case 27:
1605 #line 288 "./config_parser.y"
1606     { __sdp_rule.match_by_addr = 1; __sdp_set_ip_addr((yyvsp[(1) - (1)].sval)); }
1607     break;
1608
1609   case 28:
1610 #line 289 "./config_parser.y"
1611     { __sdp_rule.match_by_addr = 0; __sdp_rule.prefixlen = 32; }
1612     break;
1613
1614   case 29:
1615 #line 293 "./config_parser.y"
1616     { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (1)].ival); __sdp_rule.eport= (yyvsp[(1) - (1)].ival); }
1617     break;
1618
1619   case 30:
1620 #line 294 "./config_parser.y"
1621     { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (3)].ival); __sdp_rule.eport= (yyvsp[(3) - (3)].ival); }
1622     break;
1623
1624   case 31:
1625 #line 295 "./config_parser.y"
1626     { __sdp_rule.match_by_port = 0; __sdp_rule.sport= 0 ; __sdp_rule.eport= 0; }
1627     break;
1628
1629
1630 /* Line 1267 of yacc.c.  */
1631 #line 1632 "y.tab.c"
1632       default: break;
1633     }
1634   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1635
1636   YYPOPSTACK (yylen);
1637   yylen = 0;
1638   YY_STACK_PRINT (yyss, yyssp);
1639
1640   *++yyvsp = yyval;
1641
1642
1643   /* Now `shift' the result of the reduction.  Determine what state
1644      that goes to, based on the state we popped back to and the rule
1645      number reduced by.  */
1646
1647   yyn = yyr1[yyn];
1648
1649   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1650   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1651     yystate = yytable[yystate];
1652   else
1653     yystate = yydefgoto[yyn - YYNTOKENS];
1654
1655   goto yynewstate;
1656
1657
1658 /*------------------------------------.
1659 | yyerrlab -- here on detecting error |
1660 `------------------------------------*/
1661 yyerrlab:
1662   /* If not already recovering from an error, report this error.  */
1663   if (!yyerrstatus)
1664     {
1665       ++yynerrs;
1666 #if ! YYERROR_VERBOSE
1667       yyerror (YY_("syntax error"));
1668 #else
1669       {
1670         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1671         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1672           {
1673             YYSIZE_T yyalloc = 2 * yysize;
1674             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1675               yyalloc = YYSTACK_ALLOC_MAXIMUM;
1676             if (yymsg != yymsgbuf)
1677               YYSTACK_FREE (yymsg);
1678             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1679             if (yymsg)
1680               yymsg_alloc = yyalloc;
1681             else
1682               {
1683                 yymsg = yymsgbuf;
1684                 yymsg_alloc = sizeof yymsgbuf;
1685               }
1686           }
1687
1688         if (0 < yysize && yysize <= yymsg_alloc)
1689           {
1690             (void) yysyntax_error (yymsg, yystate, yychar);
1691             yyerror (yymsg);
1692           }
1693         else
1694           {
1695             yyerror (YY_("syntax error"));
1696             if (yysize != 0)
1697               goto yyexhaustedlab;
1698           }
1699       }
1700 #endif
1701     }
1702
1703
1704
1705   if (yyerrstatus == 3)
1706     {
1707       /* If just tried and failed to reuse look-ahead token after an
1708          error, discard it.  */
1709
1710       if (yychar <= YYEOF)
1711         {
1712           /* Return failure if at end of input.  */
1713           if (yychar == YYEOF)
1714             YYABORT;
1715         }
1716       else
1717         {
1718           yydestruct ("Error: discarding",
1719                       yytoken, &yylval);
1720           yychar = YYEMPTY;
1721         }
1722     }
1723
1724   /* Else will try to reuse look-ahead token after shifting the error
1725      token.  */
1726   goto yyerrlab1;
1727
1728
1729 /*---------------------------------------------------.
1730 | yyerrorlab -- error raised explicitly by YYERROR.  |
1731 `---------------------------------------------------*/
1732 yyerrorlab:
1733
1734   /* Pacify compilers like GCC when the user code never invokes
1735      YYERROR and the label yyerrorlab therefore never appears in user
1736      code.  */
1737   if (/*CONSTCOND*/ 0)
1738      goto yyerrorlab;
1739
1740   /* Do not reclaim the symbols of the rule which action triggered
1741      this YYERROR.  */
1742   YYPOPSTACK (yylen);
1743   yylen = 0;
1744   YY_STACK_PRINT (yyss, yyssp);
1745   yystate = *yyssp;
1746   goto yyerrlab1;
1747
1748
1749 /*-------------------------------------------------------------.
1750 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1751 `-------------------------------------------------------------*/
1752 yyerrlab1:
1753   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1754
1755   for (;;)
1756     {
1757       yyn = yypact[yystate];
1758       if (yyn != YYPACT_NINF)
1759         {
1760           yyn += YYTERROR;
1761           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1762             {
1763               yyn = yytable[yyn];
1764               if (0 < yyn)
1765                 break;
1766             }
1767         }
1768
1769       /* Pop the current state because it cannot handle the error token.  */
1770       if (yyssp == yyss)
1771         YYABORT;
1772
1773
1774       yydestruct ("Error: popping",
1775                   yystos[yystate], yyvsp);
1776       YYPOPSTACK (1);
1777       yystate = *yyssp;
1778       YY_STACK_PRINT (yyss, yyssp);
1779     }
1780
1781   if (yyn == YYFINAL)
1782     YYACCEPT;
1783
1784   *++yyvsp = yylval;
1785
1786
1787   /* Shift the error token.  */
1788   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1789
1790   yystate = yyn;
1791   goto yynewstate;
1792
1793
1794 /*-------------------------------------.
1795 | yyacceptlab -- YYACCEPT comes here.  |
1796 `-------------------------------------*/
1797 yyacceptlab:
1798   yyresult = 0;
1799   goto yyreturn;
1800
1801 /*-----------------------------------.
1802 | yyabortlab -- YYABORT comes here.  |
1803 `-----------------------------------*/
1804 yyabortlab:
1805   yyresult = 1;
1806   goto yyreturn;
1807
1808 #ifndef yyoverflow
1809 /*-------------------------------------------------.
1810 | yyexhaustedlab -- memory exhaustion comes here.  |
1811 `-------------------------------------------------*/
1812 yyexhaustedlab:
1813   yyerror (YY_("memory exhausted"));
1814   yyresult = 2;
1815   /* Fall through.  */
1816 #endif
1817
1818 yyreturn:
1819   if (yychar != YYEOF && yychar != YYEMPTY)
1820      yydestruct ("Cleanup: discarding lookahead",
1821                  yytoken, &yylval);
1822   /* Do not reclaim the symbols of the rule which action triggered
1823      this YYABORT or YYACCEPT.  */
1824   YYPOPSTACK (yylen);
1825   YY_STACK_PRINT (yyss, yyssp);
1826   while (yyssp != yyss)
1827     {
1828       yydestruct ("Cleanup: popping",
1829                   yystos[*yyssp], yyvsp);
1830       YYPOPSTACK (1);
1831     }
1832 #ifndef yyoverflow
1833   if (yyss != yyssa)
1834     YYSTACK_FREE (yyss);
1835 #endif
1836 #if YYERROR_VERBOSE
1837   if (yymsg != yymsgbuf)
1838     YYSTACK_FREE (yymsg);
1839 #endif
1840   /* Make sure YYID is used.  */
1841   return YYID (yyresult);
1842 }
1843
1844
1845 #line 298 "./config_parser.y"
1846
1847
1848 int yyerror(char *msg)
1849 {
1850         /* replace the $undefined and $end if exists */
1851         char *orig_msg = (char*)malloc(strlen(msg)+25);
1852         char *final_msg = (char*)malloc(strlen(msg)+25);
1853
1854         strcpy(orig_msg, msg);
1855         
1856         char *word = strtok(orig_msg, " ");
1857         final_msg[0] = '\0';
1858         while (word != NULL) {
1859                 if (!strncmp(word, "$undefined", 10)) {
1860                         strcat(final_msg, "unrecognized-token ");
1861                 } else if (!strncmp(word, "$end",4)) {
1862                         strcat(final_msg, "end-of-file ");
1863                 } else {
1864                         strcat(final_msg, word);
1865                         strcat(final_msg, " ");
1866                 }
1867                 word = strtok(NULL, " ");
1868         }
1869         
1870         __sdp_log(9, "Error (line:%ld) : %s\n", __sdp_config_line_num, final_msg);
1871         parse_err = 1;
1872         
1873         free(orig_msg);
1874         free(final_msg);
1875         return 1;
1876 }
1877
1878 #include <unistd.h>
1879 #include <errno.h>
1880
1881 /* parse apollo route dump file */
1882 int __sdp_parse_config (const char *fileName) {
1883   extern FILE * libsdp_yyin;
1884    
1885   /* open the file */
1886   if (access(fileName, R_OK)) {
1887          printf("libsdp Error: No access to open File:%s %s\n", 
1888            fileName, strerror(errno));
1889          return(1);
1890   }
1891
1892   libsdp_yyin = fopen(fileName,"r");
1893   if (!libsdp_yyin) {
1894          printf("libsdp Error: Fail to open File:%s\n", fileName);
1895          return(1);
1896   }
1897   parse_err = 0;
1898   __sdp_config_line_num = 1;
1899
1900   /* parse it */
1901   yyparse();
1902
1903   fclose(libsdp_yyin);
1904   return(parse_err);
1905 }
1906
1907
1908