PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/crypto/heimdal/appl/ftp/ftpd/ftpcmd.c

https://bitbucket.org/freebsd/freebsd-head/
C | 3532 lines | 2815 code | 414 blank | 303 comment | 494 complexity | 26c4001a2a6f5dabfde2e8157f4c1009 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, LGPL-2.0, LGPL-2.1, BSD-2-Clause, 0BSD, JSON, AGPL-1.0, GPL-2.0
  1. /* A Bison parser, made by GNU Bison 2.3. */
  2. /* Skeleton implementation for Bison's Yacc-like parsers in C
  3. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
  4. Free Software Foundation, 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 2, or (at your option)
  8. 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, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. /* As a special exception, you may create a larger work that contains
  18. part or all of the Bison parser skeleton and distribute that work
  19. under terms of your choice, so long as that work isn't itself a
  20. parser generator using the skeleton or a modified version thereof
  21. as a parser skeleton. Alternatively, if you modify or redistribute
  22. the parser skeleton itself, you may (at your option) remove this
  23. special exception, which will cause the skeleton and the resulting
  24. Bison output files to be licensed under the GNU General Public
  25. License without this special exception.
  26. This special exception was added by the Free Software Foundation in
  27. version 2.2 of Bison. */
  28. /* C LALR(1) parser skeleton written by Richard Stallman, by
  29. simplifying the original so-called "semantic" parser. */
  30. /* All symbols defined below should begin with yy or YY, to avoid
  31. infringing on user name space. This should be done even for local
  32. variables, as they might otherwise be expanded by user macros.
  33. There are some unavoidable exceptions within include files to
  34. define necessary library symbols; they are noted "INFRINGES ON
  35. USER NAME SPACE" below. */
  36. /* Identify Bison output. */
  37. #define YYBISON 1
  38. /* Bison version. */
  39. #define YYBISON_VERSION "2.3"
  40. /* Skeleton name. */
  41. #define YYSKELETON_NAME "yacc.c"
  42. /* Pure parsers. */
  43. #define YYPURE 0
  44. /* Using locations. */
  45. #define YYLSP_NEEDED 0
  46. /* Tokens. */
  47. #ifndef YYTOKENTYPE
  48. # define YYTOKENTYPE
  49. /* Put the tokens into the symbol table, so that GDB and other debuggers
  50. know about them. */
  51. enum yytokentype {
  52. A = 258,
  53. B = 259,
  54. C = 260,
  55. E = 261,
  56. F = 262,
  57. I = 263,
  58. L = 264,
  59. N = 265,
  60. P = 266,
  61. R = 267,
  62. S = 268,
  63. T = 269,
  64. SP = 270,
  65. CRLF = 271,
  66. COMMA = 272,
  67. USER = 273,
  68. PASS = 274,
  69. ACCT = 275,
  70. REIN = 276,
  71. QUIT = 277,
  72. PORT = 278,
  73. PASV = 279,
  74. TYPE = 280,
  75. STRU = 281,
  76. MODE = 282,
  77. RETR = 283,
  78. STOR = 284,
  79. APPE = 285,
  80. MLFL = 286,
  81. MAIL = 287,
  82. MSND = 288,
  83. MSOM = 289,
  84. MSAM = 290,
  85. MRSQ = 291,
  86. MRCP = 292,
  87. ALLO = 293,
  88. REST = 294,
  89. RNFR = 295,
  90. RNTO = 296,
  91. ABOR = 297,
  92. DELE = 298,
  93. CWD = 299,
  94. LIST = 300,
  95. NLST = 301,
  96. SITE = 302,
  97. sTAT = 303,
  98. HELP = 304,
  99. NOOP = 305,
  100. MKD = 306,
  101. RMD = 307,
  102. PWD = 308,
  103. CDUP = 309,
  104. STOU = 310,
  105. SMNT = 311,
  106. SYST = 312,
  107. SIZE = 313,
  108. MDTM = 314,
  109. EPRT = 315,
  110. EPSV = 316,
  111. UMASK = 317,
  112. IDLE = 318,
  113. CHMOD = 319,
  114. AUTH = 320,
  115. ADAT = 321,
  116. PROT = 322,
  117. PBSZ = 323,
  118. CCC = 324,
  119. MIC = 325,
  120. CONF = 326,
  121. ENC = 327,
  122. KAUTH = 328,
  123. KLIST = 329,
  124. KDESTROY = 330,
  125. KRBTKFILE = 331,
  126. AFSLOG = 332,
  127. LOCATE = 333,
  128. URL = 334,
  129. FEAT = 335,
  130. OPTS = 336,
  131. LEXERR = 337,
  132. STRING = 338,
  133. NUMBER = 339
  134. };
  135. #endif
  136. /* Tokens. */
  137. #define A 258
  138. #define B 259
  139. #define C 260
  140. #define E 261
  141. #define F 262
  142. #define I 263
  143. #define L 264
  144. #define N 265
  145. #define P 266
  146. #define R 267
  147. #define S 268
  148. #define T 269
  149. #define SP 270
  150. #define CRLF 271
  151. #define COMMA 272
  152. #define USER 273
  153. #define PASS 274
  154. #define ACCT 275
  155. #define REIN 276
  156. #define QUIT 277
  157. #define PORT 278
  158. #define PASV 279
  159. #define TYPE 280
  160. #define STRU 281
  161. #define MODE 282
  162. #define RETR 283
  163. #define STOR 284
  164. #define APPE 285
  165. #define MLFL 286
  166. #define MAIL 287
  167. #define MSND 288
  168. #define MSOM 289
  169. #define MSAM 290
  170. #define MRSQ 291
  171. #define MRCP 292
  172. #define ALLO 293
  173. #define REST 294
  174. #define RNFR 295
  175. #define RNTO 296
  176. #define ABOR 297
  177. #define DELE 298
  178. #define CWD 299
  179. #define LIST 300
  180. #define NLST 301
  181. #define SITE 302
  182. #define sTAT 303
  183. #define HELP 304
  184. #define NOOP 305
  185. #define MKD 306
  186. #define RMD 307
  187. #define PWD 308
  188. #define CDUP 309
  189. #define STOU 310
  190. #define SMNT 311
  191. #define SYST 312
  192. #define SIZE 313
  193. #define MDTM 314
  194. #define EPRT 315
  195. #define EPSV 316
  196. #define UMASK 317
  197. #define IDLE 318
  198. #define CHMOD 319
  199. #define AUTH 320
  200. #define ADAT 321
  201. #define PROT 322
  202. #define PBSZ 323
  203. #define CCC 324
  204. #define MIC 325
  205. #define CONF 326
  206. #define ENC 327
  207. #define KAUTH 328
  208. #define KLIST 329
  209. #define KDESTROY 330
  210. #define KRBTKFILE 331
  211. #define AFSLOG 332
  212. #define LOCATE 333
  213. #define URL 334
  214. #define FEAT 335
  215. #define OPTS 336
  216. #define LEXERR 337
  217. #define STRING 338
  218. #define NUMBER 339
  219. /* Copy the first part of user declarations. */
  220. #line 43 "ftpcmd.y"
  221. #include "ftpd_locl.h"
  222. RCSID("$Id$");
  223. off_t restart_point;
  224. static int hasyyerrored;
  225. static int cmd_type;
  226. static int cmd_form;
  227. static int cmd_bytesz;
  228. char cbuf[64*1024];
  229. char *fromname;
  230. struct tab {
  231. char *name;
  232. short token;
  233. short state;
  234. short implemented; /* 1 if command is implemented */
  235. char *help;
  236. };
  237. extern struct tab cmdtab[];
  238. extern struct tab sitetab[];
  239. static char *copy (char *);
  240. static void help (struct tab *, char *);
  241. static struct tab *
  242. lookup (struct tab *, char *);
  243. static void sizecmd (char *);
  244. static RETSIGTYPE toolong (int);
  245. static int yylex (void);
  246. /* This is for bison */
  247. #if !defined(alloca) && !defined(HAVE_ALLOCA)
  248. #define alloca(x) malloc(x)
  249. #endif
  250. /* Enabling traces. */
  251. #ifndef YYDEBUG
  252. # define YYDEBUG 0
  253. #endif
  254. /* Enabling verbose error messages. */
  255. #ifdef YYERROR_VERBOSE
  256. # undef YYERROR_VERBOSE
  257. # define YYERROR_VERBOSE 1
  258. #else
  259. # define YYERROR_VERBOSE 0
  260. #endif
  261. /* Enabling the token table. */
  262. #ifndef YYTOKEN_TABLE
  263. # define YYTOKEN_TABLE 0
  264. #endif
  265. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  266. typedef union YYSTYPE
  267. #line 86 "ftpcmd.y"
  268. {
  269. int i;
  270. char *s;
  271. }
  272. /* Line 193 of yacc.c. */
  273. #line 312 "ftpcmd.c"
  274. YYSTYPE;
  275. # define yystype YYSTYPE /* obsolescent; will be withdrawn */
  276. # define YYSTYPE_IS_DECLARED 1
  277. # define YYSTYPE_IS_TRIVIAL 1
  278. #endif
  279. /* Copy the second part of user declarations. */
  280. /* Line 216 of yacc.c. */
  281. #line 325 "ftpcmd.c"
  282. #ifdef short
  283. # undef short
  284. #endif
  285. #ifdef YYTYPE_UINT8
  286. typedef YYTYPE_UINT8 yytype_uint8;
  287. #else
  288. typedef unsigned char yytype_uint8;
  289. #endif
  290. #ifdef YYTYPE_INT8
  291. typedef YYTYPE_INT8 yytype_int8;
  292. #elif (defined __STDC__ || defined __C99__FUNC__ \
  293. || defined __cplusplus || defined _MSC_VER)
  294. typedef signed char yytype_int8;
  295. #else
  296. typedef short int yytype_int8;
  297. #endif
  298. #ifdef YYTYPE_UINT16
  299. typedef YYTYPE_UINT16 yytype_uint16;
  300. #else
  301. typedef unsigned short int yytype_uint16;
  302. #endif
  303. #ifdef YYTYPE_INT16
  304. typedef YYTYPE_INT16 yytype_int16;
  305. #else
  306. typedef short int yytype_int16;
  307. #endif
  308. #ifndef YYSIZE_T
  309. # ifdef __SIZE_TYPE__
  310. # define YYSIZE_T __SIZE_TYPE__
  311. # elif defined size_t
  312. # define YYSIZE_T size_t
  313. # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
  314. || defined __cplusplus || defined _MSC_VER)
  315. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  316. # define YYSIZE_T size_t
  317. # else
  318. # define YYSIZE_T unsigned int
  319. # endif
  320. #endif
  321. #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
  322. #ifndef YY_
  323. # if defined YYENABLE_NLS && YYENABLE_NLS
  324. # if ENABLE_NLS
  325. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  326. # define YY_(msgid) dgettext ("bison-runtime", msgid)
  327. # endif
  328. # endif
  329. # ifndef YY_
  330. # define YY_(msgid) msgid
  331. # endif
  332. #endif
  333. /* Suppress unused-variable warnings by "using" E. */
  334. #if ! defined lint || defined __GNUC__
  335. # define YYUSE(e) ((void) (e))
  336. #else
  337. # define YYUSE(e) /* empty */
  338. #endif
  339. /* Identity function, used to suppress warnings about constant conditions. */
  340. #ifndef lint
  341. # define YYID(n) (n)
  342. #else
  343. #if (defined __STDC__ || defined __C99__FUNC__ \
  344. || defined __cplusplus || defined _MSC_VER)
  345. static int
  346. YYID (int i)
  347. #else
  348. static int
  349. YYID (i)
  350. int i;
  351. #endif
  352. {
  353. return i;
  354. }
  355. #endif
  356. #if ! defined yyoverflow || YYERROR_VERBOSE
  357. /* The parser invokes alloca or malloc; define the necessary symbols. */
  358. # ifdef YYSTACK_USE_ALLOCA
  359. # if YYSTACK_USE_ALLOCA
  360. # ifdef __GNUC__
  361. # define YYSTACK_ALLOC __builtin_alloca
  362. # elif defined __BUILTIN_VA_ARG_INCR
  363. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  364. # elif defined _AIX
  365. # define YYSTACK_ALLOC __alloca
  366. # elif defined _MSC_VER
  367. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  368. # define alloca _alloca
  369. # else
  370. # define YYSTACK_ALLOC alloca
  371. # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  372. || defined __cplusplus || defined _MSC_VER)
  373. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  374. # ifndef _STDLIB_H
  375. # define _STDLIB_H 1
  376. # endif
  377. # endif
  378. # endif
  379. # endif
  380. # endif
  381. # ifdef YYSTACK_ALLOC
  382. /* Pacify GCC's `empty if-body' warning. */
  383. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
  384. # ifndef YYSTACK_ALLOC_MAXIMUM
  385. /* The OS might guarantee only one guard page at the bottom of the stack,
  386. and a page size can be as small as 4096 bytes. So we cannot safely
  387. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  388. to allow for a few compiler-allocated temporary stack slots. */
  389. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  390. # endif
  391. # else
  392. # define YYSTACK_ALLOC YYMALLOC
  393. # define YYSTACK_FREE YYFREE
  394. # ifndef YYSTACK_ALLOC_MAXIMUM
  395. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  396. # endif
  397. # if (defined __cplusplus && ! defined _STDLIB_H \
  398. && ! ((defined YYMALLOC || defined malloc) \
  399. && (defined YYFREE || defined free)))
  400. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  401. # ifndef _STDLIB_H
  402. # define _STDLIB_H 1
  403. # endif
  404. # endif
  405. # ifndef YYMALLOC
  406. # define YYMALLOC malloc
  407. # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  408. || defined __cplusplus || defined _MSC_VER)
  409. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  410. # endif
  411. # endif
  412. # ifndef YYFREE
  413. # define YYFREE free
  414. # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  415. || defined __cplusplus || defined _MSC_VER)
  416. void free (void *); /* INFRINGES ON USER NAME SPACE */
  417. # endif
  418. # endif
  419. # endif
  420. #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
  421. #if (! defined yyoverflow \
  422. && (! defined __cplusplus \
  423. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  424. /* A type that is properly aligned for any stack member. */
  425. union yyalloc
  426. {
  427. yytype_int16 yyss;
  428. YYSTYPE yyvs;
  429. };
  430. /* The size of the maximum gap between one aligned stack and the next. */
  431. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  432. /* The size of an array large to enough to hold all stacks, each with
  433. N elements. */
  434. # define YYSTACK_BYTES(N) \
  435. ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
  436. + YYSTACK_GAP_MAXIMUM)
  437. /* Copy COUNT objects from FROM to TO. The source and destination do
  438. not overlap. */
  439. # ifndef YYCOPY
  440. # if defined __GNUC__ && 1 < __GNUC__
  441. # define YYCOPY(To, From, Count) \
  442. __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  443. # else
  444. # define YYCOPY(To, From, Count) \
  445. do \
  446. { \
  447. YYSIZE_T yyi; \
  448. for (yyi = 0; yyi < (Count); yyi++) \
  449. (To)[yyi] = (From)[yyi]; \
  450. } \
  451. while (YYID (0))
  452. # endif
  453. # endif
  454. /* Relocate STACK from its old location to the new one. The
  455. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  456. elements in the stack, and YYPTR gives the new location of the
  457. stack. Advance YYPTR to a properly aligned location for the next
  458. stack. */
  459. # define YYSTACK_RELOCATE(Stack) \
  460. do \
  461. { \
  462. YYSIZE_T yynewbytes; \
  463. YYCOPY (&yyptr->Stack, Stack, yysize); \
  464. Stack = &yyptr->Stack; \
  465. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  466. yyptr += yynewbytes / sizeof (*yyptr); \
  467. } \
  468. while (YYID (0))
  469. #endif
  470. /* YYFINAL -- State number of the termination state. */
  471. #define YYFINAL 2
  472. /* YYLAST -- Last index in YYTABLE. */
  473. #define YYLAST 327
  474. /* YYNTOKENS -- Number of terminals. */
  475. #define YYNTOKENS 85
  476. /* YYNNTS -- Number of nonterminals. */
  477. #define YYNNTS 18
  478. /* YYNRULES -- Number of rules. */
  479. #define YYNRULES 98
  480. /* YYNRULES -- Number of states. */
  481. #define YYNSTATES 317
  482. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  483. #define YYUNDEFTOK 2
  484. #define YYMAXUTOK 339
  485. #define YYTRANSLATE(YYX) \
  486. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  487. /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
  488. static const yytype_uint8 yytranslate[] =
  489. {
  490. 0, 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, 2, 2, 2, 2,
  496. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  497. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  498. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  499. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  500. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  501. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  502. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  503. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  504. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  505. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  506. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  507. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  508. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  509. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  510. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  511. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  512. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  513. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  514. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  515. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  516. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  517. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  518. 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
  519. 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
  520. 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
  521. 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
  522. 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
  523. 75, 76, 77, 78, 79, 80, 81, 82, 83, 84
  524. };
  525. #if YYDEBUG
  526. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  527. YYRHS. */
  528. static const yytype_uint16 yyprhs[] =
  529. {
  530. 0, 0, 3, 4, 7, 10, 16, 22, 28, 34,
  531. 38, 42, 48, 54, 60, 66, 72, 82, 88, 94,
  532. 100, 104, 110, 114, 120, 126, 130, 136, 142, 146,
  533. 150, 156, 160, 166, 170, 176, 182, 186, 190, 194,
  534. 200, 206, 214, 220, 228, 238, 244, 252, 260, 266,
  535. 272, 280, 286, 294, 302, 308, 314, 318, 324, 330,
  536. 334, 337, 343, 349, 354, 359, 365, 371, 375, 380,
  537. 385, 390, 392, 393, 395, 397, 409, 411, 413, 415,
  538. 417, 421, 423, 427, 429, 431, 435, 438, 440, 442,
  539. 444, 446, 448, 450, 452, 454, 456, 458, 460
  540. };
  541. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  542. static const yytype_int8 yyrhs[] =
  543. {
  544. 86, 0, -1, -1, 86, 87, -1, 86, 88, -1,
  545. 18, 15, 89, 16, 102, -1, 19, 15, 90, 16,
  546. 102, -1, 23, 15, 92, 16, 102, -1, 60, 15,
  547. 83, 16, 102, -1, 24, 16, 101, -1, 61, 16,
  548. 101, -1, 61, 15, 83, 16, 101, -1, 25, 15,
  549. 94, 16, 102, -1, 26, 15, 95, 16, 102, -1,
  550. 27, 15, 96, 16, 102, -1, 38, 15, 84, 16,
  551. 102, -1, 38, 15, 84, 15, 12, 15, 84, 16,
  552. 102, -1, 28, 15, 97, 16, 101, -1, 29, 15,
  553. 97, 16, 101, -1, 30, 15, 97, 16, 101, -1,
  554. 46, 16, 101, -1, 46, 15, 83, 16, 101, -1,
  555. 45, 16, 101, -1, 45, 15, 97, 16, 101, -1,
  556. 48, 15, 97, 16, 101, -1, 48, 16, 102, -1,
  557. 43, 15, 97, 16, 100, -1, 41, 15, 97, 16,
  558. 100, -1, 42, 16, 102, -1, 44, 16, 101, -1,
  559. 44, 15, 97, 16, 101, -1, 49, 16, 102, -1,
  560. 49, 15, 83, 16, 102, -1, 50, 16, 102, -1,
  561. 51, 15, 97, 16, 101, -1, 52, 15, 97, 16,
  562. 100, -1, 53, 16, 101, -1, 54, 16, 101, -1,
  563. 80, 16, 102, -1, 81, 15, 83, 16, 102, -1,
  564. 47, 15, 49, 16, 102, -1, 47, 15, 49, 15,
  565. 83, 16, 102, -1, 47, 15, 62, 16, 101, -1,
  566. 47, 15, 62, 15, 99, 16, 100, -1, 47, 15,
  567. 64, 15, 99, 15, 97, 16, 100, -1, 47, 15,
  568. 63, 16, 102, -1, 47, 15, 63, 15, 84, 16,
  569. 102, -1, 47, 15, 73, 15, 83, 16, 101, -1,
  570. 47, 15, 74, 16, 101, -1, 47, 15, 75, 16,
  571. 101, -1, 47, 15, 76, 15, 83, 16, 101, -1,
  572. 47, 15, 77, 16, 101, -1, 47, 15, 77, 15,
  573. 83, 16, 101, -1, 47, 15, 78, 15, 83, 16,
  574. 101, -1, 47, 15, 79, 16, 102, -1, 55, 15,
  575. 97, 16, 101, -1, 57, 16, 102, -1, 58, 15,
  576. 97, 16, 101, -1, 59, 15, 97, 16, 101, -1,
  577. 22, 16, 102, -1, 1, 16, -1, 40, 15, 97,
  578. 16, 100, -1, 39, 15, 91, 16, 102, -1, 65,
  579. 15, 83, 16, -1, 66, 15, 83, 16, -1, 68,
  580. 15, 84, 16, 102, -1, 67, 15, 83, 16, 102,
  581. -1, 69, 16, 102, -1, 70, 15, 83, 16, -1,
  582. 71, 15, 83, 16, -1, 72, 15, 83, 16, -1,
  583. 83, -1, -1, 83, -1, 84, -1, 84, 17, 84,
  584. 17, 84, 17, 84, 17, 84, 17, 84, -1, 10,
  585. -1, 14, -1, 5, -1, 3, -1, 3, 15, 93,
  586. -1, 6, -1, 6, 15, 93, -1, 8, -1, 9,
  587. -1, 9, 15, 91, -1, 9, 91, -1, 7, -1,
  588. 12, -1, 11, -1, 13, -1, 4, -1, 5, -1,
  589. 98, -1, 83, -1, 84, -1, 101, -1, 102, -1,
  590. -1
  591. };
  592. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  593. static const yytype_uint16 yyrline[] =
  594. {
  595. 0, 129, 129, 131, 136, 140, 146, 154, 175, 181,
  596. 186, 191, 197, 234, 248, 262, 268, 274, 283, 292,
  597. 301, 306, 315, 320, 326, 333, 338, 345, 359, 364,
  598. 373, 380, 385, 402, 407, 414, 421, 426, 431, 441,
  599. 448, 453, 458, 466, 479, 493, 500, 517, 521, 526,
  600. 530, 534, 545, 558, 565, 570, 577, 595, 612, 640,
  601. 647, 653, 663, 673, 678, 683, 688, 693, 698, 703,
  602. 708, 716, 721, 724, 728, 732, 745, 749, 753, 760,
  603. 765, 770, 775, 780, 784, 789, 795, 803, 807, 811,
  604. 818, 822, 826, 833, 861, 865, 891, 899, 910
  605. };
  606. #endif
  607. #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
  608. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  609. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  610. static const char *const yytname[] =
  611. {
  612. "$end", "error", "$undefined", "A", "B", "C", "E", "F", "I", "L", "N",
  613. "P", "R", "S", "T", "SP", "CRLF", "COMMA", "USER", "PASS", "ACCT",
  614. "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR",
  615. "APPE", "MLFL", "MAIL", "MSND", "MSOM", "MSAM", "MRSQ", "MRCP", "ALLO",
  616. "REST", "RNFR", "RNTO", "ABOR", "DELE", "CWD", "LIST", "NLST", "SITE",
  617. "sTAT", "HELP", "NOOP", "MKD", "RMD", "PWD", "CDUP", "STOU", "SMNT",
  618. "SYST", "SIZE", "MDTM", "EPRT", "EPSV", "UMASK", "IDLE", "CHMOD", "AUTH",
  619. "ADAT", "PROT", "PBSZ", "CCC", "MIC", "CONF", "ENC", "KAUTH", "KLIST",
  620. "KDESTROY", "KRBTKFILE", "AFSLOG", "LOCATE", "URL", "FEAT", "OPTS",
  621. "LEXERR", "STRING", "NUMBER", "$accept", "cmd_list", "cmd", "rcmd",
  622. "username", "password", "byte_size", "host_port", "form_code",
  623. "type_code", "struct_code", "mode_code", "pathname", "pathstring",
  624. "octal_number", "check_login_no_guest", "check_login", "check_secure", 0
  625. };
  626. #endif
  627. # ifdef YYPRINT
  628. /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
  629. token YYLEX-NUM. */
  630. static const yytype_uint16 yytoknum[] =
  631. {
  632. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  633. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  634. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  635. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
  636. 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
  637. 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
  638. 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
  639. 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
  640. 335, 336, 337, 338, 339
  641. };
  642. # endif
  643. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  644. static const yytype_uint8 yyr1[] =
  645. {
  646. 0, 85, 86, 86, 86, 87, 87, 87, 87, 87,
  647. 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  648. 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  649. 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  650. 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  651. 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  652. 87, 88, 88, 88, 88, 88, 88, 88, 88, 88,
  653. 88, 89, 90, 90, 91, 92, 93, 93, 93, 94,
  654. 94, 94, 94, 94, 94, 94, 94, 95, 95, 95,
  655. 96, 96, 96, 97, 98, 99, 100, 101, 102
  656. };
  657. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  658. static const yytype_uint8 yyr2[] =
  659. {
  660. 0, 2, 0, 2, 2, 5, 5, 5, 5, 3,
  661. 3, 5, 5, 5, 5, 5, 9, 5, 5, 5,
  662. 3, 5, 3, 5, 5, 3, 5, 5, 3, 3,
  663. 5, 3, 5, 3, 5, 5, 3, 3, 3, 5,
  664. 5, 7, 5, 7, 9, 5, 7, 7, 5, 5,
  665. 7, 5, 7, 7, 5, 5, 3, 5, 5, 3,
  666. 2, 5, 5, 4, 4, 5, 5, 3, 4, 4,
  667. 4, 1, 0, 1, 1, 11, 1, 1, 1, 1,
  668. 3, 1, 3, 1, 1, 3, 2, 1, 1, 1,
  669. 1, 1, 1, 1, 1, 1, 1, 1, 0
  670. };
  671. /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
  672. STATE-NUM 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. 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
  677. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  678. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  679. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  680. 0, 0, 0, 0, 0, 0, 0, 0, 3, 4,
  681. 60, 0, 72, 98, 0, 98, 0, 0, 0, 0,
  682. 0, 0, 0, 0, 0, 0, 98, 0, 0, 98,
  683. 0, 98, 0, 98, 0, 0, 98, 0, 98, 98,
  684. 0, 0, 98, 98, 0, 98, 0, 0, 0, 0,
  685. 98, 0, 0, 0, 0, 98, 0, 0, 0, 98,
  686. 0, 71, 0, 73, 0, 59, 0, 0, 9, 97,
  687. 79, 81, 83, 84, 0, 87, 89, 88, 0, 91,
  688. 92, 90, 0, 94, 0, 93, 0, 0, 0, 74,
  689. 0, 0, 0, 28, 0, 0, 29, 0, 22, 0,
  690. 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  691. 0, 0, 0, 25, 0, 31, 33, 0, 0, 36,
  692. 37, 0, 56, 0, 0, 0, 0, 10, 0, 0,
  693. 0, 0, 67, 0, 0, 0, 38, 0, 98, 98,
  694. 0, 98, 0, 0, 0, 86, 98, 98, 98, 98,
  695. 98, 98, 0, 98, 98, 98, 98, 98, 98, 98,
  696. 98, 0, 98, 0, 98, 0, 98, 0, 0, 98,
  697. 98, 0, 0, 98, 0, 98, 98, 98, 98, 98,
  698. 98, 98, 98, 98, 98, 63, 64, 98, 98, 68,
  699. 69, 70, 98, 5, 6, 0, 7, 78, 76, 77,
  700. 80, 82, 85, 12, 13, 14, 17, 18, 19, 0,
  701. 15, 62, 61, 96, 27, 26, 30, 23, 21, 0,
  702. 40, 95, 0, 42, 0, 45, 0, 0, 48, 49,
  703. 0, 0, 51, 0, 54, 24, 32, 34, 35, 55,
  704. 57, 58, 8, 11, 66, 65, 39, 0, 0, 98,
  705. 98, 98, 0, 98, 98, 98, 98, 0, 0, 41,
  706. 43, 46, 0, 47, 50, 52, 53, 0, 98, 98,
  707. 0, 16, 44, 0, 0, 0, 75
  708. };
  709. /* YYDEFGOTO[NTERM-NUM]. */
  710. static const yytype_int16 yydefgoto[] =
  711. {
  712. -1, 1, 48, 49, 102, 104, 130, 107, 240, 114,
  713. 118, 122, 124, 125, 262, 252, 253, 109
  714. };
  715. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  716. STATE-NUM. */
  717. #define YYPACT_NINF -196
  718. static const yytype_int16 yypact[] =
  719. {
  720. -196, 246, -196, 3, 13, 20, 11, 24, 21, 26,
  721. 30, 45, 66, 67, 68, 69, 70, 71, 72, 76,
  722. 73, -7, -5, 15, 78, 28, 32, 80, 79, 82,
  723. 83, 91, 93, 94, 96, 97, 98, 38, 100, 101,
  724. 102, 103, 104, 106, 107, 108, 111, 109, -196, -196,
  725. -196, -66, 36, -196, 14, -196, 12, 22, 1, 46,
  726. 46, 46, 25, 48, 46, 46, -196, 46, 46, -196,
  727. 46, -196, 53, -196, 27, 46, -196, 55, -196, -196,
  728. 46, 46, -196, -196, 46, -196, 46, 46, 56, 59,
  729. -196, 60, 61, 62, 63, -196, 65, 77, 85, -196,
  730. 86, -196, 114, -196, 115, -196, 120, 130, -196, -196,
  731. 135, 136, -196, -11, 138, -196, -196, -196, 139, -196,
  732. -196, -196, 143, -196, 145, -196, 147, 156, 47, -196,
  733. 157, 162, 165, -196, 166, 168, -196, 170, -196, 174,
  734. -196, 49, 52, 54, 137, 177, 178, 179, 181, 64,
  735. 182, 183, 184, -196, 185, -196, -196, 186, 187, -196,
  736. -196, 188, -196, 189, 190, 191, 192, -196, 193, 194,
  737. 195, 196, -196, 197, 198, 199, -196, 200, -196, -196,
  738. 133, -196, 2, 2, 48, -196, -196, -196, -196, -196,
  739. -196, -196, 206, -196, -196, -196, -196, -196, -196, -196,
  740. -196, 110, -196, 140, -196, 141, -196, 140, 144, -196,
  741. -196, 146, 148, -196, 149, -196, -196, -196, -196, -196,
  742. -196, -196, -196, -196, -196, -196, -196, -196, -196, -196,
  743. -196, -196, -196, -196, -196, 202, -196, -196, -196, -196,
  744. -196, -196, -196, -196, -196, -196, -196, -196, -196, 205,
  745. -196, -196, -196, -196, -196, -196, -196, -196, -196, 207,
  746. -196, -196, 210, -196, 212, -196, 215, 217, -196, -196,
  747. 218, 219, -196, 221, -196, -196, -196, -196, -196, -196,
  748. -196, -196, -196, -196, -196, -196, -196, 155, 158, -196,
  749. -196, -196, 46, -196, -196, -196, -196, 204, 224, -196,
  750. -196, -196, 225, -196, -196, -196, -196, 159, -196, -196,
  751. 227, -196, -196, 161, 231, 167, -196
  752. };
  753. /* YYPGOTO[NTERM-NUM]. */
  754. static const yytype_int16 yypgoto[] =
  755. {
  756. -196, -196, -196, -196, -196, -196, -110, -196, 39, -196,
  757. -196, -196, -9, -196, 42, -195, -33, -53
  758. };
  759. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  760. positive, shift that token. If negative, reduce the rule which
  761. number is the opposite. If zero, do what YYDEFACT says.
  762. If YYTABLE_NINF, syntax error. */
  763. #define YYTABLE_NINF -1
  764. static const yytype_uint16 yytable[] =
  765. {
  766. 105, 254, 255, 185, 184, 119, 120, 237, 68, 69,
  767. 70, 71, 238, 133, 121, 110, 239, 101, 111, 50,
  768. 112, 113, 108, 153, 278, 155, 156, 53, 51, 115,
  769. 72, 73, 162, 116, 117, 52, 136, 55, 138, 54,
  770. 140, 56, 172, 75, 76, 57, 176, 77, 78, 159,
  771. 160, 126, 127, 89, 90, 131, 132, 167, 134, 135,
  772. 58, 137, 192, 193, 201, 202, 152, 203, 204, 205,
  773. 206, 157, 158, 129, 242, 161, 141, 163, 164, 212,
  774. 213, 59, 60, 61, 62, 63, 64, 65, 67, 142,
  775. 143, 144, 66, 74, 80, 300, 79, 81, 106, 82,
  776. 145, 146, 147, 148, 149, 150, 151, 83, 84, 128,
  777. 85, 86, 87, 88, 312, 91, 92, 93, 94, 103,
  778. 95, 96, 97, 98, 100, 233, 234, 99, 236, 123,
  779. 178, 179, 129, 243, 244, 245, 139, 180, 154, 165,
  780. 250, 251, 166, 168, 169, 170, 181, 171, 173, 260,
  781. 182, 183, 207, 265, 186, 187, 246, 247, 248, 188,
  782. 174, 189, 274, 190, 276, 256, 257, 258, 175, 177,
  783. 282, 263, 191, 194, 284, 285, 268, 269, 195, 286,
  784. 272, 196, 197, 275, 198, 277, 199, 279, 280, 281,
  785. 200, 283, 208, 259, 209, 210, 211, 214, 0, 215,
  786. 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
  787. 226, 227, 228, 229, 230, 231, 232, 235, 249, 287,
  788. 288, 307, 241, 289, 261, 264, 290, 267, 291, 270,
  789. 292, 271, 273, 293, 294, 295, 299, 296, 301, 297,
  790. 308, 309, 298, 310, 313, 314, 2, 3, 315, 266,
  791. 0, 316, 0, 0, 0, 311, 0, 0, 0, 0,
  792. 303, 304, 305, 306, 4, 5, 0, 0, 6, 7,
  793. 8, 9, 10, 11, 12, 13, 14, 0, 0, 0,
  794. 0, 0, 0, 302, 15, 16, 17, 18, 19, 20,
  795. 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  796. 31, 32, 0, 33, 34, 35, 36, 37, 0, 0,
  797. 0, 38, 39, 40, 41, 42, 43, 44, 45, 0,
  798. 0, 0, 0, 0, 0, 0, 46, 47
  799. };
  800. static const yytype_int16 yycheck[] =
  801. {
  802. 53, 196, 197, 113, 15, 4, 5, 5, 15, 16,
  803. 15, 16, 10, 66, 13, 3, 14, 83, 6, 16,
  804. 8, 9, 55, 76, 219, 78, 79, 16, 15, 7,
  805. 15, 16, 85, 11, 12, 15, 69, 16, 71, 15,
  806. 73, 15, 95, 15, 16, 15, 99, 15, 16, 82,
  807. 83, 60, 61, 15, 16, 64, 65, 90, 67, 68,
  808. 15, 70, 15, 16, 15, 16, 75, 15, 16, 15,
  809. 16, 80, 81, 84, 184, 84, 49, 86, 87, 15,
  810. 16, 15, 15, 15, 15, 15, 15, 15, 15, 62,
  811. 63, 64, 16, 15, 15, 290, 16, 15, 84, 16,
  812. 73, 74, 75, 76, 77, 78, 79, 16, 15, 84,
  813. 16, 15, 15, 15, 309, 15, 15, 15, 15, 83,
  814. 16, 15, 15, 15, 15, 178, 179, 16, 181, 83,
  815. 16, 16, 84, 186, 187, 188, 83, 17, 83, 83,
  816. 193, 194, 83, 83, 83, 83, 16, 84, 83, 202,
  817. 15, 15, 15, 206, 16, 16, 189, 190, 191, 16,
  818. 83, 16, 215, 16, 217, 198, 199, 200, 83, 83,
  819. 223, 204, 16, 16, 227, 228, 209, 210, 16, 232,
  820. 213, 16, 16, 216, 16, 218, 16, 220, 221, 222,
  821. 16, 224, 15, 83, 16, 16, 15, 15, -1, 16,
  822. 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  823. 16, 16, 16, 16, 16, 16, 16, 84, 12, 17,
  824. 15, 17, 183, 16, 84, 84, 16, 83, 16, 83,
  825. 15, 83, 83, 16, 16, 16, 289, 16, 291, 84,
  826. 16, 16, 84, 84, 17, 84, 0, 1, 17, 207,
  827. -1, 84, -1, -1, -1, 308, -1, -1, -1, -1,
  828. 293, 294, 295, 296, 18, 19, -1, -1, 22, 23,
  829. 24, 25, 26, 27, 28, 29, 30, -1, -1, -1,
  830. -1, -1, -1, 292, 38, 39, 40, 41, 42, 43,
  831. 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
  832. 54, 55, -1, 57, 58, 59, 60, 61, -1, -1,
  833. -1, 65, 66, 67, 68, 69, 70, 71, 72, -1,
  834. -1, -1, -1, -1, -1, -1, 80, 81
  835. };
  836. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  837. symbol of state STATE-NUM. */
  838. static const yytype_uint8 yystos[] =
  839. {
  840. 0, 86, 0, 1, 18, 19, 22, 23, 24, 25,
  841. 26, 27, 28, 29, 30, 38, 39, 40, 41, 42,
  842. 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
  843. 53, 54, 55, 57, 58, 59, 60, 61, 65, 66,
  844. 67, 68, 69, 70, 71, 72, 80, 81, 87, 88,
  845. 16, 15, 15, 16, 15, 16, 15, 15, 15, 15,
  846. 15, 15, 15, 15, 15, 15, 16, 15, 15, 16,
  847. 15, 16, 15, 16, 15, 15, 16, 15, 16, 16,
  848. 15, 15, 16, 16, 15, 16, 15, 15, 15, 15,
  849. 16, 15, 15, 15, 15, 16, 15, 15, 15, 16,
  850. 15, 83, 89, 83, 90, 102, 84, 92, 101, 102,
  851. 3, 6, 8, 9, 94, 7, 11, 12, 95, 4,
  852. 5, 13, 96, 83, 97, 98, 97, 97, 84, 84,
  853. 91, 97, 97, 102, 97, 97, 101, 97, 101, 83,
  854. 101, 49, 62, 63, 64, 73, 74, 75, 76, 77,
  855. 78, 79, 97, 102, 83, 102, 102, 97, 97, 101,
  856. 101, 97, 102, 97, 97, 83, 83, 101, 83, 83,
  857. 83, 84, 102, 83, 83, 83, 102, 83, 16, 16,
  858. 17, 16, 15, 15, 15, 91, 16, 16, 16, 16,
  859. 16, 16, 15, 16, 16, 16, 16, 16, 16, 16,
  860. 16, 15, 16, 15, 16, 15, 16, 15, 15, 16,
  861. 16, 15, 15, 16, 15, 16, 16, 16, 16, 16,
  862. 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  863. 16, 16, 16, 102, 102, 84, 102, 5, 10, 14,
  864. 93, 93, 91, 102, 102, 102, 101, 101, 101, 12,
  865. 102, 102, 100, 101, 100, 100, 101, 101, 101, 83,
  866. 102, 84, 99, 101, 84, 102, 99, 83, 101, 101,
  867. 83, 83, 101, 83, 102, 101, 102, 101, 100, 101,
  868. 101, 101, 102, 101, 102, 102, 102, 17, 15, 16,
  869. 16, 16, 15, 16, 16, 16, 16, 84, 84, 102,
  870. 100, 102, 97, 101, 101, 101, 101, 17, 16, 16,
  871. 84, 102, 100, 17, 84, 17, 84
  872. };
  873. #define yyerrok (yyerrstatus = 0)
  874. #define yyclearin (yychar = YYEMPTY)
  875. #define YYEMPTY (-2)
  876. #define YYEOF 0
  877. #define YYACCEPT goto yyacceptlab
  878. #define YYABORT goto yyabortlab
  879. #define YYERROR goto yyerrorlab
  880. /* Like YYERROR except do call yyerror. This remains here temporarily
  881. to ease the transition to the new meaning of YYERROR, for GCC.
  882. Once GCC version 2 has supplanted version 1, this can go. */
  883. #define YYFAIL goto yyerrlab
  884. #define YYRECOVERING() (!!yyerrstatus)
  885. #define YYBACKUP(Token, Value) \
  886. do \
  887. if (yychar == YYEMPTY && yylen == 1) \
  888. { \
  889. yychar = (Token); \
  890. yylval = (Value); \
  891. yytoken = YYTRANSLATE (yychar); \
  892. YYPOPSTACK (1); \
  893. goto yybackup; \
  894. } \
  895. else \
  896. { \
  897. yyerror (YY_("syntax error: cannot back up")); \
  898. YYERROR; \
  899. } \
  900. while (YYID (0))
  901. #define YYTERROR 1
  902. #define YYERRCODE 256
  903. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  904. If N is 0, then set CURRENT to the empty location which ends
  905. the previous symbol: RHS[0] (always defined). */
  906. #define YYRHSLOC(Rhs, K) ((Rhs)[K])
  907. #ifndef YYLLOC_DEFAULT
  908. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  909. do \
  910. if (YYID (N)) \
  911. { \
  912. (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
  913. (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
  914. (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
  915. (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
  916. } \
  917. else \
  918. { \
  919. (Current).first_line = (Current).last_line = \
  920. YYRHSLOC (Rhs, 0).last_line; \
  921. (Current).first_column = (Current).last_column = \
  922. YYRHSLOC (Rhs, 0).last_column; \
  923. } \
  924. while (YYID (0))
  925. #endif
  926. /* YY_LOCATION_PRINT -- Print the location on the stream.
  927. This macro was not mandated originally: define only if we know
  928. we won't break user code: when these are the locations we know. */
  929. #ifndef YY_LOCATION_PRINT
  930. # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
  931. # define YY_LOCATION_PRINT(File, Loc) \
  932. fprintf (File, "%d.%d-%d.%d", \
  933. (Loc).first_line, (Loc).first_column, \
  934. (Loc).last_line, (Loc).last_column)
  935. # else
  936. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  937. # endif
  938. #endif
  939. /* YYLEX -- calling `yylex' with the right arguments. */
  940. #ifdef YYLEX_PARAM
  941. # define YYLEX yylex (YYLEX_PARAM)
  942. #else
  943. # define YYLEX yylex ()
  944. #endif
  945. /* Enable debugging if requested. */
  946. #if YYDEBUG
  947. # ifndef YYFPRINTF
  948. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  949. # define YYFPRINTF fprintf
  950. # endif
  951. # define YYDPRINTF(Args) \
  952. do { \
  953. if (yydebug) \
  954. YYFPRINTF Args; \
  955. } while (YYID (0))
  956. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  957. do { \
  958. if (yydebug) \
  959. { \
  960. YYFPRINTF (stderr, "%s ", Title); \
  961. yy_symbol_print (stderr, \
  962. Type, Value); \
  963. YYFPRINTF (stderr, "\n"); \
  964. } \
  965. } while (YYID (0))
  966. /*--------------------------------.
  967. | Print this symbol on YYOUTPUT. |
  968. `--------------------------------*/
  969. /*ARGSUSED*/
  970. #if (defined __STDC__ || defined __C99__FUNC__ \
  971. || defined __cplusplus || defined _MSC_VER)
  972. static void
  973. yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  974. #else
  975. static void
  976. yy_symbol_value_print (yyoutput, yytype, yyvaluep)
  977. FILE *yyoutput;
  978. int yytype;
  979. YYSTYPE const * const yyvaluep;
  980. #endif
  981. {
  982. if (!yyvaluep)
  983. return;
  984. # ifdef YYPRINT
  985. if (yytype < YYNTOKENS)
  986. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  987. # else
  988. YYUSE (yyoutput);
  989. # endif
  990. switch (yytype)
  991. {
  992. default:
  993. break;
  994. }
  995. }
  996. /*--------------------------------.
  997. | Print this symbol on YYOUTPUT. |
  998. `--------------------------------*/
  999. #if (defined __STDC__ || defined __C99__FUNC__ \
  1000. || defined __cplusplus || defined _MSC_VER)
  1001. static void
  1002. yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  1003. #else
  1004. static void
  1005. yy_symbol_print (yyoutput, yytype, yyvaluep)
  1006. FILE *yyoutput;
  1007. int yytype;
  1008. YYSTYPE const * const yyvaluep;
  1009. #endif
  1010. {
  1011. if (yytype < YYNTOKENS)
  1012. YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  1013. else
  1014. YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
  1015. yy_symbol_value_print (yyoutput, yytype, yyvaluep);
  1016. YYFPRINTF (yyoutput, ")");
  1017. }
  1018. /*------------------------------------------------------------------.
  1019. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  1020. | TOP (included). |
  1021. `------------------------------------------------------------------*/
  1022. #if (defined __STDC__ || defined __C99__FUNC__ \
  1023. || defined __cplusplus || defined _MSC_VER)
  1024. static void
  1025. yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
  1026. #else
  1027. static void
  1028. yy_stack_print (bottom, top)
  1029. yytype_int16 *bottom;
  1030. yytype_int16 *top;
  1031. #endif
  1032. {
  1033. YYFPRINTF (stderr, "Stack now");
  1034. for (; bottom <= top; ++bottom)
  1035. YYFPRINTF (stderr, " %d", *bottom);
  1036. YYFPRINTF (stderr, "\n");
  1037. }
  1038. # define YY_STACK_PRINT(Bottom, Top) \
  1039. do { \
  1040. if (yydebug) \
  1041. yy_stack_print ((Bottom), (Top)); \
  1042. } while (YYID (0))
  1043. /*------------------------------------------------.
  1044. | Report that the YYRULE is going to be reduced. |
  1045. `------------------------------------------------*/
  1046. #if (defined __STDC__ || defined __C99__FUNC__ \
  1047. || defined __cplusplus || defined _MSC_VER)
  1048. static void
  1049. yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
  1050. #else
  1051. static void
  1052. yy_reduce_print (yyvsp, yyrule)
  1053. YYSTYPE *yyvsp;
  1054. int yyrule;
  1055. #endif
  1056. {
  1057. int yynrhs = yyr2[yyrule];
  1058. int yyi;
  1059. unsigned long int yylno = yyrline[yyrule];
  1060. YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
  1061. yyrule - 1, yylno);
  1062. /* The symbols being reduced. */
  1063. for (yyi = 0; yyi < yynrhs; yyi++)
  1064. {
  1065. fprintf (stderr, " $%d = ", yyi + 1);
  1066. yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
  1067. &(yyvsp[(yyi + 1) - (yynrhs)])
  1068. );
  1069. fprintf (stderr, "\n");
  1070. }
  1071. }
  1072. # define YY_REDUCE_PRINT(Rule) \
  1073. do { \
  1074. if (yydebug) \
  1075. yy_reduce_print (yyvsp, Rule); \
  1076. } while (YYID (0))
  1077. /* Nonzero means print parse trace. It is left uninitialized so that
  1078. multiple parsers can coexist. */
  1079. int yydebug;
  1080. #else /* !YYDEBUG */
  1081. # define YYDPRINTF(Args)
  1082. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  1083. # define YY_STACK_PRINT(Bottom, Top)
  1084. # define YY_REDUCE_PRINT(Rule)
  1085. #endif /* !YYDEBUG */
  1086. /* YYINITDEPTH -- initial size of the parser's stacks. */
  1087. #ifndef YYINITDEPTH
  1088. # define YYINITDEPTH 200
  1089. #endif
  1090. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  1091. if the built-in stack extension method is used).
  1092. Do not make this value too large; the results are undefined if
  1093. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  1094. evaluated with infinite-precision integer arithmetic. */
  1095. #ifndef YYMAXDEPTH
  1096. # define YYMAXDEPTH 10000
  1097. #endif
  1098. #if YYERROR_VERBOSE
  1099. # ifndef yystrlen
  1100. # if defined __GLIBC__ && defined _STRING_H
  1101. # define yystrlen strlen
  1102. # else
  1103. /* Return the length of YYSTR. */
  1104. #if (defined __STDC__ || defined __C99__FUNC__ \
  1105. || defined __cplusplus || defined _MSC_VER)
  1106. static YYSIZE_T
  1107. yystrlen (const char *yystr)
  1108. #else
  1109. static YYSIZE_T
  1110. yystrlen (yystr)
  1111. const char *yystr;
  1112. #endif
  1113. {
  1114. YYSIZE_T yylen;
  1115. for (yylen = 0; yystr[yylen]; yylen++)
  1116. continue;
  1117. return yylen;
  1118. }
  1119. # endif
  1120. # endif
  1121. # ifndef yystpcpy
  1122. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  1123. # define yystpcpy stpcpy
  1124. # else
  1125. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  1126. YYDEST. */
  1127. #if (defined __STDC__ || defined __C99__FUNC__ \
  1128. || defined __cplusplus || defined _MSC_VER)
  1129. static char *
  1130. yystpcpy (char *yydest, const char *yysrc)
  1131. #else
  1132. static char *
  1133. yystpcpy (yydest, yysrc)
  1134. char *yydest;
  1135. const char *yysrc;
  1136. #endif
  1137. {
  1138. char *yyd = yydest;
  1139. const char *yys = yysrc;
  1140. while ((*yyd++ = *yys++) != '\0')
  1141. continue;
  1142. return yyd - 1;
  1143. }
  1144. # endif
  1145. # endif
  1146. # ifndef yytnamerr
  1147. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  1148. quotes and backslashes, so that it's suitable for yyerror. The
  1149. heuristic is that double-quoting is unnecessary unless the string
  1150. contains an apostrophe, a comma, or backslash (other than
  1151. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  1152. null, do not copy; instead, return the length of what the result
  1153. would have been. */
  1154. static YYSIZE_T
  1155. yytnamerr (char *yyres, const char *yystr)
  1156. {
  1157. if (*yystr == '"')
  1158. {
  1159. YYSIZE_T yyn = 0;
  1160. char const *yyp = yystr;
  1161. for (;;)
  1162. switch (*++yyp)
  1163. {
  1164. case '\'':
  1165. case ',':
  1166. goto do_not_strip_quotes;
  1167. case '\\':
  1168. if (*++yyp != '\\')
  1169. goto do_not_strip_quotes;
  1170. /* Fall through. */
  1171. default:
  1172. if (yyres)
  1173. yyres[yyn] = *yyp;
  1174. yyn++;
  1175. break;
  1176. case '"':
  1177. if (yyres)
  1178. yyres[yyn] = '\0';
  1179. return yyn;
  1180. }
  1181. do_not_strip_quotes: ;
  1182. }
  1183. if (! yyres)
  1184. return yystrlen (yystr);
  1185. return yystpcpy (yyres, yystr) - yyres;
  1186. }
  1187. # endif
  1188. /* Copy into YYRESULT an error message about the unexpected token
  1189. YYCHAR while in state YYSTATE. Return the number of bytes copied,
  1190. including the terminating null byte. If YYRESULT is null, do not
  1191. copy anything; just return the number of bytes that would be
  1192. copied. As a special case, return 0 if an ordinary "syntax error"
  1193. message will do. Return YYSIZE_MAXIMUM if overflow occurs during
  1194. size calculation. */
  1195. static YYSIZE_T
  1196. yysyntax_error (char *yyresult, int yystate, int yychar)
  1197. {
  1198. int yyn = yypact[yystate];
  1199. if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
  1200. return 0;
  1201. else
  1202. {
  1203. int yytype = YYTRANSLATE (yychar);
  1204. YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
  1205. YYSIZE_T yysize = yysize0;
  1206. YYSIZE_T yysize1;
  1207. int yysize_overflow = 0;
  1208. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  1209. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  1210. int yyx;
  1211. # if 0
  1212. /* This is so xgettext sees the translatable formats that are
  1213. constructed on the fly. */
  1214. YY_("syntax error, unexpected %s");
  1215. YY_("syntax error, unexpected %s, expecting %s");
  1216. YY_("syntax error, unexpected %s, expecting %s or %s");
  1217. YY_("syntax error, unexpected %s, expecting %s or %s or %s");
  1218. YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
  1219. # endif
  1220. char *yyfmt;
  1221. char const *yyf;
  1222. static char const yyunexpected[] = "syntax error, unexpected %s";
  1223. static char const yyexpecting[] = ", expecting %s";
  1224. static char const yyor[] = " or %s";
  1225. char yyformat[sizeof yyunexpected
  1226. + sizeof yyexpecting - 1
  1227. + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
  1228. * (sizeof yyor - 1))];
  1229. char const *yyprefix = yyexpecting;
  1230. /* Start YYX at -YYN if negative to avoid negative indexes in
  1231. YYCHECK. */
  1232. int yyxbegin = yyn < 0 ? -yyn : 0;
  1233. /* Stay within bounds of both yycheck and yytname. */
  1234. int yychecklim = YYLAST - yyn + 1;
  1235. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  1236. int yycount = 1;
  1237. yyarg[0] = yytname[yytype];
  1238. yyfmt = yystpcpy (yyformat, yyunexpected);
  1239. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  1240. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  1241. {
  1242. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  1243. {
  1244. yycount = 1;
  1245. yysize = yysize0;
  1246. yyformat[sizeof yyunexpected - 1] = '\0';
  1247. break;
  1248. }
  1249. yyarg[yycount++] = yytname[yyx];
  1250. yysize1 = yysize + yytnamerr (0, yytname[yyx]);
  1251. yysize_overflow |= (yysize1 < yysize);
  1252. yysize = yysize1;
  1253. yyfmt = yystpcpy (yyfmt, yyprefix);
  1254. yyprefix = yyor;
  1255. }
  1256. yyf = YY_(yyformat);
  1257. yysize1 = yysize + yystrlen (yyf);
  1258. yysize_overflow |= (yysize1 < yysize);
  1259. yysize = yysize1;
  1260. if (yysize_overflow)
  1261. return YYSIZE_MAXIMUM;
  1262. if (yyresult)
  1263. {
  1264. /* Avoid sprintf, as that infringes on the user's name space.
  1265. Don't have undefined behavior even if the translation
  1266. produced a string with the wrong number of "%s"s. */
  1267. char *yyp = yyresult;
  1268. int yyi = 0;
  1269. while ((*yyp = *yyf) != '\0')
  1270. {
  1271. if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
  1272. {
  1273. yyp += yytnamerr (yyp, yyarg[yyi++]);
  1274. yyf += 2;
  1275. }
  1276. else
  1277. {
  1278. yyp++;
  1279. yyf++;
  1280. }
  1281. }
  1282. }
  1283. return yysize;
  1284. }
  1285. }
  1286. #endif /* YYERROR_VERBOSE */
  1287. /*-----------------------------------------------.
  1288. | Release the memory associated to this symbol. |
  1289. `-----------------------------------------------*/
  1290. /*ARGSUSED*/
  1291. #if (defined __STDC__ || defined __C99__FUNC__ \
  1292. || defined __cplusplus || defined _MSC_VER)
  1293. static void
  1294. yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
  1295. #else
  1296. static void
  1297. yydestruct (yymsg, yytype, yyvaluep)
  1298. const char *yymsg;
  1299. int yytype;
  1300. YYSTYPE *yyvaluep;
  1301. #endif
  1302. {
  1303. YYUSE (yyvaluep);
  1304. if (!yymsg)
  1305. yymsg = "Deleting";
  1306. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  1307. switch (yytype)
  1308. {
  1309. default:
  1310. break;
  1311. }
  1312. }
  1313. /* Prevent warnings from -Wmissing-prototypes. */
  1314. #ifdef YYPARSE_PARAM
  1315. #if defined __STDC__ || defined __cplusplus
  1316. int yyparse (void *YYPARSE_PARAM);
  1317. #else
  1318. int yyparse ();
  1319. #endif
  1320. #else /* ! YYPARSE_PARAM */
  1321. #if defined __STDC__ || defined __cplusplus
  1322. int yyparse (void);
  1323. #else
  1324. int yyparse ();
  1325. #endif
  1326. #endif /* ! YYPARSE_PARAM */
  1327. /* The look-ahead symbol. */
  1328. int yychar;
  1329. /* The semantic value of the look-ahead symbol. */
  1330. YYSTYPE yylval;
  1331. /* Number of syntax errors so far. */
  1332. int yynerrs;
  1333. /*----------.
  1334. | yyparse. |
  1335. `----------*/
  1336. #ifdef YYPARSE_PARAM
  1337. #if (defined __STDC__ || defined __C99__FUNC__ \
  1338. || defined __cplusplus || defined _MSC_VER)
  1339. int
  1340. yyparse (void *YYPARSE_PARAM)
  1341. #else
  1342. int
  1343. yyparse (YYPARSE_PARAM)
  1344. void *YYPARSE_PARAM;
  1345. #endif
  1346. #else /* ! YYPARSE_PARAM */
  1347. #if (defined __STDC__ || defined __C99__FUNC__ \
  1348. || defined __cplusplus || defined _MSC_VER)
  1349. int
  1350. yyparse (void)
  1351. #else
  1352. int
  1353. yyparse ()
  1354. #endif
  1355. #endif
  1356. {
  1357. int yystate;
  1358. int yyn;
  1359. int yyresult;
  1360. /* Number of tokens to shift before error messages enabled. */
  1361. int yyerrstatus;
  1362. /* Look-ahead token as an internal (translated) token number. */
  1363. int yytoken = 0;
  1364. #if YYERROR_VERBOSE
  1365. /* Buffer for error messages, and its allocated size. */
  1366. char yymsgbuf[128];
  1367. char *yymsg = yymsgbuf;
  1368. YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  1369. #endif
  1370. /* Three stacks and their tools:
  1371. `yyss': related to states,
  1372. `yyvs': related to semantic values,
  1373. `yyls': related to locations.
  1374. Refer to the stacks thru separate pointers, to allow yyoverflow
  1375. to reallocate them elsewhere. */
  1376. /* The state stack. */
  1377. yytype_int16 yyssa[YYINITDEPTH];
  1378. yytype_int16 *yyss = yyssa;
  1379. yytype_int16 *yyssp;
  1380. /* The semantic value stack. */
  1381. YYSTYPE yyvsa[YYINITDEPTH];
  1382. YYSTYPE *yyvs = yyvsa;
  1383. YYSTYPE *yyvsp;
  1384. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  1385. YYSIZE_T yystacksize = YYINITDEPTH;
  1386. /* The variables used to return semantic value and location from the
  1387. action routines. */
  1388. YYSTYPE yyval;
  1389. /* The number of symbols on the RHS of the reduced rule.
  1390. Keep to zero when no symbol should be popped. */
  1391. int yylen = 0;
  1392. YYDPRINTF ((stderr, "Starting parse\n"));
  1393. yystate = 0;
  1394. yyerrstatus = 0;
  1395. yynerrs = 0;
  1396. yychar = YYEMPTY; /* Cause a token to be read. */
  1397. /* Initialize stack pointers.
  1398. Waste one element of value and location stack
  1399. so that they stay on the same level as the state stack.
  1400. The wasted elements are never initialized. */
  1401. yyssp = yyss;
  1402. yyvsp = yyvs;
  1403. goto yysetstate;
  1404. /*------------------------------------------------------------.
  1405. | yynewstate -- Push a new state, which is found in yystate. |
  1406. `------------------------------------------------------------*/
  1407. yynewstate:
  1408. /* In all cases, when you get here, the value and location stacks
  1409. have just been pushed. So pushing a state here evens the stacks. */
  1410. yyssp++;
  1411. yysetstate:
  1412. *yyssp = yystate;
  1413. if (yyss + yystacksize - 1 <= yyssp)
  1414. {
  1415. /* Get the current used size of the three stacks, in elements. */
  1416. YYSIZE_T yysize = yyssp - yyss + 1;
  1417. #ifdef yyoverflow
  1418. {
  1419. /* Give user a chance to reallocate the stack. Use copies of
  1420. these so that the &'s don't force the real ones into
  1421. memory. */
  1422. YYSTYPE *yyvs1 = yyvs;
  1423. yytype_int16 *yyss1 = yyss;
  1424. /* Each stack pointer address is followed by the size of the
  1425. data in use in that stack, in bytes. This used to be a
  1426. conditional around just the two extra args, but that might
  1427. be undefined if yyoverflow is a macro. */
  1428. yyoverflow (YY_("memory exhausted"),
  1429. &yyss1, yysize * sizeof (*yyssp),
  1430. &yyvs1, yysize * sizeof (*yyvsp),
  1431. &yystacksize);
  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. yytype_int16 *yyss1 = yyss;
  1447. union yyalloc *yyptr =
  1448. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  1449. if (! yyptr)
  1450. goto yyexhaustedlab;
  1451. YYSTACK_RELOCATE (yyss);
  1452. YYSTACK_RELOCATE (yyvs);
  1453. # undef YYSTACK_RELOCATE
  1454. if (yyss1 != yyssa)
  1455. YYSTACK_FREE (yyss1);
  1456. }
  1457. # endif
  1458. #endif /* no yyoverflow */
  1459. yyssp = yyss + yysize - 1;
  1460. yyvsp = yyvs + yysize - 1;
  1461. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1462. (unsigned long int) yystacksize));
  1463. if (yyss + yystacksize - 1 <= yyssp)
  1464. YYABORT;
  1465. }
  1466. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1467. goto yybackup;
  1468. /*-----------.
  1469. | yybackup. |
  1470. `-----------*/
  1471. yybackup:
  1472. /* Do appropriate processing given the current state. Read a
  1473. look-ahead token if we need one and don't already have one. */
  1474. /* First try to decide what to do without reference to look-ahead token. */
  1475. yyn = yypact[yystate];
  1476. if (yyn == YYPACT_NINF)
  1477. goto yydefault;
  1478. /* Not known => get a look-ahead token if don't already have one. */
  1479. /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
  1480. if (yychar == YYEMPTY)
  1481. {
  1482. YYDPRINTF ((stderr, "Reading a token: "));
  1483. yychar = YYLEX;
  1484. }
  1485. if (yychar <= YYEOF)
  1486. {
  1487. yychar = yytoken = YYEOF;
  1488. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1489. }
  1490. else
  1491. {
  1492. yytoken = YYTRANSLATE (yychar);
  1493. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1494. }
  1495. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1496. detect an error, take that action. */
  1497. yyn += yytoken;
  1498. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1499. goto yydefault;
  1500. yyn = yytable[yyn];
  1501. if (yyn <= 0)
  1502. {
  1503. if (yyn == 0 || yyn == YYTABLE_NINF)
  1504. goto yyerrlab;
  1505. yyn = -yyn;
  1506. goto yyreduce;
  1507. }
  1508. if (yyn == YYFINAL)
  1509. YYACCEPT;
  1510. /* Count tokens shifted since error; after three, turn off error
  1511. status. */
  1512. if (yyerrstatus)
  1513. yyerrstatus--;
  1514. /* Shift the look-ahead token. */
  1515. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1516. /* Discard the shifted token unless it is eof. */
  1517. if (yychar != YYEOF)
  1518. yychar = YYEMPTY;
  1519. yystate = yyn;
  1520. *++yyvsp = yylval;
  1521. goto yynewstate;
  1522. /*-----------------------------------------------------------.
  1523. | yydefault -- do the default action for the current state. |
  1524. `-----------------------------------------------------------*/
  1525. yydefault:
  1526. yyn = yydefact[yystate];
  1527. if (yyn == 0)
  1528. goto yyerrlab;
  1529. goto yyreduce;
  1530. /*-----------------------------.
  1531. | yyreduce -- Do a reduction. |
  1532. `-----------------------------*/
  1533. yyreduce:
  1534. /* yyn is the number of a rule to reduce with. */
  1535. yylen = yyr2[yyn];
  1536. /* If YYLEN is nonzero, implement the default value of the action:
  1537. `$$ = $1'.
  1538. Otherwise, the following line sets YYVAL to garbage.
  1539. This behavior is undocumented and Bison
  1540. users should not rely upon it. Assigning to YYVAL
  1541. unconditionally makes the parser a bit smaller, and it avoids a
  1542. GCC warning that YYVAL may be used uninitialized. */
  1543. yyval = yyvsp[1-yylen];
  1544. YY_REDUCE_PRINT (yyn);
  1545. switch (yyn)
  1546. {
  1547. case 3:
  1548. #line 132 "ftpcmd.y"
  1549. {
  1550. fromname = (char *) 0;
  1551. restart_point = (off_t) 0;
  1552. }
  1553. break;
  1554. case 5:
  1555. #line 141 "ftpcmd.y"
  1556. {
  1557. if ((yyvsp[(5) - (5)].i))
  1558. user((yyvsp[(3) - (5)].s));
  1559. free((yyvsp[(3) - (5)].s));
  1560. }
  1561. break;
  1562. case 6:
  1563. #line 147 "ftpcmd.y"
  1564. {
  1565. if ((yyvsp[(5) - (5)].i))
  1566. pass((yyvsp[(3) - (5)].s));
  1567. memset ((yyvsp[(3) - (5)].s), 0, strlen((yyvsp[(3) - (5)].s)));
  1568. free((yyvsp[(3) - (5)].s));
  1569. }
  1570. break;
  1571. case 7:
  1572. #line 155 "ftpcmd.y"
  1573. {
  1574. if ((yyvsp[(5) - (5)].i)) {
  1575. if (paranoid &&
  1576. (data_dest->sa_family != his_addr->sa_family ||
  1577. (socket_get_port(data_dest) < IPPORT_RESERVED) ||
  1578. memcmp(socket_get_address(data_dest),
  1579. socket_get_address(his_addr),
  1580. socket_addr_size(his_addr)) != 0)) {
  1581. usedefault = 1;
  1582. reply(500, "Illegal PORT range rejected.");
  1583. } else {
  1584. usedefault = 0;
  1585. if (pdata >= 0) {
  1586. close(pdata);
  1587. pdata = -1;
  1588. }
  1589. reply(200, "PORT command successful.");
  1590. }
  1591. }
  1592. }
  1593. break;
  1594. case 8:
  1595. #line 176 "ftpcmd.y"
  1596. {
  1597. if ((yyvsp[(5) - (5)].i))
  1598. eprt ((yyvsp[(3) - (5)].s));
  1599. free ((yyvsp[(3) - (5)].s));
  1600. }
  1601. break;
  1602. case 9:
  1603. #line 182 "ftpcmd.y"
  1604. {
  1605. if((yyvsp[(3) - (3)].i))
  1606. pasv ();
  1607. }
  1608. break;
  1609. case 10:
  1610. #line 187 "ftpcmd.y"
  1611. {
  1612. if((yyvsp[(3) - (3)].i))
  1613. epsv (NULL);
  1614. }
  1615. break;
  1616. case 11:
  1617. #line 192 "ftpcmd.y"
  1618. {
  1619. if((yyvsp[(5) - (5)].i))
  1620. epsv ((yyvsp[(3) - (5)].s));
  1621. free ((yyvsp[(3) - (5)].s));
  1622. }
  1623. break;
  1624. case 12:
  1625. #line 198 "ftpcmd.y"
  1626. {
  1627. if ((yyvsp[(5) - (5)].i)) {
  1628. switch (cmd_type) {
  1629. case TYPE_A:
  1630. if (cmd_form == FORM_N) {
  1631. reply(200, "Type set to A.");
  1632. type = cmd_type;
  1633. form = cmd_form;
  1634. } else
  1635. reply(504, "Form must be N.");
  1636. break;
  1637. case TYPE_E:
  1638. reply(504, "Type E not implemented.");
  1639. break;
  1640. case TYPE_I:
  1641. reply(200, "Type set to I.");
  1642. type = cmd_type;
  1643. break;
  1644. case TYPE_L:
  1645. #if NBBY == 8
  1646. if (cmd_bytesz == 8) {
  1647. reply(200,
  1648. "Type set to L (byte size 8).");
  1649. type = cmd_type;
  1650. } else
  1651. reply(504, "Byte size must be 8.");
  1652. #else /* NBBY == 8 */
  1653. UNIMPLEMENTED for NBBY != 8
  1654. #endif /* NBBY == 8 */
  1655. }
  1656. }
  1657. }
  1658. break;
  1659. case 13:
  1660. #line 235 "ftpcmd.y"
  1661. {
  1662. if ((yyvsp[(5) - (5)].i)) {
  1663. switch ((yyvsp[(3) - (5)].i)) {
  1664. case STRU_F:
  1665. reply(200, "STRU F ok.");
  1666. break;
  1667. default:
  1668. reply(504, "Unimplemented STRU type.");
  1669. }
  1670. }
  1671. }
  1672. break;
  1673. case 14:
  1674. #line 249 "ftpcmd.y"
  1675. {
  1676. if ((yyvsp[(5) - (5)].i)) {
  1677. switch ((yyvsp[(3) - (5)].i)) {
  1678. case MODE_S:
  1679. reply(200, "MODE S ok.");
  1680. break;
  1681. default:
  1682. reply(502, "Unimplemented MODE type.");
  1683. }
  1684. }
  1685. }
  1686. break;
  1687. case 15:
  1688. #line 263 "ftpcmd.y"
  1689. {
  1690. if ((yyvsp[(5) - (5)].i)) {
  1691. reply(202, "ALLO command ignored.");
  1692. }
  1693. }
  1694. break;
  1695. case 16:
  1696. #line 269 "ftpcmd.y"
  1697. {
  1698. if ((yyvsp[(9) - (9)].i)) {
  1699. reply(202, "ALLO command ignored.");
  1700. }
  1701. }
  1702. break;
  1703. case 17:
  1704. #line 275 "ftpcmd.y"
  1705. {
  1706. char *name = (yyvsp[(3) - (5)].s);
  1707. if ((yyvsp[(5) - (5)].i) && name != NULL)
  1708. retrieve(0, name);
  1709. if (name != NULL)
  1710. free(name);
  1711. }
  1712. break;
  1713. case 18:
  1714. #line 284 "ftpcmd.y"
  1715. {
  1716. char *name = (yyvsp[(3) - (5)].s);
  1717. if ((yyvsp[(5) - (5)].i) && name != NULL)
  1718. do_store(name, "w", 0);
  1719. if (name != NULL)
  1720. free(name);
  1721. }
  1722. break;
  1723. case 19:
  1724. #line 293 "ftpcmd.y"
  1725. {
  1726. char *name = (yyvsp[(3) - (5)].s);
  1727. if ((yyvsp[(5) - (5)].i) && name != NULL)
  1728. do_store(name, "a", 0);
  1729. if (name != NULL)
  1730. free(name);
  1731. }
  1732. break;
  1733. case 20:
  1734. #line 302 "ftpcmd.y"
  1735. {
  1736. if ((yyvsp[(3) - (3)].i))
  1737. send_file_list(".");
  1738. }
  1739. break;
  1740. case 21:
  1741. #line 307 "ftpcmd.y"
  1742. {
  1743. char *name = (yyvsp[(3) - (5)].s);
  1744. if ((yyvsp[(5) - (5)].i) && name != NULL)
  1745. send_file_list(name);
  1746. if (name != NULL)
  1747. free(name);
  1748. }
  1749. break;
  1750. case 22:
  1751. #line 316 "ftpcmd.y"
  1752. {
  1753. if((yyvsp[(3) - (3)].i))
  1754. list_file(".");
  1755. }
  1756. break;
  1757. case 23:
  1758. #line 321 "ftpcmd.y"
  1759. {
  1760. if((yyvsp[(5) - (5)].i))
  1761. list_file((yyvsp[(3) - (5)].s));
  1762. free((yyvsp[(3) - (5)].s));
  1763. }
  1764. break;
  1765. case 24:
  1766. #line 327 "ftpcmd.y"
  1767. {
  1768. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  1769. statfilecmd((yyvsp[(3) - (5)].s));
  1770. if ((yyvsp[(3) - (5)].s) != NULL)
  1771. free((yyvsp[(3) - (5)].s));
  1772. }
  1773. break;
  1774. case 25:
  1775. #line 334 "ftpcmd.y"
  1776. {
  1777. if ((yyvsp[(3) - (3)].i))
  1778. statcmd();
  1779. }
  1780. break;
  1781. case 26:
  1782. #line 339 "ftpcmd.y"
  1783. {
  1784. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  1785. do_delete((yyvsp[(3) - (5)].s));
  1786. if ((yyvsp[(3) - (5)].s) != NULL)
  1787. free((yyvsp[(3) - (5)].s));
  1788. }
  1789. break;
  1790. case 27:
  1791. #line 346 "ftpcmd.y"
  1792. {
  1793. if((yyvsp[(5) - (5)].i)){
  1794. if (fromname) {
  1795. renamecmd(fromname, (yyvsp[(3) - (5)].s));
  1796. free(fromname);
  1797. fromname = (char *) 0;
  1798. } else {
  1799. reply(503, "Bad sequence of commands.");
  1800. }
  1801. }
  1802. if ((yyvsp[(3) - (5)].s) != NULL)
  1803. free((yyvsp[(3) - (5)].s));
  1804. }
  1805. break;
  1806. case 28:
  1807. #line 360 "ftpcmd.y"
  1808. {
  1809. if ((yyvsp[(3) - (3)].i))
  1810. reply(225, "ABOR command successful.");
  1811. }
  1812. break;
  1813. case 29:
  1814. #line 365 "ftpcmd.y"
  1815. {
  1816. if ((yyvsp[(3) - (3)].i)) {
  1817. const char *path = pw->pw_dir;
  1818. if (dochroot || guest)
  1819. path = "/";
  1820. cwd(path);
  1821. }
  1822. }
  1823. break;
  1824. case 30:
  1825. #line 374 "ftpcmd.y"
  1826. {
  1827. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  1828. cwd((yyvsp[(3) - (5)].s));
  1829. if ((yyvsp[(3) - (5)].s) != NULL)
  1830. free((yyvsp[(3) - (5)].s));
  1831. }
  1832. break;
  1833. case 31:
  1834. #line 381 "ftpcmd.y"
  1835. {
  1836. if ((yyvsp[(3) - (3)].i))
  1837. help(cmdtab, (char *) 0);
  1838. }
  1839. break;
  1840. case 32:
  1841. #line 386 "ftpcmd.y"
  1842. {
  1843. if ((yyvsp[(5) - (5)].i)) {
  1844. char *cp = (yyvsp[(3) - (5)].s);
  1845. if (strncasecmp(cp, "SITE", 4) == 0) {
  1846. cp = (yyvsp[(3) - (5)].s) + 4;
  1847. if (*cp == ' ')
  1848. cp++;
  1849. if (*cp)
  1850. help(sitetab, cp);
  1851. else
  1852. help(sitetab, (char *) 0);
  1853. } else
  1854. help(cmdtab, (yyvsp[(3) - (5)].s));
  1855. }
  1856. }
  1857. break;
  1858. case 33:
  1859. #line 403 "ftpcmd.y"
  1860. {
  1861. if ((yyvsp[(3) - (3)].i))
  1862. reply(200, "NOOP command successful.");
  1863. }
  1864. break;
  1865. case 34:
  1866. #line 408 "ftpcmd.y"
  1867. {
  1868. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  1869. makedir((yyvsp[(3) - (5)].s));
  1870. if ((yyvsp[(3) - (5)].s) != NULL)
  1871. free((yyvsp[(3) - (5)].s));
  1872. }
  1873. break;
  1874. case 35:
  1875. #line 415 "ftpcmd.y"
  1876. {
  1877. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  1878. removedir((yyvsp[(3) - (5)].s));
  1879. if ((yyvsp[(3) - (5)].s) != NULL)
  1880. free((yyvsp[(3) - (5)].s));
  1881. }
  1882. break;
  1883. case 36:
  1884. #line 422 "ftpcmd.y"
  1885. {
  1886. if ((yyvsp[(3) - (3)].i))
  1887. pwd();
  1888. }
  1889. break;
  1890. case 37:
  1891. #line 427 "ftpcmd.y"
  1892. {
  1893. if ((yyvsp[(3) - (3)].i))
  1894. cwd("..");
  1895. }
  1896. break;
  1897. case 38:
  1898. #line 432 "ftpcmd.y"
  1899. {
  1900. if ((yyvsp[(3) - (3)].i)) {
  1901. lreply(211, "Supported features:");
  1902. lreply(0, " MDTM");
  1903. lreply(0, " REST STREAM");
  1904. lreply(0, " SIZE");
  1905. reply(211, "End");
  1906. }
  1907. }
  1908. break;
  1909. case 39:
  1910. #line 442 "ftpcmd.y"
  1911. {
  1912. if ((yyvsp[(5) - (5)].i))
  1913. reply(501, "Bad options");
  1914. free ((yyvsp[(3) - (5)].s));
  1915. }
  1916. break;
  1917. case 40:
  1918. #line 449 "ftpcmd.y"
  1919. {
  1920. if ((yyvsp[(5) - (5)].i))
  1921. help(sitetab, (char *) 0);
  1922. }
  1923. break;
  1924. case 41:
  1925. #line 454 "ftpcmd.y"
  1926. {
  1927. if ((yyvsp[(7) - (7)].i))
  1928. help(sitetab, (yyvsp[(5) - (7)].s));
  1929. }
  1930. break;
  1931. case 42:
  1932. #line 459 "ftpcmd.y"
  1933. {
  1934. if ((yyvsp[(5) - (5)].i)) {
  1935. int oldmask = umask(0);
  1936. umask(oldmask);
  1937. reply(200, "Current UMASK is %03o", oldmask);
  1938. }
  1939. }
  1940. break;
  1941. case 43:
  1942. #line 467 "ftpcmd.y"
  1943. {
  1944. if ((yyvsp[(7) - (7)].i)) {
  1945. if (((yyvsp[(5) - (7)].i) == -1) || ((yyvsp[(5) - (7)].i) > 0777)) {
  1946. reply(501, "Bad UMASK value");
  1947. } else {
  1948. int oldmask = umask((yyvsp[(5) - (7)].i));
  1949. reply(200,
  1950. "UMASK set to %03o (was %03o)",
  1951. (yyvsp[(5) - (7)].i), oldmask);
  1952. }
  1953. }
  1954. }
  1955. break;
  1956. case 44:
  1957. #line 480 "ftpcmd.y"
  1958. {
  1959. if ((yyvsp[(9) - (9)].i) && (yyvsp[(7) - (9)].s) != NULL) {
  1960. if ((yyvsp[(5) - (9)].i) > 0777)
  1961. reply(501,
  1962. "CHMOD: Mode value must be between 0 and 0777");
  1963. else if (chmod((yyvsp[(7) - (9)].s), (yyvsp[(5) - (9)].i)) < 0)
  1964. perror_reply(550, (yyvsp[(7) - (9)].s));
  1965. else
  1966. reply(200, "CHMOD command successful.");
  1967. }
  1968. if ((yyvsp[(7) - (9)].s) != NULL)
  1969. free((yyvsp[(7) - (9)].s));
  1970. }
  1971. break;
  1972. case 45:
  1973. #line 494 "ftpcmd.y"
  1974. {
  1975. if ((yyvsp[(5) - (5)].i))
  1976. reply(200,
  1977. "Current IDLE time limit is %d seconds; max %d",
  1978. ftpd_timeout, maxtimeout);
  1979. }
  1980. break;
  1981. case 46:
  1982. #line 501 "ftpcmd.y"
  1983. {
  1984. if ((yyvsp[(7) - (7)].i)) {
  1985. if ((yyvsp[(5) - (7)].i) < 30 || (yyvsp[(5) - (7)].i) > maxtimeout) {
  1986. reply(501,
  1987. "Maximum IDLE time must be between 30 and %d seconds",
  1988. maxtimeout);
  1989. } else {
  1990. ftpd_timeout = (yyvsp[(5) - (7)].i);
  1991. alarm((unsigned) ftpd_timeout);
  1992. reply(200,
  1993. "Maximum IDLE time set to %d seconds",
  1994. ftpd_timeout);
  1995. }
  1996. }
  1997. }
  1998. break;
  1999. case 47:
  2000. #line 518 "ftpcmd.y"
  2001. {
  2002. reply(500, "Command not implemented.");
  2003. }
  2004. break;
  2005. case 48:
  2006. #line 522 "ftpcmd.y"
  2007. {
  2008. if((yyvsp[(5) - (5)].i))
  2009. klist();
  2010. }
  2011. break;
  2012. case 49:
  2013. #line 527 "ftpcmd.y"
  2014. {
  2015. reply(500, "Command not implemented.");
  2016. }
  2017. break;
  2018. case 50:
  2019. #line 531 "ftpcmd.y"
  2020. {
  2021. reply(500, "Command not implemented.");
  2022. }
  2023. break;
  2024. case 51:
  2025. #line 535 "ftpcmd.y"
  2026. {
  2027. #if defined(KRB5)
  2028. if(guest)
  2029. reply(500, "Can't be done as guest.");
  2030. else if((yyvsp[(5) - (5)].i))
  2031. afslog(NULL, 0);
  2032. #else
  2033. reply(500, "Command not implemented.");
  2034. #endif
  2035. }
  2036. break;
  2037. case 52:
  2038. #line 546 "ftpcmd.y"
  2039. {
  2040. #if defined(KRB5)
  2041. if(guest)
  2042. reply(500, "Can't be done as guest.");
  2043. else if((yyvsp[(7) - (7)].i))
  2044. afslog((yyvsp[(5) - (7)].s), 0);
  2045. if((yyvsp[(5) - (7)].s))
  2046. free((yyvsp[(5) - (7)].s));
  2047. #else
  2048. reply(500, "Command not implemented.");
  2049. #endif
  2050. }
  2051. break;
  2052. case 53:
  2053. #line 559 "ftpcmd.y"
  2054. {
  2055. if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s) != NULL)
  2056. find((yyvsp[(5) - (7)].s));
  2057. if((yyvsp[(5) - (7)].s) != NULL)
  2058. free((yyvsp[(5) - (7)].s));
  2059. }
  2060. break;
  2061. case 54:
  2062. #line 566 "ftpcmd.y"
  2063. {
  2064. if ((yyvsp[(5) - (5)].i))
  2065. reply(200, "http://www.pdc.kth.se/heimdal/");
  2066. }
  2067. break;
  2068. case 55:
  2069. #line 571 "ftpcmd.y"
  2070. {
  2071. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  2072. do_store((yyvsp[(3) - (5)].s), "w", 1);
  2073. if ((yyvsp[(3) - (5)].s) != NULL)
  2074. free((yyvsp[(3) - (5)].s));
  2075. }
  2076. break;
  2077. case 56:
  2078. #line 578 "ftpcmd.y"
  2079. {
  2080. if ((yyvsp[(3) - (3)].i)) {
  2081. #if !defined(WIN32) && !defined(__EMX__) && !defined(__OS2__) && !defined(__CYGWIN32__)
  2082. reply(215, "UNIX Type: L%d", NBBY);
  2083. #else
  2084. reply(215, "UNKNOWN Type: L%d", NBBY);
  2085. #endif
  2086. }
  2087. }
  2088. break;
  2089. case 57:
  2090. #line 596 "ftpcmd.y"
  2091. {
  2092. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
  2093. sizecmd((yyvsp[(3) - (5)].s));
  2094. if ((yyvsp[(3) - (5)].s) != NULL)
  2095. free((yyvsp[(3) - (5)].s));
  2096. }
  2097. break;
  2098. case 58:
  2099. #line 613 "ftpcmd.y"
  2100. {
  2101. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL) {
  2102. struct stat stbuf;
  2103. if (stat((yyvsp[(3) - (5)].s), &stbuf) < 0)
  2104. reply(550, "%s: %s",
  2105. (yyvsp[(3) - (5)].s), strerror(errno));
  2106. else if (!S_ISREG(stbuf.st_mode)) {
  2107. reply(550,
  2108. "%s: not a plain file.", (yyvsp[(3) - (5)].s));
  2109. } else {
  2110. struct tm *t;
  2111. time_t mtime = stbuf.st_mtime;
  2112. t = gmtime(&mtime);
  2113. reply(213,
  2114. "%04d%02d%02d%02d%02d%02d",
  2115. t->tm_year + 1900,
  2116. t->tm_mon + 1,
  2117. t->tm_mday,
  2118. t->tm_hour,
  2119. t->tm_min,
  2120. t->tm_sec);
  2121. }
  2122. }
  2123. if ((yyvsp[(3) - (5)].s) != NULL)
  2124. free((yyvsp[(3) - (5)].s));
  2125. }
  2126. break;
  2127. case 59:
  2128. #line 641 "ftpcmd.y"
  2129. {
  2130. if ((yyvsp[(3) - (3)].i)) {
  2131. reply(221, "Goodbye.");
  2132. dologout(0);
  2133. }
  2134. }
  2135. break;
  2136. case 60:
  2137. #line 648 "ftpcmd.y"
  2138. {
  2139. yyerrok;
  2140. }
  2141. break;
  2142. case 61:
  2143. #line 654 "ftpcmd.y"
  2144. {
  2145. restart_point = (off_t) 0;
  2146. if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s)) {
  2147. fromname = renamefrom((yyvsp[(3) - (5)].s));
  2148. if (fromname == (char *) 0 && (yyvsp[(3) - (5)].s)) {
  2149. free((yyvsp[(3) - (5)].s));
  2150. }
  2151. }
  2152. }
  2153. break;
  2154. case 62:
  2155. #line 664 "ftpcmd.y"
  2156. {
  2157. if ((yyvsp[(5) - (5)].i)) {
  2158. fromname = (char *) 0;
  2159. restart_point = (yyvsp[(3) - (5)].i); /* XXX $3 is only "int" */
  2160. reply(350, "Restarting at %ld. %s",
  2161. (long)restart_point,
  2162. "Send STORE or RETRIEVE to initiate transfer.");
  2163. }
  2164. }
  2165. break;
  2166. case 63:
  2167. #line 674 "ftpcmd.y"
  2168. {
  2169. auth((yyvsp[(3) - (4)].s));
  2170. free((yyvsp[(3) - (4)].s));
  2171. }
  2172. break;
  2173. case 64:
  2174. #line 679 "ftpcmd.y"
  2175. {
  2176. adat((yyvsp[(3) - (4)].s));
  2177. free((yyvsp[(3) - (4)].s));
  2178. }
  2179. break;
  2180. case 65:
  2181. #line 684 "ftpcmd.y"
  2182. {
  2183. if ((yyvsp[(5) - (5)].i))
  2184. pbsz((yyvsp[(3) - (5)].i));
  2185. }
  2186. break;
  2187. case 66:
  2188. #line 689 "ftpcmd.y"
  2189. {
  2190. if ((yyvsp[(5) - (5)].i))
  2191. prot((yyvsp[(3) - (5)].s));
  2192. }
  2193. break;
  2194. case 67:
  2195. #line 694 "ftpcmd.y"
  2196. {
  2197. if ((yyvsp[(3) - (3)].i))
  2198. ccc();
  2199. }
  2200. break;
  2201. case 68:
  2202. #line 699 "ftpcmd.y"
  2203. {
  2204. mec((yyvsp[(3) - (4)].s), prot_safe);
  2205. free((yyvsp[(3) - (4)].s));
  2206. }
  2207. break;
  2208. case 69:
  2209. #line 704 "ftpcmd.y"
  2210. {
  2211. mec((yyvsp[(3) - (4)].s), prot_confidential);
  2212. free((yyvsp[(3) - (4)].s));
  2213. }
  2214. break;
  2215. case 70:
  2216. #line 709 "ftpcmd.y"
  2217. {
  2218. mec((yyvsp[(3) - (4)].s), prot_private);
  2219. free((yyvsp[(3) - (4)].s));
  2220. }
  2221. break;
  2222. case 72:
  2223. #line 721 "ftpcmd.y"
  2224. {
  2225. (yyval.s) = (char *)calloc(1, sizeof(char));
  2226. }
  2227. break;
  2228. case 75:
  2229. #line 734 "ftpcmd.y"
  2230. {
  2231. struct sockaddr_in *sin4 = (struct sockaddr_in *)data_dest;
  2232. sin4->sin_family = AF_INET;
  2233. sin4->sin_port = htons((yyvsp[(9) - (11)].i) * 256 + (yyvsp[(11) - (11)].i));
  2234. sin4->sin_addr.s_addr =
  2235. htonl(((yyvsp[(1) - (11)].i) << 24) | ((yyvsp[(3) - (11)].i) << 16) | ((yyvsp[(5) - (11)].i) << 8) | (yyvsp[(7) - (11)].i));
  2236. }
  2237. break;
  2238. case 76:
  2239. #line 746 "ftpcmd.y"
  2240. {
  2241. (yyval.i) = FORM_N;
  2242. }
  2243. break;
  2244. case 77:
  2245. #line 750 "ftpcmd.y"
  2246. {
  2247. (yyval.i) = FORM_T;
  2248. }
  2249. break;
  2250. case 78:
  2251. #line 754 "ftpcmd.y"
  2252. {
  2253. (yyval.i) = FORM_C;
  2254. }
  2255. break;
  2256. case 79:
  2257. #line 761 "ftpcmd.y"
  2258. {
  2259. cmd_type = TYPE_A;
  2260. cmd_form = FORM_N;
  2261. }
  2262. break;
  2263. case 80:
  2264. #line 766 "ftpcmd.y"
  2265. {
  2266. cmd_type = TYPE_A;
  2267. cmd_form = (yyvsp[(3) - (3)].i);
  2268. }
  2269. break;
  2270. case 81:
  2271. #line 771 "ftpcmd.y"
  2272. {
  2273. cmd_type = TYPE_E;
  2274. cmd_form = FORM_N;
  2275. }
  2276. break;
  2277. case 82:
  2278. #line 776 "ftpcmd.y"
  2279. {
  2280. cmd_type = TYPE_E;
  2281. cmd_form = (yyvsp[(3) - (3)].i);
  2282. }
  2283. break;
  2284. case 83:
  2285. #line 781 "ftpcmd.y"
  2286. {
  2287. cmd_type = TYPE_I;
  2288. }
  2289. break;
  2290. case 84:
  2291. #line 785 "ftpcmd.y"
  2292. {
  2293. cmd_type = TYPE_L;
  2294. cmd_bytesz = NBBY;
  2295. }
  2296. break;
  2297. case 85:
  2298. #line 790 "ftpcmd.y"
  2299. {
  2300. cmd_type = TYPE_L;
  2301. cmd_bytesz = (yyvsp[(3) - (3)].i);
  2302. }
  2303. break;
  2304. case 86:
  2305. #line 796 "ftpcmd.y"
  2306. {
  2307. cmd_type = TYPE_L;
  2308. cmd_bytesz = (yyvsp[(2) - (2)].i);
  2309. }
  2310. break;
  2311. case 87:
  2312. #line 804 "ftpcmd.y"
  2313. {
  2314. (yyval.i) = STRU_F;
  2315. }
  2316. break;
  2317. case 88:
  2318. #line 808 "ftpcmd.y"
  2319. {
  2320. (yyval.i) = STRU_R;
  2321. }
  2322. break;
  2323. case 89:
  2324. #line 812 "ftpcmd.y"
  2325. {
  2326. (yyval.i) = STRU_P;
  2327. }
  2328. break;
  2329. case 90:
  2330. #line 819 "ftpcmd.y"
  2331. {
  2332. (yyval.i) = MODE_S;
  2333. }
  2334. break;
  2335. case 91:
  2336. #line 823 "ftpcmd.y"
  2337. {
  2338. (yyval.i) = MODE_B;
  2339. }
  2340. break;
  2341. case 92:
  2342. #line 827 "ftpcmd.y"
  2343. {
  2344. (yyval.i) = MODE_C;
  2345. }
  2346. break;
  2347. case 93:
  2348. #line 834 "ftpcmd.y"
  2349. {
  2350. /*
  2351. * Problem: this production is used for all pathname
  2352. * processing, but only gives a 550 error reply.
  2353. * This is a valid reply in some cases but not in others.
  2354. */
  2355. if (logged_in && (yyvsp[(1) - (1)].s) && *(yyvsp[(1) - (1)].s) == '~') {
  2356. glob_t gl;
  2357. int flags =
  2358. GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
  2359. memset(&gl, 0, sizeof(gl));
  2360. if (glob((yyvsp[(1) - (1)].s), flags, NULL, &gl) ||
  2361. gl.gl_pathc == 0) {
  2362. reply(550, "not found");
  2363. (yyval.s) = NULL;
  2364. } else {
  2365. (yyval.s) = strdup(gl.gl_pathv[0]);
  2366. }
  2367. globfree(&gl);
  2368. free((yyvsp[(1) - (1)].s));
  2369. } else
  2370. (yyval.s) = (yyvsp[(1) - (1)].s);
  2371. }
  2372. break;
  2373. case 95:
  2374. #line 866 "ftpcmd.y"
  2375. {
  2376. int ret, dec, multby, digit;
  2377. /*
  2378. * Convert a number that was read as decimal number
  2379. * to what it would be if it had been read as octal.
  2380. */
  2381. dec = (yyvsp[(1) - (1)].i);
  2382. multby = 1;
  2383. ret = 0;
  2384. while (dec) {
  2385. digit = dec%10;
  2386. if (digit > 7) {
  2387. ret = -1;
  2388. break;
  2389. }
  2390. ret += digit * multby;
  2391. multby *= 8;
  2392. dec /= 10;
  2393. }
  2394. (yyval.i) = ret;
  2395. }
  2396. break;
  2397. case 96:
  2398. #line 892 "ftpcmd.y"
  2399. {
  2400. (yyval.i) = (yyvsp[(1) - (1)].i) && !guest;
  2401. if((yyvsp[(1) - (1)].i) && !(yyval.i))
  2402. reply(550, "Permission denied");
  2403. }
  2404. break;
  2405. case 97:
  2406. #line 900 "ftpcmd.y"
  2407. {
  2408. if((yyvsp[(1) - (1)].i)) {
  2409. if(((yyval.i) = logged_in) == 0)
  2410. reply(530, "Please login with USER and PASS.");
  2411. } else
  2412. (yyval.i) = 0;
  2413. }
  2414. break;
  2415. case 98:
  2416. #line 910 "ftpcmd.y"
  2417. {
  2418. (yyval.i) = 1;
  2419. if(sec_complete && !ccc_passed && !secure_command()) {
  2420. (yyval.i) = 0;
  2421. reply(533, "Command protection level denied "
  2422. "for paranoid reasons.");
  2423. }
  2424. }
  2425. break;
  2426. /* Line 1267 of yacc.c. */
  2427. #line 2759 "ftpcmd.c"
  2428. default: break;
  2429. }
  2430. YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  2431. YYPOPSTACK (yylen);
  2432. yylen = 0;
  2433. YY_STACK_PRINT (yyss, yyssp);
  2434. *++yyvsp = yyval;
  2435. /* Now `shift' the result of the reduction. Determine what state
  2436. that goes to, based on the state we popped back to and the rule
  2437. number reduced by. */
  2438. yyn = yyr1[yyn];
  2439. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  2440. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  2441. yystate = yytable[yystate];
  2442. else
  2443. yystate = yydefgoto[yyn - YYNTOKENS];
  2444. goto yynewstate;
  2445. /*------------------------------------.
  2446. | yyerrlab -- here on detecting error |
  2447. `------------------------------------*/
  2448. yyerrlab:
  2449. /* If not already recovering from an error, report this error. */
  2450. if (!yyerrstatus)
  2451. {
  2452. ++yynerrs;
  2453. #if ! YYERROR_VERBOSE
  2454. yyerror (YY_("syntax error"));
  2455. #else
  2456. {
  2457. YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
  2458. if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
  2459. {
  2460. YYSIZE_T yyalloc = 2 * yysize;
  2461. if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
  2462. yyalloc = YYSTACK_ALLOC_MAXIMUM;
  2463. if (yymsg != yymsgbuf)
  2464. YYSTACK_FREE (yymsg);
  2465. yymsg = (char *) YYSTACK_ALLOC (yyalloc);
  2466. if (yymsg)
  2467. yymsg_alloc = yyalloc;
  2468. else
  2469. {
  2470. yymsg = yymsgbuf;
  2471. yymsg_alloc = sizeof yymsgbuf;
  2472. }
  2473. }
  2474. if (0 < yysize && yysize <= yymsg_alloc)
  2475. {
  2476. (void) yysyntax_error (yymsg, yystate, yychar);
  2477. yyerror (yymsg);
  2478. }
  2479. else
  2480. {
  2481. yyerror (YY_("syntax error"));
  2482. if (yysize != 0)
  2483. goto yyexhaustedlab;
  2484. }
  2485. }
  2486. #endif
  2487. }
  2488. if (yyerrstatus == 3)
  2489. {
  2490. /* If just tried and failed to reuse look-ahead token after an
  2491. error, discard it. */
  2492. if (yychar <= YYEOF)
  2493. {
  2494. /* Return failure if at end of input. */
  2495. if (yychar == YYEOF)
  2496. YYABORT;
  2497. }
  2498. else
  2499. {
  2500. yydestruct ("Error: discarding",
  2501. yytoken, &yylval);
  2502. yychar = YYEMPTY;
  2503. }
  2504. }
  2505. /* Else will try to reuse look-ahead token after shifting the error
  2506. token. */
  2507. goto yyerrlab1;
  2508. /*---------------------------------------------------.
  2509. | yyerrorlab -- error raised explicitly by YYERROR. |
  2510. `---------------------------------------------------*/
  2511. yyerrorlab:
  2512. /* Pacify compilers like GCC when the user code never invokes
  2513. YYERROR and the label yyerrorlab therefore never appears in user
  2514. code. */
  2515. if (/*CONSTCOND*/ 0)
  2516. goto yyerrorlab;
  2517. /* Do not reclaim the symbols of the rule which action triggered
  2518. this YYERROR. */
  2519. YYPOPSTACK (yylen);
  2520. yylen = 0;
  2521. YY_STACK_PRINT (yyss, yyssp);
  2522. yystate = *yyssp;
  2523. goto yyerrlab1;
  2524. /*-------------------------------------------------------------.
  2525. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  2526. `-------------------------------------------------------------*/
  2527. yyerrlab1:
  2528. yyerrstatus = 3; /* Each real token shifted decrements this. */
  2529. for (;;)
  2530. {
  2531. yyn = yypact[yystate];
  2532. if (yyn != YYPACT_NINF)
  2533. {
  2534. yyn += YYTERROR;
  2535. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  2536. {
  2537. yyn = yytable[yyn];
  2538. if (0 < yyn)
  2539. break;
  2540. }
  2541. }
  2542. /* Pop the current state because it cannot handle the error token. */
  2543. if (yyssp == yyss)
  2544. YYABORT;
  2545. yydestruct ("Error: popping",
  2546. yystos[yystate], yyvsp);
  2547. YYPOPSTACK (1);
  2548. yystate = *yyssp;
  2549. YY_STACK_PRINT (yyss, yyssp);
  2550. }
  2551. if (yyn == YYFINAL)
  2552. YYACCEPT;
  2553. *++yyvsp = yylval;
  2554. /* Shift the error token. */
  2555. YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  2556. yystate = yyn;
  2557. goto yynewstate;
  2558. /*-------------------------------------.
  2559. | yyacceptlab -- YYACCEPT comes here. |
  2560. `-------------------------------------*/
  2561. yyacceptlab:
  2562. yyresult = 0;
  2563. goto yyreturn;
  2564. /*-----------------------------------.
  2565. | yyabortlab -- YYABORT comes here. |
  2566. `-----------------------------------*/
  2567. yyabortlab:
  2568. yyresult = 1;
  2569. goto yyreturn;
  2570. #ifndef yyoverflow
  2571. /*-------------------------------------------------.
  2572. | yyexhaustedlab -- memory exhaustion comes here. |
  2573. `-------------------------------------------------*/
  2574. yyexhaustedlab:
  2575. yyerror (YY_("memory exhausted"));
  2576. yyresult = 2;
  2577. /* Fall through. */
  2578. #endif
  2579. yyreturn:
  2580. if (yychar != YYEOF && yychar != YYEMPTY)
  2581. yydestruct ("Cleanup: discarding lookahead",
  2582. yytoken, &yylval);
  2583. /* Do not reclaim the symbols of the rule which action triggered
  2584. this YYABORT or YYACCEPT. */
  2585. YYPOPSTACK (yylen);
  2586. YY_STACK_PRINT (yyss, yyssp);
  2587. while (yyssp != yyss)
  2588. {
  2589. yydestruct ("Cleanup: popping",
  2590. yystos[*yyssp], yyvsp);
  2591. YYPOPSTACK (1);
  2592. }
  2593. #ifndef yyoverflow
  2594. if (yyss != yyssa)
  2595. YYSTACK_FREE (yyss);
  2596. #endif
  2597. #if YYERROR_VERBOSE
  2598. if (yymsg != yymsgbuf)
  2599. YYSTACK_FREE (yymsg);
  2600. #endif
  2601. /* Make sure YYID is used. */
  2602. return YYID (yyresult);
  2603. }
  2604. #line 920 "ftpcmd.y"
  2605. #define CMD 0 /* beginning of command */
  2606. #define ARGS 1 /* expect miscellaneous arguments */
  2607. #define STR1 2 /* expect SP followed by STRING */
  2608. #define STR2 3 /* expect STRING */
  2609. #define OSTR 4 /* optional SP then STRING */
  2610. #define ZSTR1 5 /* SP then optional STRING */
  2611. #define ZSTR2 6 /* optional STRING after SP */
  2612. #define SITECMD 7 /* SITE command */
  2613. #define NSTR 8 /* Number followed by a string */
  2614. struct tab cmdtab[] = { /* In order defined in RFC 765 */
  2615. { "USER", USER, STR1, 1, "<sp> username" },
  2616. { "PASS", PASS, ZSTR1, 1, "<sp> password" },
  2617. { "ACCT", ACCT, STR1, 0, "(specify account)" },
  2618. { "SMNT", SMNT, ARGS, 0, "(structure mount)" },
  2619. { "REIN", REIN, ARGS, 0, "(reinitialize server state)" },
  2620. { "QUIT", QUIT, ARGS, 1, "(terminate service)", },
  2621. { "PORT", PORT, ARGS, 1, "<sp> b0, b1, b2, b3, b4" },
  2622. { "EPRT", EPRT, STR1, 1, "<sp> string" },
  2623. { "PASV", PASV, ARGS, 1, "(set server in passive mode)" },
  2624. { "EPSV", EPSV, OSTR, 1, "[<sp> foo]" },
  2625. { "TYPE", TYPE, ARGS, 1, "<sp> [ A | E | I | L ]" },
  2626. { "STRU", STRU, ARGS, 1, "(specify file structure)" },
  2627. { "MODE", MODE, ARGS, 1, "(specify transfer mode)" },
  2628. { "RETR", RETR, STR1, 1, "<sp> file-name" },
  2629. { "STOR", STOR, STR1, 1, "<sp> file-name" },
  2630. { "APPE", APPE, STR1, 1, "<sp> file-name" },
  2631. { "MLFL", MLFL, OSTR, 0, "(mail file)" },
  2632. { "MAIL", MAIL, OSTR, 0, "(mail to user)" },
  2633. { "MSND", MSND, OSTR, 0, "(mail send to terminal)" },
  2634. { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" },
  2635. { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" },
  2636. { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" },
  2637. { "MRCP", MRCP, STR1, 0, "(mail recipient)" },
  2638. { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" },
  2639. { "REST", REST, ARGS, 1, "<sp> offset (restart command)" },
  2640. { "RNFR", RNFR, STR1, 1, "<sp> file-name" },
  2641. { "RNTO", RNTO, STR1, 1, "<sp> file-name" },
  2642. { "ABOR", ABOR, ARGS, 1, "(abort operation)" },
  2643. { "DELE", DELE, STR1, 1, "<sp> file-name" },
  2644. { "CWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
  2645. { "XCWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
  2646. { "LIST", LIST, OSTR, 1, "[ <sp> path-name ]" },
  2647. { "NLST", NLST, OSTR, 1, "[ <sp> path-name ]" },
  2648. { "SITE", SITE, SITECMD, 1, "site-cmd [ <sp> arguments ]" },
  2649. { "SYST", SYST, ARGS, 1, "(get type of operating system)" },
  2650. { "STAT", sTAT, OSTR, 1, "[ <sp> path-name ]" },
  2651. { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
  2652. { "NOOP", NOOP, ARGS, 1, "" },
  2653. { "MKD", MKD, STR1, 1, "<sp> path-name" },
  2654. { "XMKD", MKD, STR1, 1, "<sp> path-name" },
  2655. { "RMD", RMD, STR1, 1, "<sp> path-name" },
  2656. { "XRMD", RMD, STR1, 1, "<sp> path-name" },
  2657. { "PWD", PWD, ARGS, 1, "(return current directory)" },
  2658. { "XPWD", PWD, ARGS, 1, "(return current directory)" },
  2659. { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" },
  2660. { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" },
  2661. { "STOU", STOU, STR1, 1, "<sp> file-name" },
  2662. { "SIZE", SIZE, OSTR, 1, "<sp> path-name" },
  2663. { "MDTM", MDTM, OSTR, 1, "<sp> path-name" },
  2664. /* extensions from RFC2228 */
  2665. { "AUTH", AUTH, STR1, 1, "<sp> auth-type" },
  2666. { "ADAT", ADAT, STR1, 1, "<sp> auth-data" },
  2667. { "PBSZ", PBSZ, ARGS, 1, "<sp> buffer-size" },
  2668. { "PROT", PROT, STR1, 1, "<sp> prot-level" },
  2669. { "CCC", CCC, ARGS, 1, "" },
  2670. { "MIC", MIC, STR1, 1, "<sp> integrity command" },
  2671. { "CONF", CONF, STR1, 1, "<sp> confidentiality command" },
  2672. { "ENC", ENC, STR1, 1, "<sp> privacy command" },
  2673. /* RFC2389 */
  2674. { "FEAT", FEAT, ARGS, 1, "" },
  2675. { "OPTS", OPTS, ARGS, 1, "<sp> command [<sp> options]" },
  2676. { NULL, 0, 0, 0, 0 }
  2677. };
  2678. struct tab sitetab[] = {
  2679. { "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" },
  2680. { "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
  2681. { "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },
  2682. { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
  2683. { "KAUTH", KAUTH, STR1, 1, "<sp> principal [ <sp> ticket ]" },
  2684. { "KLIST", KLIST, ARGS, 1, "(show ticket file)" },
  2685. { "KDESTROY", KDESTROY, ARGS, 1, "(destroy tickets)" },
  2686. { "KRBTKFILE", KRBTKFILE, STR1, 1, "<sp> ticket-file" },
  2687. { "AFSLOG", AFSLOG, OSTR, 1, "[<sp> cell]" },
  2688. { "LOCATE", LOCATE, STR1, 1, "<sp> globexpr" },
  2689. { "FIND", LOCATE, STR1, 1, "<sp> globexpr" },
  2690. { "URL", URL, ARGS, 1, "?" },
  2691. { NULL, 0, 0, 0, 0 }
  2692. };
  2693. static struct tab *
  2694. lookup(struct tab *p, char *cmd)
  2695. {
  2696. for (; p->name != NULL; p++)
  2697. if (strcmp(cmd, p->name) == 0)
  2698. return (p);
  2699. return (0);
  2700. }
  2701. /*
  2702. * ftpd_getline - a hacked up version of fgets to ignore TELNET escape codes.
  2703. */
  2704. char *
  2705. ftpd_getline(char *s, int n)
  2706. {
  2707. int c;
  2708. char *cs;
  2709. cs = s;
  2710. /* might still be data within the security MIC/CONF/ENC */
  2711. if(ftp_command){
  2712. strlcpy(s, ftp_command, n);
  2713. if (debug)
  2714. syslog(LOG_DEBUG, "command: %s", s);
  2715. return s;
  2716. }
  2717. while ((c = getc(stdin)) != EOF) {
  2718. c &= 0377;
  2719. if (c == IAC) {
  2720. if ((c = getc(stdin)) != EOF) {
  2721. c &= 0377;
  2722. switch (c) {
  2723. case WILL:
  2724. case WONT:
  2725. c = getc(stdin);
  2726. printf("%c%c%c", IAC, DONT, 0377&c);
  2727. fflush(stdout);
  2728. continue;
  2729. case DO:
  2730. case DONT:
  2731. c = getc(stdin);
  2732. printf("%c%c%c", IAC, WONT, 0377&c);
  2733. fflush(stdout);
  2734. continue;
  2735. case IAC:
  2736. break;
  2737. default:
  2738. continue; /* ignore command */
  2739. }
  2740. }
  2741. }
  2742. *cs++ = c;
  2743. if (--n <= 0 || c == '\n')
  2744. break;
  2745. }
  2746. if (c == EOF && cs == s)
  2747. return (NULL);
  2748. *cs++ = '\0';
  2749. if (debug) {
  2750. if (!guest && strncasecmp("pass ", s, 5) == 0) {
  2751. /* Don't syslog passwords */
  2752. syslog(LOG_DEBUG, "command: %.5s ???", s);
  2753. } else {
  2754. char *cp;
  2755. int len;
  2756. /* Don't syslog trailing CR-LF */
  2757. len = strlen(s);
  2758. cp = s + len - 1;
  2759. while (cp >= s && (*cp == '\n' || *cp == '\r')) {
  2760. --cp;
  2761. --len;
  2762. }
  2763. syslog(LOG_DEBUG, "command: %.*s", len, s);
  2764. }
  2765. }
  2766. #ifdef XXX
  2767. fprintf(stderr, "%s\n", s);
  2768. #endif
  2769. return (s);
  2770. }
  2771. static RETSIGTYPE
  2772. toolong(int signo)
  2773. {
  2774. reply(421,
  2775. "Timeout (%d seconds): closing control connection.",
  2776. ftpd_timeout);
  2777. if (logging)
  2778. syslog(LOG_INFO, "User %s timed out after %d seconds",
  2779. (pw ? pw -> pw_name : "unknown"), ftpd_timeout);
  2780. dologout(1);
  2781. SIGRETURN(0);
  2782. }
  2783. static int
  2784. yylex(void)
  2785. {
  2786. static int cpos, state;
  2787. char *cp, *cp2;
  2788. struct tab *p;
  2789. int n;
  2790. char c;
  2791. for (;;) {
  2792. switch (state) {
  2793. case CMD:
  2794. hasyyerrored = 0;
  2795. signal(SIGALRM, toolong);
  2796. alarm((unsigned) ftpd_timeout);
  2797. if (ftpd_getline(cbuf, sizeof(cbuf)-1) == NULL) {
  2798. reply(221, "You could at least say goodbye.");
  2799. dologout(0);
  2800. }
  2801. alarm(0);
  2802. #ifdef HAVE_SETPROCTITLE
  2803. if (strncasecmp(cbuf, "PASS", 4) != 0)
  2804. setproctitle("%s: %s", proctitle, cbuf);
  2805. #endif /* HAVE_SETPROCTITLE */
  2806. if ((cp = strchr(cbuf, '\r'))) {
  2807. *cp++ = '\n';
  2808. *cp = '\0';
  2809. }
  2810. if ((cp = strpbrk(cbuf, " \n")))
  2811. cpos = cp - cbuf;
  2812. if (cpos == 0)
  2813. cpos = 4;
  2814. c = cbuf[cpos];
  2815. cbuf[cpos] = '\0';
  2816. strupr(cbuf);
  2817. p = lookup(cmdtab, cbuf);
  2818. cbuf[cpos] = c;
  2819. if (p != 0) {
  2820. if (p->implemented == 0) {
  2821. nack(p->name);
  2822. hasyyerrored = 1;
  2823. break;
  2824. }
  2825. state = p->state;
  2826. yylval.s = p->name;
  2827. return (p->token);
  2828. }
  2829. break;
  2830. case SITECMD:
  2831. if (cbuf[cpos] == ' ') {
  2832. cpos++;
  2833. return (SP);
  2834. }
  2835. cp = &cbuf[cpos];
  2836. if ((cp2 = strpbrk(cp, " \n")))
  2837. cpos = cp2 - cbuf;
  2838. c = cbuf[cpos];
  2839. cbuf[cpos] = '\0';
  2840. strupr(cp);
  2841. p = lookup(sitetab, cp);
  2842. cbuf[cpos] = c;
  2843. if (p != 0) {
  2844. if (p->implemented == 0) {
  2845. state = CMD;
  2846. nack(p->name);
  2847. hasyyerrored = 1;
  2848. break;
  2849. }
  2850. state = p->state;
  2851. yylval.s = p->name;
  2852. return (p->token);
  2853. }
  2854. state = CMD;
  2855. break;
  2856. case OSTR:
  2857. if (cbuf[cpos] == '\n') {
  2858. state = CMD;
  2859. return (CRLF);
  2860. }
  2861. /* FALLTHROUGH */
  2862. case STR1:
  2863. case ZSTR1:
  2864. dostr1:
  2865. if (cbuf[cpos] == ' ') {
  2866. cpos++;
  2867. if(state == OSTR)
  2868. state = STR2;
  2869. else
  2870. state++;
  2871. return (SP);
  2872. }
  2873. break;
  2874. case ZSTR2:
  2875. if (cbuf[cpos] == '\n') {
  2876. state = CMD;
  2877. return (CRLF);
  2878. }
  2879. /* FALLTHROUGH */
  2880. case STR2:
  2881. cp = &cbuf[cpos];
  2882. n = strlen(cp);
  2883. cpos += n - 1;
  2884. /*
  2885. * Make sure the string is nonempty and \n terminated.
  2886. */
  2887. if (n > 1 && cbuf[cpos] == '\n') {
  2888. cbuf[cpos] = '\0';
  2889. yylval.s = copy(cp);
  2890. cbuf[cpos] = '\n';
  2891. state = ARGS;
  2892. return (STRING);
  2893. }
  2894. break;
  2895. case NSTR:
  2896. if (cbuf[cpos] == ' ') {
  2897. cpos++;
  2898. return (SP);
  2899. }
  2900. if (isdigit((unsigned char)cbuf[cpos])) {
  2901. cp = &cbuf[cpos];
  2902. while (isdigit((unsigned char)cbuf[++cpos]))
  2903. ;
  2904. c = cbuf[cpos];
  2905. cbuf[cpos] = '\0';
  2906. yylval.i = atoi(cp);
  2907. cbuf[cpos] = c;
  2908. state = STR1;
  2909. return (NUMBER);
  2910. }
  2911. state = STR1;
  2912. goto dostr1;
  2913. case ARGS:
  2914. if (isdigit((unsigned char)cbuf[cpos])) {
  2915. cp = &cbuf[cpos];
  2916. while (isdigit((unsigned char)cbuf[++cpos]))
  2917. ;
  2918. c = cbuf[cpos];
  2919. cbuf[cpos] = '\0';
  2920. yylval.i = atoi(cp);
  2921. cbuf[cpos] = c;
  2922. return (NUMBER);
  2923. }
  2924. switch (cbuf[cpos++]) {
  2925. case '\n':
  2926. state = CMD;
  2927. return (CRLF);
  2928. case ' ':
  2929. return (SP);
  2930. case ',':
  2931. return (COMMA);
  2932. case 'A':
  2933. case 'a':
  2934. return (A);
  2935. case 'B':
  2936. case 'b':
  2937. return (B);
  2938. case 'C':
  2939. case 'c':
  2940. return (C);
  2941. case 'E':
  2942. case 'e':
  2943. return (E);
  2944. case 'F':
  2945. case 'f':
  2946. return (F);
  2947. case 'I':
  2948. case 'i':
  2949. return (I);
  2950. case 'L':
  2951. case 'l':
  2952. return (L);
  2953. case 'N':
  2954. case 'n':
  2955. return (N);
  2956. case 'P':
  2957. case 'p':
  2958. return (P);
  2959. case 'R':
  2960. case 'r':
  2961. return (R);
  2962. case 'S':
  2963. case 's':
  2964. return (S);
  2965. case 'T':
  2966. case 't':
  2967. return (T);
  2968. }
  2969. break;
  2970. default:
  2971. fatal("Unknown state in scanner.");
  2972. }
  2973. yyerror(NULL);
  2974. state = CMD;
  2975. return (0);
  2976. }
  2977. }
  2978. /* ARGSUSED */
  2979. void
  2980. yyerror(char *s)
  2981. {
  2982. char *cp;
  2983. if (hasyyerrored)
  2984. return;
  2985. if ((cp = strchr(cbuf,'\n')))
  2986. *cp = '\0';
  2987. reply(500, "'%s': command not understood.", cbuf);
  2988. hasyyerrored = 1;
  2989. }
  2990. static char *
  2991. copy(char *s)
  2992. {
  2993. char *p;
  2994. p = strdup(s);
  2995. if (p == NULL)
  2996. fatal("Ran out of memory.");
  2997. return p;
  2998. }
  2999. static void
  3000. help(struct tab *ctab, char *s)
  3001. {
  3002. struct tab *c;
  3003. int width, NCMDS;
  3004. char *t;
  3005. char buf[1024];
  3006. if (ctab == sitetab)
  3007. t = "SITE ";
  3008. else
  3009. t = "";
  3010. width = 0, NCMDS = 0;
  3011. for (c = ctab; c->name != NULL; c++) {
  3012. int len = strlen(c->name);
  3013. if (len > width)
  3014. width = len;
  3015. NCMDS++;
  3016. }
  3017. width = (width + 8) &~ 7;
  3018. if (s == 0) {
  3019. int i, j, w;
  3020. int columns, lines;
  3021. lreply(214, "The following %scommands are recognized %s.",
  3022. t, "(* =>'s unimplemented)");
  3023. columns = 76 / width;
  3024. if (columns == 0)
  3025. columns = 1;
  3026. lines = (NCMDS + columns - 1) / columns;
  3027. for (i = 0; i < lines; i++) {
  3028. strlcpy (buf, " ", sizeof(buf));
  3029. for (j = 0; j < columns; j++) {
  3030. c = ctab + j * lines + i;
  3031. snprintf (buf + strlen(buf),
  3032. sizeof(buf) - strlen(buf),
  3033. "%s%c",
  3034. c->name,
  3035. c->implemented ? ' ' : '*');
  3036. if (c + lines >= &ctab[NCMDS])
  3037. break;
  3038. w = strlen(c->name) + 1;
  3039. while (w < width) {
  3040. strlcat (buf,
  3041. " ",
  3042. sizeof(buf));
  3043. w++;
  3044. }
  3045. }
  3046. lreply(214, "%s", buf);
  3047. }
  3048. reply(214, "Direct comments to kth-krb-bugs@pdc.kth.se");
  3049. return;
  3050. }
  3051. strupr(s);
  3052. c = lookup(ctab, s);
  3053. if (c == (struct tab *)0) {
  3054. reply(502, "Unknown command %s.", s);
  3055. return;
  3056. }
  3057. if (c->implemented)
  3058. reply(214, "Syntax: %s%s %s", t, c->name, c->help);
  3059. else
  3060. reply(214, "%s%-*s\t%s; unimplemented.", t, width,
  3061. c->name, c->help);
  3062. }
  3063. static void
  3064. sizecmd(char *filename)
  3065. {
  3066. switch (type) {
  3067. case TYPE_L:
  3068. case TYPE_I: {
  3069. struct stat stbuf;
  3070. if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
  3071. reply(550, "%s: not a plain file.", filename);
  3072. else
  3073. reply(213, "%lu", (unsigned long)stbuf.st_size);
  3074. break;
  3075. }
  3076. case TYPE_A: {
  3077. FILE *fin;
  3078. int c;
  3079. size_t count;
  3080. struct stat stbuf;
  3081. fin = fopen(filename, "r");
  3082. if (fin == NULL) {
  3083. perror_reply(550, filename);
  3084. return;
  3085. }
  3086. if (fstat(fileno(fin), &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
  3087. reply(550, "%s: not a plain file.", filename);
  3088. fclose(fin);
  3089. return;
  3090. }
  3091. count = 0;
  3092. while((c=getc(fin)) != EOF) {
  3093. if (c == '\n') /* will get expanded to \r\n */
  3094. count++;
  3095. count++;
  3096. }
  3097. fclose(fin);
  3098. reply(213, "%lu", (unsigned long)count);
  3099. break;
  3100. }
  3101. default:
  3102. reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
  3103. }
  3104. }