/* A Bison parser, made from cfg_parser.y by GNU bison 1.35. */ #define YYBISON 1 /* Identify Bison output. */ # define DEBUG 257 # define CHROOT 258 # define UID 259 # define GID 260 # define WORK_DIR 261 # define CACHE_DIR 262 # define COOKIE_DIR 263 # define CACHE_TIMEOUT 264 # define CACHE_FAST_TIMEOUT 265 # define MIME 266 # define SERVER 267 # define SERVER_VERSION 268 # define BROWSER_VERSION 269 # define LISTEN 270 # define CACHE 271 # define COOKIE_CHECK 272 # define SAFE_URL 273 # define HTTPS 274 # define ACCESS_LOG 275 # define HEADER_CHECK 276 # define FORWARD 277 # define FORWARD_PROXY 278 # define LOCATION 279 # define IF 280 # define ELSIF 281 # define ELSE 282 # define IP_ADDR 283 # define STRING 284 # define REGEX_STR 285 # define INCLUDE 286 # define HTPASSWD 287 # define STRLEN 288 # define CGI_DECODE 289 # define IS_CGI 290 # define IS_VALID_COOKIE 291 # define CLEAR_COOKIE 292 # define RETURN 293 # define EQ 294 # define NE 295 # define GE 296 # define GT 297 # define LE 298 # define LT 299 # define IS 300 # define AND 301 # define OR 302 # define NUMBER 303 # define LOCAL_IP 304 # define CLIENT_IP 305 # define METHOD 306 # define HOST 307 # define PATH 308 # define EXT 309 # define USER_AGENT 310 # define REFERER 311 # define QUERY 312 # define COOKIE 313 # define PORT 314 # define POST_LEN 315 # define AUTH 316 # define PROXY_AUTH 317 #line 1 "cfg_parser.y" /* Package Name : twhttpd * File Name : parser.y * Author : Sam NG * * This package is an secure HTTP application proxy writen by Sam Ng. * Copyright (C) 2001 SAM NG * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "cfg_functions.h" struct in_addr yyaddr; int yyint; int *yyintp; struct passwd *yypasswd; FILE *yyf; char yystring[MAX_LINE]; regex_t *yyregex; extern int yylineno; extern char* yytext; extern int return_code; #line 84 "cfg_parser.y" #ifndef YYSTYPE typedef union { int INT; char *STR; struct decision_tree_st *DT; struct ip_range_struct *IP; struct srv_cfg_struct *SC; struct cfg_variable_struct *CV; } yystype; # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif #ifndef YYDEBUG # define YYDEBUG 0 #endif #define YYFINAL 213 #define YYFLAG -32768 #define YYNTBASE 75 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ #define YYTRANSLATE(x) ((unsigned)(x) <= 317 ? yytranslate[x] : 102) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 72, 2, 2, 2, 2, 2, 2, 66, 67, 2, 2, 70, 74, 2, 73, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 71, 65, 2, 64, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 68, 2, 69, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 }; #if YYDEBUG static const short yyprhs[] = { 0, 0, 2, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 68, 70, 74, 80, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 128, 131, 133, 135, 137, 140, 144, 152, 154, 157, 165, 170, 172, 176, 179, 183, 187, 191, 195, 199, 206, 213, 217, 221, 223, 226, 233, 238, 243, 248, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 281, 283, 285, 289, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313 }; static const short yyrhs[] = { 76, 0, 75, 78, 0, 77, 0, 76, 77, 0, 3, 64, 30, 65, 0, 4, 64, 30, 65, 0, 5, 64, 30, 65, 0, 6, 64, 30, 65, 0, 7, 64, 30, 65, 0, 8, 64, 30, 65, 0, 9, 64, 30, 65, 0, 10, 64, 49, 65, 0, 11, 64, 49, 65, 0, 12, 64, 30, 65, 0, 13, 66, 79, 67, 68, 81, 69, 0, 80, 0, 79, 70, 80, 0, 16, 64, 29, 71, 49, 0, 23, 64, 29, 71, 49, 0, 23, 64, 29, 0, 24, 64, 30, 0, 17, 64, 30, 0, 18, 64, 30, 0, 19, 64, 30, 0, 20, 64, 30, 0, 21, 64, 30, 0, 22, 64, 30, 0, 14, 64, 30, 0, 15, 64, 30, 0, 82, 0, 81, 82, 0, 83, 0, 90, 0, 84, 0, 84, 87, 0, 84, 85, 87, 0, 26, 66, 88, 67, 68, 81, 69, 0, 86, 0, 85, 86, 0, 27, 66, 88, 67, 68, 81, 69, 0, 28, 68, 81, 69, 0, 89, 0, 88, 98, 88, 0, 72, 88, 0, 66, 88, 67, 0, 93, 99, 97, 0, 94, 100, 30, 0, 94, 46, 31, 0, 95, 101, 49, 0, 33, 66, 96, 70, 30, 67, 0, 35, 66, 30, 70, 30, 67, 0, 36, 66, 67, 0, 37, 66, 67, 0, 92, 0, 91, 90, 0, 23, 64, 29, 71, 49, 65, 0, 23, 64, 29, 65, 0, 24, 64, 30, 65, 0, 25, 64, 30, 65, 0, 39, 49, 65, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 56, 0, 57, 0, 55, 0, 58, 0, 59, 0, 60, 0, 61, 0, 34, 66, 94, 67, 0, 62, 0, 63, 0, 29, 73, 49, 0, 29, 74, 29, 0, 29, 0, 47, 0, 48, 0, 40, 0, 41, 0, 99, 0, 99, 0, 42, 0, 43, 0, 44, 0, 45, 0 }; #endif #if YYDEBUG /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { 0, 98, 99, 117, 118, 121, 125, 136, 146, 156, 160, 164, 168, 172, 176, 182, 192, 193, 196, 211, 226, 236, 247, 258, 269, 280, 291, 310, 338, 342, 348, 352, 358, 362, 368, 372, 376, 382, 388, 392, 398, 404, 410, 414, 420, 425, 431, 440, 449, 467, 477, 485, 489, 496, 502, 506, 512, 532, 548, 563, 572, 582, 586, 592, 596, 600, 604, 608, 612, 616, 620, 626, 632, 638, 646, 650, 656, 674, 694, 709, 710, 714, 715, 719, 723, 724, 725, 726, 727 }; #endif #if (YYDEBUG) || defined YYERROR_VERBOSE /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { "$", "error", "$undefined.", "DEBUG", "CHROOT", "UID", "GID", "WORK_DIR", "CACHE_DIR", "COOKIE_DIR", "CACHE_TIMEOUT", "CACHE_FAST_TIMEOUT", "MIME", "SERVER", "SERVER_VERSION", "BROWSER_VERSION", "LISTEN", "CACHE", "COOKIE_CHECK", "SAFE_URL", "HTTPS", "ACCESS_LOG", "HEADER_CHECK", "FORWARD", "FORWARD_PROXY", "LOCATION", "IF", "ELSIF", "ELSE", "IP_ADDR", "STRING", "REGEX_STR", "INCLUDE", "HTPASSWD", "STRLEN", "CGI_DECODE", "IS_CGI", "IS_VALID_COOKIE", "CLEAR_COOKIE", "RETURN", "EQ", "NE", "GE", "GT", "LE", "LT", "IS", "AND", "OR", "NUMBER", "LOCAL_IP", "CLIENT_IP", "METHOD", "HOST", "PATH", "EXT", "USER_AGENT", "REFERER", "QUERY", "COOKIE", "PORT", "POST_LEN", "AUTH", "PROXY_AUTH", "'='", "';'", "'('", "')'", "'{'", "'}'", "','", "':'", "'!'", "'/'", "'-'", "config_file", "general_list", "general_stat", "server_cfg", "server_opt_list", "server_opt", "stat_list", "statment", "if_then_else", "if_stat", "elsif_stat_list", "elsif_stat", "else_stat", "condition_list", "condition", "expression_list", "expression", "return_statment", "ip_var", "str_var", "num_var", "auth_var", "ip_range", "logic", "eq_test", "str_test", "num_test", 0 }; #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { 0, 75, 75, 76, 76, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 78, 79, 79, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 82, 82, 83, 83, 83, 84, 85, 85, 86, 87, 88, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 89, 90, 90, 91, 91, 91, 91, 92, 93, 93, 94, 94, 94, 94, 94, 94, 94, 94, 95, 95, 95, 96, 96, 97, 97, 97, 98, 98, 99, 99, 100, 101, 101, 101, 101, 101 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { 0, 1, 2, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 1, 3, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 1, 1, 1, 2, 3, 7, 1, 2, 7, 4, 1, 3, 2, 3, 3, 3, 3, 3, 6, 6, 3, 3, 1, 2, 6, 4, 4, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const short yydefact[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 0, 22, 23, 24, 25, 26, 27, 20, 21, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 30, 32, 34, 33, 0, 54, 18, 19, 0, 0, 0, 0, 0, 15, 31, 0, 0, 0, 38, 35, 55, 0, 0, 0, 0, 0, 0, 0, 0, 61, 62, 63, 64, 65, 68, 66, 67, 69, 70, 71, 72, 0, 0, 0, 42, 0, 0, 0, 60, 0, 0, 39, 36, 57, 0, 58, 59, 0, 0, 0, 0, 0, 0, 44, 79, 80, 0, 0, 81, 82, 0, 0, 83, 0, 85, 86, 87, 88, 84, 0, 0, 0, 0, 74, 75, 0, 0, 0, 52, 53, 45, 0, 43, 78, 46, 48, 47, 49, 0, 41, 56, 0, 73, 0, 0, 0, 0, 0, 0, 0, 37, 76, 77, 0, 50, 51, 40, 0, 0 }; static const short yydefgoto[] = { 11, 12, 13, 25, 59, 60, 94, 95, 96, 97, 112, 113, 114, 138, 139, 98, 99, 100, 140, 141, 142, 180, 189, 162, 165, 168, 174 }; static const short yypact[] = { 123, -27, -20, -7, -5, 2, 37, 39, 40, 49, 80, 36, 123,-32768, 20, 25, 46, 53, 72, 115, 116, -28, 30, 117, 82,-32768,-32768, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 101,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 96, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, -42, -32768, 119, 135, 143, 144, 145, 146, 147, 148, 149, 151, 152, 113, 101,-32768,-32768, 112,-32768,-32768,-32768, -32768,-32768,-32768, 114,-32768, 15,-32768, 124, 137, 120, 125, 126, 121, 139, -21,-32768,-32768, 19,-32768, 38, -32768,-32768,-32768, 162, 163, 164, 34, 127,-32768,-32768, 129, 128, 19,-32768,-32768,-32768, -36, 132, 133, 134, 136, 138, 140, 141,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768, 34, 34, -24,-32768, 24, 32, 67,-32768, 34, 15,-32768,-32768,-32768, 150, -32768,-32768, 12, 84, 171, 142, 153, -16, 33,-32768, -32768, 154, 34,-32768,-32768, 174, 177,-32768, 175,-32768, -32768,-32768,-32768,-32768, 161, -14, -17, 156,-32768,-32768, 155, 157, 158,-32768,-32768,-32768, 15, 33, 23,-32768, -32768,-32768,-32768, 159,-32768,-32768, 181,-32768, 182, -13, 165, 184, 15, 166, 167,-32768,-32768,-32768, -9,-32768, -32768,-32768, 215,-32768 }; static const short yypgoto[] = { -32768,-32768, 204,-32768,-32768, 168, -144, -94,-32768,-32768, -32768, 111, 118, -117,-32768, 130,-32768,-32768,-32768, 64, -32768,-32768,-32768,-32768, -43,-32768,-32768 }; #define YYLAST 241 static const short yytable[] = { 109, 176, 89, 90, 91, 92, 89, 90, 91, 92, 89, 90, 91, 92, 89, 90, 91, 92, 93, 157, 158, 34, 93, 159, 160, 72, 93, 175, 73, 148, 93, 159, 160, 159, 160, 149, 212, 14, 89, 90, 91, 92, 199, 161, 15, 187, 110, 111, 108, 24, 27, 185, 194, 193, 93, 28, 205, 16, 208, 17, 211, 89, 90, 91, 163, 164, 18, 119, 120, 121, 122, 123, 163, 164, 178, 179, 29, 93, 166, 35, 159, 160, 109, 30, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 200, 201, 167, 173, 136, 19, 31, 20, 21, 109, 137, 163, 164, 169, 170, 171, 172, 22, 109, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 126, 127, 128, 129, 130, 131, 132, 133, 23, 32, 33, 36, 37, 74, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 61, 62, 63, 64, 65, 75, 66, 67, 68, 69, 70, 71, 76, 101, 77, 78, 79, 80, 81, 82, 83, 85, 84, 87, 103, 88, 102, 106, 107, 104, 105, 116, 143, 117, 118, 144, 145, 150, 151, 177, 152, 182, 153, 188, 154, 191, 155, 156, 190, 183, 192, 203, 204, 207, 206, 213, 26, 181, 0, 0, 184, 195, 186, 146, 197, 196, 0, 202, 198, 115, 147, 0, 0, 209, 210, 0, 0, 0, 0, 0, 0, 86 }; static const short yycheck[] = { 94, 145, 23, 24, 25, 26, 23, 24, 25, 26, 23, 24, 25, 26, 23, 24, 25, 26, 39, 136, 137, 49, 39, 47, 48, 67, 39, 144, 70, 65, 39, 47, 48, 47, 48, 71, 0, 64, 23, 24, 25, 26, 186, 67, 64, 162, 27, 28, 69, 13, 30, 67, 69, 67, 39, 30, 69, 64, 202, 64, 69, 23, 24, 25, 40, 41, 64, 33, 34, 35, 36, 37, 40, 41, 62, 63, 30, 39, 46, 49, 47, 48, 176, 30, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 73, 74, 141, 142, 66, 64, 30, 64, 64, 199, 72, 40, 41, 42, 43, 44, 45, 64, 208, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 52, 53, 54, 55, 56, 57, 58, 59, 64, 30, 30, 30, 66, 30, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 30, 64, 64, 64, 64, 64, 64, 29, 49, 30, 30, 30, 30, 30, 30, 29, 68, 30, 71, 64, 71, 49, 66, 49, 64, 64, 29, 65, 30, 30, 66, 68, 65, 65, 49, 66, 30, 66, 29, 66, 30, 66, 66, 31, 67, 49, 30, 30, 29, 49, 0, 12, 153, -1, -1, 67, 65, 68, 112, 67, 70, -1, 68, 70, 99, 112, -1, -1, 67, 67, -1, -1, -1, -1, -1, -1, 73 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/local/share/bison/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; # if YYLSP_NEEDED YYLTYPE yyls; # endif }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # if YYLSP_NEEDED # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAX) # else # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAX) # endif /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). When YYLLOC_DEFAULT is run, CURRENT is set the location of the first token. By default, to implement support for ranges, extend its range to the last symbol. */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ #if YYPURE # if YYLSP_NEEDED # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) # else # define YYLEX yylex (&yylval, &yylloc) # endif # else /* !YYLSP_NEEDED */ # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) # else # define YYLEX yylex (&yylval) # endif # endif /* !YYLSP_NEEDED */ #else /* !YYPURE */ # define YYLEX yylex () #endif /* !YYPURE */ /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #ifdef YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif #line 315 "/usr/local/share/bison/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM # define YYPARSE_PARAM_DECL # else # define YYPARSE_PARAM_ARG YYPARSE_PARAM # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; # endif #else /* !YYPARSE_PARAM */ # define YYPARSE_PARAM_ARG # define YYPARSE_PARAM_DECL #endif /* !YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ # ifdef YYPARSE_PARAM int yyparse (void *); # else int yyparse (void); # endif #endif /* YY_DECL_VARIABLES -- depending whether we use a pure parser, variables are global, or local to YYPARSE. */ #define YY_DECL_NON_LSP_VARIABLES \ /* The lookahead symbol. */ \ int yychar; \ \ /* The semantic value of the lookahead symbol. */ \ YYSTYPE yylval; \ \ /* Number of parse errors so far. */ \ int yynerrs; #if YYLSP_NEEDED # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES \ \ /* Location data for the lookahead symbol. */ \ YYLTYPE yylloc; #else # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES #endif /* If nonreentrant, generate the variables here. */ #if !YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ int yyparse (YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL { /* If reentrant, generate the variables here. */ #if YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yychar1 = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #if YYLSP_NEEDED /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; #endif #if YYLSP_NEEDED # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else # define YYPOPSTACK (yyvsp--, yyssp--) #endif YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYLSP_NEEDED YYLTYPE yyloc; #endif /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; #if YYLSP_NEEDED yylsp = yyls; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ # if YYLSP_NEEDED YYLTYPE *yyls1 = yyls; /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; # else yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); # endif yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) goto yyoverflowlab; yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # if YYLSP_NEEDED YYSTACK_RELOCATE (yyls); # endif # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; #if YYLSP_NEEDED yylsp = yyls + yysize - 1; #endif YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyssp >= yyss + yystacksize - 1) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yychar1 = YYTRANSLATE (yychar); #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { YYFPRINTF (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ # ifdef YYPRINT YYPRINT (stderr, yychar, yylval); # endif YYFPRINTF (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to the semantic value of the lookahead token. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; #if YYLSP_NEEDED /* Similarly for the default location. Let the user run additional commands if for instance locations are ranges. */ yyloc = yylsp[1-yylen]; YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); #endif #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { int yyi; YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 2: #line 100 "cfg_parser.y" { for( yyint = 0; yyint < MAX_SC ; yyint++ ) { if ( NULL == yycfg.sclist[yyint] ) break; } if ( MAX_SC == yyint ) { fprintf(stderr, "Config Error: Too Many Server Config Sections\n"); exit(-1); } else { yycfg.sclist[yyint] = yyvsp[0].SC; } } break; case 5: #line 122 "cfg_parser.y" { yyval.SC = NULL; } break; case 6: #line 126 "cfg_parser.y" { if ( !strcasecmp(yyvsp[-1].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[-1].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $chroot\n"); exit(-1); } yycfg.enable_chroot = yyint; } break; case 7: #line 137 "cfg_parser.y" { yypasswd = getpwnam(yyvsp[-1].STR); if ( NULL == yypasswd ) { fprintf(stderr, "Config Error: Invalid $uid %s\n", yyvsp[-1].STR); exit(-1); } yycfg.uid = yypasswd->pw_uid; } break; case 8: #line 147 "cfg_parser.y" { yypasswd = getpwnam(yyvsp[-1].STR); if ( NULL == yypasswd ) { fprintf(stderr, "Config Error: Invalid $uid %s\n", yyvsp[-1].STR); exit(-1); } yycfg.gid = yypasswd->pw_gid; } break; case 9: #line 157 "cfg_parser.y" { yycfg.work_dir = yyvsp[-1].STR; } break; case 10: #line 161 "cfg_parser.y" { yycfg.cache_dir = yyvsp[-1].STR; } break; case 11: #line 165 "cfg_parser.y" { yycfg.cookie_dir = yyvsp[-1].STR; } break; case 12: #line 169 "cfg_parser.y" { yycfg.cache_tout = yyvsp[-1].INT; } break; case 13: #line 173 "cfg_parser.y" { yycfg.cache_fast_tout = yyvsp[-1].INT; } break; case 14: #line 177 "cfg_parser.y" { yycfg.mime_type = yyvsp[-1].STR; } break; case 15: #line 183 "cfg_parser.y" { yyval.SC = (srv_cfg *)cf_malloc(sizeof(srv_cfg)); memcpy(yyval.SC, &yysco, sizeof(srv_cfg)); yyval.SC->dt = yyvsp[-1].DT; /* clear out yysco after use */ init_srv_cfg(&yysco); } break; case 18: #line 197 "cfg_parser.y" { if ( 0 == yyvsp[0].INT ) { fprintf(stderr, "Config Error: Invalid $listen port\n"); exit(-1); } (yysco.ip).sin_family = AF_INET; if ( 1 != str2addr(yyvsp[-2].STR, &((yysco.ip).sin_addr)) ) { fprintf(stderr, "Config Error: Invalid Server IP Address\n"); exit(-1); } (yysco.ip).sin_port = htons(yyvsp[0].INT); } break; case 19: #line 212 "cfg_parser.y" { if ( 0 == yyvsp[0].INT ) { fprintf(stderr, "Config Error: Invalid forward port\n"); exit(-1); } (yysco.forward).sin_family = AF_INET; if ( 1 != str2addr(yyvsp[-2].STR, &((yysco.forward).sin_addr)) ) { fprintf(stderr, "Config Error: Invalid Server IP Address\n"); exit(-1); } (yysco.forward).sin_port = htons(yyvsp[0].INT); } break; case 20: #line 227 "cfg_parser.y" { (yysco.forward).sin_family = AF_INET; if ( 1 != str2addr(yyvsp[0].STR, &((yysco.forward).sin_addr)) ) { fprintf(stderr, "Config Error: Invalid Server IP Address\n"); exit(-1); } (yysco.forward).sin_port = htons(80); } break; case 21: #line 237 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[0].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $forward_proxy option\n"); exit(-1); } yysco.forward_proxy = yyint; } break; case 22: #line 248 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[0].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $cache option\n"); exit(-1); } yysco.enable_cache = yyint; } break; case 23: #line 259 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[0].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $cookie_check option\n"); exit(-1); } yysco.enable_cookie_chk = yyint; } break; case 24: #line 270 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[0].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $safe_url option\n"); exit(-1); } yysco.safe_url = yyint; } break; case 25: #line 281 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[0].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $https option\n"); exit(-1); } yysco.enable_https = yyint; } break; case 26: #line 292 "cfg_parser.y" { if ( strlen(yycfg.work_dir) + strlen(yyvsp[0].STR) >= MAX_LINE - 2 ) { fprintf(stderr, "Config Error: $work_dir+$access_log file name too long\n"); exit(-1); } strcpy(yystring, yycfg.work_dir); /* well, double "/" does not hurt */ strcat(yystring, "/"); strcat(yystring, yyvsp[0].STR); yyf = fopen(yystring, "a"); if ( NULL == yyf ) { fprintf(stderr, "Config Error: Error open access_log, %s\n", strerror(errno)); exit(-1); } yysco.alog = yyf; } break; case 27: #line 311 "cfg_parser.y" { if ( !strcasecmp(yyvsp[0].STR, "request") ) { yysco.srv_hd_chk = 0; yysco.clt_hd_chk = 1; } else if ( !strcasecmp(yyvsp[0].STR, "response") ) { yysco.srv_hd_chk = 1; yysco.clt_hd_chk = 0; } else if ( !strcasecmp(yyvsp[0].STR, "both") ) { yysco.srv_hd_chk = 1; yysco.clt_hd_chk = 1; } else if ( !strcasecmp(yyvsp[0].STR, "disable") ) { yysco.srv_hd_chk = 0; yysco.clt_hd_chk = 0; } else { fprintf(stderr, "Config Error: Invalid $header_check option\n"); exit(-1); } } break; case 28: #line 339 "cfg_parser.y" { yysco.srv_ver = yyvsp[0].STR; } break; case 29: #line 343 "cfg_parser.y" { yysco.browser_ver = yyvsp[0].STR; } break; case 30: #line 349 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 31: #line 353 "cfg_parser.y" { yyval.DT = or_dt(yyvsp[-1].DT, yyvsp[0].DT); } break; case 32: #line 359 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 33: #line 363 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 34: #line 369 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 35: #line 373 "cfg_parser.y" { yyval.DT = or_dt(yyvsp[-1].DT, yyvsp[0].DT); } break; case 36: #line 377 "cfg_parser.y" { yyval.DT = or_dt(or_dt(yyvsp[-2].DT, yyvsp[-1].DT), yyvsp[0].DT); } break; case 37: #line 383 "cfg_parser.y" { yyval.DT = seq_and_dt(yyvsp[-4].DT, yyvsp[-1].DT); } break; case 38: #line 389 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 39: #line 393 "cfg_parser.y" { yyval.DT = or_dt(yyvsp[-1].DT, yyvsp[0].DT); } break; case 40: #line 399 "cfg_parser.y" { yyval.DT = seq_and_dt(yyvsp[-4].DT, yyvsp[-1].DT); } break; case 41: #line 405 "cfg_parser.y" { yyval.DT = yyvsp[-1].DT; } break; case 42: #line 411 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 43: #line 415 "cfg_parser.y" { if ( AND == yyvsp[-1].INT ) yyval.DT = and_dt(yyvsp[-2].DT, yyvsp[0].DT); else if ( OR == yyvsp[-1].INT ) yyval.DT = or_dt(yyvsp[-2].DT, yyvsp[0].DT); else yyval.DT = NULL; } break; case 44: #line 421 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; yyval.DT->inverted = 1; } break; case 45: #line 426 "cfg_parser.y" { yyval.DT = yyvsp[-1].DT; } break; case 46: #line 432 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_ip_range; yyval.DT->value = yyvsp[0].IP; yyval.DT->property = yyvsp[-2].INT; if ( NE == yyvsp[-1].INT ) yyval.DT->inverted = 1; } break; case 47: #line 441 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_str_fnmatch; yyval.DT->property = yyvsp[-2].INT; if ( NE == yyvsp[-1].INT ) yyval.DT->inverted = 1; yyval.DT->value = yyvsp[0].STR; } break; case 48: #line 450 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_str_regex; yyval.DT->property = yyvsp[-2].INT; yyval.DT->inverted = 0; /* if the first char is "s", that is a case sensitive search */ if ( 's' == *(yyvsp[0].STR) ) { yyint = REG_EXTENDED|REG_NOSUB; } else { yyint = REG_EXTENDED|REG_NOSUB|REG_ICASE; } yyregex = (regex_t *)cf_malloc(sizeof(regex_t)); if ( regcomp(yyregex, yyvsp[0].STR+1, yyint) ) { fprintf(stderr, "regcomp(): %s\n", strerror(errno)); exit(-1); } yyval.DT->value = yyregex; } break; case 49: #line 468 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_numeric_test; yyval.DT->value = yyvsp[-2].CV; yyval.DT->value2 = cf_malloc(sizeof(int)); *(int *)yyval.DT->value2 = yyvsp[0].INT; yyval.DT->property = yyvsp[-1].INT; } break; case 50: #line 478 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_htpasswd; yyval.DT->value = yyvsp[-1].STR; yyval.DT->property = yyvsp[-3].INT; } break; case 51: #line 486 "cfg_parser.y" { yyval.DT = NULL; } break; case 52: #line 490 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_is_cgi; yyval.DT->value = "(null)"; } break; case 53: #line 497 "cfg_parser.y" { yyval.DT = NULL; } break; case 54: #line 503 "cfg_parser.y" { yyval.DT = yyvsp[0].DT; } break; case 55: #line 507 "cfg_parser.y" { yyval.DT = seq_and_dt(yyvsp[-1].DT, yyvsp[0].DT); } break; case 56: #line 513 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_set_forward; yyval.DT->value = (struct sockaddr_in *)cf_malloc(sizeof(struct sockaddr_in)); /* malloc OK, now check for validity */ if ( 0 == yyvsp[-1].INT ) { fprintf(stderr, "Config Error: Invalid forward port\n"); exit(-1); } if ( 1 != str2addr(yyvsp[-3].STR, &(((struct sockaddr_in *)yyval.DT->value)->sin_addr)) ) { fprintf(stderr, "Config Error: Invalid Server IP Address\n"); exit(-1); } ((struct sockaddr_in *)yyval.DT->value)->sin_family = AF_INET; ((struct sockaddr_in *)yyval.DT->value)->sin_port = htons(yyvsp[-1].INT); } break; case 57: #line 533 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_set_forward; yyval.DT->value = (struct sockaddr_in *)cf_malloc(sizeof(struct sockaddr_in)); /* malloc OK, now check for validity */ if ( 1 != str2addr(yyvsp[-1].STR, &(((struct sockaddr_in *)yyval.DT->value)->sin_addr)) ) { fprintf(stderr, "Config Error: Invalid Server IP Address\n"); exit(-1); } ((struct sockaddr_in *)yyval.DT->value)->sin_family = AF_INET; /* no port defined, use standard port 80 */ ((struct sockaddr_in *)yyval.DT->value)->sin_port = htons(80); } break; case 58: #line 549 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_set_forward_proxy; if ( !strcasecmp(yyvsp[-1].STR, "enable") ) yyint = 1; else if ( !strcasecmp(yyvsp[-1].STR, "disable") ) yyint = 0; else { fprintf(stderr, "Config Error: Invalid $forward_proxy value\n"); exit(-1); } yyval.DT->value = (int *)cf_malloc(sizeof(int)); *(int *)(yyval.DT->value) = yyint; } break; case 59: #line 564 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_set_location; yyval.DT->value = strdup(yyvsp[-1].STR); } break; case 60: #line 573 "cfg_parser.y" { yyval.DT = (decision_tree *)cf_malloc(sizeof(decision_tree)); init_dt(yyval.DT); yyval.DT->f = &cfg_return; yyval.DT->value = (int *)cf_malloc(sizeof(int)); *((int *)yyval.DT->value) = yyvsp[-1].INT; } break; case 61: #line 583 "cfg_parser.y" { yyval.INT = LOCAL_IP; } break; case 62: #line 587 "cfg_parser.y" { yyval.INT = CLIENT_IP; } break; case 63: #line 593 "cfg_parser.y" { yyval.INT = METHOD; } break; case 64: #line 597 "cfg_parser.y" { yyval.INT = HOST; } break; case 65: #line 601 "cfg_parser.y" { yyval.INT = PATH; } break; case 66: #line 605 "cfg_parser.y" { yyval.INT = USER_AGENT; } break; case 67: #line 609 "cfg_parser.y" { yyval.INT = REFERER; } break; case 68: #line 613 "cfg_parser.y" { yyval.INT = EXT; } break; case 69: #line 617 "cfg_parser.y" { yyval.INT = QUERY; } break; case 70: #line 621 "cfg_parser.y" { yyval.INT = COOKIE; } break; case 71: #line 627 "cfg_parser.y" { yyval.CV = (cfg_variable *)cf_malloc(sizeof(cfg_variable)); yyval.CV->type = PORT; yyval.CV->f = NULL; } break; case 72: #line 633 "cfg_parser.y" { yyval.CV = (cfg_variable *)cf_malloc(sizeof(cfg_variable)); yyval.CV->type = POST_LEN; yyval.CV->f = NULL; } break; case 73: #line 639 "cfg_parser.y" { yyval.CV = (cfg_variable *)cf_malloc(sizeof(cfg_variable)); yyval.CV->type = yyvsp[-1].INT; yyval.CV->f = &cfg_strlen; } break; case 74: #line 647 "cfg_parser.y" { yyval.INT = AUTH; } break; case 75: #line 651 "cfg_parser.y" { yyval.INT = PROXY_AUTH; } break; case 76: #line 657 "cfg_parser.y" { yyval.IP = (ip_range_t *)cf_malloc(sizeof(ip_range_t)); if ( 1 == str2addr(yyvsp[-2].STR, &yyaddr) ) { yyval.IP->start_addr = ntohl(yyaddr.s_addr); } else { printf("Invalid IP address: %s\n", yyvsp[-2].STR); } yyint = yyvsp[0].INT; if ( yyint <= 0 || yyint >= 32 ) { printf("Invalid Network Mask: %d\n", yyint); } yyval.IP->end_addr = yyval.IP->start_addr | (0xFFFFFFFF >> yyint); } break; case 77: #line 675 "cfg_parser.y" { yyval.IP = (ip_range_t *)cf_malloc(sizeof(ip_range_t)); if ( 1 == str2addr(yyvsp[-2].STR, &yyaddr) ) { yyval.IP->start_addr = ntohl(yyaddr.s_addr); } else { printf("Invalid IP address: %s\n", yyvsp[-2].STR); } if ( 1 == str2addr(yyvsp[0].STR, &yyaddr) ) { yyval.IP->end_addr = ntohl(yyaddr.s_addr); } else { printf("Invalid IP address: %s\n", yyvsp[-2].STR); } } break; case 78: #line 695 "cfg_parser.y" { yyval.IP = (ip_range_t *)cf_malloc(sizeof(ip_range_t)); if ( 1 == str2addr(yyvsp[0].STR, &yyaddr) ) { yyval.IP->start_addr = ntohl(yyaddr.s_addr); } else { printf("Invalid IP address: %s\n", yyvsp[0].STR); } yyval.IP->end_addr = yyval.IP->start_addr; } break; case 79: #line 709 "cfg_parser.y" { yyval.INT = AND; } break; case 80: #line 710 "cfg_parser.y" { yyval.INT = OR; } break; case 81: #line 714 "cfg_parser.y" { yyval.INT = EQ; } break; case 82: #line 715 "cfg_parser.y" { yyval.INT = NE; } break; case 85: #line 724 "cfg_parser.y" { yyval.INT = GE; } break; case 86: #line 725 "cfg_parser.y" { yyval.INT = GT; } break; case 87: #line 726 "cfg_parser.y" { yyval.INT = LE; } break; case 88: #line 727 "cfg_parser.y" { yyval.INT = LT; } break; } #line 705 "/usr/local/share/bison/bison.simple" yyvsp -= yylen; yyssp -= yylen; #if YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif *++yyvsp = yyval; #if YYLSP_NEEDED *++yylsp = yyloc; #endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else #endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1; /*--------------------------------------------------. | yyerrlab1 -- error raised explicitly by an action | `--------------------------------------------------*/ yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; /*-------------------------------------------------------------------. | yyerrdefault -- current state does not do anything special for the | | error token. | `-------------------------------------------------------------------*/ yyerrdefault: #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault; #endif /*---------------------------------------------------------------. | yyerrpop -- pop the current state because it cannot handle the | | error token | `---------------------------------------------------------------*/ yyerrpop: if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #if YYLSP_NEEDED yylsp--; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif /*--------------. | yyerrhandle. | `--------------*/ yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; /*---------------------------------------------. | yyoverflowab -- parser overflow comes here. | `---------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 730 "cfg_parser.y" yyerror(char *err_msg) { printf("Config Error in Line %d: %s near \"%s\"\n", yylineno, err_msg, yytext); exit(-1); }