[ff36f5e] | 1 | /* A Bison parser, made by GNU Bison 2.6.2. */ |
---|
| 2 | |
---|
| 3 | /* Bison implementation for Yacc-like parsers in C |
---|
| 4 | |
---|
| 5 | Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. |
---|
| 6 | |
---|
| 7 | This program is free software: you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation, either version 3 of the License, or |
---|
| 10 | (at your option) any later version. |
---|
| 11 | |
---|
| 12 | This program is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU General Public License |
---|
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
---|
| 19 | |
---|
| 20 | /* As a special exception, you may create a larger work that contains |
---|
| 21 | part or all of the Bison parser skeleton and distribute that work |
---|
| 22 | under terms of your choice, so long as that work isn't itself a |
---|
| 23 | parser generator using the skeleton or a modified version thereof |
---|
| 24 | as a parser skeleton. Alternatively, if you modify or redistribute |
---|
| 25 | the parser skeleton itself, you may (at your option) remove this |
---|
| 26 | special exception, which will cause the skeleton and the resulting |
---|
| 27 | Bison output files to be licensed under the GNU General Public |
---|
| 28 | License without this special exception. |
---|
| 29 | |
---|
| 30 | This special exception was added by the Free Software Foundation in |
---|
| 31 | version 2.2 of Bison. */ |
---|
| 32 | |
---|
| 33 | /* C LALR(1) parser skeleton written by Richard Stallman, by |
---|
| 34 | simplifying the original so-called "semantic" parser. */ |
---|
| 35 | |
---|
| 36 | /* All symbols defined below should begin with yy or YY, to avoid |
---|
| 37 | infringing on user name space. This should be done even for local |
---|
| 38 | variables, as they might otherwise be expanded by user macros. |
---|
| 39 | There are some unavoidable exceptions within include files to |
---|
| 40 | define necessary library symbols; they are noted "INFRINGES ON |
---|
| 41 | USER NAME SPACE" below. */ |
---|
| 42 | |
---|
| 43 | /* Identify Bison output. */ |
---|
| 44 | #define YYBISON 1 |
---|
| 45 | |
---|
| 46 | /* Bison version. */ |
---|
| 47 | #define YYBISON_VERSION "2.6.2" |
---|
| 48 | |
---|
| 49 | /* Skeleton name. */ |
---|
| 50 | #define YYSKELETON_NAME "yacc.c" |
---|
| 51 | |
---|
| 52 | /* Pure parsers. */ |
---|
| 53 | #define YYPURE 0 |
---|
| 54 | |
---|
| 55 | /* Push parsers. */ |
---|
| 56 | #define YYPUSH 0 |
---|
| 57 | |
---|
| 58 | /* Pull parsers. */ |
---|
| 59 | #define YYPULL 1 |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | /* Substitute the variable and function names. */ |
---|
| 63 | #define yyparse prsaparse |
---|
| 64 | #define yylex prsalex |
---|
| 65 | #define yyerror prsaerror |
---|
| 66 | #define yylval prsalval |
---|
| 67 | #define yychar prsachar |
---|
| 68 | #define yydebug prsadebug |
---|
| 69 | #define yynerrs prsanerrs |
---|
| 70 | |
---|
| 71 | /* Copy the first part of user declarations. */ |
---|
| 72 | /* Line 336 of yacc.c */ |
---|
| 73 | #line 5 "prsa_par.y" |
---|
| 74 | |
---|
| 75 | /* |
---|
| 76 | * Copyright (C) 2004 SuSE Linux AG, Nuernberg, Germany. |
---|
| 77 | * Contributed by: Michal Ludvig <mludvig@suse.cz>, SUSE Labs |
---|
| 78 | * All rights reserved. |
---|
| 79 | * |
---|
| 80 | * Redistribution and use in source and binary forms, with or without |
---|
| 81 | * modification, are permitted provided that the following conditions |
---|
| 82 | * are met: |
---|
| 83 | * 1. Redistributions of source code must retain the above copyright |
---|
| 84 | * notice, this list of conditions and the following disclaimer. |
---|
| 85 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
| 86 | * notice, this list of conditions and the following disclaimer in the |
---|
| 87 | * documentation and/or other materials provided with the distribution. |
---|
| 88 | * 3. Neither the name of the project nor the names of its contributors |
---|
| 89 | * may be used to endorse or promote products derived from this software |
---|
| 90 | * without specific prior written permission. |
---|
| 91 | * |
---|
| 92 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
---|
| 93 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 94 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 95 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE |
---|
| 96 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
| 97 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
| 98 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
| 99 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
| 100 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
| 101 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
| 102 | * SUCH DAMAGE. |
---|
| 103 | */ |
---|
| 104 | |
---|
| 105 | /* This file contains a parser for FreeS/WAN-style ipsec.secrets RSA keys. */ |
---|
| 106 | |
---|
| 107 | #include "config.h" |
---|
| 108 | |
---|
| 109 | #include <stdio.h> |
---|
| 110 | #include <stdarg.h> |
---|
| 111 | #include <string.h> |
---|
| 112 | #include <errno.h> |
---|
| 113 | #include <unistd.h> |
---|
| 114 | |
---|
| 115 | #ifdef HAVE_STDARG_H |
---|
| 116 | #include <stdarg.h> |
---|
| 117 | #else |
---|
| 118 | #include <varargs.h> |
---|
| 119 | #endif |
---|
| 120 | |
---|
| 121 | #include <netdb.h> |
---|
| 122 | #include <netinet/in.h> |
---|
| 123 | #include <sys/socket.h> |
---|
| 124 | #include <arpa/inet.h> |
---|
| 125 | #include <sys/types.h> |
---|
| 126 | |
---|
| 127 | #include <sys/stat.h> |
---|
| 128 | #include <unistd.h> |
---|
| 129 | |
---|
| 130 | #include <openssl/bn.h> |
---|
| 131 | #include <openssl/rsa.h> |
---|
| 132 | |
---|
| 133 | #include "misc.h" |
---|
| 134 | #include "vmbuf.h" |
---|
| 135 | #include "plog.h" |
---|
| 136 | #include "oakley.h" |
---|
| 137 | #include "isakmp_var.h" |
---|
| 138 | #include "handler.h" |
---|
| 139 | #include "crypto_openssl.h" |
---|
| 140 | #include "sockmisc.h" |
---|
| 141 | #include "rsalist.h" |
---|
| 142 | |
---|
| 143 | extern void prsaerror(const char *str, ...); |
---|
| 144 | extern int prsawrap (void); |
---|
| 145 | extern int prsalex (void); |
---|
| 146 | |
---|
| 147 | extern char *prsatext; |
---|
| 148 | extern int prsa_cur_lineno; |
---|
| 149 | extern char *prsa_cur_fname; |
---|
| 150 | extern FILE *prsain; |
---|
| 151 | |
---|
| 152 | int prsa_cur_lineno = 0; |
---|
| 153 | char *prsa_cur_fname = NULL; |
---|
| 154 | struct genlist *prsa_cur_list = NULL; |
---|
| 155 | enum rsa_key_type prsa_cur_type = RSA_TYPE_ANY; |
---|
| 156 | |
---|
| 157 | static RSA *rsa_cur; |
---|
| 158 | |
---|
| 159 | void |
---|
| 160 | prsaerror(const char *s, ...) |
---|
| 161 | { |
---|
| 162 | char fmt[512]; |
---|
| 163 | |
---|
| 164 | va_list ap; |
---|
| 165 | #ifdef HAVE_STDARG_H |
---|
| 166 | va_start(ap, s); |
---|
| 167 | #else |
---|
| 168 | va_start(ap); |
---|
| 169 | #endif |
---|
| 170 | snprintf(fmt, sizeof(fmt), "%s:%d: %s", |
---|
| 171 | prsa_cur_fname, prsa_cur_lineno, s); |
---|
| 172 | plogv(LLV_ERROR, LOCATION, NULL, fmt, ap); |
---|
| 173 | va_end(ap); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | void |
---|
| 177 | prsawarning(const char *s, ...) |
---|
| 178 | { |
---|
| 179 | char fmt[512]; |
---|
| 180 | |
---|
| 181 | va_list ap; |
---|
| 182 | #ifdef HAVE_STDARG_H |
---|
| 183 | va_start(ap, s); |
---|
| 184 | #else |
---|
| 185 | va_start(ap); |
---|
| 186 | #endif |
---|
| 187 | snprintf(fmt, sizeof(fmt), "%s:%d: %s", |
---|
| 188 | prsa_cur_fname, prsa_cur_lineno, s); |
---|
| 189 | plogv(LLV_WARNING, LOCATION, NULL, fmt, ap); |
---|
| 190 | va_end(ap); |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | int |
---|
| 194 | prsawrap() |
---|
| 195 | { |
---|
| 196 | return 1; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | /* Line 336 of yacc.c */ |
---|
| 200 | #line 201 "prsa_par.c" |
---|
| 201 | |
---|
| 202 | # ifndef YY_NULL |
---|
| 203 | # if defined __cplusplus && 201103L <= __cplusplus |
---|
| 204 | # define YY_NULL nullptr |
---|
| 205 | # else |
---|
| 206 | # define YY_NULL 0 |
---|
| 207 | # endif |
---|
| 208 | # endif |
---|
| 209 | |
---|
| 210 | /* Enabling verbose error messages. */ |
---|
| 211 | #ifdef YYERROR_VERBOSE |
---|
| 212 | # undef YYERROR_VERBOSE |
---|
| 213 | # define YYERROR_VERBOSE 1 |
---|
| 214 | #else |
---|
| 215 | # define YYERROR_VERBOSE 0 |
---|
| 216 | #endif |
---|
| 217 | |
---|
| 218 | /* In a future release of Bison, this section will be replaced |
---|
| 219 | by #include "y.tab.h". */ |
---|
| 220 | #ifndef PRSA_Y_TAB_H |
---|
| 221 | # define PRSA_Y_TAB_H |
---|
| 222 | /* Enabling traces. */ |
---|
| 223 | #ifndef YYDEBUG |
---|
| 224 | # define YYDEBUG 0 |
---|
| 225 | #endif |
---|
| 226 | #if YYDEBUG |
---|
| 227 | extern int prsadebug; |
---|
| 228 | #endif |
---|
| 229 | |
---|
| 230 | /* Tokens. */ |
---|
| 231 | #ifndef YYTOKENTYPE |
---|
| 232 | # define YYTOKENTYPE |
---|
| 233 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
---|
| 234 | know about them. */ |
---|
| 235 | enum yytokentype { |
---|
| 236 | COLON = 258, |
---|
| 237 | HEX = 259, |
---|
| 238 | OBRACE = 260, |
---|
| 239 | EBRACE = 261, |
---|
| 240 | TAG_RSA = 262, |
---|
| 241 | TAG_PUB = 263, |
---|
| 242 | TAG_PSK = 264, |
---|
| 243 | MODULUS = 265, |
---|
| 244 | PUBLIC_EXPONENT = 266, |
---|
| 245 | PRIVATE_EXPONENT = 267, |
---|
| 246 | PRIME1 = 268, |
---|
| 247 | PRIME2 = 269, |
---|
| 248 | EXPONENT1 = 270, |
---|
| 249 | EXPONENT2 = 271, |
---|
| 250 | COEFFICIENT = 272, |
---|
| 251 | ADDR4 = 273, |
---|
| 252 | ADDR6 = 274, |
---|
| 253 | ADDRANY = 275, |
---|
| 254 | SLASH = 276, |
---|
| 255 | NUMBER = 277, |
---|
| 256 | BASE64 = 278 |
---|
| 257 | }; |
---|
| 258 | #endif |
---|
| 259 | /* Tokens. */ |
---|
| 260 | #define COLON 258 |
---|
| 261 | #define HEX 259 |
---|
| 262 | #define OBRACE 260 |
---|
| 263 | #define EBRACE 261 |
---|
| 264 | #define TAG_RSA 262 |
---|
| 265 | #define TAG_PUB 263 |
---|
| 266 | #define TAG_PSK 264 |
---|
| 267 | #define MODULUS 265 |
---|
| 268 | #define PUBLIC_EXPONENT 266 |
---|
| 269 | #define PRIVATE_EXPONENT 267 |
---|
| 270 | #define PRIME1 268 |
---|
| 271 | #define PRIME2 269 |
---|
| 272 | #define EXPONENT1 270 |
---|
| 273 | #define EXPONENT2 271 |
---|
| 274 | #define COEFFICIENT 272 |
---|
| 275 | #define ADDR4 273 |
---|
| 276 | #define ADDR6 274 |
---|
| 277 | #define ADDRANY 275 |
---|
| 278 | #define SLASH 276 |
---|
| 279 | #define NUMBER 277 |
---|
| 280 | #define BASE64 278 |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
---|
| 285 | typedef union YYSTYPE |
---|
| 286 | { |
---|
| 287 | /* Line 350 of yacc.c */ |
---|
| 288 | #line 130 "prsa_par.y" |
---|
| 289 | |
---|
| 290 | BIGNUM *bn; |
---|
| 291 | RSA *rsa; |
---|
| 292 | char *chr; |
---|
| 293 | long num; |
---|
| 294 | struct netaddr *naddr; |
---|
| 295 | |
---|
| 296 | |
---|
| 297 | /* Line 350 of yacc.c */ |
---|
| 298 | #line 299 "prsa_par.c" |
---|
| 299 | } YYSTYPE; |
---|
| 300 | # define YYSTYPE_IS_TRIVIAL 1 |
---|
| 301 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
---|
| 302 | # define YYSTYPE_IS_DECLARED 1 |
---|
| 303 | #endif |
---|
| 304 | |
---|
| 305 | extern YYSTYPE prsalval; |
---|
| 306 | |
---|
| 307 | #ifdef YYPARSE_PARAM |
---|
| 308 | #if defined __STDC__ || defined __cplusplus |
---|
| 309 | int prsaparse (void *YYPARSE_PARAM); |
---|
| 310 | #else |
---|
| 311 | int prsaparse (); |
---|
| 312 | #endif |
---|
| 313 | #else /* ! YYPARSE_PARAM */ |
---|
| 314 | #if defined __STDC__ || defined __cplusplus |
---|
| 315 | int prsaparse (void); |
---|
| 316 | #else |
---|
| 317 | int prsaparse (); |
---|
| 318 | #endif |
---|
| 319 | #endif /* ! YYPARSE_PARAM */ |
---|
| 320 | |
---|
| 321 | #endif /* !PRSA_Y_TAB_H */ |
---|
| 322 | |
---|
| 323 | /* Copy the second part of user declarations. */ |
---|
| 324 | |
---|
| 325 | /* Line 353 of yacc.c */ |
---|
| 326 | #line 327 "prsa_par.c" |
---|
| 327 | |
---|
| 328 | #ifdef short |
---|
| 329 | # undef short |
---|
| 330 | #endif |
---|
| 331 | |
---|
| 332 | #ifdef YYTYPE_UINT8 |
---|
| 333 | typedef YYTYPE_UINT8 yytype_uint8; |
---|
| 334 | #else |
---|
| 335 | typedef unsigned char yytype_uint8; |
---|
| 336 | #endif |
---|
| 337 | |
---|
| 338 | #ifdef YYTYPE_INT8 |
---|
| 339 | typedef YYTYPE_INT8 yytype_int8; |
---|
| 340 | #elif (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 341 | || defined __cplusplus || defined _MSC_VER) |
---|
| 342 | typedef signed char yytype_int8; |
---|
| 343 | #else |
---|
| 344 | typedef short int yytype_int8; |
---|
| 345 | #endif |
---|
| 346 | |
---|
| 347 | #ifdef YYTYPE_UINT16 |
---|
| 348 | typedef YYTYPE_UINT16 yytype_uint16; |
---|
| 349 | #else |
---|
| 350 | typedef unsigned short int yytype_uint16; |
---|
| 351 | #endif |
---|
| 352 | |
---|
| 353 | #ifdef YYTYPE_INT16 |
---|
| 354 | typedef YYTYPE_INT16 yytype_int16; |
---|
| 355 | #else |
---|
| 356 | typedef short int yytype_int16; |
---|
| 357 | #endif |
---|
| 358 | |
---|
| 359 | #ifndef YYSIZE_T |
---|
| 360 | # ifdef __SIZE_TYPE__ |
---|
| 361 | # define YYSIZE_T __SIZE_TYPE__ |
---|
| 362 | # elif defined size_t |
---|
| 363 | # define YYSIZE_T size_t |
---|
| 364 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 365 | || defined __cplusplus || defined _MSC_VER) |
---|
| 366 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 367 | # define YYSIZE_T size_t |
---|
| 368 | # else |
---|
| 369 | # define YYSIZE_T unsigned int |
---|
| 370 | # endif |
---|
| 371 | #endif |
---|
| 372 | |
---|
| 373 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
---|
| 374 | |
---|
| 375 | #ifndef YY_ |
---|
| 376 | # if defined YYENABLE_NLS && YYENABLE_NLS |
---|
| 377 | # if ENABLE_NLS |
---|
| 378 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 379 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
---|
| 380 | # endif |
---|
| 381 | # endif |
---|
| 382 | # ifndef YY_ |
---|
| 383 | # define YY_(msgid) msgid |
---|
| 384 | # endif |
---|
| 385 | #endif |
---|
| 386 | |
---|
| 387 | /* Suppress unused-variable warnings by "using" E. */ |
---|
| 388 | #if ! defined lint || defined __GNUC__ |
---|
| 389 | # define YYUSE(e) ((void) (e)) |
---|
| 390 | #else |
---|
| 391 | # define YYUSE(e) /* empty */ |
---|
| 392 | #endif |
---|
| 393 | |
---|
| 394 | /* Identity function, used to suppress warnings about constant conditions. */ |
---|
| 395 | #ifndef lint |
---|
| 396 | # define YYID(n) (n) |
---|
| 397 | #else |
---|
| 398 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 399 | || defined __cplusplus || defined _MSC_VER) |
---|
| 400 | static int |
---|
| 401 | YYID (int yyi) |
---|
| 402 | #else |
---|
| 403 | static int |
---|
| 404 | YYID (yyi) |
---|
| 405 | int yyi; |
---|
| 406 | #endif |
---|
| 407 | { |
---|
| 408 | return yyi; |
---|
| 409 | } |
---|
| 410 | #endif |
---|
| 411 | |
---|
| 412 | #if ! defined yyoverflow || YYERROR_VERBOSE |
---|
| 413 | |
---|
| 414 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
---|
| 415 | |
---|
| 416 | # ifdef YYSTACK_USE_ALLOCA |
---|
| 417 | # if YYSTACK_USE_ALLOCA |
---|
| 418 | # ifdef __GNUC__ |
---|
| 419 | # define YYSTACK_ALLOC __builtin_alloca |
---|
| 420 | # elif defined __BUILTIN_VA_ARG_INCR |
---|
| 421 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 422 | # elif defined _AIX |
---|
| 423 | # define YYSTACK_ALLOC __alloca |
---|
| 424 | # elif defined _MSC_VER |
---|
| 425 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 426 | # define alloca _alloca |
---|
| 427 | # else |
---|
| 428 | # define YYSTACK_ALLOC alloca |
---|
| 429 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 430 | || defined __cplusplus || defined _MSC_VER) |
---|
| 431 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 432 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ |
---|
| 433 | # ifndef EXIT_SUCCESS |
---|
| 434 | # define EXIT_SUCCESS 0 |
---|
| 435 | # endif |
---|
| 436 | # endif |
---|
| 437 | # endif |
---|
| 438 | # endif |
---|
| 439 | # endif |
---|
| 440 | |
---|
| 441 | # ifdef YYSTACK_ALLOC |
---|
| 442 | /* Pacify GCC's `empty if-body' warning. */ |
---|
| 443 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) |
---|
| 444 | # ifndef YYSTACK_ALLOC_MAXIMUM |
---|
| 445 | /* The OS might guarantee only one guard page at the bottom of the stack, |
---|
| 446 | and a page size can be as small as 4096 bytes. So we cannot safely |
---|
| 447 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
---|
| 448 | to allow for a few compiler-allocated temporary stack slots. */ |
---|
| 449 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
---|
| 450 | # endif |
---|
| 451 | # else |
---|
| 452 | # define YYSTACK_ALLOC YYMALLOC |
---|
| 453 | # define YYSTACK_FREE YYFREE |
---|
| 454 | # ifndef YYSTACK_ALLOC_MAXIMUM |
---|
| 455 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
---|
| 456 | # endif |
---|
| 457 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ |
---|
| 458 | && ! ((defined YYMALLOC || defined malloc) \ |
---|
| 459 | && (defined YYFREE || defined free))) |
---|
| 460 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 461 | # ifndef EXIT_SUCCESS |
---|
| 462 | # define EXIT_SUCCESS 0 |
---|
| 463 | # endif |
---|
| 464 | # endif |
---|
| 465 | # ifndef YYMALLOC |
---|
| 466 | # define YYMALLOC malloc |
---|
| 467 | # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 468 | || defined __cplusplus || defined _MSC_VER) |
---|
| 469 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
---|
| 470 | # endif |
---|
| 471 | # endif |
---|
| 472 | # ifndef YYFREE |
---|
| 473 | # define YYFREE free |
---|
| 474 | # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 475 | || defined __cplusplus || defined _MSC_VER) |
---|
| 476 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
---|
| 477 | # endif |
---|
| 478 | # endif |
---|
| 479 | # endif |
---|
| 480 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
---|
| 481 | |
---|
| 482 | |
---|
| 483 | #if (! defined yyoverflow \ |
---|
| 484 | && (! defined __cplusplus \ |
---|
| 485 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
---|
| 486 | |
---|
| 487 | /* A type that is properly aligned for any stack member. */ |
---|
| 488 | union yyalloc |
---|
| 489 | { |
---|
| 490 | yytype_int16 yyss_alloc; |
---|
| 491 | YYSTYPE yyvs_alloc; |
---|
| 492 | }; |
---|
| 493 | |
---|
| 494 | /* The size of the maximum gap between one aligned stack and the next. */ |
---|
| 495 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
---|
| 496 | |
---|
| 497 | /* The size of an array large to enough to hold all stacks, each with |
---|
| 498 | N elements. */ |
---|
| 499 | # define YYSTACK_BYTES(N) \ |
---|
| 500 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
---|
| 501 | + YYSTACK_GAP_MAXIMUM) |
---|
| 502 | |
---|
| 503 | # define YYCOPY_NEEDED 1 |
---|
| 504 | |
---|
| 505 | /* Relocate STACK from its old location to the new one. The |
---|
| 506 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
---|
| 507 | elements in the stack, and YYPTR gives the new location of the |
---|
| 508 | stack. Advance YYPTR to a properly aligned location for the next |
---|
| 509 | stack. */ |
---|
| 510 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ |
---|
| 511 | do \ |
---|
| 512 | { \ |
---|
| 513 | YYSIZE_T yynewbytes; \ |
---|
| 514 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ |
---|
| 515 | Stack = &yyptr->Stack_alloc; \ |
---|
| 516 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
---|
| 517 | yyptr += yynewbytes / sizeof (*yyptr); \ |
---|
| 518 | } \ |
---|
| 519 | while (YYID (0)) |
---|
| 520 | |
---|
| 521 | #endif |
---|
| 522 | |
---|
| 523 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
---|
| 524 | /* Copy COUNT objects from SRC to DST. The source and destination do |
---|
| 525 | not overlap. */ |
---|
| 526 | # ifndef YYCOPY |
---|
| 527 | # if defined __GNUC__ && 1 < __GNUC__ |
---|
| 528 | # define YYCOPY(Dst, Src, Count) \ |
---|
| 529 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) |
---|
| 530 | # else |
---|
| 531 | # define YYCOPY(Dst, Src, Count) \ |
---|
| 532 | do \ |
---|
| 533 | { \ |
---|
| 534 | YYSIZE_T yyi; \ |
---|
| 535 | for (yyi = 0; yyi < (Count); yyi++) \ |
---|
| 536 | (Dst)[yyi] = (Src)[yyi]; \ |
---|
| 537 | } \ |
---|
| 538 | while (YYID (0)) |
---|
| 539 | # endif |
---|
| 540 | # endif |
---|
| 541 | #endif /* !YYCOPY_NEEDED */ |
---|
| 542 | |
---|
| 543 | /* YYFINAL -- State number of the termination state. */ |
---|
| 544 | #define YYFINAL 16 |
---|
| 545 | /* YYLAST -- Last index in YYTABLE. */ |
---|
| 546 | #define YYLAST 60 |
---|
| 547 | |
---|
| 548 | /* YYNTOKENS -- Number of terminals. */ |
---|
| 549 | #define YYNTOKENS 24 |
---|
| 550 | /* YYNNTS -- Number of nonterminals. */ |
---|
| 551 | #define YYNNTS 10 |
---|
| 552 | /* YYNRULES -- Number of rules. */ |
---|
| 553 | #define YYNRULES 26 |
---|
| 554 | /* YYNRULES -- Number of states. */ |
---|
| 555 | #define YYNSTATES 55 |
---|
| 556 | |
---|
| 557 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
---|
| 558 | #define YYUNDEFTOK 2 |
---|
| 559 | #define YYMAXUTOK 278 |
---|
| 560 | |
---|
| 561 | #define YYTRANSLATE(YYX) \ |
---|
| 562 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
---|
| 563 | |
---|
| 564 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
---|
| 565 | static const yytype_uint8 yytranslate[] = |
---|
| 566 | { |
---|
| 567 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 568 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 569 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 570 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 571 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 572 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 573 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 574 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 575 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 576 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 577 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 578 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 579 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 580 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 581 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 582 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 583 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 584 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 585 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 586 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 587 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 588 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 589 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 590 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 591 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 592 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
---|
| 593 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
---|
| 594 | 15, 16, 17, 18, 19, 20, 21, 22, 23 |
---|
| 595 | }; |
---|
| 596 | |
---|
| 597 | #if YYDEBUG |
---|
| 598 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
---|
| 599 | YYRHS. */ |
---|
| 600 | static const yytype_uint8 yyprhs[] = |
---|
| 601 | { |
---|
| 602 | 0, 0, 3, 6, 8, 13, 17, 20, 25, 28, |
---|
| 603 | 31, 33, 35, 37, 40, 43, 44, 47, 50, 52, |
---|
| 604 | 56, 60, 64, 68, 72, 76, 80 |
---|
| 605 | }; |
---|
| 606 | |
---|
| 607 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
---|
| 608 | static const yytype_int8 yyrhs[] = |
---|
| 609 | { |
---|
| 610 | 25, 0, -1, 25, 26, -1, 26, -1, 28, 28, |
---|
| 611 | 3, 27, -1, 28, 3, 27, -1, 3, 27, -1, |
---|
| 612 | 7, 5, 32, 6, -1, 8, 23, -1, 8, 4, |
---|
| 613 | -1, 29, -1, 30, -1, 20, -1, 18, 31, -1, |
---|
| 614 | 19, 31, -1, -1, 21, 22, -1, 32, 33, -1, |
---|
| 615 | 33, -1, 10, 3, 4, -1, 11, 3, 4, -1, |
---|
| 616 | 12, 3, 4, -1, 13, 3, 4, -1, 14, 3, |
---|
| 617 | 4, -1, 15, 3, 4, -1, 16, 3, 4, -1, |
---|
| 618 | 17, 3, 4, -1 |
---|
| 619 | }; |
---|
| 620 | |
---|
| 621 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
---|
| 622 | static const yytype_uint16 yyrline[] = |
---|
| 623 | { |
---|
| 624 | 0, 155, 155, 156, 160, 164, 168, 175, 207, 216, |
---|
| 625 | 227, 228, 229, 236, 265, 294, 295, 298, 299, 303, |
---|
| 626 | 305, 307, 309, 311, 313, 315, 317 |
---|
| 627 | }; |
---|
| 628 | #endif |
---|
| 629 | |
---|
| 630 | #if YYDEBUG || YYERROR_VERBOSE || 0 |
---|
| 631 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
---|
| 632 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
---|
| 633 | static const char *const yytname[] = |
---|
| 634 | { |
---|
| 635 | "$end", "error", "$undefined", "COLON", "HEX", "OBRACE", "EBRACE", |
---|
| 636 | "TAG_RSA", "TAG_PUB", "TAG_PSK", "MODULUS", "PUBLIC_EXPONENT", |
---|
| 637 | "PRIVATE_EXPONENT", "PRIME1", "PRIME2", "EXPONENT1", "EXPONENT2", |
---|
| 638 | "COEFFICIENT", "ADDR4", "ADDR6", "ADDRANY", "SLASH", "NUMBER", "BASE64", |
---|
| 639 | "$accept", "statements", "statement", "rsa_statement", "addr", "addr4", |
---|
| 640 | "addr6", "prefix", "params", "param", YY_NULL |
---|
| 641 | }; |
---|
| 642 | #endif |
---|
| 643 | |
---|
| 644 | # ifdef YYPRINT |
---|
| 645 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
---|
| 646 | token YYLEX-NUM. */ |
---|
| 647 | static const yytype_uint16 yytoknum[] = |
---|
| 648 | { |
---|
| 649 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
---|
| 650 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
---|
| 651 | 275, 276, 277, 278 |
---|
| 652 | }; |
---|
| 653 | # endif |
---|
| 654 | |
---|
| 655 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
---|
| 656 | static const yytype_uint8 yyr1[] = |
---|
| 657 | { |
---|
| 658 | 0, 24, 25, 25, 26, 26, 26, 27, 27, 27, |
---|
| 659 | 28, 28, 28, 29, 30, 31, 31, 32, 32, 33, |
---|
| 660 | 33, 33, 33, 33, 33, 33, 33 |
---|
| 661 | }; |
---|
| 662 | |
---|
| 663 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
---|
| 664 | static const yytype_uint8 yyr2[] = |
---|
| 665 | { |
---|
| 666 | 0, 2, 2, 1, 4, 3, 2, 4, 2, 2, |
---|
| 667 | 1, 1, 1, 2, 2, 0, 2, 2, 1, 3, |
---|
| 668 | 3, 3, 3, 3, 3, 3, 3 |
---|
| 669 | }; |
---|
| 670 | |
---|
| 671 | /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. |
---|
| 672 | Performed when YYTABLE doesn't specify something else to do. Zero |
---|
| 673 | means the default is an error. */ |
---|
| 674 | static const yytype_uint8 yydefact[] = |
---|
| 675 | { |
---|
| 676 | 0, 0, 15, 15, 12, 0, 3, 0, 10, 11, |
---|
| 677 | 0, 0, 6, 0, 13, 14, 1, 2, 0, 0, |
---|
| 678 | 0, 9, 8, 16, 5, 0, 0, 0, 0, 0, |
---|
| 679 | 0, 0, 0, 0, 0, 18, 4, 0, 0, 0, |
---|
| 680 | 0, 0, 0, 0, 0, 7, 17, 19, 20, 21, |
---|
| 681 | 22, 23, 24, 25, 26 |
---|
| 682 | }; |
---|
| 683 | |
---|
| 684 | /* YYDEFGOTO[NTERM-NUM]. */ |
---|
| 685 | static const yytype_int8 yydefgoto[] = |
---|
| 686 | { |
---|
| 687 | -1, 5, 6, 12, 7, 8, 9, 14, 34, 35 |
---|
| 688 | }; |
---|
| 689 | |
---|
| 690 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
---|
| 691 | STATE-NUM. */ |
---|
| 692 | #define YYPACT_NINF -18 |
---|
| 693 | static const yytype_int8 yypact[] = |
---|
| 694 | { |
---|
| 695 | 4, -3, -15, -15, -18, 0, -18, 7, -18, -18, |
---|
| 696 | 6, -2, -18, -13, -18, -18, -18, -18, -3, 9, |
---|
| 697 | 30, -18, -18, -18, -18, -3, 10, 11, 12, 13, |
---|
| 698 | 14, 26, 27, 28, 22, -18, -18, 44, 45, 46, |
---|
| 699 | 47, 48, 49, 50, 51, -18, -18, -18, -18, -18, |
---|
| 700 | -18, -18, -18, -18, -18 |
---|
| 701 | }; |
---|
| 702 | |
---|
| 703 | /* YYPGOTO[NTERM-NUM]. */ |
---|
| 704 | static const yytype_int8 yypgoto[] = |
---|
| 705 | { |
---|
| 706 | -18, -18, 52, -17, 53, -18, -18, 55, -18, 25 |
---|
| 707 | }; |
---|
| 708 | |
---|
| 709 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
---|
| 710 | positive, shift that token. If negative, reduce the rule which |
---|
| 711 | number is the opposite. If YYTABLE_NINF, syntax error. */ |
---|
| 712 | #define YYTABLE_NINF -1 |
---|
| 713 | static const yytype_uint8 yytable[] = |
---|
| 714 | { |
---|
| 715 | 16, 24, 21, 1, 10, 11, 13, 1, 36, 23, |
---|
| 716 | 18, 20, 25, 37, 38, 39, 40, 41, 2, 3, |
---|
| 717 | 4, 22, 2, 3, 4, 2, 3, 4, 45, 42, |
---|
| 718 | 43, 44, 26, 27, 28, 29, 30, 31, 32, 33, |
---|
| 719 | 26, 27, 28, 29, 30, 31, 32, 33, 47, 48, |
---|
| 720 | 49, 50, 51, 52, 53, 54, 0, 17, 15, 46, |
---|
| 721 | 19 |
---|
| 722 | }; |
---|
| 723 | |
---|
| 724 | #define yypact_value_is_default(yystate) \ |
---|
| 725 | ((yystate) == (-18)) |
---|
| 726 | |
---|
| 727 | #define yytable_value_is_error(yytable_value) \ |
---|
| 728 | YYID (0) |
---|
| 729 | |
---|
| 730 | static const yytype_int8 yycheck[] = |
---|
| 731 | { |
---|
| 732 | 0, 18, 4, 3, 7, 8, 21, 3, 25, 22, |
---|
| 733 | 3, 5, 3, 3, 3, 3, 3, 3, 18, 19, |
---|
| 734 | 20, 23, 18, 19, 20, 18, 19, 20, 6, 3, |
---|
| 735 | 3, 3, 10, 11, 12, 13, 14, 15, 16, 17, |
---|
| 736 | 10, 11, 12, 13, 14, 15, 16, 17, 4, 4, |
---|
| 737 | 4, 4, 4, 4, 4, 4, -1, 5, 3, 34, |
---|
| 738 | 7 |
---|
| 739 | }; |
---|
| 740 | |
---|
| 741 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
---|
| 742 | symbol of state STATE-NUM. */ |
---|
| 743 | static const yytype_uint8 yystos[] = |
---|
| 744 | { |
---|
| 745 | 0, 3, 18, 19, 20, 25, 26, 28, 29, 30, |
---|
| 746 | 7, 8, 27, 21, 31, 31, 0, 26, 3, 28, |
---|
| 747 | 5, 4, 23, 22, 27, 3, 10, 11, 12, 13, |
---|
| 748 | 14, 15, 16, 17, 32, 33, 27, 3, 3, 3, |
---|
| 749 | 3, 3, 3, 3, 3, 6, 33, 4, 4, 4, |
---|
| 750 | 4, 4, 4, 4, 4 |
---|
| 751 | }; |
---|
| 752 | |
---|
| 753 | #define yyerrok (yyerrstatus = 0) |
---|
| 754 | #define yyclearin (yychar = YYEMPTY) |
---|
| 755 | #define YYEMPTY (-2) |
---|
| 756 | #define YYEOF 0 |
---|
| 757 | |
---|
| 758 | #define YYACCEPT goto yyacceptlab |
---|
| 759 | #define YYABORT goto yyabortlab |
---|
| 760 | #define YYERROR goto yyerrorlab |
---|
| 761 | |
---|
| 762 | |
---|
| 763 | /* Like YYERROR except do call yyerror. This remains here temporarily |
---|
| 764 | to ease the transition to the new meaning of YYERROR, for GCC. |
---|
| 765 | Once GCC version 2 has supplanted version 1, this can go. However, |
---|
| 766 | YYFAIL appears to be in use. Nevertheless, it is formally deprecated |
---|
| 767 | in Bison 2.4.2's NEWS entry, where a plan to phase it out is |
---|
| 768 | discussed. */ |
---|
| 769 | |
---|
| 770 | #define YYFAIL goto yyerrlab |
---|
| 771 | #if defined YYFAIL |
---|
| 772 | /* This is here to suppress warnings from the GCC cpp's |
---|
| 773 | -Wunused-macros. Normally we don't worry about that warning, but |
---|
| 774 | some users do, and we want to make it easy for users to remove |
---|
| 775 | YYFAIL uses, which will produce warnings from Bison 2.5. */ |
---|
| 776 | #endif |
---|
| 777 | |
---|
| 778 | #define YYRECOVERING() (!!yyerrstatus) |
---|
| 779 | |
---|
| 780 | #define YYBACKUP(Token, Value) \ |
---|
| 781 | do \ |
---|
| 782 | if (yychar == YYEMPTY) \ |
---|
| 783 | { \ |
---|
| 784 | yychar = (Token); \ |
---|
| 785 | yylval = (Value); \ |
---|
| 786 | YYPOPSTACK (yylen); \ |
---|
| 787 | yystate = *yyssp; \ |
---|
| 788 | goto yybackup; \ |
---|
| 789 | } \ |
---|
| 790 | else \ |
---|
| 791 | { \ |
---|
| 792 | yyerror (YY_("syntax error: cannot back up")); \ |
---|
| 793 | YYERROR; \ |
---|
| 794 | } \ |
---|
| 795 | while (YYID (0)) |
---|
| 796 | |
---|
| 797 | |
---|
| 798 | #define YYTERROR 1 |
---|
| 799 | #define YYERRCODE 256 |
---|
| 800 | |
---|
| 801 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
---|
| 802 | If N is 0, then set CURRENT to the empty location which ends |
---|
| 803 | the previous symbol: RHS[0] (always defined). */ |
---|
| 804 | |
---|
| 805 | #ifndef YYLLOC_DEFAULT |
---|
| 806 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
---|
| 807 | do \ |
---|
| 808 | if (YYID (N)) \ |
---|
| 809 | { \ |
---|
| 810 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
---|
| 811 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
---|
| 812 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
---|
| 813 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
---|
| 814 | } \ |
---|
| 815 | else \ |
---|
| 816 | { \ |
---|
| 817 | (Current).first_line = (Current).last_line = \ |
---|
| 818 | YYRHSLOC (Rhs, 0).last_line; \ |
---|
| 819 | (Current).first_column = (Current).last_column = \ |
---|
| 820 | YYRHSLOC (Rhs, 0).last_column; \ |
---|
| 821 | } \ |
---|
| 822 | while (YYID (0)) |
---|
| 823 | #endif |
---|
| 824 | |
---|
| 825 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
---|
| 826 | |
---|
| 827 | |
---|
| 828 | |
---|
| 829 | /* This macro is provided for backward compatibility. */ |
---|
| 830 | |
---|
| 831 | #ifndef YY_LOCATION_PRINT |
---|
| 832 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
---|
| 833 | #endif |
---|
| 834 | |
---|
| 835 | |
---|
| 836 | /* YYLEX -- calling `yylex' with the right arguments. */ |
---|
| 837 | |
---|
| 838 | #ifdef YYLEX_PARAM |
---|
| 839 | # define YYLEX yylex (YYLEX_PARAM) |
---|
| 840 | #else |
---|
| 841 | # define YYLEX yylex () |
---|
| 842 | #endif |
---|
| 843 | |
---|
| 844 | /* Enable debugging if requested. */ |
---|
| 845 | #if YYDEBUG |
---|
| 846 | |
---|
| 847 | # ifndef YYFPRINTF |
---|
| 848 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
---|
| 849 | # define YYFPRINTF fprintf |
---|
| 850 | # endif |
---|
| 851 | |
---|
| 852 | # define YYDPRINTF(Args) \ |
---|
| 853 | do { \ |
---|
| 854 | if (yydebug) \ |
---|
| 855 | YYFPRINTF Args; \ |
---|
| 856 | } while (YYID (0)) |
---|
| 857 | |
---|
| 858 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
---|
| 859 | do { \ |
---|
| 860 | if (yydebug) \ |
---|
| 861 | { \ |
---|
| 862 | YYFPRINTF (stderr, "%s ", Title); \ |
---|
| 863 | yy_symbol_print (stderr, \ |
---|
| 864 | Type, Value); \ |
---|
| 865 | YYFPRINTF (stderr, "\n"); \ |
---|
| 866 | } \ |
---|
| 867 | } while (YYID (0)) |
---|
| 868 | |
---|
| 869 | |
---|
| 870 | /*--------------------------------. |
---|
| 871 | | Print this symbol on YYOUTPUT. | |
---|
| 872 | `--------------------------------*/ |
---|
| 873 | |
---|
| 874 | /*ARGSUSED*/ |
---|
| 875 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 876 | || defined __cplusplus || defined _MSC_VER) |
---|
| 877 | static void |
---|
| 878 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
---|
| 879 | #else |
---|
| 880 | static void |
---|
| 881 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) |
---|
| 882 | FILE *yyoutput; |
---|
| 883 | int yytype; |
---|
| 884 | YYSTYPE const * const yyvaluep; |
---|
| 885 | #endif |
---|
| 886 | { |
---|
| 887 | FILE *yyo = yyoutput; |
---|
| 888 | YYUSE (yyo); |
---|
| 889 | if (!yyvaluep) |
---|
| 890 | return; |
---|
| 891 | # ifdef YYPRINT |
---|
| 892 | if (yytype < YYNTOKENS) |
---|
| 893 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
---|
| 894 | # else |
---|
| 895 | YYUSE (yyoutput); |
---|
| 896 | # endif |
---|
| 897 | switch (yytype) |
---|
| 898 | { |
---|
| 899 | default: |
---|
| 900 | break; |
---|
| 901 | } |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | |
---|
| 905 | /*--------------------------------. |
---|
| 906 | | Print this symbol on YYOUTPUT. | |
---|
| 907 | `--------------------------------*/ |
---|
| 908 | |
---|
| 909 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 910 | || defined __cplusplus || defined _MSC_VER) |
---|
| 911 | static void |
---|
| 912 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
---|
| 913 | #else |
---|
| 914 | static void |
---|
| 915 | yy_symbol_print (yyoutput, yytype, yyvaluep) |
---|
| 916 | FILE *yyoutput; |
---|
| 917 | int yytype; |
---|
| 918 | YYSTYPE const * const yyvaluep; |
---|
| 919 | #endif |
---|
| 920 | { |
---|
| 921 | if (yytype < YYNTOKENS) |
---|
| 922 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
---|
| 923 | else |
---|
| 924 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
---|
| 925 | |
---|
| 926 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
---|
| 927 | YYFPRINTF (yyoutput, ")"); |
---|
| 928 | } |
---|
| 929 | |
---|
| 930 | /*------------------------------------------------------------------. |
---|
| 931 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
---|
| 932 | | TOP (included). | |
---|
| 933 | `------------------------------------------------------------------*/ |
---|
| 934 | |
---|
| 935 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 936 | || defined __cplusplus || defined _MSC_VER) |
---|
| 937 | static void |
---|
| 938 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) |
---|
| 939 | #else |
---|
| 940 | static void |
---|
| 941 | yy_stack_print (yybottom, yytop) |
---|
| 942 | yytype_int16 *yybottom; |
---|
| 943 | yytype_int16 *yytop; |
---|
| 944 | #endif |
---|
| 945 | { |
---|
| 946 | YYFPRINTF (stderr, "Stack now"); |
---|
| 947 | for (; yybottom <= yytop; yybottom++) |
---|
| 948 | { |
---|
| 949 | int yybot = *yybottom; |
---|
| 950 | YYFPRINTF (stderr, " %d", yybot); |
---|
| 951 | } |
---|
| 952 | YYFPRINTF (stderr, "\n"); |
---|
| 953 | } |
---|
| 954 | |
---|
| 955 | # define YY_STACK_PRINT(Bottom, Top) \ |
---|
| 956 | do { \ |
---|
| 957 | if (yydebug) \ |
---|
| 958 | yy_stack_print ((Bottom), (Top)); \ |
---|
| 959 | } while (YYID (0)) |
---|
| 960 | |
---|
| 961 | |
---|
| 962 | /*------------------------------------------------. |
---|
| 963 | | Report that the YYRULE is going to be reduced. | |
---|
| 964 | `------------------------------------------------*/ |
---|
| 965 | |
---|
| 966 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 967 | || defined __cplusplus || defined _MSC_VER) |
---|
| 968 | static void |
---|
| 969 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) |
---|
| 970 | #else |
---|
| 971 | static void |
---|
| 972 | yy_reduce_print (yyvsp, yyrule) |
---|
| 973 | YYSTYPE *yyvsp; |
---|
| 974 | int yyrule; |
---|
| 975 | #endif |
---|
| 976 | { |
---|
| 977 | int yynrhs = yyr2[yyrule]; |
---|
| 978 | int yyi; |
---|
| 979 | unsigned long int yylno = yyrline[yyrule]; |
---|
| 980 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
---|
| 981 | yyrule - 1, yylno); |
---|
| 982 | /* The symbols being reduced. */ |
---|
| 983 | for (yyi = 0; yyi < yynrhs; yyi++) |
---|
| 984 | { |
---|
| 985 | YYFPRINTF (stderr, " $%d = ", yyi + 1); |
---|
| 986 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
---|
| 987 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
---|
| 988 | ); |
---|
| 989 | YYFPRINTF (stderr, "\n"); |
---|
| 990 | } |
---|
| 991 | } |
---|
| 992 | |
---|
| 993 | # define YY_REDUCE_PRINT(Rule) \ |
---|
| 994 | do { \ |
---|
| 995 | if (yydebug) \ |
---|
| 996 | yy_reduce_print (yyvsp, Rule); \ |
---|
| 997 | } while (YYID (0)) |
---|
| 998 | |
---|
| 999 | /* Nonzero means print parse trace. It is left uninitialized so that |
---|
| 1000 | multiple parsers can coexist. */ |
---|
| 1001 | int yydebug; |
---|
| 1002 | #else /* !YYDEBUG */ |
---|
| 1003 | # define YYDPRINTF(Args) |
---|
| 1004 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
---|
| 1005 | # define YY_STACK_PRINT(Bottom, Top) |
---|
| 1006 | # define YY_REDUCE_PRINT(Rule) |
---|
| 1007 | #endif /* !YYDEBUG */ |
---|
| 1008 | |
---|
| 1009 | |
---|
| 1010 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
---|
| 1011 | #ifndef YYINITDEPTH |
---|
| 1012 | # define YYINITDEPTH 200 |
---|
| 1013 | #endif |
---|
| 1014 | |
---|
| 1015 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
---|
| 1016 | if the built-in stack extension method is used). |
---|
| 1017 | |
---|
| 1018 | Do not make this value too large; the results are undefined if |
---|
| 1019 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
---|
| 1020 | evaluated with infinite-precision integer arithmetic. */ |
---|
| 1021 | |
---|
| 1022 | #ifndef YYMAXDEPTH |
---|
| 1023 | # define YYMAXDEPTH 10000 |
---|
| 1024 | #endif |
---|
| 1025 | |
---|
| 1026 | |
---|
| 1027 | #if YYERROR_VERBOSE |
---|
| 1028 | |
---|
| 1029 | # ifndef yystrlen |
---|
| 1030 | # if defined __GLIBC__ && defined _STRING_H |
---|
| 1031 | # define yystrlen strlen |
---|
| 1032 | # else |
---|
| 1033 | /* Return the length of YYSTR. */ |
---|
| 1034 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 1035 | || defined __cplusplus || defined _MSC_VER) |
---|
| 1036 | static YYSIZE_T |
---|
| 1037 | yystrlen (const char *yystr) |
---|
| 1038 | #else |
---|
| 1039 | static YYSIZE_T |
---|
| 1040 | yystrlen (yystr) |
---|
| 1041 | const char *yystr; |
---|
| 1042 | #endif |
---|
| 1043 | { |
---|
| 1044 | YYSIZE_T yylen; |
---|
| 1045 | for (yylen = 0; yystr[yylen]; yylen++) |
---|
| 1046 | continue; |
---|
| 1047 | return yylen; |
---|
| 1048 | } |
---|
| 1049 | # endif |
---|
| 1050 | # endif |
---|
| 1051 | |
---|
| 1052 | # ifndef yystpcpy |
---|
| 1053 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
---|
| 1054 | # define yystpcpy stpcpy |
---|
| 1055 | # else |
---|
| 1056 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
---|
| 1057 | YYDEST. */ |
---|
| 1058 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 1059 | || defined __cplusplus || defined _MSC_VER) |
---|
| 1060 | static char * |
---|
| 1061 | yystpcpy (char *yydest, const char *yysrc) |
---|
| 1062 | #else |
---|
| 1063 | static char * |
---|
| 1064 | yystpcpy (yydest, yysrc) |
---|
| 1065 | char *yydest; |
---|
| 1066 | const char *yysrc; |
---|
| 1067 | #endif |
---|
| 1068 | { |
---|
| 1069 | char *yyd = yydest; |
---|
| 1070 | const char *yys = yysrc; |
---|
| 1071 | |
---|
| 1072 | while ((*yyd++ = *yys++) != '\0') |
---|
| 1073 | continue; |
---|
| 1074 | |
---|
| 1075 | return yyd - 1; |
---|
| 1076 | } |
---|
| 1077 | # endif |
---|
| 1078 | # endif |
---|
| 1079 | |
---|
| 1080 | # ifndef yytnamerr |
---|
| 1081 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
---|
| 1082 | quotes and backslashes, so that it's suitable for yyerror. The |
---|
| 1083 | heuristic is that double-quoting is unnecessary unless the string |
---|
| 1084 | contains an apostrophe, a comma, or backslash (other than |
---|
| 1085 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
---|
| 1086 | null, do not copy; instead, return the length of what the result |
---|
| 1087 | would have been. */ |
---|
| 1088 | static YYSIZE_T |
---|
| 1089 | yytnamerr (char *yyres, const char *yystr) |
---|
| 1090 | { |
---|
| 1091 | if (*yystr == '"') |
---|
| 1092 | { |
---|
| 1093 | YYSIZE_T yyn = 0; |
---|
| 1094 | char const *yyp = yystr; |
---|
| 1095 | |
---|
| 1096 | for (;;) |
---|
| 1097 | switch (*++yyp) |
---|
| 1098 | { |
---|
| 1099 | case '\'': |
---|
| 1100 | case ',': |
---|
| 1101 | goto do_not_strip_quotes; |
---|
| 1102 | |
---|
| 1103 | case '\\': |
---|
| 1104 | if (*++yyp != '\\') |
---|
| 1105 | goto do_not_strip_quotes; |
---|
| 1106 | /* Fall through. */ |
---|
| 1107 | default: |
---|
| 1108 | if (yyres) |
---|
| 1109 | yyres[yyn] = *yyp; |
---|
| 1110 | yyn++; |
---|
| 1111 | break; |
---|
| 1112 | |
---|
| 1113 | case '"': |
---|
| 1114 | if (yyres) |
---|
| 1115 | yyres[yyn] = '\0'; |
---|
| 1116 | return yyn; |
---|
| 1117 | } |
---|
| 1118 | do_not_strip_quotes: ; |
---|
| 1119 | } |
---|
| 1120 | |
---|
| 1121 | if (! yyres) |
---|
| 1122 | return yystrlen (yystr); |
---|
| 1123 | |
---|
| 1124 | return yystpcpy (yyres, yystr) - yyres; |
---|
| 1125 | } |
---|
| 1126 | # endif |
---|
| 1127 | |
---|
| 1128 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message |
---|
| 1129 | about the unexpected token YYTOKEN for the state stack whose top is |
---|
| 1130 | YYSSP. |
---|
| 1131 | |
---|
| 1132 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is |
---|
| 1133 | not large enough to hold the message. In that case, also set |
---|
| 1134 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the |
---|
| 1135 | required number of bytes is too large to store. */ |
---|
| 1136 | static int |
---|
| 1137 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, |
---|
| 1138 | yytype_int16 *yyssp, int yytoken) |
---|
| 1139 | { |
---|
| 1140 | YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); |
---|
| 1141 | YYSIZE_T yysize = yysize0; |
---|
| 1142 | YYSIZE_T yysize1; |
---|
| 1143 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
---|
| 1144 | /* Internationalized format string. */ |
---|
| 1145 | const char *yyformat = YY_NULL; |
---|
| 1146 | /* Arguments of yyformat. */ |
---|
| 1147 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
---|
| 1148 | /* Number of reported tokens (one for the "unexpected", one per |
---|
| 1149 | "expected"). */ |
---|
| 1150 | int yycount = 0; |
---|
| 1151 | |
---|
| 1152 | /* There are many possibilities here to consider: |
---|
| 1153 | - Assume YYFAIL is not used. It's too flawed to consider. See |
---|
| 1154 | <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> |
---|
| 1155 | for details. YYERROR is fine as it does not invoke this |
---|
| 1156 | function. |
---|
| 1157 | - If this state is a consistent state with a default action, then |
---|
| 1158 | the only way this function was invoked is if the default action |
---|
| 1159 | is an error action. In that case, don't check for expected |
---|
| 1160 | tokens because there are none. |
---|
| 1161 | - The only way there can be no lookahead present (in yychar) is if |
---|
| 1162 | this state is a consistent state with a default action. Thus, |
---|
| 1163 | detecting the absence of a lookahead is sufficient to determine |
---|
| 1164 | that there is no unexpected or expected token to report. In that |
---|
| 1165 | case, just report a simple "syntax error". |
---|
| 1166 | - Don't assume there isn't a lookahead just because this state is a |
---|
| 1167 | consistent state with a default action. There might have been a |
---|
| 1168 | previous inconsistent state, consistent state with a non-default |
---|
| 1169 | action, or user semantic action that manipulated yychar. |
---|
| 1170 | - Of course, the expected token list depends on states to have |
---|
| 1171 | correct lookahead information, and it depends on the parser not |
---|
| 1172 | to perform extra reductions after fetching a lookahead from the |
---|
| 1173 | scanner and before detecting a syntax error. Thus, state merging |
---|
| 1174 | (from LALR or IELR) and default reductions corrupt the expected |
---|
| 1175 | token list. However, the list is correct for canonical LR with |
---|
| 1176 | one exception: it will still contain any token that will not be |
---|
| 1177 | accepted due to an error action in a later state. |
---|
| 1178 | */ |
---|
| 1179 | if (yytoken != YYEMPTY) |
---|
| 1180 | { |
---|
| 1181 | int yyn = yypact[*yyssp]; |
---|
| 1182 | yyarg[yycount++] = yytname[yytoken]; |
---|
| 1183 | if (!yypact_value_is_default (yyn)) |
---|
| 1184 | { |
---|
| 1185 | /* Start YYX at -YYN if negative to avoid negative indexes in |
---|
| 1186 | YYCHECK. In other words, skip the first -YYN actions for |
---|
| 1187 | this state because they are default actions. */ |
---|
| 1188 | int yyxbegin = yyn < 0 ? -yyn : 0; |
---|
| 1189 | /* Stay within bounds of both yycheck and yytname. */ |
---|
| 1190 | int yychecklim = YYLAST - yyn + 1; |
---|
| 1191 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
---|
| 1192 | int yyx; |
---|
| 1193 | |
---|
| 1194 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
---|
| 1195 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR |
---|
| 1196 | && !yytable_value_is_error (yytable[yyx + yyn])) |
---|
| 1197 | { |
---|
| 1198 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
---|
| 1199 | { |
---|
| 1200 | yycount = 1; |
---|
| 1201 | yysize = yysize0; |
---|
| 1202 | break; |
---|
| 1203 | } |
---|
| 1204 | yyarg[yycount++] = yytname[yyx]; |
---|
| 1205 | yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); |
---|
| 1206 | if (! (yysize <= yysize1 |
---|
| 1207 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
---|
| 1208 | return 2; |
---|
| 1209 | yysize = yysize1; |
---|
| 1210 | } |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | |
---|
| 1214 | switch (yycount) |
---|
| 1215 | { |
---|
| 1216 | # define YYCASE_(N, S) \ |
---|
| 1217 | case N: \ |
---|
| 1218 | yyformat = S; \ |
---|
| 1219 | break |
---|
| 1220 | YYCASE_(0, YY_("syntax error")); |
---|
| 1221 | YYCASE_(1, YY_("syntax error, unexpected %s")); |
---|
| 1222 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); |
---|
| 1223 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); |
---|
| 1224 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); |
---|
| 1225 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); |
---|
| 1226 | # undef YYCASE_ |
---|
| 1227 | } |
---|
| 1228 | |
---|
| 1229 | yysize1 = yysize + yystrlen (yyformat); |
---|
| 1230 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
---|
| 1231 | return 2; |
---|
| 1232 | yysize = yysize1; |
---|
| 1233 | |
---|
| 1234 | if (*yymsg_alloc < yysize) |
---|
| 1235 | { |
---|
| 1236 | *yymsg_alloc = 2 * yysize; |
---|
| 1237 | if (! (yysize <= *yymsg_alloc |
---|
| 1238 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) |
---|
| 1239 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; |
---|
| 1240 | return 1; |
---|
| 1241 | } |
---|
| 1242 | |
---|
| 1243 | /* Avoid sprintf, as that infringes on the user's name space. |
---|
| 1244 | Don't have undefined behavior even if the translation |
---|
| 1245 | produced a string with the wrong number of "%s"s. */ |
---|
| 1246 | { |
---|
| 1247 | char *yyp = *yymsg; |
---|
| 1248 | int yyi = 0; |
---|
| 1249 | while ((*yyp = *yyformat) != '\0') |
---|
| 1250 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) |
---|
| 1251 | { |
---|
| 1252 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
---|
| 1253 | yyformat += 2; |
---|
| 1254 | } |
---|
| 1255 | else |
---|
| 1256 | { |
---|
| 1257 | yyp++; |
---|
| 1258 | yyformat++; |
---|
| 1259 | } |
---|
| 1260 | } |
---|
| 1261 | return 0; |
---|
| 1262 | } |
---|
| 1263 | #endif /* YYERROR_VERBOSE */ |
---|
| 1264 | |
---|
| 1265 | /*-----------------------------------------------. |
---|
| 1266 | | Release the memory associated to this symbol. | |
---|
| 1267 | `-----------------------------------------------*/ |
---|
| 1268 | |
---|
| 1269 | /*ARGSUSED*/ |
---|
| 1270 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 1271 | || defined __cplusplus || defined _MSC_VER) |
---|
| 1272 | static void |
---|
| 1273 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
---|
| 1274 | #else |
---|
| 1275 | static void |
---|
| 1276 | yydestruct (yymsg, yytype, yyvaluep) |
---|
| 1277 | const char *yymsg; |
---|
| 1278 | int yytype; |
---|
| 1279 | YYSTYPE *yyvaluep; |
---|
| 1280 | #endif |
---|
| 1281 | { |
---|
| 1282 | YYUSE (yyvaluep); |
---|
| 1283 | |
---|
| 1284 | if (!yymsg) |
---|
| 1285 | yymsg = "Deleting"; |
---|
| 1286 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
---|
| 1287 | |
---|
| 1288 | switch (yytype) |
---|
| 1289 | { |
---|
| 1290 | |
---|
| 1291 | default: |
---|
| 1292 | break; |
---|
| 1293 | } |
---|
| 1294 | } |
---|
| 1295 | |
---|
| 1296 | |
---|
| 1297 | |
---|
| 1298 | |
---|
| 1299 | /* The lookahead symbol. */ |
---|
| 1300 | int yychar; |
---|
| 1301 | |
---|
| 1302 | /* The semantic value of the lookahead symbol. */ |
---|
| 1303 | YYSTYPE yylval; |
---|
| 1304 | |
---|
| 1305 | /* Number of syntax errors so far. */ |
---|
| 1306 | int yynerrs; |
---|
| 1307 | |
---|
| 1308 | |
---|
| 1309 | /*----------. |
---|
| 1310 | | yyparse. | |
---|
| 1311 | `----------*/ |
---|
| 1312 | |
---|
| 1313 | #ifdef YYPARSE_PARAM |
---|
| 1314 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 1315 | || defined __cplusplus || defined _MSC_VER) |
---|
| 1316 | int |
---|
| 1317 | yyparse (void *YYPARSE_PARAM) |
---|
| 1318 | #else |
---|
| 1319 | int |
---|
| 1320 | yyparse (YYPARSE_PARAM) |
---|
| 1321 | void *YYPARSE_PARAM; |
---|
| 1322 | #endif |
---|
| 1323 | #else /* ! YYPARSE_PARAM */ |
---|
| 1324 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
---|
| 1325 | || defined __cplusplus || defined _MSC_VER) |
---|
| 1326 | int |
---|
| 1327 | yyparse (void) |
---|
| 1328 | #else |
---|
| 1329 | int |
---|
| 1330 | yyparse () |
---|
| 1331 | |
---|
| 1332 | #endif |
---|
| 1333 | #endif |
---|
| 1334 | { |
---|
| 1335 | int yystate; |
---|
| 1336 | /* Number of tokens to shift before error messages enabled. */ |
---|
| 1337 | int yyerrstatus; |
---|
| 1338 | |
---|
| 1339 | /* The stacks and their tools: |
---|
| 1340 | `yyss': related to states. |
---|
| 1341 | `yyvs': related to semantic values. |
---|
| 1342 | |
---|
| 1343 | Refer to the stacks through separate pointers, to allow yyoverflow |
---|
| 1344 | to reallocate them elsewhere. */ |
---|
| 1345 | |
---|
| 1346 | /* The state stack. */ |
---|
| 1347 | yytype_int16 yyssa[YYINITDEPTH]; |
---|
| 1348 | yytype_int16 *yyss; |
---|
| 1349 | yytype_int16 *yyssp; |
---|
| 1350 | |
---|
| 1351 | /* The semantic value stack. */ |
---|
| 1352 | YYSTYPE yyvsa[YYINITDEPTH]; |
---|
| 1353 | YYSTYPE *yyvs; |
---|
| 1354 | YYSTYPE *yyvsp; |
---|
| 1355 | |
---|
| 1356 | YYSIZE_T yystacksize; |
---|
| 1357 | |
---|
| 1358 | int yyn; |
---|
| 1359 | int yyresult; |
---|
| 1360 | /* Lookahead token as an internal (translated) token number. */ |
---|
| 1361 | int yytoken; |
---|
| 1362 | /* The variables used to return semantic value and location from the |
---|
| 1363 | action routines. */ |
---|
| 1364 | YYSTYPE yyval; |
---|
| 1365 | |
---|
| 1366 | #if YYERROR_VERBOSE |
---|
| 1367 | /* Buffer for error messages, and its allocated size. */ |
---|
| 1368 | char yymsgbuf[128]; |
---|
| 1369 | char *yymsg = yymsgbuf; |
---|
| 1370 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
---|
| 1371 | #endif |
---|
| 1372 | |
---|
| 1373 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
---|
| 1374 | |
---|
| 1375 | /* The number of symbols on the RHS of the reduced rule. |
---|
| 1376 | Keep to zero when no symbol should be popped. */ |
---|
| 1377 | int yylen = 0; |
---|
| 1378 | |
---|
| 1379 | yytoken = 0; |
---|
| 1380 | yyss = yyssa; |
---|
| 1381 | yyvs = yyvsa; |
---|
| 1382 | yystacksize = YYINITDEPTH; |
---|
| 1383 | |
---|
| 1384 | YYDPRINTF ((stderr, "Starting parse\n")); |
---|
| 1385 | |
---|
| 1386 | yystate = 0; |
---|
| 1387 | yyerrstatus = 0; |
---|
| 1388 | yynerrs = 0; |
---|
| 1389 | yychar = YYEMPTY; /* Cause a token to be read. */ |
---|
| 1390 | |
---|
| 1391 | /* Initialize stack pointers. |
---|
| 1392 | Waste one element of value and location stack |
---|
| 1393 | so that they stay on the same level as the state stack. |
---|
| 1394 | The wasted elements are never initialized. */ |
---|
| 1395 | yyssp = yyss; |
---|
| 1396 | yyvsp = yyvs; |
---|
| 1397 | goto yysetstate; |
---|
| 1398 | |
---|
| 1399 | /*------------------------------------------------------------. |
---|
| 1400 | | yynewstate -- Push a new state, which is found in yystate. | |
---|
| 1401 | `------------------------------------------------------------*/ |
---|
| 1402 | yynewstate: |
---|
| 1403 | /* In all cases, when you get here, the value and location stacks |
---|
| 1404 | have just been pushed. So pushing a state here evens the stacks. */ |
---|
| 1405 | yyssp++; |
---|
| 1406 | |
---|
| 1407 | yysetstate: |
---|
| 1408 | *yyssp = yystate; |
---|
| 1409 | |
---|
| 1410 | if (yyss + yystacksize - 1 <= yyssp) |
---|
| 1411 | { |
---|
| 1412 | /* Get the current used size of the three stacks, in elements. */ |
---|
| 1413 | YYSIZE_T yysize = yyssp - yyss + 1; |
---|
| 1414 | |
---|
| 1415 | #ifdef yyoverflow |
---|
| 1416 | { |
---|
| 1417 | /* Give user a chance to reallocate the stack. Use copies of |
---|
| 1418 | these so that the &'s don't force the real ones into |
---|
| 1419 | memory. */ |
---|
| 1420 | YYSTYPE *yyvs1 = yyvs; |
---|
| 1421 | yytype_int16 *yyss1 = yyss; |
---|
| 1422 | |
---|
| 1423 | /* Each stack pointer address is followed by the size of the |
---|
| 1424 | data in use in that stack, in bytes. This used to be a |
---|
| 1425 | conditional around just the two extra args, but that might |
---|
| 1426 | be undefined if yyoverflow is a macro. */ |
---|
| 1427 | yyoverflow (YY_("memory exhausted"), |
---|
| 1428 | &yyss1, yysize * sizeof (*yyssp), |
---|
| 1429 | &yyvs1, yysize * sizeof (*yyvsp), |
---|
| 1430 | &yystacksize); |
---|
| 1431 | |
---|
| 1432 | yyss = yyss1; |
---|
| 1433 | yyvs = yyvs1; |
---|
| 1434 | } |
---|
| 1435 | #else /* no yyoverflow */ |
---|
| 1436 | # ifndef YYSTACK_RELOCATE |
---|
| 1437 | goto yyexhaustedlab; |
---|
| 1438 | # else |
---|
| 1439 | /* Extend the stack our own way. */ |
---|
| 1440 | if (YYMAXDEPTH <= yystacksize) |
---|
| 1441 | goto yyexhaustedlab; |
---|
| 1442 | yystacksize *= 2; |
---|
| 1443 | if (YYMAXDEPTH < yystacksize) |
---|
| 1444 | yystacksize = YYMAXDEPTH; |
---|
| 1445 | |
---|
| 1446 | { |
---|
| 1447 | yytype_int16 *yyss1 = yyss; |
---|
| 1448 | union yyalloc *yyptr = |
---|
| 1449 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
---|
| 1450 | if (! yyptr) |
---|
| 1451 | goto yyexhaustedlab; |
---|
| 1452 | YYSTACK_RELOCATE (yyss_alloc, yyss); |
---|
| 1453 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); |
---|
| 1454 | # undef YYSTACK_RELOCATE |
---|
| 1455 | if (yyss1 != yyssa) |
---|
| 1456 | YYSTACK_FREE (yyss1); |
---|
| 1457 | } |
---|
| 1458 | # endif |
---|
| 1459 | #endif /* no yyoverflow */ |
---|
| 1460 | |
---|
| 1461 | yyssp = yyss + yysize - 1; |
---|
| 1462 | yyvsp = yyvs + yysize - 1; |
---|
| 1463 | |
---|
| 1464 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
---|
| 1465 | (unsigned long int) yystacksize)); |
---|
| 1466 | |
---|
| 1467 | if (yyss + yystacksize - 1 <= yyssp) |
---|
| 1468 | YYABORT; |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
---|
| 1472 | |
---|
| 1473 | if (yystate == YYFINAL) |
---|
| 1474 | YYACCEPT; |
---|
| 1475 | |
---|
| 1476 | goto yybackup; |
---|
| 1477 | |
---|
| 1478 | /*-----------. |
---|
| 1479 | | yybackup. | |
---|
| 1480 | `-----------*/ |
---|
| 1481 | yybackup: |
---|
| 1482 | |
---|
| 1483 | /* Do appropriate processing given the current state. Read a |
---|
| 1484 | lookahead token if we need one and don't already have one. */ |
---|
| 1485 | |
---|
| 1486 | /* First try to decide what to do without reference to lookahead token. */ |
---|
| 1487 | yyn = yypact[yystate]; |
---|
| 1488 | if (yypact_value_is_default (yyn)) |
---|
| 1489 | goto yydefault; |
---|
| 1490 | |
---|
| 1491 | /* Not known => get a lookahead token if don't already have one. */ |
---|
| 1492 | |
---|
| 1493 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
---|
| 1494 | if (yychar == YYEMPTY) |
---|
| 1495 | { |
---|
| 1496 | YYDPRINTF ((stderr, "Reading a token: ")); |
---|
| 1497 | yychar = YYLEX; |
---|
| 1498 | } |
---|
| 1499 | |
---|
| 1500 | if (yychar <= YYEOF) |
---|
| 1501 | { |
---|
| 1502 | yychar = yytoken = YYEOF; |
---|
| 1503 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
---|
| 1504 | } |
---|
| 1505 | else |
---|
| 1506 | { |
---|
| 1507 | yytoken = YYTRANSLATE (yychar); |
---|
| 1508 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
---|
| 1509 | } |
---|
| 1510 | |
---|
| 1511 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
---|
| 1512 | detect an error, take that action. */ |
---|
| 1513 | yyn += yytoken; |
---|
| 1514 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
---|
| 1515 | goto yydefault; |
---|
| 1516 | yyn = yytable[yyn]; |
---|
| 1517 | if (yyn <= 0) |
---|
| 1518 | { |
---|
| 1519 | if (yytable_value_is_error (yyn)) |
---|
| 1520 | goto yyerrlab; |
---|
| 1521 | yyn = -yyn; |
---|
| 1522 | goto yyreduce; |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | /* Count tokens shifted since error; after three, turn off error |
---|
| 1526 | status. */ |
---|
| 1527 | if (yyerrstatus) |
---|
| 1528 | yyerrstatus--; |
---|
| 1529 | |
---|
| 1530 | /* Shift the lookahead token. */ |
---|
| 1531 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
---|
| 1532 | |
---|
| 1533 | /* Discard the shifted token. */ |
---|
| 1534 | yychar = YYEMPTY; |
---|
| 1535 | |
---|
| 1536 | yystate = yyn; |
---|
| 1537 | *++yyvsp = yylval; |
---|
| 1538 | |
---|
| 1539 | goto yynewstate; |
---|
| 1540 | |
---|
| 1541 | |
---|
| 1542 | /*-----------------------------------------------------------. |
---|
| 1543 | | yydefault -- do the default action for the current state. | |
---|
| 1544 | `-----------------------------------------------------------*/ |
---|
| 1545 | yydefault: |
---|
| 1546 | yyn = yydefact[yystate]; |
---|
| 1547 | if (yyn == 0) |
---|
| 1548 | goto yyerrlab; |
---|
| 1549 | goto yyreduce; |
---|
| 1550 | |
---|
| 1551 | |
---|
| 1552 | /*-----------------------------. |
---|
| 1553 | | yyreduce -- Do a reduction. | |
---|
| 1554 | `-----------------------------*/ |
---|
| 1555 | yyreduce: |
---|
| 1556 | /* yyn is the number of a rule to reduce with. */ |
---|
| 1557 | yylen = yyr2[yyn]; |
---|
| 1558 | |
---|
| 1559 | /* If YYLEN is nonzero, implement the default value of the action: |
---|
| 1560 | `$$ = $1'. |
---|
| 1561 | |
---|
| 1562 | Otherwise, the following line sets YYVAL to garbage. |
---|
| 1563 | This behavior is undocumented and Bison |
---|
| 1564 | users should not rely upon it. Assigning to YYVAL |
---|
| 1565 | unconditionally makes the parser a bit smaller, and it avoids a |
---|
| 1566 | GCC warning that YYVAL may be used uninitialized. */ |
---|
| 1567 | yyval = yyvsp[1-yylen]; |
---|
| 1568 | |
---|
| 1569 | |
---|
| 1570 | YY_REDUCE_PRINT (yyn); |
---|
| 1571 | switch (yyn) |
---|
| 1572 | { |
---|
| 1573 | case 4: |
---|
| 1574 | /* Line 1787 of yacc.c */ |
---|
| 1575 | #line 161 "prsa_par.y" |
---|
| 1576 | { |
---|
| 1577 | rsa_key_insert(prsa_cur_list, (yyvsp[(1) - (4)].naddr), (yyvsp[(2) - (4)].naddr), (yyvsp[(4) - (4)].rsa)); |
---|
| 1578 | } |
---|
| 1579 | break; |
---|
| 1580 | |
---|
| 1581 | case 5: |
---|
| 1582 | /* Line 1787 of yacc.c */ |
---|
| 1583 | #line 165 "prsa_par.y" |
---|
| 1584 | { |
---|
| 1585 | rsa_key_insert(prsa_cur_list, NULL, (yyvsp[(1) - (3)].naddr), (yyvsp[(3) - (3)].rsa)); |
---|
| 1586 | } |
---|
| 1587 | break; |
---|
| 1588 | |
---|
| 1589 | case 6: |
---|
| 1590 | /* Line 1787 of yacc.c */ |
---|
| 1591 | #line 169 "prsa_par.y" |
---|
| 1592 | { |
---|
| 1593 | rsa_key_insert(prsa_cur_list, NULL, NULL, (yyvsp[(2) - (2)].rsa)); |
---|
| 1594 | } |
---|
| 1595 | break; |
---|
| 1596 | |
---|
| 1597 | case 7: |
---|
| 1598 | /* Line 1787 of yacc.c */ |
---|
| 1599 | #line 176 "prsa_par.y" |
---|
| 1600 | { |
---|
| 1601 | if (prsa_cur_type == RSA_TYPE_PUBLIC) { |
---|
| 1602 | prsawarning("Using private key for public key purpose.\n"); |
---|
| 1603 | if (!rsa_cur->n || !rsa_cur->e) { |
---|
| 1604 | prsaerror("Incomplete key. Mandatory parameters are missing!\n"); |
---|
| 1605 | YYABORT; |
---|
| 1606 | } |
---|
| 1607 | } |
---|
| 1608 | else { |
---|
| 1609 | if (!rsa_cur->n || !rsa_cur->e || !rsa_cur->d) { |
---|
| 1610 | prsaerror("Incomplete key. Mandatory parameters are missing!\n"); |
---|
| 1611 | YYABORT; |
---|
| 1612 | } |
---|
| 1613 | if (!rsa_cur->p || !rsa_cur->q || !rsa_cur->dmp1 |
---|
| 1614 | || !rsa_cur->dmq1 || !rsa_cur->iqmp) { |
---|
| 1615 | if (rsa_cur->p) BN_clear_free(rsa_cur->p); |
---|
| 1616 | if (rsa_cur->q) BN_clear_free(rsa_cur->q); |
---|
| 1617 | if (rsa_cur->dmp1) BN_clear_free(rsa_cur->dmp1); |
---|
| 1618 | if (rsa_cur->dmq1) BN_clear_free(rsa_cur->dmq1); |
---|
| 1619 | if (rsa_cur->iqmp) BN_clear_free(rsa_cur->iqmp); |
---|
| 1620 | |
---|
| 1621 | rsa_cur->p = NULL; |
---|
| 1622 | rsa_cur->q = NULL; |
---|
| 1623 | rsa_cur->dmp1 = NULL; |
---|
| 1624 | rsa_cur->dmq1 = NULL; |
---|
| 1625 | rsa_cur->iqmp = NULL; |
---|
| 1626 | } |
---|
| 1627 | } |
---|
| 1628 | (yyval.rsa) = rsa_cur; |
---|
| 1629 | rsa_cur = RSA_new(); |
---|
| 1630 | } |
---|
| 1631 | break; |
---|
| 1632 | |
---|
| 1633 | case 8: |
---|
| 1634 | /* Line 1787 of yacc.c */ |
---|
| 1635 | #line 208 "prsa_par.y" |
---|
| 1636 | { |
---|
| 1637 | if (prsa_cur_type == RSA_TYPE_PRIVATE) { |
---|
| 1638 | prsaerror("Public key in private-key file!\n"); |
---|
| 1639 | YYABORT; |
---|
| 1640 | } |
---|
| 1641 | (yyval.rsa) = base64_pubkey2rsa((yyvsp[(2) - (2)].chr)); |
---|
| 1642 | free((yyvsp[(2) - (2)].chr)); |
---|
| 1643 | } |
---|
| 1644 | break; |
---|
| 1645 | |
---|
| 1646 | case 9: |
---|
| 1647 | /* Line 1787 of yacc.c */ |
---|
| 1648 | #line 217 "prsa_par.y" |
---|
| 1649 | { |
---|
| 1650 | if (prsa_cur_type == RSA_TYPE_PRIVATE) { |
---|
| 1651 | prsaerror("Public key in private-key file!\n"); |
---|
| 1652 | YYABORT; |
---|
| 1653 | } |
---|
| 1654 | (yyval.rsa) = bignum_pubkey2rsa((yyvsp[(2) - (2)].bn)); |
---|
| 1655 | } |
---|
| 1656 | break; |
---|
| 1657 | |
---|
| 1658 | case 12: |
---|
| 1659 | /* Line 1787 of yacc.c */ |
---|
| 1660 | #line 230 "prsa_par.y" |
---|
| 1661 | { |
---|
| 1662 | (yyval.naddr) = NULL; |
---|
| 1663 | } |
---|
| 1664 | break; |
---|
| 1665 | |
---|
| 1666 | case 13: |
---|
| 1667 | /* Line 1787 of yacc.c */ |
---|
| 1668 | #line 237 "prsa_par.y" |
---|
| 1669 | { |
---|
| 1670 | int err; |
---|
| 1671 | struct sockaddr_in *sap; |
---|
| 1672 | struct addrinfo hints, *res; |
---|
| 1673 | |
---|
| 1674 | if ((yyvsp[(2) - (2)].num) == -1) (yyvsp[(2) - (2)].num) = 32; |
---|
| 1675 | if ((yyvsp[(2) - (2)].num) < 0 || (yyvsp[(2) - (2)].num) > 32) { |
---|
| 1676 | prsaerror ("Invalid IPv4 prefix\n"); |
---|
| 1677 | YYABORT; |
---|
| 1678 | } |
---|
| 1679 | (yyval.naddr) = calloc (sizeof(struct netaddr), 1); |
---|
| 1680 | (yyval.naddr)->prefix = (yyvsp[(2) - (2)].num); |
---|
| 1681 | sap = (struct sockaddr_in *)(&(yyval.naddr)->sa); |
---|
| 1682 | memset(&hints, 0, sizeof(hints)); |
---|
| 1683 | hints.ai_family = AF_INET; |
---|
| 1684 | hints.ai_flags = AI_NUMERICHOST; |
---|
| 1685 | err = getaddrinfo((yyvsp[(1) - (2)].chr), NULL, &hints, &res); |
---|
| 1686 | if (err < 0) { |
---|
| 1687 | prsaerror("getaddrinfo(%s): %s\n", (yyvsp[(1) - (2)].chr), gai_strerror(err)); |
---|
| 1688 | YYABORT; |
---|
| 1689 | } |
---|
| 1690 | memcpy(sap, res->ai_addr, res->ai_addrlen); |
---|
| 1691 | freeaddrinfo(res); |
---|
| 1692 | free((yyvsp[(1) - (2)].chr)); |
---|
| 1693 | } |
---|
| 1694 | break; |
---|
| 1695 | |
---|
| 1696 | case 14: |
---|
| 1697 | /* Line 1787 of yacc.c */ |
---|
| 1698 | #line 266 "prsa_par.y" |
---|
| 1699 | { |
---|
| 1700 | int err; |
---|
| 1701 | struct sockaddr_in6 *sap; |
---|
| 1702 | struct addrinfo hints, *res; |
---|
| 1703 | |
---|
| 1704 | if ((yyvsp[(2) - (2)].num) == -1) (yyvsp[(2) - (2)].num) = 128; |
---|
| 1705 | if ((yyvsp[(2) - (2)].num) < 0 || (yyvsp[(2) - (2)].num) > 128) { |
---|
| 1706 | prsaerror ("Invalid IPv6 prefix\n"); |
---|
| 1707 | YYABORT; |
---|
| 1708 | } |
---|
| 1709 | (yyval.naddr) = calloc (sizeof(struct netaddr), 1); |
---|
| 1710 | (yyval.naddr)->prefix = (yyvsp[(2) - (2)].num); |
---|
| 1711 | sap = (struct sockaddr_in6 *)(&(yyval.naddr)->sa); |
---|
| 1712 | memset(&hints, 0, sizeof(hints)); |
---|
| 1713 | hints.ai_family = AF_INET6; |
---|
| 1714 | hints.ai_flags = AI_NUMERICHOST; |
---|
| 1715 | err = getaddrinfo((yyvsp[(1) - (2)].chr), NULL, &hints, &res); |
---|
| 1716 | if (err < 0) { |
---|
| 1717 | prsaerror("getaddrinfo(%s): %s\n", (yyvsp[(1) - (2)].chr), gai_strerror(err)); |
---|
| 1718 | YYABORT; |
---|
| 1719 | } |
---|
| 1720 | memcpy(sap, res->ai_addr, res->ai_addrlen); |
---|
| 1721 | freeaddrinfo(res); |
---|
| 1722 | free((yyvsp[(1) - (2)].chr)); |
---|
| 1723 | } |
---|
| 1724 | break; |
---|
| 1725 | |
---|
| 1726 | case 15: |
---|
| 1727 | /* Line 1787 of yacc.c */ |
---|
| 1728 | #line 294 "prsa_par.y" |
---|
| 1729 | { (yyval.num) = -1; } |
---|
| 1730 | break; |
---|
| 1731 | |
---|
| 1732 | case 16: |
---|
| 1733 | /* Line 1787 of yacc.c */ |
---|
| 1734 | #line 295 "prsa_par.y" |
---|
| 1735 | { (yyval.num) = (yyvsp[(2) - (2)].num); } |
---|
| 1736 | break; |
---|
| 1737 | |
---|
| 1738 | case 19: |
---|
| 1739 | /* Line 1787 of yacc.c */ |
---|
| 1740 | #line 304 "prsa_par.y" |
---|
| 1741 | { if (!rsa_cur->n) rsa_cur->n = (yyvsp[(3) - (3)].bn); else { prsaerror ("Modulus already defined\n"); YYABORT; } } |
---|
| 1742 | break; |
---|
| 1743 | |
---|
| 1744 | case 20: |
---|
| 1745 | /* Line 1787 of yacc.c */ |
---|
| 1746 | #line 306 "prsa_par.y" |
---|
| 1747 | { if (!rsa_cur->e) rsa_cur->e = (yyvsp[(3) - (3)].bn); else { prsaerror ("PublicExponent already defined\n"); YYABORT; } } |
---|
| 1748 | break; |
---|
| 1749 | |
---|
| 1750 | case 21: |
---|
| 1751 | /* Line 1787 of yacc.c */ |
---|
| 1752 | #line 308 "prsa_par.y" |
---|
| 1753 | { if (!rsa_cur->d) rsa_cur->d = (yyvsp[(3) - (3)].bn); else { prsaerror ("PrivateExponent already defined\n"); YYABORT; } } |
---|
| 1754 | break; |
---|
| 1755 | |
---|
| 1756 | case 22: |
---|
| 1757 | /* Line 1787 of yacc.c */ |
---|
| 1758 | #line 310 "prsa_par.y" |
---|
| 1759 | { if (!rsa_cur->p) rsa_cur->p = (yyvsp[(3) - (3)].bn); else { prsaerror ("Prime1 already defined\n"); YYABORT; } } |
---|
| 1760 | break; |
---|
| 1761 | |
---|
| 1762 | case 23: |
---|
| 1763 | /* Line 1787 of yacc.c */ |
---|
| 1764 | #line 312 "prsa_par.y" |
---|
| 1765 | { if (!rsa_cur->q) rsa_cur->q = (yyvsp[(3) - (3)].bn); else { prsaerror ("Prime2 already defined\n"); YYABORT; } } |
---|
| 1766 | break; |
---|
| 1767 | |
---|
| 1768 | case 24: |
---|
| 1769 | /* Line 1787 of yacc.c */ |
---|
| 1770 | #line 314 "prsa_par.y" |
---|
| 1771 | { if (!rsa_cur->dmp1) rsa_cur->dmp1 = (yyvsp[(3) - (3)].bn); else { prsaerror ("Exponent1 already defined\n"); YYABORT; } } |
---|
| 1772 | break; |
---|
| 1773 | |
---|
| 1774 | case 25: |
---|
| 1775 | /* Line 1787 of yacc.c */ |
---|
| 1776 | #line 316 "prsa_par.y" |
---|
| 1777 | { if (!rsa_cur->dmq1) rsa_cur->dmq1 = (yyvsp[(3) - (3)].bn); else { prsaerror ("Exponent2 already defined\n"); YYABORT; } } |
---|
| 1778 | break; |
---|
| 1779 | |
---|
| 1780 | case 26: |
---|
| 1781 | /* Line 1787 of yacc.c */ |
---|
| 1782 | #line 318 "prsa_par.y" |
---|
| 1783 | { if (!rsa_cur->iqmp) rsa_cur->iqmp = (yyvsp[(3) - (3)].bn); else { prsaerror ("Coefficient already defined\n"); YYABORT; } } |
---|
| 1784 | break; |
---|
| 1785 | |
---|
| 1786 | |
---|
| 1787 | /* Line 1787 of yacc.c */ |
---|
| 1788 | #line 1789 "prsa_par.c" |
---|
| 1789 | default: break; |
---|
| 1790 | } |
---|
| 1791 | /* User semantic actions sometimes alter yychar, and that requires |
---|
| 1792 | that yytoken be updated with the new translation. We take the |
---|
| 1793 | approach of translating immediately before every use of yytoken. |
---|
| 1794 | One alternative is translating here after every semantic action, |
---|
| 1795 | but that translation would be missed if the semantic action invokes |
---|
| 1796 | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or |
---|
| 1797 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an |
---|
| 1798 | incorrect destructor might then be invoked immediately. In the |
---|
| 1799 | case of YYERROR or YYBACKUP, subsequent parser actions might lead |
---|
| 1800 | to an incorrect destructor call or verbose syntax error message |
---|
| 1801 | before the lookahead is translated. */ |
---|
| 1802 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
---|
| 1803 | |
---|
| 1804 | YYPOPSTACK (yylen); |
---|
| 1805 | yylen = 0; |
---|
| 1806 | YY_STACK_PRINT (yyss, yyssp); |
---|
| 1807 | |
---|
| 1808 | *++yyvsp = yyval; |
---|
| 1809 | |
---|
| 1810 | /* Now `shift' the result of the reduction. Determine what state |
---|
| 1811 | that goes to, based on the state we popped back to and the rule |
---|
| 1812 | number reduced by. */ |
---|
| 1813 | |
---|
| 1814 | yyn = yyr1[yyn]; |
---|
| 1815 | |
---|
| 1816 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
---|
| 1817 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
---|
| 1818 | yystate = yytable[yystate]; |
---|
| 1819 | else |
---|
| 1820 | yystate = yydefgoto[yyn - YYNTOKENS]; |
---|
| 1821 | |
---|
| 1822 | goto yynewstate; |
---|
| 1823 | |
---|
| 1824 | |
---|
| 1825 | /*------------------------------------. |
---|
| 1826 | | yyerrlab -- here on detecting error | |
---|
| 1827 | `------------------------------------*/ |
---|
| 1828 | yyerrlab: |
---|
| 1829 | /* Make sure we have latest lookahead translation. See comments at |
---|
| 1830 | user semantic actions for why this is necessary. */ |
---|
| 1831 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); |
---|
| 1832 | |
---|
| 1833 | /* If not already recovering from an error, report this error. */ |
---|
| 1834 | if (!yyerrstatus) |
---|
| 1835 | { |
---|
| 1836 | ++yynerrs; |
---|
| 1837 | #if ! YYERROR_VERBOSE |
---|
| 1838 | yyerror (YY_("syntax error")); |
---|
| 1839 | #else |
---|
| 1840 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ |
---|
| 1841 | yyssp, yytoken) |
---|
| 1842 | { |
---|
| 1843 | char const *yymsgp = YY_("syntax error"); |
---|
| 1844 | int yysyntax_error_status; |
---|
| 1845 | yysyntax_error_status = YYSYNTAX_ERROR; |
---|
| 1846 | if (yysyntax_error_status == 0) |
---|
| 1847 | yymsgp = yymsg; |
---|
| 1848 | else if (yysyntax_error_status == 1) |
---|
| 1849 | { |
---|
| 1850 | if (yymsg != yymsgbuf) |
---|
| 1851 | YYSTACK_FREE (yymsg); |
---|
| 1852 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); |
---|
| 1853 | if (!yymsg) |
---|
| 1854 | { |
---|
| 1855 | yymsg = yymsgbuf; |
---|
| 1856 | yymsg_alloc = sizeof yymsgbuf; |
---|
| 1857 | yysyntax_error_status = 2; |
---|
| 1858 | } |
---|
| 1859 | else |
---|
| 1860 | { |
---|
| 1861 | yysyntax_error_status = YYSYNTAX_ERROR; |
---|
| 1862 | yymsgp = yymsg; |
---|
| 1863 | } |
---|
| 1864 | } |
---|
| 1865 | yyerror (yymsgp); |
---|
| 1866 | if (yysyntax_error_status == 2) |
---|
| 1867 | goto yyexhaustedlab; |
---|
| 1868 | } |
---|
| 1869 | # undef YYSYNTAX_ERROR |
---|
| 1870 | #endif |
---|
| 1871 | } |
---|
| 1872 | |
---|
| 1873 | |
---|
| 1874 | |
---|
| 1875 | if (yyerrstatus == 3) |
---|
| 1876 | { |
---|
| 1877 | /* If just tried and failed to reuse lookahead token after an |
---|
| 1878 | error, discard it. */ |
---|
| 1879 | |
---|
| 1880 | if (yychar <= YYEOF) |
---|
| 1881 | { |
---|
| 1882 | /* Return failure if at end of input. */ |
---|
| 1883 | if (yychar == YYEOF) |
---|
| 1884 | YYABORT; |
---|
| 1885 | } |
---|
| 1886 | else |
---|
| 1887 | { |
---|
| 1888 | yydestruct ("Error: discarding", |
---|
| 1889 | yytoken, &yylval); |
---|
| 1890 | yychar = YYEMPTY; |
---|
| 1891 | } |
---|
| 1892 | } |
---|
| 1893 | |
---|
| 1894 | /* Else will try to reuse lookahead token after shifting the error |
---|
| 1895 | token. */ |
---|
| 1896 | goto yyerrlab1; |
---|
| 1897 | |
---|
| 1898 | |
---|
| 1899 | /*---------------------------------------------------. |
---|
| 1900 | | yyerrorlab -- error raised explicitly by YYERROR. | |
---|
| 1901 | `---------------------------------------------------*/ |
---|
| 1902 | yyerrorlab: |
---|
| 1903 | |
---|
| 1904 | /* Pacify compilers like GCC when the user code never invokes |
---|
| 1905 | YYERROR and the label yyerrorlab therefore never appears in user |
---|
| 1906 | code. */ |
---|
| 1907 | if (/*CONSTCOND*/ 0) |
---|
| 1908 | goto yyerrorlab; |
---|
| 1909 | |
---|
| 1910 | /* Do not reclaim the symbols of the rule which action triggered |
---|
| 1911 | this YYERROR. */ |
---|
| 1912 | YYPOPSTACK (yylen); |
---|
| 1913 | yylen = 0; |
---|
| 1914 | YY_STACK_PRINT (yyss, yyssp); |
---|
| 1915 | yystate = *yyssp; |
---|
| 1916 | goto yyerrlab1; |
---|
| 1917 | |
---|
| 1918 | |
---|
| 1919 | /*-------------------------------------------------------------. |
---|
| 1920 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
---|
| 1921 | `-------------------------------------------------------------*/ |
---|
| 1922 | yyerrlab1: |
---|
| 1923 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
---|
| 1924 | |
---|
| 1925 | for (;;) |
---|
| 1926 | { |
---|
| 1927 | yyn = yypact[yystate]; |
---|
| 1928 | if (!yypact_value_is_default (yyn)) |
---|
| 1929 | { |
---|
| 1930 | yyn += YYTERROR; |
---|
| 1931 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
---|
| 1932 | { |
---|
| 1933 | yyn = yytable[yyn]; |
---|
| 1934 | if (0 < yyn) |
---|
| 1935 | break; |
---|
| 1936 | } |
---|
| 1937 | } |
---|
| 1938 | |
---|
| 1939 | /* Pop the current state because it cannot handle the error token. */ |
---|
| 1940 | if (yyssp == yyss) |
---|
| 1941 | YYABORT; |
---|
| 1942 | |
---|
| 1943 | |
---|
| 1944 | yydestruct ("Error: popping", |
---|
| 1945 | yystos[yystate], yyvsp); |
---|
| 1946 | YYPOPSTACK (1); |
---|
| 1947 | yystate = *yyssp; |
---|
| 1948 | YY_STACK_PRINT (yyss, yyssp); |
---|
| 1949 | } |
---|
| 1950 | |
---|
| 1951 | *++yyvsp = yylval; |
---|
| 1952 | |
---|
| 1953 | |
---|
| 1954 | /* Shift the error token. */ |
---|
| 1955 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
---|
| 1956 | |
---|
| 1957 | yystate = yyn; |
---|
| 1958 | goto yynewstate; |
---|
| 1959 | |
---|
| 1960 | |
---|
| 1961 | /*-------------------------------------. |
---|
| 1962 | | yyacceptlab -- YYACCEPT comes here. | |
---|
| 1963 | `-------------------------------------*/ |
---|
| 1964 | yyacceptlab: |
---|
| 1965 | yyresult = 0; |
---|
| 1966 | goto yyreturn; |
---|
| 1967 | |
---|
| 1968 | /*-----------------------------------. |
---|
| 1969 | | yyabortlab -- YYABORT comes here. | |
---|
| 1970 | `-----------------------------------*/ |
---|
| 1971 | yyabortlab: |
---|
| 1972 | yyresult = 1; |
---|
| 1973 | goto yyreturn; |
---|
| 1974 | |
---|
| 1975 | #if !defined yyoverflow || YYERROR_VERBOSE |
---|
| 1976 | /*-------------------------------------------------. |
---|
| 1977 | | yyexhaustedlab -- memory exhaustion comes here. | |
---|
| 1978 | `-------------------------------------------------*/ |
---|
| 1979 | yyexhaustedlab: |
---|
| 1980 | yyerror (YY_("memory exhausted")); |
---|
| 1981 | yyresult = 2; |
---|
| 1982 | /* Fall through. */ |
---|
| 1983 | #endif |
---|
| 1984 | |
---|
| 1985 | yyreturn: |
---|
| 1986 | if (yychar != YYEMPTY) |
---|
| 1987 | { |
---|
| 1988 | /* Make sure we have latest lookahead translation. See comments at |
---|
| 1989 | user semantic actions for why this is necessary. */ |
---|
| 1990 | yytoken = YYTRANSLATE (yychar); |
---|
| 1991 | yydestruct ("Cleanup: discarding lookahead", |
---|
| 1992 | yytoken, &yylval); |
---|
| 1993 | } |
---|
| 1994 | /* Do not reclaim the symbols of the rule which action triggered |
---|
| 1995 | this YYABORT or YYACCEPT. */ |
---|
| 1996 | YYPOPSTACK (yylen); |
---|
| 1997 | YY_STACK_PRINT (yyss, yyssp); |
---|
| 1998 | while (yyssp != yyss) |
---|
| 1999 | { |
---|
| 2000 | yydestruct ("Cleanup: popping", |
---|
| 2001 | yystos[*yyssp], yyvsp); |
---|
| 2002 | YYPOPSTACK (1); |
---|
| 2003 | } |
---|
| 2004 | #ifndef yyoverflow |
---|
| 2005 | if (yyss != yyssa) |
---|
| 2006 | YYSTACK_FREE (yyss); |
---|
| 2007 | #endif |
---|
| 2008 | #if YYERROR_VERBOSE |
---|
| 2009 | if (yymsg != yymsgbuf) |
---|
| 2010 | YYSTACK_FREE (yymsg); |
---|
| 2011 | #endif |
---|
| 2012 | /* Make sure YYID is used. */ |
---|
| 2013 | return YYID (yyresult); |
---|
| 2014 | } |
---|
| 2015 | |
---|
| 2016 | |
---|
| 2017 | /* Line 2048 of yacc.c */ |
---|
| 2018 | #line 320 "prsa_par.y" |
---|
| 2019 | |
---|
| 2020 | |
---|
| 2021 | int prsaparse(void); |
---|
| 2022 | |
---|
| 2023 | int |
---|
| 2024 | prsa_parse_file(struct genlist *list, char *fname, enum rsa_key_type type) |
---|
| 2025 | { |
---|
| 2026 | FILE *fp = NULL; |
---|
| 2027 | int ret; |
---|
| 2028 | |
---|
| 2029 | if (!fname) |
---|
| 2030 | return -1; |
---|
| 2031 | if (type == RSA_TYPE_PRIVATE) { |
---|
| 2032 | struct stat st; |
---|
| 2033 | if (stat(fname, &st) < 0) |
---|
| 2034 | return -1; |
---|
| 2035 | if (st.st_mode & (S_IRWXG | S_IRWXO)) { |
---|
| 2036 | plog(LLV_ERROR, LOCATION, NULL, |
---|
| 2037 | "Too slack permissions on private key '%s'\n", |
---|
| 2038 | fname); |
---|
| 2039 | plog(LLV_ERROR, LOCATION, NULL, |
---|
| 2040 | "Should be at most 0600, now is 0%o\n", |
---|
| 2041 | st.st_mode & 0777); |
---|
| 2042 | return -1; |
---|
| 2043 | } |
---|
| 2044 | } |
---|
| 2045 | fp = fopen(fname, "r"); |
---|
| 2046 | if (!fp) |
---|
| 2047 | return -1; |
---|
| 2048 | prsain = fp; |
---|
| 2049 | prsa_cur_lineno = 1; |
---|
| 2050 | prsa_cur_fname = fname; |
---|
| 2051 | prsa_cur_list = list; |
---|
| 2052 | prsa_cur_type = type; |
---|
| 2053 | rsa_cur = RSA_new(); |
---|
| 2054 | ret = prsaparse(); |
---|
| 2055 | if (rsa_cur) { |
---|
| 2056 | RSA_free(rsa_cur); |
---|
| 2057 | rsa_cur = NULL; |
---|
| 2058 | } |
---|
| 2059 | fclose (fp); |
---|
| 2060 | prsain = NULL; |
---|
| 2061 | return ret; |
---|
| 2062 | } |
---|