pam_conv_y.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535
  1. /* A Bison parser, made by GNU Bison 3.7.6. */
  2. /* Bison implementation for Yacc-like parsers in C
  3. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
  4. Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  15. /* As a special exception, you may create a larger work that contains
  16. part or all of the Bison parser skeleton and distribute that work
  17. under terms of your choice, so long as that work isn't itself a
  18. parser generator using the skeleton or a modified version thereof
  19. as a parser skeleton. Alternatively, if you modify or redistribute
  20. the parser skeleton itself, you may (at your option) remove this
  21. special exception, which will cause the skeleton and the resulting
  22. Bison output files to be licensed under the GNU General Public
  23. License without this special exception.
  24. This special exception was added by the Free Software Foundation in
  25. version 2.2 of Bison. */
  26. /* C LALR(1) parser skeleton written by Richard Stallman, by
  27. simplifying the original so-called "semantic" parser. */
  28. /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
  29. especially those whose name start with YY_ or yy_. They are
  30. private implementation details that can be changed or removed. */
  31. /* All symbols defined below should begin with yy or YY, to avoid
  32. infringing on user name space. This should be done even for local
  33. variables, as they might otherwise be expanded by user macros.
  34. There are some unavoidable exceptions within include files to
  35. define necessary library symbols; they are noted "INFRINGES ON
  36. USER NAME SPACE" below. */
  37. /* Identify Bison output, and Bison version. */
  38. #define YYBISON 30706
  39. /* Bison version string. */
  40. #define YYBISON_VERSION "3.7.6"
  41. /* Skeleton name. */
  42. #define YYSKELETON_NAME "yacc.c"
  43. /* Pure parsers. */
  44. #define YYPURE 0
  45. /* Push parsers. */
  46. #define YYPUSH 0
  47. /* Pull parsers. */
  48. #define YYPULL 1
  49. /* First part of user prologue. */
  50. #line 1 "pam_conv_y.y"
  51. /*
  52. * $Id$
  53. *
  54. * Copyright (c) Andrew G. Morgan 1997 <morgan@parc.power.net>
  55. *
  56. * This file is covered by the Linux-PAM License (which should be
  57. * distributed with this file.)
  58. */
  59. #ifdef HAVE_CONFIG_H
  60. # include <config.h>
  61. #endif
  62. #include <string.h>
  63. #include <stdio.h>
  64. #include <stdarg.h>
  65. #include <stdlib.h>
  66. #include <ctype.h>
  67. #include <sys/stat.h>
  68. #include <security/_pam_types.h>
  69. extern int yylex(void);
  70. int current_line=1;
  71. extern char *yytext;
  72. /* XXX - later we'll change this to be the specific conf file(s) */
  73. #define newpamf stderr
  74. #define PAM_D "./pam.d"
  75. #define PAM_D_MODE 0755
  76. #define PAM_D_MAGIC_HEADER \
  77. "#%%PAM-1.0\n" \
  78. "#[For version 1.0 syntax, the above header is optional]\n"
  79. #define PAM_D_FILE_FMT PAM_D "/%s"
  80. const char *old_to_new_ctrl_flag(const char *old);
  81. void yyerror(const char *format, ...);
  82. #line 115 "pam_conv_y.c"
  83. # ifndef YY_CAST
  84. # ifdef __cplusplus
  85. # define YY_CAST(Type, Val) static_cast<Type> (Val)
  86. # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
  87. # else
  88. # define YY_CAST(Type, Val) ((Type) (Val))
  89. # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
  90. # endif
  91. # endif
  92. # ifndef YY_NULLPTR
  93. # if defined __cplusplus
  94. # if 201103L <= __cplusplus
  95. # define YY_NULLPTR nullptr
  96. # else
  97. # define YY_NULLPTR 0
  98. # endif
  99. # else
  100. # define YY_NULLPTR ((void*)0)
  101. # endif
  102. # endif
  103. /* Use api.header.include to #include this header
  104. instead of duplicating it here. */
  105. #ifndef YY_YY_PAM_CONV_Y_H_INCLUDED
  106. # define YY_YY_PAM_CONV_Y_H_INCLUDED
  107. /* Debug traces. */
  108. #ifndef YYDEBUG
  109. # define YYDEBUG 0
  110. #endif
  111. #if YYDEBUG
  112. extern int yydebug;
  113. #endif
  114. /* Token kinds. */
  115. #ifndef YYTOKENTYPE
  116. # define YYTOKENTYPE
  117. enum yytokentype
  118. {
  119. YYEMPTY = -2,
  120. YYEOF = 0, /* "end of file" */
  121. YYerror = 256, /* error */
  122. YYUNDEF = 257, /* "invalid token" */
  123. NL = 258, /* NL */
  124. EOFILE = 259, /* EOFILE */
  125. TOK = 260 /* TOK */
  126. };
  127. typedef enum yytokentype yytoken_kind_t;
  128. #endif
  129. /* Token kinds. */
  130. #define YYEMPTY -2
  131. #define YYEOF 0
  132. #define YYerror 256
  133. #define YYUNDEF 257
  134. #define NL 258
  135. #define EOFILE 259
  136. #define TOK 260
  137. /* Value type. */
  138. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  139. union YYSTYPE
  140. {
  141. #line 45 "pam_conv_y.y"
  142. int def;
  143. char *string;
  144. #line 183 "pam_conv_y.c"
  145. };
  146. typedef union YYSTYPE YYSTYPE;
  147. # define YYSTYPE_IS_TRIVIAL 1
  148. # define YYSTYPE_IS_DECLARED 1
  149. #endif
  150. extern YYSTYPE yylval;
  151. int yyparse (void);
  152. #endif /* !YY_YY_PAM_CONV_Y_H_INCLUDED */
  153. /* Symbol kind. */
  154. enum yysymbol_kind_t
  155. {
  156. YYSYMBOL_YYEMPTY = -2,
  157. YYSYMBOL_YYEOF = 0, /* "end of file" */
  158. YYSYMBOL_YYerror = 1, /* error */
  159. YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
  160. YYSYMBOL_NL = 3, /* NL */
  161. YYSYMBOL_EOFILE = 4, /* EOFILE */
  162. YYSYMBOL_TOK = 5, /* TOK */
  163. YYSYMBOL_YYACCEPT = 6, /* $accept */
  164. YYSYMBOL_complete = 7, /* complete */
  165. YYSYMBOL_line = 8, /* line */
  166. YYSYMBOL_tokenls = 9, /* tokenls */
  167. YYSYMBOL_path = 10, /* path */
  168. YYSYMBOL_tok = 11 /* tok */
  169. };
  170. typedef enum yysymbol_kind_t yysymbol_kind_t;
  171. #ifdef short
  172. # undef short
  173. #endif
  174. /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
  175. <limits.h> and (if available) <stdint.h> are included
  176. so that the code can choose integer types of a good width. */
  177. #ifndef __PTRDIFF_MAX__
  178. # include <limits.h> /* INFRINGES ON USER NAME SPACE */
  179. # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  180. # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
  181. # define YY_STDINT_H
  182. # endif
  183. #endif
  184. /* Narrow types that promote to a signed type and that can represent a
  185. signed or unsigned integer of at least N bits. In tables they can
  186. save space and decrease cache pressure. Promoting to a signed type
  187. helps avoid bugs in integer arithmetic. */
  188. #ifdef __INT_LEAST8_MAX__
  189. typedef __INT_LEAST8_TYPE__ yytype_int8;
  190. #elif defined YY_STDINT_H
  191. typedef int_least8_t yytype_int8;
  192. #else
  193. typedef signed char yytype_int8;
  194. #endif
  195. #ifdef __INT_LEAST16_MAX__
  196. typedef __INT_LEAST16_TYPE__ yytype_int16;
  197. #elif defined YY_STDINT_H
  198. typedef int_least16_t yytype_int16;
  199. #else
  200. typedef short yytype_int16;
  201. #endif
  202. /* Work around bug in HP-UX 11.23, which defines these macros
  203. incorrectly for preprocessor constants. This workaround can likely
  204. be removed in 2023, as HPE has promised support for HP-UX 11.23
  205. (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
  206. <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
  207. #ifdef __hpux
  208. # undef UINT_LEAST8_MAX
  209. # undef UINT_LEAST16_MAX
  210. # define UINT_LEAST8_MAX 255
  211. # define UINT_LEAST16_MAX 65535
  212. #endif
  213. #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
  214. typedef __UINT_LEAST8_TYPE__ yytype_uint8;
  215. #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
  216. && UINT_LEAST8_MAX <= INT_MAX)
  217. typedef uint_least8_t yytype_uint8;
  218. #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
  219. typedef unsigned char yytype_uint8;
  220. #else
  221. typedef short yytype_uint8;
  222. #endif
  223. #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
  224. typedef __UINT_LEAST16_TYPE__ yytype_uint16;
  225. #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
  226. && UINT_LEAST16_MAX <= INT_MAX)
  227. typedef uint_least16_t yytype_uint16;
  228. #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
  229. typedef unsigned short yytype_uint16;
  230. #else
  231. typedef int yytype_uint16;
  232. #endif
  233. #ifndef YYPTRDIFF_T
  234. # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
  235. # define YYPTRDIFF_T __PTRDIFF_TYPE__
  236. # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
  237. # elif defined PTRDIFF_MAX
  238. # ifndef ptrdiff_t
  239. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  240. # endif
  241. # define YYPTRDIFF_T ptrdiff_t
  242. # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
  243. # else
  244. # define YYPTRDIFF_T long
  245. # define YYPTRDIFF_MAXIMUM LONG_MAX
  246. # endif
  247. #endif
  248. #ifndef YYSIZE_T
  249. # ifdef __SIZE_TYPE__
  250. # define YYSIZE_T __SIZE_TYPE__
  251. # elif defined size_t
  252. # define YYSIZE_T size_t
  253. # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  254. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  255. # define YYSIZE_T size_t
  256. # else
  257. # define YYSIZE_T unsigned
  258. # endif
  259. #endif
  260. #define YYSIZE_MAXIMUM \
  261. YY_CAST (YYPTRDIFF_T, \
  262. (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
  263. ? YYPTRDIFF_MAXIMUM \
  264. : YY_CAST (YYSIZE_T, -1)))
  265. #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
  266. /* Stored state numbers (used for stacks). */
  267. typedef yytype_int8 yy_state_t;
  268. /* State numbers in computations. */
  269. typedef int yy_state_fast_t;
  270. #ifndef YY_
  271. # if defined YYENABLE_NLS && YYENABLE_NLS
  272. # if ENABLE_NLS
  273. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  274. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  275. # endif
  276. # endif
  277. # ifndef YY_
  278. # define YY_(Msgid) Msgid
  279. # endif
  280. #endif
  281. #ifndef YY_ATTRIBUTE_PURE
  282. # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
  283. # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
  284. # else
  285. # define YY_ATTRIBUTE_PURE
  286. # endif
  287. #endif
  288. #ifndef YY_ATTRIBUTE_UNUSED
  289. # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
  290. # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  291. # else
  292. # define YY_ATTRIBUTE_UNUSED
  293. # endif
  294. #endif
  295. /* Suppress unused-variable warnings by "using" E. */
  296. #if ! defined lint || defined __GNUC__
  297. # define YY_USE(E) ((void) (E))
  298. #else
  299. # define YY_USE(E) /* empty */
  300. #endif
  301. #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  302. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  303. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  304. _Pragma ("GCC diagnostic push") \
  305. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
  306. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  307. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  308. _Pragma ("GCC diagnostic pop")
  309. #else
  310. # define YY_INITIAL_VALUE(Value) Value
  311. #endif
  312. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  313. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  314. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  315. #endif
  316. #ifndef YY_INITIAL_VALUE
  317. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  318. #endif
  319. #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
  320. # define YY_IGNORE_USELESS_CAST_BEGIN \
  321. _Pragma ("GCC diagnostic push") \
  322. _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
  323. # define YY_IGNORE_USELESS_CAST_END \
  324. _Pragma ("GCC diagnostic pop")
  325. #endif
  326. #ifndef YY_IGNORE_USELESS_CAST_BEGIN
  327. # define YY_IGNORE_USELESS_CAST_BEGIN
  328. # define YY_IGNORE_USELESS_CAST_END
  329. #endif
  330. #define YY_ASSERT(E) ((void) (0 && (E)))
  331. #if !defined yyoverflow
  332. /* The parser invokes alloca or malloc; define the necessary symbols. */
  333. # ifdef YYSTACK_USE_ALLOCA
  334. # if YYSTACK_USE_ALLOCA
  335. # ifdef __GNUC__
  336. # define YYSTACK_ALLOC __builtin_alloca
  337. # elif defined __BUILTIN_VA_ARG_INCR
  338. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  339. # elif defined _AIX
  340. # define YYSTACK_ALLOC __alloca
  341. # elif defined _MSC_VER
  342. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  343. # define alloca _alloca
  344. # else
  345. # define YYSTACK_ALLOC alloca
  346. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  347. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  348. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  349. # ifndef EXIT_SUCCESS
  350. # define EXIT_SUCCESS 0
  351. # endif
  352. # endif
  353. # endif
  354. # endif
  355. # endif
  356. # ifdef YYSTACK_ALLOC
  357. /* Pacify GCC's 'empty if-body' warning. */
  358. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  359. # ifndef YYSTACK_ALLOC_MAXIMUM
  360. /* The OS might guarantee only one guard page at the bottom of the stack,
  361. and a page size can be as small as 4096 bytes. So we cannot safely
  362. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  363. to allow for a few compiler-allocated temporary stack slots. */
  364. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  365. # endif
  366. # else
  367. # define YYSTACK_ALLOC YYMALLOC
  368. # define YYSTACK_FREE YYFREE
  369. # ifndef YYSTACK_ALLOC_MAXIMUM
  370. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  371. # endif
  372. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  373. && ! ((defined YYMALLOC || defined malloc) \
  374. && (defined YYFREE || defined free)))
  375. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  376. # ifndef EXIT_SUCCESS
  377. # define EXIT_SUCCESS 0
  378. # endif
  379. # endif
  380. # ifndef YYMALLOC
  381. # define YYMALLOC malloc
  382. # if ! defined malloc && ! defined EXIT_SUCCESS
  383. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  384. # endif
  385. # endif
  386. # ifndef YYFREE
  387. # define YYFREE free
  388. # if ! defined free && ! defined EXIT_SUCCESS
  389. void free (void *); /* INFRINGES ON USER NAME SPACE */
  390. # endif
  391. # endif
  392. # endif
  393. #endif /* !defined yyoverflow */
  394. #if (! defined yyoverflow \
  395. && (! defined __cplusplus \
  396. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  397. /* A type that is properly aligned for any stack member. */
  398. union yyalloc
  399. {
  400. yy_state_t yyss_alloc;
  401. YYSTYPE yyvs_alloc;
  402. };
  403. /* The size of the maximum gap between one aligned stack and the next. */
  404. # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
  405. /* The size of an array large to enough to hold all stacks, each with
  406. N elements. */
  407. # define YYSTACK_BYTES(N) \
  408. ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
  409. + YYSTACK_GAP_MAXIMUM)
  410. # define YYCOPY_NEEDED 1
  411. /* Relocate STACK from its old location to the new one. The
  412. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  413. elements in the stack, and YYPTR gives the new location of the
  414. stack. Advance YYPTR to a properly aligned location for the next
  415. stack. */
  416. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  417. do \
  418. { \
  419. YYPTRDIFF_T yynewbytes; \
  420. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  421. Stack = &yyptr->Stack_alloc; \
  422. yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
  423. yyptr += yynewbytes / YYSIZEOF (*yyptr); \
  424. } \
  425. while (0)
  426. #endif
  427. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  428. /* Copy COUNT objects from SRC to DST. The source and destination do
  429. not overlap. */
  430. # ifndef YYCOPY
  431. # if defined __GNUC__ && 1 < __GNUC__
  432. # define YYCOPY(Dst, Src, Count) \
  433. __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
  434. # else
  435. # define YYCOPY(Dst, Src, Count) \
  436. do \
  437. { \
  438. YYPTRDIFF_T yyi; \
  439. for (yyi = 0; yyi < (Count); yyi++) \
  440. (Dst)[yyi] = (Src)[yyi]; \
  441. } \
  442. while (0)
  443. # endif
  444. # endif
  445. #endif /* !YYCOPY_NEEDED */
  446. /* YYFINAL -- State number of the termination state. */
  447. #define YYFINAL 2
  448. /* YYLAST -- Last index in YYTABLE. */
  449. #define YYLAST 13
  450. /* YYNTOKENS -- Number of terminals. */
  451. #define YYNTOKENS 6
  452. /* YYNNTS -- Number of nonterminals. */
  453. #define YYNNTS 6
  454. /* YYNRULES -- Number of rules. */
  455. #define YYNRULES 11
  456. /* YYNSTATES -- Number of states. */
  457. #define YYNSTATES 17
  458. /* YYMAXUTOK -- Last valid token kind. */
  459. #define YYMAXUTOK 260
  460. /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
  461. as returned by yylex, with out-of-bounds checking. */
  462. #define YYTRANSLATE(YYX) \
  463. (0 <= (YYX) && (YYX) <= YYMAXUTOK \
  464. ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
  465. : YYSYMBOL_YYUNDEF)
  466. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  467. as returned by yylex. */
  468. static const yytype_int8 yytranslate[] =
  469. {
  470. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  471. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  472. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  473. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  474. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  475. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  476. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  477. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  478. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  479. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  480. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  481. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  482. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  483. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  484. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  485. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  486. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  487. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  488. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  489. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  490. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  491. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  492. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  493. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  494. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  495. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  496. 5
  497. };
  498. #if YYDEBUG
  499. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  500. static const yytype_uint8 yyrline[] =
  501. {
  502. 0, 59, 59, 60, 61, 62, 68, 132, 138, 141,
  503. 157, 163
  504. };
  505. #endif
  506. /** Accessing symbol of state STATE. */
  507. #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
  508. #if YYDEBUG || 0
  509. /* The user-facing name of the symbol whose (internal) number is
  510. YYSYMBOL. No bounds checking. */
  511. static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
  512. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  513. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  514. static const char *const yytname[] =
  515. {
  516. "\"end of file\"", "error", "\"invalid token\"", "NL", "EOFILE", "TOK",
  517. "$accept", "complete", "line", "tokenls", "path", "tok", YY_NULLPTR
  518. };
  519. static const char *
  520. yysymbol_name (yysymbol_kind_t yysymbol)
  521. {
  522. return yytname[yysymbol];
  523. }
  524. #endif
  525. #ifdef YYPRINT
  526. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  527. (internal) symbol number NUM (which must be that of a token). */
  528. static const yytype_int16 yytoknum[] =
  529. {
  530. 0, 256, 257, 258, 259, 260
  531. };
  532. #endif
  533. #define YYPACT_NINF (-9)
  534. #define yypact_value_is_default(Yyn) \
  535. ((Yyn) == YYPACT_NINF)
  536. #define YYTABLE_NINF (-1)
  537. #define yytable_value_is_error(Yyn) \
  538. 0
  539. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  540. STATE-NUM. */
  541. static const yytype_int8 yypact[] =
  542. {
  543. -9, 4, -9, 7, -9, -9, -9, -9, 6, -9,
  544. 6, 8, -9, -9, -2, -9, -9
  545. };
  546. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  547. Performed when YYTABLE does not specify something else to do. Zero
  548. means the default is an error. */
  549. static const yytype_int8 yydefact[] =
  550. {
  551. 2, 0, 1, 0, 3, 5, 11, 4, 0, 7,
  552. 0, 0, 10, 8, 0, 6, 9
  553. };
  554. /* YYPGOTO[NTERM-NUM]. */
  555. static const yytype_int8 yypgoto[] =
  556. {
  557. -9, -9, -9, -9, -9, -8
  558. };
  559. /* YYDEFGOTO[NTERM-NUM]. */
  560. static const yytype_int8 yydefgoto[] =
  561. {
  562. 0, 1, 7, 14, 13, 8
  563. };
  564. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  565. positive, shift that token. If negative, reduce the rule whose
  566. number is the opposite. If YYTABLE_NINF, syntax error. */
  567. static const yytype_int8 yytable[] =
  568. {
  569. 10, 15, 11, 6, 2, 3, 16, 4, 5, 6,
  570. 9, 6, 0, 12
  571. };
  572. static const yytype_int8 yycheck[] =
  573. {
  574. 8, 3, 10, 5, 0, 1, 14, 3, 4, 5,
  575. 3, 5, -1, 5
  576. };
  577. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  578. symbol of state STATE-NUM. */
  579. static const yytype_int8 yystos[] =
  580. {
  581. 0, 7, 0, 1, 3, 4, 5, 8, 11, 3,
  582. 11, 11, 5, 10, 9, 3, 11
  583. };
  584. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  585. static const yytype_int8 yyr1[] =
  586. {
  587. 0, 6, 7, 7, 7, 7, 8, 8, 9, 9,
  588. 10, 11
  589. };
  590. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  591. static const yytype_int8 yyr2[] =
  592. {
  593. 0, 2, 0, 2, 2, 2, 6, 2, 0, 2,
  594. 1, 1
  595. };
  596. enum { YYENOMEM = -2 };
  597. #define yyerrok (yyerrstatus = 0)
  598. #define yyclearin (yychar = YYEMPTY)
  599. #define YYACCEPT goto yyacceptlab
  600. #define YYABORT goto yyabortlab
  601. #define YYERROR goto yyerrorlab
  602. #define YYRECOVERING() (!!yyerrstatus)
  603. #define YYBACKUP(Token, Value) \
  604. do \
  605. if (yychar == YYEMPTY) \
  606. { \
  607. yychar = (Token); \
  608. yylval = (Value); \
  609. YYPOPSTACK (yylen); \
  610. yystate = *yyssp; \
  611. goto yybackup; \
  612. } \
  613. else \
  614. { \
  615. yyerror (YY_("syntax error: cannot back up")); \
  616. YYERROR; \
  617. } \
  618. while (0)
  619. /* Backward compatibility with an undocumented macro.
  620. Use YYerror or YYUNDEF. */
  621. #define YYERRCODE YYUNDEF
  622. /* Enable debugging if requested. */
  623. #if YYDEBUG
  624. # ifndef YYFPRINTF
  625. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  626. # define YYFPRINTF fprintf
  627. # endif
  628. # define YYDPRINTF(Args) \
  629. do { \
  630. if (yydebug) \
  631. YYFPRINTF Args; \
  632. } while (0)
  633. /* This macro is provided for backward compatibility. */
  634. # ifndef YY_LOCATION_PRINT
  635. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  636. # endif
  637. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
  638. do { \
  639. if (yydebug) \
  640. { \
  641. YYFPRINTF (stderr, "%s ", Title); \
  642. yy_symbol_print (stderr, \
  643. Kind, Value); \
  644. YYFPRINTF (stderr, "\n"); \
  645. } \
  646. } while (0)
  647. /*-----------------------------------.
  648. | Print this symbol's value on YYO. |
  649. `-----------------------------------*/
  650. static void
  651. yy_symbol_value_print (FILE *yyo,
  652. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
  653. {
  654. FILE *yyoutput = yyo;
  655. YY_USE (yyoutput);
  656. if (!yyvaluep)
  657. return;
  658. # ifdef YYPRINT
  659. if (yykind < YYNTOKENS)
  660. YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
  661. # endif
  662. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  663. YY_USE (yykind);
  664. YY_IGNORE_MAYBE_UNINITIALIZED_END
  665. }
  666. /*---------------------------.
  667. | Print this symbol on YYO. |
  668. `---------------------------*/
  669. static void
  670. yy_symbol_print (FILE *yyo,
  671. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
  672. {
  673. YYFPRINTF (yyo, "%s %s (",
  674. yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
  675. yy_symbol_value_print (yyo, yykind, yyvaluep);
  676. YYFPRINTF (yyo, ")");
  677. }
  678. /*------------------------------------------------------------------.
  679. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  680. | TOP (included). |
  681. `------------------------------------------------------------------*/
  682. static void
  683. yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
  684. {
  685. YYFPRINTF (stderr, "Stack now");
  686. for (; yybottom <= yytop; yybottom++)
  687. {
  688. int yybot = *yybottom;
  689. YYFPRINTF (stderr, " %d", yybot);
  690. }
  691. YYFPRINTF (stderr, "\n");
  692. }
  693. # define YY_STACK_PRINT(Bottom, Top) \
  694. do { \
  695. if (yydebug) \
  696. yy_stack_print ((Bottom), (Top)); \
  697. } while (0)
  698. /*------------------------------------------------.
  699. | Report that the YYRULE is going to be reduced. |
  700. `------------------------------------------------*/
  701. static void
  702. yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
  703. int yyrule)
  704. {
  705. int yylno = yyrline[yyrule];
  706. int yynrhs = yyr2[yyrule];
  707. int yyi;
  708. YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
  709. yyrule - 1, yylno);
  710. /* The symbols being reduced. */
  711. for (yyi = 0; yyi < yynrhs; yyi++)
  712. {
  713. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  714. yy_symbol_print (stderr,
  715. YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
  716. &yyvsp[(yyi + 1) - (yynrhs)]);
  717. YYFPRINTF (stderr, "\n");
  718. }
  719. }
  720. # define YY_REDUCE_PRINT(Rule) \
  721. do { \
  722. if (yydebug) \
  723. yy_reduce_print (yyssp, yyvsp, Rule); \
  724. } while (0)
  725. /* Nonzero means print parse trace. It is left uninitialized so that
  726. multiple parsers can coexist. */
  727. int yydebug;
  728. #else /* !YYDEBUG */
  729. # define YYDPRINTF(Args) ((void) 0)
  730. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
  731. # define YY_STACK_PRINT(Bottom, Top)
  732. # define YY_REDUCE_PRINT(Rule)
  733. #endif /* !YYDEBUG */
  734. /* YYINITDEPTH -- initial size of the parser's stacks. */
  735. #ifndef YYINITDEPTH
  736. # define YYINITDEPTH 200
  737. #endif
  738. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  739. if the built-in stack extension method is used).
  740. Do not make this value too large; the results are undefined if
  741. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  742. evaluated with infinite-precision integer arithmetic. */
  743. #ifndef YYMAXDEPTH
  744. # define YYMAXDEPTH 10000
  745. #endif
  746. /*-----------------------------------------------.
  747. | Release the memory associated to this symbol. |
  748. `-----------------------------------------------*/
  749. static void
  750. yydestruct (const char *yymsg,
  751. yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
  752. {
  753. YY_USE (yyvaluep);
  754. if (!yymsg)
  755. yymsg = "Deleting";
  756. YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
  757. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  758. YY_USE (yykind);
  759. YY_IGNORE_MAYBE_UNINITIALIZED_END
  760. }
  761. /* Lookahead token kind. */
  762. int yychar;
  763. /* The semantic value of the lookahead symbol. */
  764. YYSTYPE yylval;
  765. /* Number of syntax errors so far. */
  766. int yynerrs;
  767. /*----------.
  768. | yyparse. |
  769. `----------*/
  770. int
  771. yyparse (void)
  772. {
  773. yy_state_fast_t yystate = 0;
  774. /* Number of tokens to shift before error messages enabled. */
  775. int yyerrstatus = 0;
  776. /* Refer to the stacks through separate pointers, to allow yyoverflow
  777. to reallocate them elsewhere. */
  778. /* Their size. */
  779. YYPTRDIFF_T yystacksize = YYINITDEPTH;
  780. /* The state stack: array, bottom, top. */
  781. yy_state_t yyssa[YYINITDEPTH];
  782. yy_state_t *yyss = yyssa;
  783. yy_state_t *yyssp = yyss;
  784. /* The semantic value stack: array, bottom, top. */
  785. YYSTYPE yyvsa[YYINITDEPTH];
  786. YYSTYPE *yyvs = yyvsa;
  787. YYSTYPE *yyvsp = yyvs;
  788. int yyn;
  789. /* The return value of yyparse. */
  790. int yyresult;
  791. /* Lookahead symbol kind. */
  792. yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  793. /* The variables used to return semantic value and location from the
  794. action routines. */
  795. YYSTYPE yyval;
  796. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  797. /* The number of symbols on the RHS of the reduced rule.
  798. Keep to zero when no symbol should be popped. */
  799. int yylen = 0;
  800. YYDPRINTF ((stderr, "Starting parse\n"));
  801. yychar = YYEMPTY; /* Cause a token to be read. */
  802. goto yysetstate;
  803. /*------------------------------------------------------------.
  804. | yynewstate -- push a new state, which is found in yystate. |
  805. `------------------------------------------------------------*/
  806. yynewstate:
  807. /* In all cases, when you get here, the value and location stacks
  808. have just been pushed. So pushing a state here evens the stacks. */
  809. yyssp++;
  810. /*--------------------------------------------------------------------.
  811. | yysetstate -- set current state (the top of the stack) to yystate. |
  812. `--------------------------------------------------------------------*/
  813. yysetstate:
  814. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  815. YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  816. YY_IGNORE_USELESS_CAST_BEGIN
  817. *yyssp = YY_CAST (yy_state_t, yystate);
  818. YY_IGNORE_USELESS_CAST_END
  819. YY_STACK_PRINT (yyss, yyssp);
  820. if (yyss + yystacksize - 1 <= yyssp)
  821. #if !defined yyoverflow && !defined YYSTACK_RELOCATE
  822. goto yyexhaustedlab;
  823. #else
  824. {
  825. /* Get the current used size of the three stacks, in elements. */
  826. YYPTRDIFF_T yysize = yyssp - yyss + 1;
  827. # if defined yyoverflow
  828. {
  829. /* Give user a chance to reallocate the stack. Use copies of
  830. these so that the &'s don't force the real ones into
  831. memory. */
  832. yy_state_t *yyss1 = yyss;
  833. YYSTYPE *yyvs1 = yyvs;
  834. /* Each stack pointer address is followed by the size of the
  835. data in use in that stack, in bytes. This used to be a
  836. conditional around just the two extra args, but that might
  837. be undefined if yyoverflow is a macro. */
  838. yyoverflow (YY_("memory exhausted"),
  839. &yyss1, yysize * YYSIZEOF (*yyssp),
  840. &yyvs1, yysize * YYSIZEOF (*yyvsp),
  841. &yystacksize);
  842. yyss = yyss1;
  843. yyvs = yyvs1;
  844. }
  845. # else /* defined YYSTACK_RELOCATE */
  846. /* Extend the stack our own way. */
  847. if (YYMAXDEPTH <= yystacksize)
  848. goto yyexhaustedlab;
  849. yystacksize *= 2;
  850. if (YYMAXDEPTH < yystacksize)
  851. yystacksize = YYMAXDEPTH;
  852. {
  853. yy_state_t *yyss1 = yyss;
  854. union yyalloc *yyptr =
  855. YY_CAST (union yyalloc *,
  856. YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
  857. if (! yyptr)
  858. goto yyexhaustedlab;
  859. YYSTACK_RELOCATE (yyss_alloc, yyss);
  860. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  861. # undef YYSTACK_RELOCATE
  862. if (yyss1 != yyssa)
  863. YYSTACK_FREE (yyss1);
  864. }
  865. # endif
  866. yyssp = yyss + yysize - 1;
  867. yyvsp = yyvs + yysize - 1;
  868. YY_IGNORE_USELESS_CAST_BEGIN
  869. YYDPRINTF ((stderr, "Stack size increased to %ld\n",
  870. YY_CAST (long, yystacksize)));
  871. YY_IGNORE_USELESS_CAST_END
  872. if (yyss + yystacksize - 1 <= yyssp)
  873. YYABORT;
  874. }
  875. #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
  876. if (yystate == YYFINAL)
  877. YYACCEPT;
  878. goto yybackup;
  879. /*-----------.
  880. | yybackup. |
  881. `-----------*/
  882. yybackup:
  883. /* Do appropriate processing given the current state. Read a
  884. lookahead token if we need one and don't already have one. */
  885. /* First try to decide what to do without reference to lookahead token. */
  886. yyn = yypact[yystate];
  887. if (yypact_value_is_default (yyn))
  888. goto yydefault;
  889. /* Not known => get a lookahead token if don't already have one. */
  890. /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
  891. if (yychar == YYEMPTY)
  892. {
  893. YYDPRINTF ((stderr, "Reading a token\n"));
  894. yychar = yylex ();
  895. }
  896. if (yychar <= YYEOF)
  897. {
  898. yychar = YYEOF;
  899. yytoken = YYSYMBOL_YYEOF;
  900. YYDPRINTF ((stderr, "Now at end of input.\n"));
  901. }
  902. else if (yychar == YYerror)
  903. {
  904. /* The scanner already issued an error message, process directly
  905. to error recovery. But do not keep the error token as
  906. lookahead, it is too special and may lead us to an endless
  907. loop in error recovery. */
  908. yychar = YYUNDEF;
  909. yytoken = YYSYMBOL_YYerror;
  910. goto yyerrlab1;
  911. }
  912. else
  913. {
  914. yytoken = YYTRANSLATE (yychar);
  915. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  916. }
  917. /* If the proper action on seeing token YYTOKEN is to reduce or to
  918. detect an error, take that action. */
  919. yyn += yytoken;
  920. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  921. goto yydefault;
  922. yyn = yytable[yyn];
  923. if (yyn <= 0)
  924. {
  925. if (yytable_value_is_error (yyn))
  926. goto yyerrlab;
  927. yyn = -yyn;
  928. goto yyreduce;
  929. }
  930. /* Count tokens shifted since error; after three, turn off error
  931. status. */
  932. if (yyerrstatus)
  933. yyerrstatus--;
  934. /* Shift the lookahead token. */
  935. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  936. yystate = yyn;
  937. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  938. *++yyvsp = yylval;
  939. YY_IGNORE_MAYBE_UNINITIALIZED_END
  940. /* Discard the shifted token. */
  941. yychar = YYEMPTY;
  942. goto yynewstate;
  943. /*-----------------------------------------------------------.
  944. | yydefault -- do the default action for the current state. |
  945. `-----------------------------------------------------------*/
  946. yydefault:
  947. yyn = yydefact[yystate];
  948. if (yyn == 0)
  949. goto yyerrlab;
  950. goto yyreduce;
  951. /*-----------------------------.
  952. | yyreduce -- do a reduction. |
  953. `-----------------------------*/
  954. yyreduce:
  955. /* yyn is the number of a rule to reduce with. */
  956. yylen = yyr2[yyn];
  957. /* If YYLEN is nonzero, implement the default value of the action:
  958. '$$ = $1'.
  959. Otherwise, the following line sets YYVAL to garbage.
  960. This behavior is undocumented and Bison
  961. users should not rely upon it. Assigning to YYVAL
  962. unconditionally makes the parser a bit smaller, and it avoids a
  963. GCC warning that YYVAL may be used uninitialized. */
  964. yyval = yyvsp[1-yylen];
  965. YY_REDUCE_PRINT (yyn);
  966. switch (yyn)
  967. {
  968. case 5: /* complete: complete EOFILE */
  969. #line 62 "pam_conv_y.y"
  970. {
  971. return 0;
  972. }
  973. #line 1175 "pam_conv_y.c"
  974. break;
  975. case 6: /* line: tok tok tok path tokenls NL */
  976. #line 68 "pam_conv_y.y"
  977. {
  978. char *filename;
  979. FILE *conf;
  980. int i;
  981. /* make sure we have lower case */
  982. for (i=0; (yyvsp[-5].string)[i]; ++i) {
  983. (yyvsp[-5].string)[i] = tolower((yyvsp[-5].string)[i]);
  984. }
  985. /* $1 = service-name */
  986. yyerror("Appending to " PAM_D "/%s", (yyvsp[-5].string));
  987. filename = malloc(strlen((yyvsp[-5].string)) + sizeof(PAM_D) + 6);
  988. sprintf(filename, PAM_D_FILE_FMT, (yyvsp[-5].string));
  989. conf = fopen(filename, "r");
  990. if (conf == NULL) {
  991. /* new file */
  992. conf = fopen(filename, "w");
  993. if (conf != NULL) {
  994. fprintf(conf, PAM_D_MAGIC_HEADER);
  995. fprintf(conf,
  996. "#\n"
  997. "# The PAM configuration file for the `%s' service\n"
  998. "#\n", (yyvsp[-5].string));
  999. }
  1000. } else {
  1001. fclose(conf);
  1002. conf = fopen(filename, "a");
  1003. }
  1004. if (conf == NULL) {
  1005. yyerror("trouble opening %s - aborting", filename);
  1006. exit(1);
  1007. }
  1008. free(filename);
  1009. /* $2 = module-type */
  1010. fprintf(conf, "%-10s", (yyvsp[-4].string));
  1011. free((yyvsp[-4].string));
  1012. /* $3 = required etc. */
  1013. {
  1014. const char *trans;
  1015. trans = old_to_new_ctrl_flag((yyvsp[-3].string));
  1016. free((yyvsp[-3].string));
  1017. fprintf(conf, " %-10s", trans);
  1018. }
  1019. /* $4 = module-path */
  1020. fprintf(conf, " %s", (yyvsp[-2].string));
  1021. free((yyvsp[-2].string));
  1022. /* $5 = arguments */
  1023. if ((yyvsp[-1].string) != NULL) {
  1024. fprintf(conf, " \\\n\t\t%s", (yyvsp[-1].string));
  1025. free((yyvsp[-1].string));
  1026. }
  1027. /* end line */
  1028. fprintf(conf, "\n");
  1029. fclose(conf);
  1030. }
  1031. #line 1244 "pam_conv_y.c"
  1032. break;
  1033. case 7: /* line: error NL */
  1034. #line 132 "pam_conv_y.y"
  1035. {
  1036. yyerror("malformed line");
  1037. }
  1038. #line 1252 "pam_conv_y.c"
  1039. break;
  1040. case 8: /* tokenls: %empty */
  1041. #line 138 "pam_conv_y.y"
  1042. {
  1043. (yyval.string)=NULL;
  1044. }
  1045. #line 1260 "pam_conv_y.c"
  1046. break;
  1047. case 9: /* tokenls: tokenls tok */
  1048. #line 141 "pam_conv_y.y"
  1049. {
  1050. int len;
  1051. if ((yyvsp[-1].string)) {
  1052. len = strlen((yyvsp[-1].string)) + strlen((yyvsp[0].string)) + 2;
  1053. (yyval.string) = malloc(len);
  1054. sprintf((yyval.string),"%s %s",(yyvsp[-1].string),(yyvsp[0].string));
  1055. free((yyvsp[-1].string));
  1056. free((yyvsp[0].string));
  1057. } else {
  1058. (yyval.string) = (yyvsp[0].string);
  1059. }
  1060. }
  1061. #line 1278 "pam_conv_y.c"
  1062. break;
  1063. case 10: /* path: TOK */
  1064. #line 157 "pam_conv_y.y"
  1065. {
  1066. /* XXX - this could be used to check if file present */
  1067. (yyval.string) = strdup(yytext);
  1068. }
  1069. #line 1287 "pam_conv_y.c"
  1070. break;
  1071. case 11: /* tok: TOK */
  1072. #line 163 "pam_conv_y.y"
  1073. {
  1074. (yyval.string) = strdup(yytext);
  1075. }
  1076. #line 1295 "pam_conv_y.c"
  1077. break;
  1078. #line 1299 "pam_conv_y.c"
  1079. default: break;
  1080. }
  1081. /* User semantic actions sometimes alter yychar, and that requires
  1082. that yytoken be updated with the new translation. We take the
  1083. approach of translating immediately before every use of yytoken.
  1084. One alternative is translating here after every semantic action,
  1085. but that translation would be missed if the semantic action invokes
  1086. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1087. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1088. incorrect destructor might then be invoked immediately. In the
  1089. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1090. to an incorrect destructor call or verbose syntax error message
  1091. before the lookahead is translated. */
  1092. YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
  1093. YYPOPSTACK (yylen);
  1094. yylen = 0;
  1095. *++yyvsp = yyval;
  1096. /* Now 'shift' the result of the reduction. Determine what state
  1097. that goes to, based on the state we popped back to and the rule
  1098. number reduced by. */
  1099. {
  1100. const int yylhs = yyr1[yyn] - YYNTOKENS;
  1101. const int yyi = yypgoto[yylhs] + *yyssp;
  1102. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
  1103. ? yytable[yyi]
  1104. : yydefgoto[yylhs]);
  1105. }
  1106. goto yynewstate;
  1107. /*--------------------------------------.
  1108. | yyerrlab -- here on detecting error. |
  1109. `--------------------------------------*/
  1110. yyerrlab:
  1111. /* Make sure we have latest lookahead translation. See comments at
  1112. user semantic actions for why this is necessary. */
  1113. yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
  1114. /* If not already recovering from an error, report this error. */
  1115. if (!yyerrstatus)
  1116. {
  1117. ++yynerrs;
  1118. yyerror (YY_("syntax error"));
  1119. }
  1120. if (yyerrstatus == 3)
  1121. {
  1122. /* If just tried and failed to reuse lookahead token after an
  1123. error, discard it. */
  1124. if (yychar <= YYEOF)
  1125. {
  1126. /* Return failure if at end of input. */
  1127. if (yychar == YYEOF)
  1128. YYABORT;
  1129. }
  1130. else
  1131. {
  1132. yydestruct ("Error: discarding",
  1133. yytoken, &yylval);
  1134. yychar = YYEMPTY;
  1135. }
  1136. }
  1137. /* Else will try to reuse lookahead token after shifting the error
  1138. token. */
  1139. goto yyerrlab1;
  1140. /*---------------------------------------------------.
  1141. | yyerrorlab -- error raised explicitly by YYERROR. |
  1142. `---------------------------------------------------*/
  1143. yyerrorlab:
  1144. /* Pacify compilers when the user code never invokes YYERROR and the
  1145. label yyerrorlab therefore never appears in user code. */
  1146. if (0)
  1147. YYERROR;
  1148. /* Do not reclaim the symbols of the rule whose action triggered
  1149. this YYERROR. */
  1150. YYPOPSTACK (yylen);
  1151. yylen = 0;
  1152. YY_STACK_PRINT (yyss, yyssp);
  1153. yystate = *yyssp;
  1154. goto yyerrlab1;
  1155. /*-------------------------------------------------------------.
  1156. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1157. `-------------------------------------------------------------*/
  1158. yyerrlab1:
  1159. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1160. /* Pop stack until we find a state that shifts the error token. */
  1161. for (;;)
  1162. {
  1163. yyn = yypact[yystate];
  1164. if (!yypact_value_is_default (yyn))
  1165. {
  1166. yyn += YYSYMBOL_YYerror;
  1167. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
  1168. {
  1169. yyn = yytable[yyn];
  1170. if (0 < yyn)
  1171. break;
  1172. }
  1173. }
  1174. /* Pop the current state because it cannot handle the error token. */
  1175. if (yyssp == yyss)
  1176. YYABORT;
  1177. yydestruct ("Error: popping",
  1178. YY_ACCESSING_SYMBOL (yystate), yyvsp);
  1179. YYPOPSTACK (1);
  1180. yystate = *yyssp;
  1181. YY_STACK_PRINT (yyss, yyssp);
  1182. }
  1183. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1184. *++yyvsp = yylval;
  1185. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1186. /* Shift the error token. */
  1187. YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
  1188. yystate = yyn;
  1189. goto yynewstate;
  1190. /*-------------------------------------.
  1191. | yyacceptlab -- YYACCEPT comes here. |
  1192. `-------------------------------------*/
  1193. yyacceptlab:
  1194. yyresult = 0;
  1195. goto yyreturn;
  1196. /*-----------------------------------.
  1197. | yyabortlab -- YYABORT comes here. |
  1198. `-----------------------------------*/
  1199. yyabortlab:
  1200. yyresult = 1;
  1201. goto yyreturn;
  1202. #if !defined yyoverflow
  1203. /*-------------------------------------------------.
  1204. | yyexhaustedlab -- memory exhaustion comes here. |
  1205. `-------------------------------------------------*/
  1206. yyexhaustedlab:
  1207. yyerror (YY_("memory exhausted"));
  1208. yyresult = 2;
  1209. goto yyreturn;
  1210. #endif
  1211. /*-------------------------------------------------------.
  1212. | yyreturn -- parsing is finished, clean up and return. |
  1213. `-------------------------------------------------------*/
  1214. yyreturn:
  1215. if (yychar != YYEMPTY)
  1216. {
  1217. /* Make sure we have latest lookahead translation. See comments at
  1218. user semantic actions for why this is necessary. */
  1219. yytoken = YYTRANSLATE (yychar);
  1220. yydestruct ("Cleanup: discarding lookahead",
  1221. yytoken, &yylval);
  1222. }
  1223. /* Do not reclaim the symbols of the rule whose action triggered
  1224. this YYABORT or YYACCEPT. */
  1225. YYPOPSTACK (yylen);
  1226. YY_STACK_PRINT (yyss, yyssp);
  1227. while (yyssp != yyss)
  1228. {
  1229. yydestruct ("Cleanup: popping",
  1230. YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
  1231. YYPOPSTACK (1);
  1232. }
  1233. #ifndef yyoverflow
  1234. if (yyss != yyssa)
  1235. YYSTACK_FREE (yyss);
  1236. #endif
  1237. return yyresult;
  1238. }
  1239. #line 167 "pam_conv_y.y"
  1240. const char *old_to_new_ctrl_flag(const char *old)
  1241. {
  1242. static const char *clist[] = {
  1243. "requisite",
  1244. "required",
  1245. "sufficient",
  1246. "optional",
  1247. NULL,
  1248. };
  1249. int i;
  1250. for (i=0; clist[i]; ++i) {
  1251. if (strcasecmp(clist[i], old) == 0) {
  1252. break;
  1253. }
  1254. }
  1255. return clist[i];
  1256. }
  1257. PAM_FORMAT((printf, 1, 2))
  1258. void yyerror(const char *format, ...)
  1259. {
  1260. va_list args;
  1261. fprintf(stderr, "line %d: ", current_line);
  1262. va_start(args, format);
  1263. vfprintf(stderr, format, args);
  1264. va_end(args);
  1265. fprintf(stderr, "\n");
  1266. }
  1267. int main(void)
  1268. {
  1269. if (mkdir(PAM_D, PAM_D_MODE) != 0) {
  1270. yyerror(PAM_D " already exists.. aborting");
  1271. exit(1);
  1272. }
  1273. yyparse();
  1274. exit(0);
  1275. }