1 /* A Bison parser, made from flagexp.y, by GNU bison 1.75.  */
2 
3 /* Skeleton parser for Yacc-like parsing with Bison,
4    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20 
21 /* As a special exception, when this file is copied by Bison into a
22    Bison output file, you may use that output file without restriction.
23    This special exception was added by the Free Software Foundation
24    in version 1.24 of Bison.  */
25 
26 /* Written by Richard Stallman by simplifying the original so called
27    ``semantic'' parser.  */
28 
29 /* All symbols defined below should begin with yy or YY, to avoid
30    infringing on user name space.  This should be done even for local
31    variables, as they might otherwise be expanded by user macros.
32    There are some unavoidable exceptions within include files to
33    define necessary library symbols; they are noted "INFRINGES ON
34    USER NAME SPACE" below.  */
35 
36 /* Identify Bison output.  */
37 #define YYBISON	1
38 
39 /* Pure parsers.  */
40 #define YYPURE	0
41 
42 /* Using locations.  */
43 #define YYLSP_NEEDED 0
44 
45 
46 
47 /* Tokens.  */
48 #ifndef YYTOKENTYPE
49 # define YYTOKENTYPE
50    /* Put the tokens into the symbol table, so that GDB and other debuggers
51       know about them.  */
52    enum yytokentype {
53      DATESTR = 258,
54      GAPSTR = 259,
55      PHSTR = 260,
56      TIMESTR = 261,
57      ADDRSTR = 262,
58      PATHSTR = 263,
59      ANYSTR = 264,
60      IDENT = 265,
61      NUMBER = 266,
62      AROP = 267,
63      LOGOP = 268,
64      EQ = 269,
65      NE = 270,
66      GT = 271,
67      GE = 272,
68      LT = 273,
69      LE = 274,
70      AND = 275,
71      OR = 276,
72      NOT = 277,
73      XOR = 278,
74      LB = 279,
75      RB = 280,
76      COMMA = 281,
77      ADDRESS = 282,
78      ITIME = 283,
79      CONNSTR = 284,
80      SPEED = 285,
81      CONNECT = 286,
82      PHONE = 287,
83      MAILER = 288,
84      CID = 289,
85      FLTIME = 290,
86      FLDATE = 291,
87      EXEC = 292,
88      FLLINE = 293,
89      PORT = 294,
90      FLFILE = 295,
91      HOST = 296,
92      SFREE = 297
93    };
94 #endif
95 #define DATESTR 258
96 #define GAPSTR 259
97 #define PHSTR 260
98 #define TIMESTR 261
99 #define ADDRSTR 262
100 #define PATHSTR 263
101 #define ANYSTR 264
102 #define IDENT 265
103 #define NUMBER 266
104 #define AROP 267
105 #define LOGOP 268
106 #define EQ 269
107 #define NE 270
108 #define GT 271
109 #define GE 272
110 #define LT 273
111 #define LE 274
112 #define AND 275
113 #define OR 276
114 #define NOT 277
115 #define XOR 278
116 #define LB 279
117 #define RB 280
118 #define COMMA 281
119 #define ADDRESS 282
120 #define ITIME 283
121 #define CONNSTR 284
122 #define SPEED 285
123 #define CONNECT 286
124 #define PHONE 287
125 #define MAILER 288
126 #define CID 289
127 #define FLTIME 290
128 #define FLDATE 291
129 #define EXEC 292
130 #define FLLINE 293
131 #define PORT 294
132 #define FLFILE 295
133 #define HOST 296
134 #define SFREE 297
135 
136 
137 
138 
139 /* Copy the first part of user declarations.  */
140 #line 16 "flagexp.y"
141 
142 #include "headers.h"
143 #include <fnmatch.h>
144 
145 #ifdef NEED_DEBUG
146 #define YYERROR_VERBOSE 1
147 #endif
148 #define YYDEBUG 0
149 
150 #ifdef YYTEXT_POINTER
151 extern char *yytext;
152 #else
153 extern char yytext[];
154 #endif
155 extern char *yyPTR;
156 extern int yylex();
157 static int logic(int e1,int op,int e2);
158 static int checkflag(void);
159 static int checkconnstr(void);
160 static int checkspeed(int op, int speed, int real);
161 static int checksfree(int op, int sp);
162 static int checkmailer(void);
163 static int checkphone(void);
164 static int checkport(void);
165 static int checkcid(void);
166 static int checkhost(void);
167 static int checkfile(void);
168 static int checkexec(void);
169 static int checkline(int lnum);
170 static int yyerror(char *s);
171 static int flxpres;
172 
173 
174 /* Enabling traces.  */
175 #ifndef YYDEBUG
176 # define YYDEBUG 0
177 #endif
178 
179 /* Enabling verbose error messages.  */
180 #ifdef YYERROR_VERBOSE
181 # undef YYERROR_VERBOSE
182 # define YYERROR_VERBOSE 1
183 #else
184 # define YYERROR_VERBOSE 0
185 #endif
186 
187 #ifndef YYSTYPE
188 typedef int yystype;
189 # define YYSTYPE yystype
190 # define YYSTYPE_IS_TRIVIAL 1
191 #endif
192 
193 #ifndef YYLTYPE
194 typedef struct yyltype
195 {
196   int first_line;
197   int first_column;
198   int last_line;
199   int last_column;
200 } yyltype;
201 # define YYLTYPE yyltype
202 # define YYLTYPE_IS_TRIVIAL 1
203 #endif
204 
205 /* Copy the second part of user declarations.  */
206 
207 
208 /* Line 213 of /usr/local/share/bison/yacc.c.  */
209 #line 210 "flagexp.c"
210 
211 #if ! defined (yyoverflow) || YYERROR_VERBOSE
212 
213 /* The parser invokes alloca or malloc; define the necessary symbols.  */
214 
215 # if YYSTACK_USE_ALLOCA
216 #  define YYSTACK_ALLOC alloca
217 # else
218 #  ifndef YYSTACK_USE_ALLOCA
219 #   if defined (alloca) || defined (_ALLOCA_H)
220 #    define YYSTACK_ALLOC alloca
221 #   else
222 #    ifdef __GNUC__
223 #     define YYSTACK_ALLOC __builtin_alloca
224 #    endif
225 #   endif
226 #  endif
227 # endif
228 
229 # ifdef YYSTACK_ALLOC
230    /* Pacify GCC's `empty if-body' warning. */
231 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
232 # else
233 #  if defined (__STDC__) || defined (__cplusplus)
234 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
235 #   define YYSIZE_T size_t
236 #  endif
237 #  define YYSTACK_ALLOC malloc
238 #  define YYSTACK_FREE free
239 # endif
240 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
241 
242 
243 #if (! defined (yyoverflow) \
244      && (! defined (__cplusplus) \
245 	 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
246 
247 /* A type that is properly aligned for any stack member.  */
248 union yyalloc
249 {
250   short yyss;
251   YYSTYPE yyvs;
252   };
253 
254 /* The size of the maximum gap between one aligned stack and the next.  */
255 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
256 
257 /* The size of an array large to enough to hold all stacks, each with
258    N elements.  */
259 # define YYSTACK_BYTES(N) \
260      ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
261       + YYSTACK_GAP_MAX)
262 
263 /* Copy COUNT objects from FROM to TO.  The source and destination do
264    not overlap.  */
265 # ifndef YYCOPY
266 #  if 1 < __GNUC__
267 #   define YYCOPY(To, From, Count) \
268       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
269 #  else
270 #   define YYCOPY(To, From, Count)		\
271       do					\
272 	{					\
273 	  register YYSIZE_T yyi;		\
274 	  for (yyi = 0; yyi < (Count); yyi++)	\
275 	    (To)[yyi] = (From)[yyi];	\
276 	}					\
277       while (0)
278 #  endif
279 # endif
280 
281 /* Relocate STACK from its old location to the new one.  The
282    local variables YYSIZE and YYSTACKSIZE give the old and new number of
283    elements in the stack, and YYPTR gives the new location of the
284    stack.  Advance YYPTR to a properly aligned location for the next
285    stack.  */
286 # define YYSTACK_RELOCATE(Stack)					\
287     do									\
288       {									\
289 	YYSIZE_T yynewbytes;						\
290 	YYCOPY (&yyptr->Stack, Stack, yysize);				\
291 	Stack = &yyptr->Stack;						\
292 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;	\
293 	yyptr += yynewbytes / sizeof (*yyptr);				\
294       }									\
295     while (0)
296 
297 #endif
298 
299 #if defined (__STDC__) || defined (__cplusplus)
300    typedef signed char yysigned_char;
301 #else
302    typedef short yysigned_char;
303 #endif
304 
305 /* YYFINAL -- State number of the termination state. */
306 #define YYFINAL  45
307 #define YYLAST   54
308 
309 /* YYNTOKENS -- Number of terminals. */
310 #define YYNTOKENS  43
311 /* YYNNTS -- Number of nonterminals. */
312 #define YYNNTS  8
313 /* YYNRULES -- Number of rules. */
314 #define YYNRULES  30
315 /* YYNRULES -- Number of states. */
316 #define YYNSTATES  59
317 
318 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
319 #define YYUNDEFTOK  2
320 #define YYMAXUTOK   297
321 
322 #define YYTRANSLATE(X) \
323   ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK)
324 
325 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
326 static const unsigned char yytranslate[] =
327 {
328        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
329        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
330        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
331        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
332        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
333        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
334        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
335        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
336        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
337        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
338        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
339        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
340        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
341        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
342        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
343        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
344        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
345        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
346        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
347        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
348        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
349        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
350        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
351        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
352        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
353        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
354        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
355       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
356       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
357       35,    36,    37,    38,    39,    40,    41,    42
358 };
359 
360 #if YYDEBUG
361 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
362    YYRHS.  */
363 static const unsigned char yyprhs[] =
364 {
365        0,     0,     3,     5,     7,    10,    14,    18,    20,    24,
366       28,    33,    36,    39,    42,    45,    48,    51,    54,    57,
367       60,    63,    66,    69,    72,    74,    76,    80,    82,    86,
368       88
369 };
370 
371 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
372 static const yysigned_char yyrhs[] =
373 {
374       44,     0,    -1,    45,    -1,    46,    -1,    22,    45,    -1,
375       45,    13,    45,    -1,    24,    45,    25,    -1,    47,    -1,
376       31,    12,    11,    -1,    30,    12,    11,    -1,    42,    12,
377       11,     8,    -1,    29,    29,    -1,    32,     5,    -1,    33,
378       10,    -1,    34,     5,    -1,    41,    10,    -1,    39,    10,
379       -1,    37,     9,    -1,    40,     8,    -1,    38,    11,    -1,
380       28,    49,    -1,    35,    50,    -1,    36,    48,    -1,    27,
381        7,    -1,    10,    -1,     3,    -1,     3,    26,    48,    -1,
382        6,    -1,     6,    26,    49,    -1,     4,    -1,     4,    26,
383       50,    -1
384 };
385 
386 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
387 static const unsigned char yyrline[] =
388 {
389        0,    56,    56,    59,    61,    63,    65,    68,    69,    71,
390       73,    75,    77,    79,    81,    83,    85,    87,    89,    91,
391       93,    95,    97,    99,   102,   105,   107,   110,   112,   115,
392      117
393 };
394 #endif
395 
396 #if YYDEBUG || YYERROR_VERBOSE
397 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
398    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
399 static const char *const yytname[] =
400 {
401   "$end", "error", "$undefined", "DATESTR", "GAPSTR", "PHSTR", "TIMESTR",
402   "ADDRSTR", "PATHSTR", "ANYSTR", "IDENT", "NUMBER", "AROP", "LOGOP",
403   "EQ", "NE", "GT", "GE", "LT", "LE", "AND", "OR", "NOT", "XOR", "LB",
404   "RB", "COMMA", "ADDRESS", "ITIME", "CONNSTR", "SPEED", "CONNECT",
405   "PHONE", "MAILER", "CID", "FLTIME", "FLDATE", "EXEC", "FLLINE", "PORT",
406   "FLFILE", "HOST", "SFREE", "$accept", "fullline", "expression",
407   "elemexp", "flag", "datestring", "timestring", "gapstring", 0
408 };
409 #endif
410 
411 # ifdef YYPRINT
412 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
413    token YYLEX-NUM.  */
414 static const unsigned short yytoknum[] =
415 {
416        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
417      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
418      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
419      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
420      295,   296,   297
421 };
422 # endif
423 
424 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
425 static const unsigned char yyr1[] =
426 {
427        0,    43,    44,    45,    45,    45,    45,    46,    46,    46,
428       46,    46,    46,    46,    46,    46,    46,    46,    46,    46,
429       46,    46,    46,    46,    47,    48,    48,    49,    49,    50,
430       50
431 };
432 
433 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
434 static const unsigned char yyr2[] =
435 {
436        0,     2,     1,     1,     2,     3,     3,     1,     3,     3,
437        4,     2,     2,     2,     2,     2,     2,     2,     2,     2,
438        2,     2,     2,     2,     1,     1,     3,     1,     3,     1,
439        3
440 };
441 
442 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
443    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
444    means the default is an error.  */
445 static const unsigned char yydefact[] =
446 {
447        0,    24,     0,     0,     0,     0,     0,     0,     0,     0,
448        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
449        0,     2,     3,     7,     4,     0,    23,    27,    20,    11,
450        0,     0,    12,    13,    14,    29,    21,    25,    22,    17,
451       19,    16,    18,    15,     0,     1,     0,     6,     0,     9,
452        8,     0,     0,     0,     5,    28,    30,    26,    10
453 };
454 
455 /* YYDEFGOTO[NTERM-NUM]. */
456 static const yysigned_char yydefgoto[] =
457 {
458       -1,    20,    21,    22,    23,    38,    28,    36
459 };
460 
461 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
462    STATE-NUM.  */
463 #define YYPACT_NINF -24
464 static const yysigned_char yypact[] =
465 {
466       -8,   -24,    -8,    -8,    -3,    -1,   -23,    -5,    -4,     4,
467        0,     6,     8,    10,     9,    24,     7,    28,    27,    26,
468       39,    29,   -24,   -24,    29,   -10,   -24,    14,   -24,   -24,
469       30,    32,   -24,   -24,   -24,    19,   -24,    20,   -24,   -24,
470      -24,   -24,   -24,   -24,    36,   -24,    -8,   -24,    -1,   -24,
471      -24,     8,    10,    40,    29,   -24,   -24,   -24,   -24
472 };
473 
474 /* YYPGOTO[NTERM-NUM].  */
475 static const yysigned_char yypgoto[] =
476 {
477      -24,   -24,    -2,   -24,   -24,     1,     2,     3
478 };
479 
480 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
481    positive, shift that token.  If negative, reduce the rule which
482    number is the opposite.  If zero, do what YYDEFACT says.
483    If YYTABLE_NINF, parse error.  */
484 #define YYTABLE_NINF -1
485 static const unsigned char yytable[] =
486 {
487       24,    25,     1,    46,    26,    27,    29,    30,    31,    32,
488       33,    34,    35,    37,     2,    47,     3,    41,    39,     4,
489        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
490       15,    16,    17,    18,    19,    40,    42,    43,    44,    45,
491       48,    49,    46,    50,    54,    51,    52,    53,    58,     0,
492       55,     0,     0,    57,    56
493 };
494 
495 static const yysigned_char yycheck[] =
496 {
497        2,     3,    10,    13,     7,     6,    29,    12,    12,     5,
498       10,     5,     4,     3,    22,    25,    24,    10,     9,    27,
499       28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
500       38,    39,    40,    41,    42,    11,     8,    10,    12,     0,
501       26,    11,    13,    11,    46,    26,    26,    11,     8,    -1,
502       48,    -1,    -1,    52,    51
503 };
504 
505 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
506    symbol of state STATE-NUM.  */
507 static const unsigned char yystos[] =
508 {
509        0,    10,    22,    24,    27,    28,    29,    30,    31,    32,
510       33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
511       44,    45,    46,    47,    45,    45,     7,     6,    49,    29,
512       12,    12,     5,    10,     5,     4,    50,     3,    48,     9,
513       11,    10,     8,    10,    12,     0,    13,    25,    26,    11,
514       11,    26,    26,    11,    45,    49,    50,    48,     8
515 };
516 
517 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
518 # define YYSIZE_T __SIZE_TYPE__
519 #endif
520 #if ! defined (YYSIZE_T) && defined (size_t)
521 # define YYSIZE_T size_t
522 #endif
523 #if ! defined (YYSIZE_T)
524 # if defined (__STDC__) || defined (__cplusplus)
525 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
526 #  define YYSIZE_T size_t
527 # endif
528 #endif
529 #if ! defined (YYSIZE_T)
530 # define YYSIZE_T unsigned int
531 #endif
532 
533 #define yyerrok		(yyerrstatus = 0)
534 #define yyclearin	(yychar = YYEMPTY)
535 #define YYEMPTY		-2
536 #define YYEOF		0
537 
538 #define YYACCEPT	goto yyacceptlab
539 #define YYABORT		goto yyabortlab
540 #define YYERROR		goto yyerrlab1
541 
542 /* Like YYERROR except do call yyerror.  This remains here temporarily
543    to ease the transition to the new meaning of YYERROR, for GCC.
544    Once GCC version 2 has supplanted version 1, this can go.  */
545 
546 #define YYFAIL		goto yyerrlab
547 
548 #define YYRECOVERING()  (!!yyerrstatus)
549 
550 #define YYBACKUP(Token, Value)					\
551 do								\
552   if (yychar == YYEMPTY && yylen == 1)				\
553     {								\
554       yychar = (Token);						\
555       yylval = (Value);						\
556       yychar1 = YYTRANSLATE (yychar);				\
557       YYPOPSTACK;						\
558       goto yybackup;						\
559     }								\
560   else								\
561     { 								\
562       yyerror ("syntax error: cannot back up");			\
563       YYERROR;							\
564     }								\
565 while (0)
566 
567 #define YYTERROR	1
568 #define YYERRCODE	256
569 
570 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
571    are run).  */
572 
573 #ifndef YYLLOC_DEFAULT
574 # define YYLLOC_DEFAULT(Current, Rhs, N)           \
575   Current.first_line   = Rhs[1].first_line;      \
576   Current.first_column = Rhs[1].first_column;    \
577   Current.last_line    = Rhs[N].last_line;       \
578   Current.last_column  = Rhs[N].last_column;
579 #endif
580 
581 /* YYLEX -- calling `yylex' with the right arguments.  */
582 
583 #define YYLEX	yylex ()
584 
585 /* Enable debugging if requested.  */
586 #if YYDEBUG
587 
588 # ifndef YYFPRINTF
589 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
590 #  define YYFPRINTF fprintf
591 # endif
592 
593 # define YYDPRINTF(Args)			\
594 do {						\
595   if (yydebug)					\
596     YYFPRINTF Args;				\
597 } while (0)
598 # define YYDSYMPRINT(Args)			\
599 do {						\
600   if (yydebug)					\
601     yysymprint Args;				\
602 } while (0)
603 /* Nonzero means print parse trace.  It is left uninitialized so that
604    multiple parsers can coexist.  */
605 int yydebug;
606 #else /* !YYDEBUG */
607 # define YYDPRINTF(Args)
608 # define YYDSYMPRINT(Args)
609 #endif /* !YYDEBUG */
610 
611 /* YYINITDEPTH -- initial size of the parser's stacks.  */
612 #ifndef	YYINITDEPTH
613 # define YYINITDEPTH 200
614 #endif
615 
616 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
617    if the built-in stack extension method is used).
618 
619    Do not make this value too large; the results are undefined if
620    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
621    evaluated with infinite-precision integer arithmetic.  */
622 
623 #if YYMAXDEPTH == 0
624 # undef YYMAXDEPTH
625 #endif
626 
627 #ifndef YYMAXDEPTH
628 # define YYMAXDEPTH 10000
629 #endif
630 
631 
632 
633 #if YYERROR_VERBOSE
634 
635 # ifndef yystrlen
636 #  if defined (__GLIBC__) && defined (_STRING_H)
637 #   define yystrlen strlen
638 #  else
639 /* Return the length of YYSTR.  */
640 static YYSIZE_T
641 #   if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)642 yystrlen (const char *yystr)
643 #   else
644 yystrlen (yystr)
645      const char *yystr;
646 #   endif
647 {
648   register const char *yys = yystr;
649 
650   while (*yys++ != '\0')
651     continue;
652 
653   return yys - yystr - 1;
654 }
655 #  endif
656 # endif
657 
658 # ifndef yystpcpy
659 #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
660 #   define yystpcpy stpcpy
661 #  else
662 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
663    YYDEST.  */
664 static char *
665 #   if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)666 yystpcpy (char *yydest, const char *yysrc)
667 #   else
668 yystpcpy (yydest, yysrc)
669      char *yydest;
670      const char *yysrc;
671 #   endif
672 {
673   register char *yyd = yydest;
674   register const char *yys = yysrc;
675 
676   while ((*yyd++ = *yys++) != '\0')
677     continue;
678 
679   return yyd - 1;
680 }
681 #  endif
682 # endif
683 
684 #endif /* !YYERROR_VERBOSE */
685 
686 
687 
688 #if YYDEBUG
689 /*-----------------------------.
690 | Print this symbol on YYOUT.  |
691 `-----------------------------*/
692 
693 static void
694 #if defined (__STDC__) || defined (__cplusplus)
yysymprint(FILE * yyout,int yytype,YYSTYPE yyvalue)695 yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue)
696 #else
697 yysymprint (yyout, yytype, yyvalue)
698     FILE* yyout;
699     int yytype;
700     YYSTYPE yyvalue;
701 #endif
702 {
703   /* Pacify ``unused variable'' warnings.  */
704   (void) yyvalue;
705 
706   if (yytype < YYNTOKENS)
707     {
708       YYFPRINTF (yyout, "token %s (", yytname[yytype]);
709 # ifdef YYPRINT
710       YYPRINT (yyout, yytoknum[yytype], yyvalue);
711 # endif
712     }
713   else
714     YYFPRINTF (yyout, "nterm %s (", yytname[yytype]);
715 
716   switch (yytype)
717     {
718       default:
719         break;
720     }
721   YYFPRINTF (yyout, ")");
722 }
723 #endif /* YYDEBUG. */
724 
725 
726 /*-----------------------------------------------.
727 | Release the memory associated to this symbol.  |
728 `-----------------------------------------------*/
729 
730 static void
731 #if defined (__STDC__) || defined (__cplusplus)
yydestruct(int yytype,YYSTYPE yyvalue)732 yydestruct (int yytype, YYSTYPE yyvalue)
733 #else
734 yydestruct (yytype, yyvalue)
735     int yytype;
736     YYSTYPE yyvalue;
737 #endif
738 {
739   /* Pacify ``unused variable'' warnings.  */
740   (void) yyvalue;
741 
742   switch (yytype)
743     {
744       default:
745         break;
746     }
747 }
748 
749 
750 
751 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
752    into yyparse.  The argument should have type void *.
753    It should actually point to an object.
754    Grammar actions can access the variable by casting it
755    to the proper pointer type.  */
756 
757 #ifdef YYPARSE_PARAM
758 # if defined (__STDC__) || defined (__cplusplus)
759 #  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
760 #  define YYPARSE_PARAM_DECL
761 # else
762 #  define YYPARSE_PARAM_ARG YYPARSE_PARAM
763 #  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
764 # endif
765 #else /* !YYPARSE_PARAM */
766 # define YYPARSE_PARAM_ARG
767 # define YYPARSE_PARAM_DECL
768 #endif /* !YYPARSE_PARAM */
769 
770 /* Prevent warning if -Wstrict-prototypes.  */
771 #ifdef __GNUC__
772 # ifdef YYPARSE_PARAM
773 int yyparse (void *);
774 # else
775 int yyparse (void);
776 # endif
777 #endif
778 
779 
780 /* The lookahead symbol.  */
781 int yychar;
782 
783 /* The semantic value of the lookahead symbol.  */
784 YYSTYPE yylval;
785 
786 /* Number of parse errors so far.  */
787 int yynerrs;
788 
789 
790 int
yyparse(YYPARSE_PARAM_ARG)791 yyparse (YYPARSE_PARAM_ARG)
792      YYPARSE_PARAM_DECL
793 {
794 
795   register int yystate;
796   register int yyn;
797   int yyresult;
798   /* Number of tokens to shift before error messages enabled.  */
799   int yyerrstatus;
800   /* Lookahead token as an internal (translated) token number.  */
801   int yychar1 = 0;
802 
803   /* Three stacks and their tools:
804      `yyss': related to states,
805      `yyvs': related to semantic values,
806      `yyls': related to locations.
807 
808      Refer to the stacks thru separate pointers, to allow yyoverflow
809      to reallocate them elsewhere.  */
810 
811   /* The state stack.  */
812   short	yyssa[YYINITDEPTH];
813   short *yyss = yyssa;
814   register short *yyssp;
815 
816   /* The semantic value stack.  */
817   YYSTYPE yyvsa[YYINITDEPTH];
818   YYSTYPE *yyvs = yyvsa;
819   register YYSTYPE *yyvsp;
820 
821 
822 
823 #define YYPOPSTACK   (yyvsp--, yyssp--)
824 
825   YYSIZE_T yystacksize = YYINITDEPTH;
826 
827   /* The variables used to return semantic value and location from the
828      action routines.  */
829   YYSTYPE yyval;
830 
831 
832   /* When reducing, the number of symbols on the RHS of the reduced
833      rule.  */
834   int yylen;
835 
836   YYDPRINTF ((stderr, "Starting parse\n"));
837 
838   yystate = 0;
839   yyerrstatus = 0;
840   yynerrs = 0;
841   yychar = YYEMPTY;		/* Cause a token to be read.  */
842 
843   /* Initialize stack pointers.
844      Waste one element of value and location stack
845      so that they stay on the same level as the state stack.
846      The wasted elements are never initialized.  */
847 
848   yyssp = yyss;
849   yyvsp = yyvs;
850 
851   goto yysetstate;
852 
853 /*------------------------------------------------------------.
854 | yynewstate -- Push a new state, which is found in yystate.  |
855 `------------------------------------------------------------*/
856  yynewstate:
857   /* In all cases, when you get here, the value and location stacks
858      have just been pushed. so pushing a state here evens the stacks.
859      */
860   yyssp++;
861 
862  yysetstate:
863   *yyssp = yystate;
864 
865   if (yyssp >= yyss + yystacksize - 1)
866     {
867       /* Get the current used size of the three stacks, in elements.  */
868       YYSIZE_T yysize = yyssp - yyss + 1;
869 
870 #ifdef yyoverflow
871       {
872 	/* Give user a chance to reallocate the stack. Use copies of
873 	   these so that the &'s don't force the real ones into
874 	   memory.  */
875 	YYSTYPE *yyvs1 = yyvs;
876 	short *yyss1 = yyss;
877 
878 
879 	/* Each stack pointer address is followed by the size of the
880 	   data in use in that stack, in bytes.  This used to be a
881 	   conditional around just the two extra args, but that might
882 	   be undefined if yyoverflow is a macro.  */
883 	yyoverflow ("parser stack overflow",
884 		    &yyss1, yysize * sizeof (*yyssp),
885 		    &yyvs1, yysize * sizeof (*yyvsp),
886 
887 		    &yystacksize);
888 
889 	yyss = yyss1;
890 	yyvs = yyvs1;
891       }
892 #else /* no yyoverflow */
893 # ifndef YYSTACK_RELOCATE
894       goto yyoverflowlab;
895 # else
896       /* Extend the stack our own way.  */
897       if (yystacksize >= YYMAXDEPTH)
898 	goto yyoverflowlab;
899       yystacksize *= 2;
900       if (yystacksize > YYMAXDEPTH)
901 	yystacksize = YYMAXDEPTH;
902 
903       {
904 	short *yyss1 = yyss;
905 	union yyalloc *yyptr =
906 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
907 	if (! yyptr)
908 	  goto yyoverflowlab;
909 	YYSTACK_RELOCATE (yyss);
910 	YYSTACK_RELOCATE (yyvs);
911 
912 #  undef YYSTACK_RELOCATE
913 	if (yyss1 != yyssa)
914 	  YYSTACK_FREE (yyss1);
915       }
916 # endif
917 #endif /* no yyoverflow */
918 
919       yyssp = yyss + yysize - 1;
920       yyvsp = yyvs + yysize - 1;
921 
922 
923       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
924 		  (unsigned long int) yystacksize));
925 
926       if (yyssp >= yyss + yystacksize - 1)
927 	YYABORT;
928     }
929 
930   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
931 
932   goto yybackup;
933 
934 /*-----------.
935 | yybackup.  |
936 `-----------*/
937 yybackup:
938 
939 /* Do appropriate processing given the current state.  */
940 /* Read a lookahead token if we need one and don't already have one.  */
941 /* yyresume: */
942 
943   /* First try to decide what to do without reference to lookahead token.  */
944 
945   yyn = yypact[yystate];
946   if (yyn == YYPACT_NINF)
947     goto yydefault;
948 
949   /* Not known => get a lookahead token if don't already have one.  */
950 
951   /* yychar is either YYEMPTY or YYEOF
952      or a valid token in external form.  */
953 
954   if (yychar == YYEMPTY)
955     {
956       YYDPRINTF ((stderr, "Reading a token: "));
957       yychar = YYLEX;
958     }
959 
960   /* Convert token to internal form (in yychar1) for indexing tables with.  */
961 
962   if (yychar <= 0)		/* This means end of input.  */
963     {
964       yychar1 = 0;
965       yychar = YYEOF;		/* Don't call YYLEX any more.  */
966 
967       YYDPRINTF ((stderr, "Now at end of input.\n"));
968     }
969   else
970     {
971       yychar1 = YYTRANSLATE (yychar);
972 
973       /* We have to keep this `#if YYDEBUG', since we use variables
974 	 which are defined only if `YYDEBUG' is set.  */
975       YYDPRINTF ((stderr, "Next token is "));
976       YYDSYMPRINT ((stderr, yychar1, yylval));
977       YYDPRINTF ((stderr, "\n"));
978     }
979 
980   /* If the proper action on seeing token YYCHAR1 is to reduce or to
981      detect an error, take that action.  */
982   yyn += yychar1;
983   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
984     goto yydefault;
985   yyn = yytable[yyn];
986   if (yyn <= 0)
987     {
988       if (yyn == 0 || yyn == YYTABLE_NINF)
989 	goto yyerrlab;
990       yyn = -yyn;
991       goto yyreduce;
992     }
993 
994   if (yyn == YYFINAL)
995     YYACCEPT;
996 
997   /* Shift the lookahead token.  */
998   YYDPRINTF ((stderr, "Shifting token %d (%s), ",
999 	      yychar, yytname[yychar1]));
1000 
1001   /* Discard the token being shifted unless it is eof.  */
1002   if (yychar != YYEOF)
1003     yychar = YYEMPTY;
1004 
1005   *++yyvsp = yylval;
1006 
1007 
1008   /* Count tokens shifted since error; after three, turn off error
1009      status.  */
1010   if (yyerrstatus)
1011     yyerrstatus--;
1012 
1013   yystate = yyn;
1014   goto yynewstate;
1015 
1016 
1017 /*-----------------------------------------------------------.
1018 | yydefault -- do the default action for the current state.  |
1019 `-----------------------------------------------------------*/
1020 yydefault:
1021   yyn = yydefact[yystate];
1022   if (yyn == 0)
1023     goto yyerrlab;
1024   goto yyreduce;
1025 
1026 
1027 /*-----------------------------.
1028 | yyreduce -- Do a reduction.  |
1029 `-----------------------------*/
1030 yyreduce:
1031   /* yyn is the number of a rule to reduce with.  */
1032   yylen = yyr2[yyn];
1033 
1034   /* If YYLEN is nonzero, implement the default value of the action:
1035      `$$ = $1'.
1036 
1037      Otherwise, the following line sets YYVAL to garbage.
1038      This behavior is undocumented and Bison
1039      users should not rely upon it.  Assigning to YYVAL
1040      unconditionally makes the parser a bit smaller, and it avoids a
1041      GCC warning that YYVAL may be used uninitialized.  */
1042   yyval = yyvsp[1-yylen];
1043 
1044 
1045 
1046 #if YYDEBUG
1047   /* We have to keep this `#if YYDEBUG', since we use variables which
1048      are defined only if `YYDEBUG' is set.  */
1049   if (yydebug)
1050     {
1051       int yyi;
1052 
1053       YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1054 		 yyn - 1, yyrline[yyn]);
1055 
1056       /* Print the symbols being reduced, and their result.  */
1057       for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
1058 	YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1059       YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1060     }
1061 #endif
1062   switch (yyn)
1063     {
1064         case 2:
1065 #line 57 "flagexp.y"
1066     {flxpres=yyvsp[0];}
1067     break;
1068 
1069   case 3:
1070 #line 60 "flagexp.y"
1071     {yyval = yyvsp[0];}
1072     break;
1073 
1074   case 4:
1075 #line 62 "flagexp.y"
1076     {yyval = !(yyvsp[0]);}
1077     break;
1078 
1079   case 5:
1080 #line 64 "flagexp.y"
1081     {yyval = logic(yyvsp[-2],yyvsp[-1],yyvsp[0]);}
1082     break;
1083 
1084   case 6:
1085 #line 66 "flagexp.y"
1086     {yyval = yyvsp[-1];}
1087     break;
1088 
1089   case 8:
1090 #line 70 "flagexp.y"
1091     {yyval = checkspeed(yyvsp[-1],yyvsp[0],1);}
1092     break;
1093 
1094   case 9:
1095 #line 72 "flagexp.y"
1096     {yyval = checkspeed(yyvsp[-1],yyvsp[0],0);}
1097     break;
1098 
1099   case 10:
1100 #line 74 "flagexp.y"
1101     {yyval = checksfree(yyvsp[-2],yyvsp[-1]);}
1102     break;
1103 
1104   case 11:
1105 #line 76 "flagexp.y"
1106     {yyval = checkconnstr();}
1107     break;
1108 
1109   case 12:
1110 #line 78 "flagexp.y"
1111     {yyval = checkphone();}
1112     break;
1113 
1114   case 13:
1115 #line 80 "flagexp.y"
1116     {yyval = checkmailer();}
1117     break;
1118 
1119   case 14:
1120 #line 82 "flagexp.y"
1121     {yyval = checkcid();}
1122     break;
1123 
1124   case 15:
1125 #line 84 "flagexp.y"
1126     {yyval = checkhost();}
1127     break;
1128 
1129   case 16:
1130 #line 86 "flagexp.y"
1131     {yyval = checkport();}
1132     break;
1133 
1134   case 17:
1135 #line 88 "flagexp.y"
1136     {yyval = checkexec();}
1137     break;
1138 
1139   case 18:
1140 #line 90 "flagexp.y"
1141     {yyval = checkfile();}
1142     break;
1143 
1144   case 19:
1145 #line 92 "flagexp.y"
1146     {yyval = checkline(yyvsp[0]);}
1147     break;
1148 
1149   case 20:
1150 #line 94 "flagexp.y"
1151     {yyval = yyvsp[0];}
1152     break;
1153 
1154   case 21:
1155 #line 96 "flagexp.y"
1156     {yyval = yyvsp[0];}
1157     break;
1158 
1159   case 22:
1160 #line 98 "flagexp.y"
1161     {yyval = yyvsp[0];}
1162     break;
1163 
1164   case 23:
1165 #line 100 "flagexp.y"
1166     {yyval = yyvsp[0];}
1167     break;
1168 
1169   case 24:
1170 #line 103 "flagexp.y"
1171     {yyval = checkflag();}
1172     break;
1173 
1174   case 25:
1175 #line 106 "flagexp.y"
1176     {yyval = yyvsp[0];}
1177     break;
1178 
1179   case 26:
1180 #line 108 "flagexp.y"
1181     {yyval = logic(yyvsp[-2],OR,yyvsp[0]);}
1182     break;
1183 
1184   case 27:
1185 #line 111 "flagexp.y"
1186     {yyval = yyvsp[0];}
1187     break;
1188 
1189   case 28:
1190 #line 113 "flagexp.y"
1191     {yyval = logic(yyvsp[-2],OR,yyvsp[0]);}
1192     break;
1193 
1194   case 29:
1195 #line 116 "flagexp.y"
1196     {yyval = yyvsp[0];}
1197     break;
1198 
1199   case 30:
1200 #line 118 "flagexp.y"
1201     {yyval = logic(yyvsp[-2],OR,yyvsp[0]);}
1202     break;
1203 
1204 
1205     }
1206 
1207 /* Line 1016 of /usr/local/share/bison/yacc.c.  */
1208 #line 1209 "flagexp.c"
1209 
1210   yyvsp -= yylen;
1211   yyssp -= yylen;
1212 
1213 
1214 #if YYDEBUG
1215   if (yydebug)
1216     {
1217       short *yyssp1 = yyss - 1;
1218       YYFPRINTF (stderr, "state stack now");
1219       while (yyssp1 != yyssp)
1220 	YYFPRINTF (stderr, " %d", *++yyssp1);
1221       YYFPRINTF (stderr, "\n");
1222     }
1223 #endif
1224 
1225   *++yyvsp = yyval;
1226 
1227 
1228   /* Now `shift' the result of the reduction.  Determine what state
1229      that goes to, based on the state we popped back to and the rule
1230      number reduced by.  */
1231 
1232   yyn = yyr1[yyn];
1233 
1234   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1235   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1236     yystate = yytable[yystate];
1237   else
1238     yystate = yydefgoto[yyn - YYNTOKENS];
1239 
1240   goto yynewstate;
1241 
1242 
1243 /*------------------------------------.
1244 | yyerrlab -- here on detecting error |
1245 `------------------------------------*/
1246 yyerrlab:
1247   /* If not already recovering from an error, report this error.  */
1248   if (!yyerrstatus)
1249     {
1250       ++yynerrs;
1251 #if YYERROR_VERBOSE
1252       yyn = yypact[yystate];
1253 
1254       if (YYPACT_NINF < yyn && yyn < YYLAST)
1255 	{
1256 	  YYSIZE_T yysize = 0;
1257 	  int yytype = YYTRANSLATE (yychar);
1258 	  char *yymsg;
1259 	  int yyx, yycount;
1260 
1261 	  yycount = 0;
1262 	  /* Start YYX at -YYN if negative to avoid negative indexes in
1263 	     YYCHECK.  */
1264 	  for (yyx = yyn < 0 ? -yyn : 0;
1265 	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1266 	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1267 	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1268 	  yysize += yystrlen ("parse error, unexpected ") + 1;
1269 	  yysize += yystrlen (yytname[yytype]);
1270 	  yymsg = (char *) YYSTACK_ALLOC (yysize);
1271 	  if (yymsg != 0)
1272 	    {
1273 	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1274 	      yyp = yystpcpy (yyp, yytname[yytype]);
1275 
1276 	      if (yycount < 5)
1277 		{
1278 		  yycount = 0;
1279 		  for (yyx = yyn < 0 ? -yyn : 0;
1280 		       yyx < (int) (sizeof (yytname) / sizeof (char *));
1281 		       yyx++)
1282 		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1283 		      {
1284 			const char *yyq = ! yycount ? ", expecting " : " or ";
1285 			yyp = yystpcpy (yyp, yyq);
1286 			yyp = yystpcpy (yyp, yytname[yyx]);
1287 			yycount++;
1288 		      }
1289 		}
1290 	      yyerror (yymsg);
1291 	      YYSTACK_FREE (yymsg);
1292 	    }
1293 	  else
1294 	    yyerror ("parse error; also virtual memory exhausted");
1295 	}
1296       else
1297 #endif /* YYERROR_VERBOSE */
1298 	yyerror ("parse error");
1299     }
1300   goto yyerrlab1;
1301 
1302 
1303 /*----------------------------------------------------.
1304 | yyerrlab1 -- error raised explicitly by an action.  |
1305 `----------------------------------------------------*/
1306 yyerrlab1:
1307   if (yyerrstatus == 3)
1308     {
1309       /* If just tried and failed to reuse lookahead token after an
1310 	 error, discard it.  */
1311 
1312       /* Return failure if at end of input.  */
1313       if (yychar == YYEOF)
1314         {
1315 	  /* Pop the error token.  */
1316           YYPOPSTACK;
1317 	  /* Pop the rest of the stack.  */
1318 	  while (yyssp > yyss)
1319 	    {
1320 	      YYDPRINTF ((stderr, "Error: popping "));
1321 	      YYDSYMPRINT ((stderr,
1322 			    yystos[*yyssp],
1323 			    *yyvsp));
1324 	      YYDPRINTF ((stderr, "\n"));
1325 	      yydestruct (yystos[*yyssp], *yyvsp);
1326 	      YYPOPSTACK;
1327 	    }
1328 	  YYABORT;
1329         }
1330 
1331       YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1332 		  yychar, yytname[yychar1]));
1333       yydestruct (yychar1, yylval);
1334       yychar = YYEMPTY;
1335     }
1336 
1337   /* Else will try to reuse lookahead token after shifting the error
1338      token.  */
1339 
1340   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1341 
1342   for (;;)
1343     {
1344       yyn = yypact[yystate];
1345       if (yyn != YYPACT_NINF)
1346 	{
1347 	  yyn += YYTERROR;
1348 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1349 	    {
1350 	      yyn = yytable[yyn];
1351 	      if (0 < yyn)
1352 		break;
1353 	    }
1354 	}
1355 
1356       /* Pop the current state because it cannot handle the error token.  */
1357       if (yyssp == yyss)
1358 	YYABORT;
1359 
1360       YYDPRINTF ((stderr, "Error: popping "));
1361       YYDSYMPRINT ((stderr,
1362 		    yystos[*yyssp], *yyvsp));
1363       YYDPRINTF ((stderr, "\n"));
1364 
1365       yydestruct (yystos[yystate], *yyvsp);
1366       yyvsp--;
1367       yystate = *--yyssp;
1368 
1369 
1370 #if YYDEBUG
1371       if (yydebug)
1372 	{
1373 	  short *yyssp1 = yyss - 1;
1374 	  YYFPRINTF (stderr, "Error: state stack now");
1375 	  while (yyssp1 != yyssp)
1376 	    YYFPRINTF (stderr, " %d", *++yyssp1);
1377 	  YYFPRINTF (stderr, "\n");
1378 	}
1379 #endif
1380     }
1381 
1382   if (yyn == YYFINAL)
1383     YYACCEPT;
1384 
1385   YYDPRINTF ((stderr, "Shifting error token, "));
1386 
1387   *++yyvsp = yylval;
1388 
1389 
1390   yystate = yyn;
1391   goto yynewstate;
1392 
1393 
1394 /*-------------------------------------.
1395 | yyacceptlab -- YYACCEPT comes here.  |
1396 `-------------------------------------*/
1397 yyacceptlab:
1398   yyresult = 0;
1399   goto yyreturn;
1400 
1401 /*-----------------------------------.
1402 | yyabortlab -- YYABORT comes here.  |
1403 `-----------------------------------*/
1404 yyabortlab:
1405   yyresult = 1;
1406   goto yyreturn;
1407 
1408 #ifndef yyoverflow
1409 /*----------------------------------------------.
1410 | yyoverflowlab -- parser overflow comes here.  |
1411 `----------------------------------------------*/
1412 yyoverflowlab:
1413   yyerror ("parser stack overflow");
1414   yyresult = 2;
1415   /* Fall through.  */
1416 #endif
1417 
1418 yyreturn:
1419 #ifndef yyoverflow
1420   if (yyss != yyssa)
1421     YYSTACK_FREE (yyss);
1422 #endif
1423   return yyresult;
1424 }
1425 
1426 
1427 #line 120 "flagexp.y"
1428 
1429 
logic(int e1,int op,int e2)1430 static int logic(int e1, int op, int e2)
1431 {
1432 	DEBUG(('Y',2,"Logic: %d (%d,%s) %d",e1,op,
1433 		(AND==op?"AND":
1434 		(OR==op?"OR":
1435 		(XOR==op?"XOR":"???"
1436 		))),e2));
1437 	switch (op)
1438 	{
1439 	case AND:	return(e1 && e2);
1440 	case OR:	return(e1 || e2);
1441 	case XOR:	return(e1 ^ e2)?1:0;
1442 	default:
1443 		DEBUG(('Y',1,"Logic: invalid logical operator %d",op));
1444 		return 0;
1445 	}
1446 }
1447 
checkflag(void)1448 static int checkflag(void)
1449 {
1450 	int fln;
1451 	char *p, *q;
1452 	DEBUG(('Y',2,"checkflag: \"%s\"",yytext));
1453 #ifdef WITH_PERL
1454 	if(!strncasecmp(yytext,"perl",4)) {
1455 		if((fln=atoi(yytext+4))<0||fln>9) {
1456 			write_log("error: invalid perl flag: %s",yytext);
1457 			return 0;
1458 		}
1459 		DEBUG(('Y',3,"checkflag: perl%d: %d",fln,(perl_flg&(1<<fln))?1:0));
1460 		return((perl_flg&(1<<fln))?1:0);
1461 	}
1462 #endif
1463 	if(!rnode)return 0;
1464  	if(!strncasecmp(yytext,"list",4)) {
1465 		DEBUG(('Y',3,"checkflag: listed: %d",rnode->options&O_LST));
1466 		return rnode->options&O_LST;
1467 	}
1468 	if(!strncasecmp(yytext,"prot",4)) {
1469 		DEBUG(('Y',3,"checkflag: protected: %d",rnode->options&O_PWD));
1470 		return rnode->options&O_PWD;
1471 	}
1472 	if(!strncasecmp(yytext,"in",2)) {
1473 		DEBUG(('Y',3,"checkflag: inbound: %d",rnode->options&O_INB));
1474 		return rnode->options&O_INB;
1475 	}
1476 	if(!strncasecmp(yytext,"out",3)) {
1477 		DEBUG(('Y',3,"checkflag: outbound: %d",!(rnode->options&O_INB)));
1478 		return !(rnode->options&O_INB);
1479 	}
1480 	if(!strncasecmp(yytext,"tcp",3)) {
1481 		DEBUG(('Y',3,"checkflag: tcp/ip: %d",rnode->options&O_TCP));
1482 		return rnode->options&O_TCP;
1483 	}
1484 	if(!strncasecmp(yytext,"binkp",5)) {
1485 		DEBUG(('Y',3,"checkflag: binkp: %d",bink));
1486 		return bink;
1487 	}
1488 	if(!strncasecmp(yytext,"bad",3)) {
1489 		DEBUG(('Y',3,"checkflag: bad password: %d",rnode->options&O_BAD));
1490 		return rnode->options&O_BAD;
1491 	}
1492 	if(rnode->flags) {
1493 		char *r;
1494 		q = xstrdup(rnode->flags);
1495 		r = q;;
1496 		while(( p = strsep( &r, "," ))) {
1497 			if(!strcasecmp(yytext,p)) {
1498 				xfree(q);
1499 				DEBUG(('Y',3,"checkflag: other: 1"));
1500 				return 1;
1501 			}
1502 		}
1503 		xfree(q);
1504 	}
1505 	DEBUG(('Y',3,"checkflag: other: 0"));
1506 	return 0;
1507 }
1508 
1509 
checkconnstr(void)1510 static int checkconnstr(void)
1511 {
1512 	DEBUG(('Y',2,"checkconnstr: \"%s\"",yytext));
1513 	if(!connstr||is_ip) return 0;
1514 	DEBUG(('Y',3,"checkconnstr: \"%s\" <-> \"%s\"",yytext,connstr));
1515 	if(!strstr(connstr,yytext)) return 1;
1516 	return 0;
1517 }
1518 
checkspeed(int op,int speed,int real)1519 static int checkspeed(int op, int speed, int real)
1520 {
1521 	DEBUG(('Y',2,"checkspeed: \"%s\"",yytext));
1522 	if(!rnode) return 0;
1523 	DEBUG(('Y',3,"check%sspeed: %d (%d,%s) %d",real?"real":"",real?rnode->realspeed:rnode->speed,op,
1524 		(EQ==op?"==":
1525 		(NE==op?"!=":
1526 	        (GT==op?">":
1527 	        (GE==op?">=":
1528 	        (LT==op?"<":
1529 	        (LE==op?"<=":"???"
1530 		)))))),speed));
1531 	switch (op)
1532 	{
1533 	case EQ:	return(real?rnode->realspeed:rnode->speed == speed);
1534 	case NE:	return(real?rnode->realspeed:rnode->speed != speed);
1535 	case GT:	return(real?rnode->realspeed:rnode->speed >  speed);
1536 	case GE:	return(real?rnode->realspeed:rnode->speed >= speed);
1537 	case LT:	return(real?rnode->realspeed:rnode->speed <  speed);
1538 	case LE:	return(real?rnode->realspeed:rnode->speed <= speed);
1539 	default:
1540 		DEBUG(('Y',1,"Logic: invalid comparsion operator %d",op));
1541 		return 0;
1542 	}
1543 }
1544 
checksfree(int op,int sf)1545 static int checksfree(int op, int sf)
1546 {
1547 	int fs=getfreespace((const char*)yytext);
1548 	DEBUG(('Y',2,"checksfree: '%s' %d (%d,%s) %d",yytext,fs,op,
1549 	        (GT==op?">":(GE==op?">=":
1550 	        (LT==op?"<":(LE==op?"<=":"???")))),sf));
1551 	switch (op) {
1552 	case GT:	return(fs >  sf);
1553 	case GE:	return(fs >= sf);
1554 	case LT:	return(fs <  sf);
1555 	case LE:	return(fs <= sf);
1556 	default:
1557 		DEBUG(('Y',1,"Logic: invalid comparsion operator %d",op));
1558 		return 0;
1559 	}
1560 }
1561 
checkphone(void)1562 static int checkphone(void)
1563 {
1564 	DEBUG(('Y',2,"checkphone: \"%s\"",yytext));
1565 	if(!rnode||!rnode->phone) return 0;
1566 	DEBUG(('Y',3,"checkphone: \"%s\" <-> \"%s\"",yytext,rnode->phone));
1567 	if(!strncasecmp(yytext,rnode->phone,strlen(yytext))) return 1;
1568 	return 0;
1569 }
1570 
checkmailer(void)1571 static int checkmailer(void)
1572 {
1573 	DEBUG(('Y',2,"checkmailer: \"%s\"",yytext));
1574 	if(!rnode||!rnode->mailer) return 0;
1575 	DEBUG(('Y',3,"checkmailer: \"%s\" <-> \"%s\"",yytext,rnode->mailer));
1576 	if(!strstr(rnode->mailer,yytext)) return 1;
1577 	return 0;
1578 }
1579 
checkcid(void)1580 static int checkcid(void)
1581 {
1582 	char *cid = getenv("CALLER_ID");
1583 	if(!cid||strlen(cid)<4) cid = "none";
1584 	DEBUG(('Y',2,"checkcid: \"%s\" <-> \"%s\"",yytext,cid));
1585 	if(!strncasecmp(yytext,cid,strlen(yytext))) return 1;
1586 	return 0;
1587 }
1588 
checkhost(void)1589 static int checkhost(void)
1590 {
1591 	DEBUG(('Y',2,"checkhost: \"%s\"",yytext));
1592 	if(!rnode || !rnode->host) return 0;
1593 	DEBUG(('Y',3,"checkhost: \"%s\" <-> \"%s\"",yytext,rnode->host));
1594 	if(!strncasecmp(yytext,rnode->host,strlen(yytext)))return 1;
1595 	return 0;
1596 }
1597 
checkport(void)1598 static int checkport(void)
1599 {
1600 	DEBUG(('Y',2,"checkport: \"%s\"",yytext));
1601 	if(!rnode || !rnode->tty) return 0;
1602 	DEBUG(('Y',3,"checkport: \"%s\" <-> \"%s\"",yytext,rnode->tty));
1603 	if(!fnmatch(yytext,rnode->tty,FNM_NOESCAPE|FNM_PATHNAME)) return 1;
1604 	return 0;
1605 }
1606 
checkfile(void)1607 static int checkfile(void)
1608 {
1609 	struct stat sb;
1610 	DEBUG(('Y',2,"checkfile: \"%s\" -> %d",yytext,!stat(yytext,&sb)));
1611 	if(!stat(yytext,&sb)) return 1;
1612 	return 0;
1613 }
1614 
checkexec(void)1615 static int checkexec(void)
1616 {
1617 	int rc;
1618 	char *cmd=xstrdup(yytext);
1619 	DEBUG(('Y',2,"checkexec: \"%s\"",yytext));
1620 	strtr(cmd,',',' ');
1621 	rc=execsh(cmd);
1622 	DEBUG(('Y',3,"checkexec: \"%s\" -> %d",cmd,!rc));
1623 	xfree(cmd);
1624 	return !rc;
1625 }
1626 
checkline(int lnum)1627 static int checkline(int lnum)
1628 {
1629 	DEBUG(('Y',2,"checkline: \"%s\"",yytext));
1630 	if(!rnode) return 0;
1631 	DEBUG(('Y',3,"checkline: %d <-> %d",lnum,rnode->hidnum));
1632 	if(rnode->hidnum==lnum)return 1;
1633 	return 0;
1634 }
1635 
flagexp(slist_t * expr,int strict)1636 int flagexp(slist_t *expr, int strict)
1637 {
1638 	char *p;
1639 #if YYDEBUG==1
1640 	yydebug=1;
1641 #endif
1642 	for(;expr;expr=expr->next) {
1643 		DEBUG(('Y',1,"checkexpression: \"%s\"",expr->str));
1644 		p=xstrdup(expr->str);
1645 		yyPTR=p;
1646 		flxpres=0;
1647 		if(yyparse()) {
1648 			DEBUG(('Y',1,"checkexpression: couldn't parse%s",strict?"":", assume 'false'",expr->str));
1649 			xfree(p);
1650 			return(strict?-1:0);
1651 		}
1652 #ifdef NEED_DEBUG
1653 		if(strict!=1)DEBUG(('Y',1,"checkexpression: result is \"%s\"",flxpres?"true":"false"));
1654 #endif
1655 		xfree(p);
1656 		if(!flxpres)return 0;
1657 	}
1658 	return 1;
1659 }
1660 
yyerror(char * s)1661 static int yyerror(char *s)
1662 {
1663 	DEBUG(('Y',1,"yyerror: %s at %s",s,(yytext&&*yytext)?yytext:"end of input"));
1664 	return 0;
1665 }
1666 
1667