No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / appl / ftp / ftpd / ftpcmd.c
blob3f88735ffb84675bada6153e8a620e2b30057666
1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 0
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
63 /* Tokens. */
64 #ifndef YYTOKENTYPE
65 # define YYTOKENTYPE
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
67 know about them. */
68 enum yytokentype {
69 A = 258,
70 B = 259,
71 C = 260,
72 E = 261,
73 F = 262,
74 I = 263,
75 L = 264,
76 N = 265,
77 P = 266,
78 R = 267,
79 S = 268,
80 T = 269,
81 SP = 270,
82 CRLF = 271,
83 COMMA = 272,
84 USER = 273,
85 PASS = 274,
86 ACCT = 275,
87 REIN = 276,
88 QUIT = 277,
89 PORT = 278,
90 PASV = 279,
91 TYPE = 280,
92 STRU = 281,
93 MODE = 282,
94 RETR = 283,
95 STOR = 284,
96 APPE = 285,
97 MLFL = 286,
98 MAIL = 287,
99 MSND = 288,
100 MSOM = 289,
101 MSAM = 290,
102 MRSQ = 291,
103 MRCP = 292,
104 ALLO = 293,
105 REST = 294,
106 RNFR = 295,
107 RNTO = 296,
108 ABOR = 297,
109 DELE = 298,
110 CWD = 299,
111 LIST = 300,
112 NLST = 301,
113 SITE = 302,
114 sTAT = 303,
115 HELP = 304,
116 NOOP = 305,
117 MKD = 306,
118 RMD = 307,
119 PWD = 308,
120 CDUP = 309,
121 STOU = 310,
122 SMNT = 311,
123 SYST = 312,
124 SIZE = 313,
125 MDTM = 314,
126 EPRT = 315,
127 EPSV = 316,
128 UMASK = 317,
129 IDLE = 318,
130 CHMOD = 319,
131 AUTH = 320,
132 ADAT = 321,
133 PROT = 322,
134 PBSZ = 323,
135 CCC = 324,
136 MIC = 325,
137 CONF = 326,
138 ENC = 327,
139 KAUTH = 328,
140 KLIST = 329,
141 KDESTROY = 330,
142 KRBTKFILE = 331,
143 AFSLOG = 332,
144 LOCATE = 333,
145 URL = 334,
146 FEAT = 335,
147 OPTS = 336,
148 LEXERR = 337,
149 STRING = 338,
150 NUMBER = 339
152 #endif
153 /* Tokens. */
154 #define A 258
155 #define B 259
156 #define C 260
157 #define E 261
158 #define F 262
159 #define I 263
160 #define L 264
161 #define N 265
162 #define P 266
163 #define R 267
164 #define S 268
165 #define T 269
166 #define SP 270
167 #define CRLF 271
168 #define COMMA 272
169 #define USER 273
170 #define PASS 274
171 #define ACCT 275
172 #define REIN 276
173 #define QUIT 277
174 #define PORT 278
175 #define PASV 279
176 #define TYPE 280
177 #define STRU 281
178 #define MODE 282
179 #define RETR 283
180 #define STOR 284
181 #define APPE 285
182 #define MLFL 286
183 #define MAIL 287
184 #define MSND 288
185 #define MSOM 289
186 #define MSAM 290
187 #define MRSQ 291
188 #define MRCP 292
189 #define ALLO 293
190 #define REST 294
191 #define RNFR 295
192 #define RNTO 296
193 #define ABOR 297
194 #define DELE 298
195 #define CWD 299
196 #define LIST 300
197 #define NLST 301
198 #define SITE 302
199 #define sTAT 303
200 #define HELP 304
201 #define NOOP 305
202 #define MKD 306
203 #define RMD 307
204 #define PWD 308
205 #define CDUP 309
206 #define STOU 310
207 #define SMNT 311
208 #define SYST 312
209 #define SIZE 313
210 #define MDTM 314
211 #define EPRT 315
212 #define EPSV 316
213 #define UMASK 317
214 #define IDLE 318
215 #define CHMOD 319
216 #define AUTH 320
217 #define ADAT 321
218 #define PROT 322
219 #define PBSZ 323
220 #define CCC 324
221 #define MIC 325
222 #define CONF 326
223 #define ENC 327
224 #define KAUTH 328
225 #define KLIST 329
226 #define KDESTROY 330
227 #define KRBTKFILE 331
228 #define AFSLOG 332
229 #define LOCATE 333
230 #define URL 334
231 #define FEAT 335
232 #define OPTS 336
233 #define LEXERR 337
234 #define STRING 338
235 #define NUMBER 339
240 /* Copy the first part of user declarations. */
241 #line 43 "ftpcmd.y"
244 #include "ftpd_locl.h"
245 __RCSID("$Heimdal: ftpcmd.y 15677 2005-07-19 18:33:08Z lha $"
246 "$NetBSD$");
248 off_t restart_point;
250 static int hasyyerrored;
253 static int cmd_type;
254 static int cmd_form;
255 static int cmd_bytesz;
256 char cbuf[64*1024];
257 char *fromname;
259 struct tab {
260 char *name;
261 short token;
262 short state;
263 short implemented; /* 1 if command is implemented */
264 char *help;
267 extern struct tab cmdtab[];
268 extern struct tab sitetab[];
270 static char *copy (char *);
271 static void help (struct tab *, char *);
272 static struct tab *
273 lookup (struct tab *, char *);
274 static void sizecmd (char *);
275 static RETSIGTYPE toolong (int);
276 static int yylex (void);
278 /* This is for bison */
280 #if !defined(alloca) && !defined(HAVE_ALLOCA)
281 #define alloca(x) malloc(x)
282 #endif
286 /* Enabling traces. */
287 #ifndef YYDEBUG
288 # define YYDEBUG 0
289 #endif
291 /* Enabling verbose error messages. */
292 #ifdef YYERROR_VERBOSE
293 # undef YYERROR_VERBOSE
294 # define YYERROR_VERBOSE 1
295 #else
296 # define YYERROR_VERBOSE 0
297 #endif
299 /* Enabling the token table. */
300 #ifndef YYTOKEN_TABLE
301 # define YYTOKEN_TABLE 0
302 #endif
304 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
305 typedef union YYSTYPE
306 #line 86 "ftpcmd.y"
308 int i;
309 char *s;
311 /* Line 193 of yacc.c. */
312 #line 312 "ftpcmd.c"
313 YYSTYPE;
314 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
315 # define YYSTYPE_IS_DECLARED 1
316 # define YYSTYPE_IS_TRIVIAL 1
317 #endif
321 /* Copy the second part of user declarations. */
324 /* Line 216 of yacc.c. */
325 #line 325 "ftpcmd.c"
327 #ifdef short
328 # undef short
329 #endif
331 #ifdef YYTYPE_UINT8
332 typedef YYTYPE_UINT8 yytype_uint8;
333 #else
334 typedef unsigned char yytype_uint8;
335 #endif
337 #ifdef YYTYPE_INT8
338 typedef YYTYPE_INT8 yytype_int8;
339 #elif (defined __STDC__ || defined __C99__FUNC__ \
340 || defined __cplusplus || defined _MSC_VER)
341 typedef signed char yytype_int8;
342 #else
343 typedef short int yytype_int8;
344 #endif
346 #ifdef YYTYPE_UINT16
347 typedef YYTYPE_UINT16 yytype_uint16;
348 #else
349 typedef unsigned short int yytype_uint16;
350 #endif
352 #ifdef YYTYPE_INT16
353 typedef YYTYPE_INT16 yytype_int16;
354 #else
355 typedef short int yytype_int16;
356 #endif
358 #ifndef YYSIZE_T
359 # ifdef __SIZE_TYPE__
360 # define YYSIZE_T __SIZE_TYPE__
361 # elif defined size_t
362 # define YYSIZE_T size_t
363 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
364 || defined __cplusplus || defined _MSC_VER)
365 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
366 # define YYSIZE_T size_t
367 # else
368 # define YYSIZE_T unsigned int
369 # endif
370 #endif
372 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
374 #ifndef YY_
375 # if defined YYENABLE_NLS && YYENABLE_NLS
376 # if ENABLE_NLS
377 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
378 # define YY_(msgid) dgettext ("bison-runtime", msgid)
379 # endif
380 # endif
381 # ifndef YY_
382 # define YY_(msgid) msgid
383 # endif
384 #endif
386 /* Suppress unused-variable warnings by "using" E. */
387 #if ! defined lint || defined __GNUC__
388 # define YYUSE(e) ((void) (e))
389 #else
390 # define YYUSE(e) /* empty */
391 #endif
393 /* Identity function, used to suppress warnings about constant conditions. */
394 #ifndef lint
395 # define YYID(n) (n)
396 #else
397 #if (defined __STDC__ || defined __C99__FUNC__ \
398 || defined __cplusplus || defined _MSC_VER)
399 static int
400 YYID (int i)
401 #else
402 static int
403 YYID (i)
404 int i;
405 #endif
407 return i;
409 #endif
411 #if ! defined yyoverflow || YYERROR_VERBOSE
413 /* The parser invokes alloca or malloc; define the necessary symbols. */
415 # ifdef YYSTACK_USE_ALLOCA
416 # if YYSTACK_USE_ALLOCA
417 # ifdef __GNUC__
418 # define YYSTACK_ALLOC __builtin_alloca
419 # elif defined __BUILTIN_VA_ARG_INCR
420 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
421 # elif defined _AIX
422 # define YYSTACK_ALLOC __alloca
423 # elif defined _MSC_VER
424 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
425 # define alloca _alloca
426 # else
427 # define YYSTACK_ALLOC alloca
428 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
429 || defined __cplusplus || defined _MSC_VER)
430 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
431 # ifndef _STDLIB_H
432 # define _STDLIB_H 1
433 # endif
434 # endif
435 # endif
436 # endif
437 # endif
439 # ifdef YYSTACK_ALLOC
440 /* Pacify GCC's `empty if-body' warning. */
441 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
442 # ifndef YYSTACK_ALLOC_MAXIMUM
443 /* The OS might guarantee only one guard page at the bottom of the stack,
444 and a page size can be as small as 4096 bytes. So we cannot safely
445 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
446 to allow for a few compiler-allocated temporary stack slots. */
447 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
448 # endif
449 # else
450 # define YYSTACK_ALLOC YYMALLOC
451 # define YYSTACK_FREE YYFREE
452 # ifndef YYSTACK_ALLOC_MAXIMUM
453 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
454 # endif
455 # if (defined __cplusplus && ! defined _STDLIB_H \
456 && ! ((defined YYMALLOC || defined malloc) \
457 && (defined YYFREE || defined free)))
458 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
459 # ifndef _STDLIB_H
460 # define _STDLIB_H 1
461 # endif
462 # endif
463 # ifndef YYMALLOC
464 # define YYMALLOC malloc
465 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
466 || defined __cplusplus || defined _MSC_VER)
467 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
468 # endif
469 # endif
470 # ifndef YYFREE
471 # define YYFREE free
472 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
473 || defined __cplusplus || defined _MSC_VER)
474 void free (void *); /* INFRINGES ON USER NAME SPACE */
475 # endif
476 # endif
477 # endif
478 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
481 #if (! defined yyoverflow \
482 && (! defined __cplusplus \
483 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
485 /* A type that is properly aligned for any stack member. */
486 union yyalloc
488 yytype_int16 yyss;
489 YYSTYPE yyvs;
492 /* The size of the maximum gap between one aligned stack and the next. */
493 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
495 /* The size of an array large to enough to hold all stacks, each with
496 N elements. */
497 # define YYSTACK_BYTES(N) \
498 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
499 + YYSTACK_GAP_MAXIMUM)
501 /* Copy COUNT objects from FROM to TO. The source and destination do
502 not overlap. */
503 # ifndef YYCOPY
504 # if defined __GNUC__ && 1 < __GNUC__
505 # define YYCOPY(To, From, Count) \
506 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
507 # else
508 # define YYCOPY(To, From, Count) \
509 do \
511 YYSIZE_T yyi; \
512 for (yyi = 0; yyi < (Count); yyi++) \
513 (To)[yyi] = (From)[yyi]; \
515 while (YYID (0))
516 # endif
517 # endif
519 /* Relocate STACK from its old location to the new one. The
520 local variables YYSIZE and YYSTACKSIZE give the old and new number of
521 elements in the stack, and YYPTR gives the new location of the
522 stack. Advance YYPTR to a properly aligned location for the next
523 stack. */
524 # define YYSTACK_RELOCATE(Stack) \
525 do \
527 YYSIZE_T yynewbytes; \
528 YYCOPY (&yyptr->Stack, Stack, yysize); \
529 Stack = &yyptr->Stack; \
530 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
531 yyptr += yynewbytes / sizeof (*yyptr); \
533 while (YYID (0))
535 #endif
537 /* YYFINAL -- State number of the termination state. */
538 #define YYFINAL 2
539 /* YYLAST -- Last index in YYTABLE. */
540 #define YYLAST 327
542 /* YYNTOKENS -- Number of terminals. */
543 #define YYNTOKENS 85
544 /* YYNNTS -- Number of nonterminals. */
545 #define YYNNTS 18
546 /* YYNRULES -- Number of rules. */
547 #define YYNRULES 98
548 /* YYNRULES -- Number of states. */
549 #define YYNSTATES 317
551 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
552 #define YYUNDEFTOK 2
553 #define YYMAXUTOK 339
555 #define YYTRANSLATE(YYX) \
556 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
558 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
559 static const yytype_uint8 yytranslate[] =
561 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
587 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
588 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
589 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
590 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
591 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
592 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
593 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
594 75, 76, 77, 78, 79, 80, 81, 82, 83, 84
597 #if YYDEBUG
598 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
599 YYRHS. */
600 static const yytype_uint16 yyprhs[] =
602 0, 0, 3, 4, 7, 10, 16, 22, 28, 34,
603 38, 42, 48, 54, 60, 66, 72, 82, 88, 94,
604 100, 104, 110, 114, 120, 126, 130, 136, 142, 146,
605 150, 156, 160, 166, 170, 176, 182, 186, 190, 194,
606 200, 206, 214, 220, 228, 238, 244, 252, 260, 266,
607 272, 280, 286, 294, 302, 308, 314, 318, 324, 330,
608 334, 337, 343, 349, 354, 359, 365, 371, 375, 380,
609 385, 390, 392, 393, 395, 397, 409, 411, 413, 415,
610 417, 421, 423, 427, 429, 431, 435, 438, 440, 442,
611 444, 446, 448, 450, 452, 454, 456, 458, 460
614 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
615 static const yytype_int8 yyrhs[] =
617 86, 0, -1, -1, 86, 87, -1, 86, 88, -1,
618 18, 15, 89, 16, 102, -1, 19, 15, 90, 16,
619 102, -1, 23, 15, 92, 16, 102, -1, 60, 15,
620 83, 16, 102, -1, 24, 16, 101, -1, 61, 16,
621 101, -1, 61, 15, 83, 16, 101, -1, 25, 15,
622 94, 16, 102, -1, 26, 15, 95, 16, 102, -1,
623 27, 15, 96, 16, 102, -1, 38, 15, 84, 16,
624 102, -1, 38, 15, 84, 15, 12, 15, 84, 16,
625 102, -1, 28, 15, 97, 16, 101, -1, 29, 15,
626 97, 16, 101, -1, 30, 15, 97, 16, 101, -1,
627 46, 16, 101, -1, 46, 15, 83, 16, 101, -1,
628 45, 16, 101, -1, 45, 15, 97, 16, 101, -1,
629 48, 15, 97, 16, 101, -1, 48, 16, 102, -1,
630 43, 15, 97, 16, 100, -1, 41, 15, 97, 16,
631 100, -1, 42, 16, 102, -1, 44, 16, 101, -1,
632 44, 15, 97, 16, 101, -1, 49, 16, 102, -1,
633 49, 15, 83, 16, 102, -1, 50, 16, 102, -1,
634 51, 15, 97, 16, 101, -1, 52, 15, 97, 16,
635 100, -1, 53, 16, 101, -1, 54, 16, 101, -1,
636 80, 16, 102, -1, 81, 15, 83, 16, 102, -1,
637 47, 15, 49, 16, 102, -1, 47, 15, 49, 15,
638 83, 16, 102, -1, 47, 15, 62, 16, 101, -1,
639 47, 15, 62, 15, 99, 16, 100, -1, 47, 15,
640 64, 15, 99, 15, 97, 16, 100, -1, 47, 15,
641 63, 16, 102, -1, 47, 15, 63, 15, 84, 16,
642 102, -1, 47, 15, 73, 15, 83, 16, 101, -1,
643 47, 15, 74, 16, 101, -1, 47, 15, 75, 16,
644 101, -1, 47, 15, 76, 15, 83, 16, 101, -1,
645 47, 15, 77, 16, 101, -1, 47, 15, 77, 15,
646 83, 16, 101, -1, 47, 15, 78, 15, 83, 16,
647 101, -1, 47, 15, 79, 16, 102, -1, 55, 15,
648 97, 16, 101, -1, 57, 16, 102, -1, 58, 15,
649 97, 16, 101, -1, 59, 15, 97, 16, 101, -1,
650 22, 16, 102, -1, 1, 16, -1, 40, 15, 97,
651 16, 100, -1, 39, 15, 91, 16, 102, -1, 65,
652 15, 83, 16, -1, 66, 15, 83, 16, -1, 68,
653 15, 84, 16, 102, -1, 67, 15, 83, 16, 102,
654 -1, 69, 16, 102, -1, 70, 15, 83, 16, -1,
655 71, 15, 83, 16, -1, 72, 15, 83, 16, -1,
656 83, -1, -1, 83, -1, 84, -1, 84, 17, 84,
657 17, 84, 17, 84, 17, 84, 17, 84, -1, 10,
658 -1, 14, -1, 5, -1, 3, -1, 3, 15, 93,
659 -1, 6, -1, 6, 15, 93, -1, 8, -1, 9,
660 -1, 9, 15, 91, -1, 9, 91, -1, 7, -1,
661 12, -1, 11, -1, 13, -1, 4, -1, 5, -1,
662 98, -1, 83, -1, 84, -1, 101, -1, 102, -1,
666 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
667 static const yytype_uint16 yyrline[] =
669 0, 129, 129, 131, 136, 140, 146, 153, 164, 170,
670 175, 180, 186, 223, 237, 251, 257, 263, 272, 281,
671 290, 295, 304, 309, 315, 322, 327, 334, 348, 353,
672 358, 365, 370, 387, 392, 399, 406, 411, 416, 426,
673 433, 438, 443, 451, 464, 478, 485, 502, 525, 530,
674 539, 552, 563, 576, 583, 588, 595, 613, 630, 658,
675 665, 671, 681, 691, 696, 701, 706, 711, 716, 721,
676 726, 734, 739, 742, 746, 750, 763, 767, 771, 778,
677 783, 788, 793, 798, 802, 807, 813, 821, 825, 829,
678 836, 840, 844, 851, 879, 883, 909, 917, 928
680 #endif
682 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
683 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
684 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
685 static const char *const yytname[] =
687 "$end", "error", "$undefined", "A", "B", "C", "E", "F", "I", "L", "N",
688 "P", "R", "S", "T", "SP", "CRLF", "COMMA", "USER", "PASS", "ACCT",
689 "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR",
690 "APPE", "MLFL", "MAIL", "MSND", "MSOM", "MSAM", "MRSQ", "MRCP", "ALLO",
691 "REST", "RNFR", "RNTO", "ABOR", "DELE", "CWD", "LIST", "NLST", "SITE",
692 "sTAT", "HELP", "NOOP", "MKD", "RMD", "PWD", "CDUP", "STOU", "SMNT",
693 "SYST", "SIZE", "MDTM", "EPRT", "EPSV", "UMASK", "IDLE", "CHMOD", "AUTH",
694 "ADAT", "PROT", "PBSZ", "CCC", "MIC", "CONF", "ENC", "KAUTH", "KLIST",
695 "KDESTROY", "KRBTKFILE", "AFSLOG", "LOCATE", "URL", "FEAT", "OPTS",
696 "LEXERR", "STRING", "NUMBER", "$accept", "cmd_list", "cmd", "rcmd",
697 "username", "password", "byte_size", "host_port", "form_code",
698 "type_code", "struct_code", "mode_code", "pathname", "pathstring",
699 "octal_number", "check_login_no_guest", "check_login", "check_secure", 0
701 #endif
703 # ifdef YYPRINT
704 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
705 token YYLEX-NUM. */
706 static const yytype_uint16 yytoknum[] =
708 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
709 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
710 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
711 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
712 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
713 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
714 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
715 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
716 335, 336, 337, 338, 339
718 # endif
720 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
721 static const yytype_uint8 yyr1[] =
723 0, 85, 86, 86, 86, 87, 87, 87, 87, 87,
724 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
725 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
726 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
727 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
728 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
729 87, 88, 88, 88, 88, 88, 88, 88, 88, 88,
730 88, 89, 90, 90, 91, 92, 93, 93, 93, 94,
731 94, 94, 94, 94, 94, 94, 94, 95, 95, 95,
732 96, 96, 96, 97, 98, 99, 100, 101, 102
735 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
736 static const yytype_uint8 yyr2[] =
738 0, 2, 0, 2, 2, 5, 5, 5, 5, 3,
739 3, 5, 5, 5, 5, 5, 9, 5, 5, 5,
740 3, 5, 3, 5, 5, 3, 5, 5, 3, 3,
741 5, 3, 5, 3, 5, 5, 3, 3, 3, 5,
742 5, 7, 5, 7, 9, 5, 7, 7, 5, 5,
743 7, 5, 7, 7, 5, 5, 3, 5, 5, 3,
744 2, 5, 5, 4, 4, 5, 5, 3, 4, 4,
745 4, 1, 0, 1, 1, 11, 1, 1, 1, 1,
746 3, 1, 3, 1, 1, 3, 2, 1, 1, 1,
747 1, 1, 1, 1, 1, 1, 1, 1, 0
750 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
751 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
752 means the default is an error. */
753 static const yytype_uint8 yydefact[] =
755 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
756 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
758 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
759 0, 0, 0, 0, 0, 0, 0, 0, 3, 4,
760 60, 0, 72, 98, 0, 98, 0, 0, 0, 0,
761 0, 0, 0, 0, 0, 0, 98, 0, 0, 98,
762 0, 98, 0, 98, 0, 0, 98, 0, 98, 98,
763 0, 0, 98, 98, 0, 98, 0, 0, 0, 0,
764 98, 0, 0, 0, 0, 98, 0, 0, 0, 98,
765 0, 71, 0, 73, 0, 59, 0, 0, 9, 97,
766 79, 81, 83, 84, 0, 87, 89, 88, 0, 91,
767 92, 90, 0, 94, 0, 93, 0, 0, 0, 74,
768 0, 0, 0, 28, 0, 0, 29, 0, 22, 0,
769 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
770 0, 0, 0, 25, 0, 31, 33, 0, 0, 36,
771 37, 0, 56, 0, 0, 0, 0, 10, 0, 0,
772 0, 0, 67, 0, 0, 0, 38, 0, 98, 98,
773 0, 98, 0, 0, 0, 86, 98, 98, 98, 98,
774 98, 98, 0, 98, 98, 98, 98, 98, 98, 98,
775 98, 0, 98, 0, 98, 0, 98, 0, 0, 98,
776 98, 0, 0, 98, 0, 98, 98, 98, 98, 98,
777 98, 98, 98, 98, 98, 63, 64, 98, 98, 68,
778 69, 70, 98, 5, 6, 0, 7, 78, 76, 77,
779 80, 82, 85, 12, 13, 14, 17, 18, 19, 0,
780 15, 62, 61, 96, 27, 26, 30, 23, 21, 0,
781 40, 95, 0, 42, 0, 45, 0, 0, 48, 49,
782 0, 0, 51, 0, 54, 24, 32, 34, 35, 55,
783 57, 58, 8, 11, 66, 65, 39, 0, 0, 98,
784 98, 98, 0, 98, 98, 98, 98, 0, 0, 41,
785 43, 46, 0, 47, 50, 52, 53, 0, 98, 98,
786 0, 16, 44, 0, 0, 0, 75
789 /* YYDEFGOTO[NTERM-NUM]. */
790 static const yytype_int16 yydefgoto[] =
792 -1, 1, 48, 49, 102, 104, 130, 107, 240, 114,
793 118, 122, 124, 125, 262, 252, 253, 109
796 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
797 STATE-NUM. */
798 #define YYPACT_NINF -196
799 static const yytype_int16 yypact[] =
801 -196, 246, -196, 3, 13, 20, 11, 24, 21, 26,
802 30, 45, 66, 67, 68, 69, 70, 71, 72, 76,
803 73, -7, -5, 15, 78, 28, 32, 80, 79, 82,
804 83, 91, 93, 94, 96, 97, 98, 38, 100, 101,
805 102, 103, 104, 106, 107, 108, 111, 109, -196, -196,
806 -196, -66, 36, -196, 14, -196, 12, 22, 1, 46,
807 46, 46, 25, 48, 46, 46, -196, 46, 46, -196,
808 46, -196, 53, -196, 27, 46, -196, 55, -196, -196,
809 46, 46, -196, -196, 46, -196, 46, 46, 56, 59,
810 -196, 60, 61, 62, 63, -196, 65, 77, 85, -196,
811 86, -196, 114, -196, 115, -196, 120, 130, -196, -196,
812 135, 136, -196, -11, 138, -196, -196, -196, 139, -196,
813 -196, -196, 143, -196, 145, -196, 147, 156, 47, -196,
814 157, 162, 165, -196, 166, 168, -196, 170, -196, 174,
815 -196, 49, 52, 54, 137, 177, 178, 179, 181, 64,
816 182, 183, 184, -196, 185, -196, -196, 186, 187, -196,
817 -196, 188, -196, 189, 190, 191, 192, -196, 193, 194,
818 195, 196, -196, 197, 198, 199, -196, 200, -196, -196,
819 133, -196, 2, 2, 48, -196, -196, -196, -196, -196,
820 -196, -196, 206, -196, -196, -196, -196, -196, -196, -196,
821 -196, 110, -196, 140, -196, 141, -196, 140, 144, -196,
822 -196, 146, 148, -196, 149, -196, -196, -196, -196, -196,
823 -196, -196, -196, -196, -196, -196, -196, -196, -196, -196,
824 -196, -196, -196, -196, -196, 202, -196, -196, -196, -196,
825 -196, -196, -196, -196, -196, -196, -196, -196, -196, 205,
826 -196, -196, -196, -196, -196, -196, -196, -196, -196, 207,
827 -196, -196, 210, -196, 212, -196, 215, 217, -196, -196,
828 218, 219, -196, 221, -196, -196, -196, -196, -196, -196,
829 -196, -196, -196, -196, -196, -196, -196, 155, 158, -196,
830 -196, -196, 46, -196, -196, -196, -196, 204, 224, -196,
831 -196, -196, 225, -196, -196, -196, -196, 159, -196, -196,
832 227, -196, -196, 161, 231, 167, -196
835 /* YYPGOTO[NTERM-NUM]. */
836 static const yytype_int16 yypgoto[] =
838 -196, -196, -196, -196, -196, -196, -110, -196, 39, -196,
839 -196, -196, -9, -196, 42, -195, -33, -53
842 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
843 positive, shift that token. If negative, reduce the rule which
844 number is the opposite. If zero, do what YYDEFACT says.
845 If YYTABLE_NINF, syntax error. */
846 #define YYTABLE_NINF -1
847 static const yytype_uint16 yytable[] =
849 105, 254, 255, 185, 184, 119, 120, 237, 68, 69,
850 70, 71, 238, 133, 121, 110, 239, 101, 111, 50,
851 112, 113, 108, 153, 278, 155, 156, 53, 51, 115,
852 72, 73, 162, 116, 117, 52, 136, 55, 138, 54,
853 140, 56, 172, 75, 76, 57, 176, 77, 78, 159,
854 160, 126, 127, 89, 90, 131, 132, 167, 134, 135,
855 58, 137, 192, 193, 201, 202, 152, 203, 204, 205,
856 206, 157, 158, 129, 242, 161, 141, 163, 164, 212,
857 213, 59, 60, 61, 62, 63, 64, 65, 67, 142,
858 143, 144, 66, 74, 80, 300, 79, 81, 106, 82,
859 145, 146, 147, 148, 149, 150, 151, 83, 84, 128,
860 85, 86, 87, 88, 312, 91, 92, 93, 94, 103,
861 95, 96, 97, 98, 100, 233, 234, 99, 236, 123,
862 178, 179, 129, 243, 244, 245, 139, 180, 154, 165,
863 250, 251, 166, 168, 169, 170, 181, 171, 173, 260,
864 182, 183, 207, 265, 186, 187, 246, 247, 248, 188,
865 174, 189, 274, 190, 276, 256, 257, 258, 175, 177,
866 282, 263, 191, 194, 284, 285, 268, 269, 195, 286,
867 272, 196, 197, 275, 198, 277, 199, 279, 280, 281,
868 200, 283, 208, 259, 209, 210, 211, 214, 0, 215,
869 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
870 226, 227, 228, 229, 230, 231, 232, 235, 249, 287,
871 288, 307, 241, 289, 261, 264, 290, 267, 291, 270,
872 292, 271, 273, 293, 294, 295, 299, 296, 301, 297,
873 308, 309, 298, 310, 313, 314, 2, 3, 315, 266,
874 0, 316, 0, 0, 0, 311, 0, 0, 0, 0,
875 303, 304, 305, 306, 4, 5, 0, 0, 6, 7,
876 8, 9, 10, 11, 12, 13, 14, 0, 0, 0,
877 0, 0, 0, 302, 15, 16, 17, 18, 19, 20,
878 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
879 31, 32, 0, 33, 34, 35, 36, 37, 0, 0,
880 0, 38, 39, 40, 41, 42, 43, 44, 45, 0,
881 0, 0, 0, 0, 0, 0, 46, 47
884 static const yytype_int16 yycheck[] =
886 53, 196, 197, 113, 15, 4, 5, 5, 15, 16,
887 15, 16, 10, 66, 13, 3, 14, 83, 6, 16,
888 8, 9, 55, 76, 219, 78, 79, 16, 15, 7,
889 15, 16, 85, 11, 12, 15, 69, 16, 71, 15,
890 73, 15, 95, 15, 16, 15, 99, 15, 16, 82,
891 83, 60, 61, 15, 16, 64, 65, 90, 67, 68,
892 15, 70, 15, 16, 15, 16, 75, 15, 16, 15,
893 16, 80, 81, 84, 184, 84, 49, 86, 87, 15,
894 16, 15, 15, 15, 15, 15, 15, 15, 15, 62,
895 63, 64, 16, 15, 15, 290, 16, 15, 84, 16,
896 73, 74, 75, 76, 77, 78, 79, 16, 15, 84,
897 16, 15, 15, 15, 309, 15, 15, 15, 15, 83,
898 16, 15, 15, 15, 15, 178, 179, 16, 181, 83,
899 16, 16, 84, 186, 187, 188, 83, 17, 83, 83,
900 193, 194, 83, 83, 83, 83, 16, 84, 83, 202,
901 15, 15, 15, 206, 16, 16, 189, 190, 191, 16,
902 83, 16, 215, 16, 217, 198, 199, 200, 83, 83,
903 223, 204, 16, 16, 227, 228, 209, 210, 16, 232,
904 213, 16, 16, 216, 16, 218, 16, 220, 221, 222,
905 16, 224, 15, 83, 16, 16, 15, 15, -1, 16,
906 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
907 16, 16, 16, 16, 16, 16, 16, 84, 12, 17,
908 15, 17, 183, 16, 84, 84, 16, 83, 16, 83,
909 15, 83, 83, 16, 16, 16, 289, 16, 291, 84,
910 16, 16, 84, 84, 17, 84, 0, 1, 17, 207,
911 -1, 84, -1, -1, -1, 308, -1, -1, -1, -1,
912 293, 294, 295, 296, 18, 19, -1, -1, 22, 23,
913 24, 25, 26, 27, 28, 29, 30, -1, -1, -1,
914 -1, -1, -1, 292, 38, 39, 40, 41, 42, 43,
915 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
916 54, 55, -1, 57, 58, 59, 60, 61, -1, -1,
917 -1, 65, 66, 67, 68, 69, 70, 71, 72, -1,
918 -1, -1, -1, -1, -1, -1, 80, 81
921 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
922 symbol of state STATE-NUM. */
923 static const yytype_uint8 yystos[] =
925 0, 86, 0, 1, 18, 19, 22, 23, 24, 25,
926 26, 27, 28, 29, 30, 38, 39, 40, 41, 42,
927 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
928 53, 54, 55, 57, 58, 59, 60, 61, 65, 66,
929 67, 68, 69, 70, 71, 72, 80, 81, 87, 88,
930 16, 15, 15, 16, 15, 16, 15, 15, 15, 15,
931 15, 15, 15, 15, 15, 15, 16, 15, 15, 16,
932 15, 16, 15, 16, 15, 15, 16, 15, 16, 16,
933 15, 15, 16, 16, 15, 16, 15, 15, 15, 15,
934 16, 15, 15, 15, 15, 16, 15, 15, 15, 16,
935 15, 83, 89, 83, 90, 102, 84, 92, 101, 102,
936 3, 6, 8, 9, 94, 7, 11, 12, 95, 4,
937 5, 13, 96, 83, 97, 98, 97, 97, 84, 84,
938 91, 97, 97, 102, 97, 97, 101, 97, 101, 83,
939 101, 49, 62, 63, 64, 73, 74, 75, 76, 77,
940 78, 79, 97, 102, 83, 102, 102, 97, 97, 101,
941 101, 97, 102, 97, 97, 83, 83, 101, 83, 83,
942 83, 84, 102, 83, 83, 83, 102, 83, 16, 16,
943 17, 16, 15, 15, 15, 91, 16, 16, 16, 16,
944 16, 16, 15, 16, 16, 16, 16, 16, 16, 16,
945 16, 15, 16, 15, 16, 15, 16, 15, 15, 16,
946 16, 15, 15, 16, 15, 16, 16, 16, 16, 16,
947 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
948 16, 16, 16, 102, 102, 84, 102, 5, 10, 14,
949 93, 93, 91, 102, 102, 102, 101, 101, 101, 12,
950 102, 102, 100, 101, 100, 100, 101, 101, 101, 83,
951 102, 84, 99, 101, 84, 102, 99, 83, 101, 101,
952 83, 83, 101, 83, 102, 101, 102, 101, 100, 101,
953 101, 101, 102, 101, 102, 102, 102, 17, 15, 16,
954 16, 16, 15, 16, 16, 16, 16, 84, 84, 102,
955 100, 102, 97, 101, 101, 101, 101, 17, 16, 16,
956 84, 102, 100, 17, 84, 17, 84
959 #define yyerrok (yyerrstatus = 0)
960 #define yyclearin (yychar = YYEMPTY)
961 #define YYEMPTY (-2)
962 #define YYEOF 0
964 #define YYACCEPT goto yyacceptlab
965 #define YYABORT goto yyabortlab
966 #define YYERROR goto yyerrorlab
969 /* Like YYERROR except do call yyerror. This remains here temporarily
970 to ease the transition to the new meaning of YYERROR, for GCC.
971 Once GCC version 2 has supplanted version 1, this can go. */
973 #define YYFAIL goto yyerrlab
975 #define YYRECOVERING() (!!yyerrstatus)
977 #define YYBACKUP(Token, Value) \
978 do \
979 if (yychar == YYEMPTY && yylen == 1) \
981 yychar = (Token); \
982 yylval = (Value); \
983 yytoken = YYTRANSLATE (yychar); \
984 YYPOPSTACK (1); \
985 goto yybackup; \
987 else \
989 yyerror (YY_("syntax error: cannot back up")); \
990 YYERROR; \
992 while (YYID (0))
995 #define YYTERROR 1
996 #define YYERRCODE 256
999 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1000 If N is 0, then set CURRENT to the empty location which ends
1001 the previous symbol: RHS[0] (always defined). */
1003 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1004 #ifndef YYLLOC_DEFAULT
1005 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1006 do \
1007 if (YYID (N)) \
1009 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1010 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1011 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1012 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1014 else \
1016 (Current).first_line = (Current).last_line = \
1017 YYRHSLOC (Rhs, 0).last_line; \
1018 (Current).first_column = (Current).last_column = \
1019 YYRHSLOC (Rhs, 0).last_column; \
1021 while (YYID (0))
1022 #endif
1025 /* YY_LOCATION_PRINT -- Print the location on the stream.
1026 This macro was not mandated originally: define only if we know
1027 we won't break user code: when these are the locations we know. */
1029 #ifndef YY_LOCATION_PRINT
1030 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1031 # define YY_LOCATION_PRINT(File, Loc) \
1032 fprintf (File, "%d.%d-%d.%d", \
1033 (Loc).first_line, (Loc).first_column, \
1034 (Loc).last_line, (Loc).last_column)
1035 # else
1036 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1037 # endif
1038 #endif
1041 /* YYLEX -- calling `yylex' with the right arguments. */
1043 #ifdef YYLEX_PARAM
1044 # define YYLEX yylex (YYLEX_PARAM)
1045 #else
1046 # define YYLEX yylex ()
1047 #endif
1049 /* Enable debugging if requested. */
1050 #if YYDEBUG
1052 # ifndef YYFPRINTF
1053 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1054 # define YYFPRINTF fprintf
1055 # endif
1057 # define YYDPRINTF(Args) \
1058 do { \
1059 if (yydebug) \
1060 YYFPRINTF Args; \
1061 } while (YYID (0))
1063 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1064 do { \
1065 if (yydebug) \
1067 YYFPRINTF (stderr, "%s ", Title); \
1068 yy_symbol_print (stderr, \
1069 Type, Value); \
1070 YYFPRINTF (stderr, "\n"); \
1072 } while (YYID (0))
1075 /*--------------------------------.
1076 | Print this symbol on YYOUTPUT. |
1077 `--------------------------------*/
1079 /*ARGSUSED*/
1080 #if (defined __STDC__ || defined __C99__FUNC__ \
1081 || defined __cplusplus || defined _MSC_VER)
1082 static void
1083 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1084 #else
1085 static void
1086 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1087 FILE *yyoutput;
1088 int yytype;
1089 YYSTYPE const * const yyvaluep;
1090 #endif
1092 if (!yyvaluep)
1093 return;
1094 # ifdef YYPRINT
1095 if (yytype < YYNTOKENS)
1096 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1097 # else
1098 YYUSE (yyoutput);
1099 # endif
1100 switch (yytype)
1102 default:
1103 break;
1108 /*--------------------------------.
1109 | Print this symbol on YYOUTPUT. |
1110 `--------------------------------*/
1112 #if (defined __STDC__ || defined __C99__FUNC__ \
1113 || defined __cplusplus || defined _MSC_VER)
1114 static void
1115 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1116 #else
1117 static void
1118 yy_symbol_print (yyoutput, yytype, yyvaluep)
1119 FILE *yyoutput;
1120 int yytype;
1121 YYSTYPE const * const yyvaluep;
1122 #endif
1124 if (yytype < YYNTOKENS)
1125 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1126 else
1127 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1129 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1130 YYFPRINTF (yyoutput, ")");
1133 /*------------------------------------------------------------------.
1134 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1135 | TOP (included). |
1136 `------------------------------------------------------------------*/
1138 #if (defined __STDC__ || defined __C99__FUNC__ \
1139 || defined __cplusplus || defined _MSC_VER)
1140 static void
1141 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1142 #else
1143 static void
1144 yy_stack_print (bottom, top)
1145 yytype_int16 *bottom;
1146 yytype_int16 *top;
1147 #endif
1149 YYFPRINTF (stderr, "Stack now");
1150 for (; bottom <= top; ++bottom)
1151 YYFPRINTF (stderr, " %d", *bottom);
1152 YYFPRINTF (stderr, "\n");
1155 # define YY_STACK_PRINT(Bottom, Top) \
1156 do { \
1157 if (yydebug) \
1158 yy_stack_print ((Bottom), (Top)); \
1159 } while (YYID (0))
1162 /*------------------------------------------------.
1163 | Report that the YYRULE is going to be reduced. |
1164 `------------------------------------------------*/
1166 #if (defined __STDC__ || defined __C99__FUNC__ \
1167 || defined __cplusplus || defined _MSC_VER)
1168 static void
1169 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1170 #else
1171 static void
1172 yy_reduce_print (yyvsp, yyrule)
1173 YYSTYPE *yyvsp;
1174 int yyrule;
1175 #endif
1177 int yynrhs = yyr2[yyrule];
1178 int yyi;
1179 unsigned long int yylno = yyrline[yyrule];
1180 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1181 yyrule - 1, yylno);
1182 /* The symbols being reduced. */
1183 for (yyi = 0; yyi < yynrhs; yyi++)
1185 fprintf (stderr, " $%d = ", yyi + 1);
1186 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1187 &(yyvsp[(yyi + 1) - (yynrhs)])
1189 fprintf (stderr, "\n");
1193 # define YY_REDUCE_PRINT(Rule) \
1194 do { \
1195 if (yydebug) \
1196 yy_reduce_print (yyvsp, Rule); \
1197 } while (YYID (0))
1199 /* Nonzero means print parse trace. It is left uninitialized so that
1200 multiple parsers can coexist. */
1201 int yydebug;
1202 #else /* !YYDEBUG */
1203 # define YYDPRINTF(Args)
1204 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1205 # define YY_STACK_PRINT(Bottom, Top)
1206 # define YY_REDUCE_PRINT(Rule)
1207 #endif /* !YYDEBUG */
1210 /* YYINITDEPTH -- initial size of the parser's stacks. */
1211 #ifndef YYINITDEPTH
1212 # define YYINITDEPTH 200
1213 #endif
1215 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1216 if the built-in stack extension method is used).
1218 Do not make this value too large; the results are undefined if
1219 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1220 evaluated with infinite-precision integer arithmetic. */
1222 #ifndef YYMAXDEPTH
1223 # define YYMAXDEPTH 10000
1224 #endif
1228 #if YYERROR_VERBOSE
1230 # ifndef yystrlen
1231 # if defined __GLIBC__ && defined _STRING_H
1232 # define yystrlen strlen
1233 # else
1234 /* Return the length of YYSTR. */
1235 #if (defined __STDC__ || defined __C99__FUNC__ \
1236 || defined __cplusplus || defined _MSC_VER)
1237 static YYSIZE_T
1238 yystrlen (const char *yystr)
1239 #else
1240 static YYSIZE_T
1241 yystrlen (yystr)
1242 const char *yystr;
1243 #endif
1245 YYSIZE_T yylen;
1246 for (yylen = 0; yystr[yylen]; yylen++)
1247 continue;
1248 return yylen;
1250 # endif
1251 # endif
1253 # ifndef yystpcpy
1254 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1255 # define yystpcpy stpcpy
1256 # else
1257 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1258 YYDEST. */
1259 #if (defined __STDC__ || defined __C99__FUNC__ \
1260 || defined __cplusplus || defined _MSC_VER)
1261 static char *
1262 yystpcpy (char *yydest, const char *yysrc)
1263 #else
1264 static char *
1265 yystpcpy (yydest, yysrc)
1266 char *yydest;
1267 const char *yysrc;
1268 #endif
1270 char *yyd = yydest;
1271 const char *yys = yysrc;
1273 while ((*yyd++ = *yys++) != '\0')
1274 continue;
1276 return yyd - 1;
1278 # endif
1279 # endif
1281 # ifndef yytnamerr
1282 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1283 quotes and backslashes, so that it's suitable for yyerror. The
1284 heuristic is that double-quoting is unnecessary unless the string
1285 contains an apostrophe, a comma, or backslash (other than
1286 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1287 null, do not copy; instead, return the length of what the result
1288 would have been. */
1289 static YYSIZE_T
1290 yytnamerr (char *yyres, const char *yystr)
1292 if (*yystr == '"')
1294 YYSIZE_T yyn = 0;
1295 char const *yyp = yystr;
1297 for (;;)
1298 switch (*++yyp)
1300 case '\'':
1301 case ',':
1302 goto do_not_strip_quotes;
1304 case '\\':
1305 if (*++yyp != '\\')
1306 goto do_not_strip_quotes;
1307 /* Fall through. */
1308 default:
1309 if (yyres)
1310 yyres[yyn] = *yyp;
1311 yyn++;
1312 break;
1314 case '"':
1315 if (yyres)
1316 yyres[yyn] = '\0';
1317 return yyn;
1319 do_not_strip_quotes: ;
1322 if (! yyres)
1323 return yystrlen (yystr);
1325 return yystpcpy (yyres, yystr) - yyres;
1327 # endif
1329 /* Copy into YYRESULT an error message about the unexpected token
1330 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1331 including the terminating null byte. If YYRESULT is null, do not
1332 copy anything; just return the number of bytes that would be
1333 copied. As a special case, return 0 if an ordinary "syntax error"
1334 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1335 size calculation. */
1336 static YYSIZE_T
1337 yysyntax_error (char *yyresult, int yystate, int yychar)
1339 int yyn = yypact[yystate];
1341 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1342 return 0;
1343 else
1345 int yytype = YYTRANSLATE (yychar);
1346 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1347 YYSIZE_T yysize = yysize0;
1348 YYSIZE_T yysize1;
1349 int yysize_overflow = 0;
1350 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1351 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1352 int yyx;
1354 # if 0
1355 /* This is so xgettext sees the translatable formats that are
1356 constructed on the fly. */
1357 YY_("syntax error, unexpected %s");
1358 YY_("syntax error, unexpected %s, expecting %s");
1359 YY_("syntax error, unexpected %s, expecting %s or %s");
1360 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1361 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1362 # endif
1363 char *yyfmt;
1364 char const *yyf;
1365 static char const yyunexpected[] = "syntax error, unexpected %s";
1366 static char const yyexpecting[] = ", expecting %s";
1367 static char const yyor[] = " or %s";
1368 char yyformat[sizeof yyunexpected
1369 + sizeof yyexpecting - 1
1370 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1371 * (sizeof yyor - 1))];
1372 char const *yyprefix = yyexpecting;
1374 /* Start YYX at -YYN if negative to avoid negative indexes in
1375 YYCHECK. */
1376 int yyxbegin = yyn < 0 ? -yyn : 0;
1378 /* Stay within bounds of both yycheck and yytname. */
1379 int yychecklim = YYLAST - yyn + 1;
1380 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1381 int yycount = 1;
1383 yyarg[0] = yytname[yytype];
1384 yyfmt = yystpcpy (yyformat, yyunexpected);
1386 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1387 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1389 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1391 yycount = 1;
1392 yysize = yysize0;
1393 yyformat[sizeof yyunexpected - 1] = '\0';
1394 break;
1396 yyarg[yycount++] = yytname[yyx];
1397 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1398 yysize_overflow |= (yysize1 < yysize);
1399 yysize = yysize1;
1400 yyfmt = yystpcpy (yyfmt, yyprefix);
1401 yyprefix = yyor;
1404 yyf = YY_(yyformat);
1405 yysize1 = yysize + yystrlen (yyf);
1406 yysize_overflow |= (yysize1 < yysize);
1407 yysize = yysize1;
1409 if (yysize_overflow)
1410 return YYSIZE_MAXIMUM;
1412 if (yyresult)
1414 /* Avoid sprintf, as that infringes on the user's name space.
1415 Don't have undefined behavior even if the translation
1416 produced a string with the wrong number of "%s"s. */
1417 char *yyp = yyresult;
1418 int yyi = 0;
1419 while ((*yyp = *yyf) != '\0')
1421 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1423 yyp += yytnamerr (yyp, yyarg[yyi++]);
1424 yyf += 2;
1426 else
1428 yyp++;
1429 yyf++;
1433 return yysize;
1436 #endif /* YYERROR_VERBOSE */
1439 /*-----------------------------------------------.
1440 | Release the memory associated to this symbol. |
1441 `-----------------------------------------------*/
1443 /*ARGSUSED*/
1444 #if (defined __STDC__ || defined __C99__FUNC__ \
1445 || defined __cplusplus || defined _MSC_VER)
1446 static void
1447 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1448 #else
1449 static void
1450 yydestruct (yymsg, yytype, yyvaluep)
1451 const char *yymsg;
1452 int yytype;
1453 YYSTYPE *yyvaluep;
1454 #endif
1456 YYUSE (yyvaluep);
1458 if (!yymsg)
1459 yymsg = "Deleting";
1460 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1462 switch (yytype)
1465 default:
1466 break;
1471 /* Prevent warnings from -Wmissing-prototypes. */
1473 #ifdef YYPARSE_PARAM
1474 #if defined __STDC__ || defined __cplusplus
1475 int yyparse (void *YYPARSE_PARAM);
1476 #else
1477 int yyparse ();
1478 #endif
1479 #else /* ! YYPARSE_PARAM */
1480 #if defined __STDC__ || defined __cplusplus
1481 int yyparse (void);
1482 #else
1483 int yyparse ();
1484 #endif
1485 #endif /* ! YYPARSE_PARAM */
1489 /* The look-ahead symbol. */
1490 int yychar;
1492 /* The semantic value of the look-ahead symbol. */
1493 YYSTYPE yylval;
1495 /* Number of syntax errors so far. */
1496 int yynerrs;
1500 /*----------.
1501 | yyparse. |
1502 `----------*/
1504 #ifdef YYPARSE_PARAM
1505 #if (defined __STDC__ || defined __C99__FUNC__ \
1506 || defined __cplusplus || defined _MSC_VER)
1508 yyparse (void *YYPARSE_PARAM)
1509 #else
1511 yyparse (YYPARSE_PARAM)
1512 void *YYPARSE_PARAM;
1513 #endif
1514 #else /* ! YYPARSE_PARAM */
1515 #if (defined __STDC__ || defined __C99__FUNC__ \
1516 || defined __cplusplus || defined _MSC_VER)
1518 yyparse (void)
1519 #else
1521 yyparse ()
1523 #endif
1524 #endif
1527 int yystate;
1528 int yyn;
1529 int yyresult;
1530 /* Number of tokens to shift before error messages enabled. */
1531 int yyerrstatus;
1532 /* Look-ahead token as an internal (translated) token number. */
1533 int yytoken = 0;
1534 #if YYERROR_VERBOSE
1535 /* Buffer for error messages, and its allocated size. */
1536 char yymsgbuf[128];
1537 char *yymsg = yymsgbuf;
1538 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1539 #endif
1541 /* Three stacks and their tools:
1542 `yyss': related to states,
1543 `yyvs': related to semantic values,
1544 `yyls': related to locations.
1546 Refer to the stacks thru separate pointers, to allow yyoverflow
1547 to reallocate them elsewhere. */
1549 /* The state stack. */
1550 yytype_int16 yyssa[YYINITDEPTH];
1551 yytype_int16 *yyss = yyssa;
1552 yytype_int16 *yyssp;
1554 /* The semantic value stack. */
1555 YYSTYPE yyvsa[YYINITDEPTH];
1556 YYSTYPE *yyvs = yyvsa;
1557 YYSTYPE *yyvsp;
1561 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1563 YYSIZE_T yystacksize = YYINITDEPTH;
1565 /* The variables used to return semantic value and location from the
1566 action routines. */
1567 YYSTYPE yyval;
1570 /* The number of symbols on the RHS of the reduced rule.
1571 Keep to zero when no symbol should be popped. */
1572 int yylen = 0;
1574 YYDPRINTF ((stderr, "Starting parse\n"));
1576 yystate = 0;
1577 yyerrstatus = 0;
1578 yynerrs = 0;
1579 yychar = YYEMPTY; /* Cause a token to be read. */
1581 /* Initialize stack pointers.
1582 Waste one element of value and location stack
1583 so that they stay on the same level as the state stack.
1584 The wasted elements are never initialized. */
1586 yyssp = yyss;
1587 yyvsp = yyvs;
1589 goto yysetstate;
1591 /*------------------------------------------------------------.
1592 | yynewstate -- Push a new state, which is found in yystate. |
1593 `------------------------------------------------------------*/
1594 yynewstate:
1595 /* In all cases, when you get here, the value and location stacks
1596 have just been pushed. So pushing a state here evens the stacks. */
1597 yyssp++;
1599 yysetstate:
1600 *yyssp = yystate;
1602 if (yyss + yystacksize - 1 <= yyssp)
1604 /* Get the current used size of the three stacks, in elements. */
1605 YYSIZE_T yysize = yyssp - yyss + 1;
1607 #ifdef yyoverflow
1609 /* Give user a chance to reallocate the stack. Use copies of
1610 these so that the &'s don't force the real ones into
1611 memory. */
1612 YYSTYPE *yyvs1 = yyvs;
1613 yytype_int16 *yyss1 = yyss;
1616 /* Each stack pointer address is followed by the size of the
1617 data in use in that stack, in bytes. This used to be a
1618 conditional around just the two extra args, but that might
1619 be undefined if yyoverflow is a macro. */
1620 yyoverflow (YY_("memory exhausted"),
1621 &yyss1, yysize * sizeof (*yyssp),
1622 &yyvs1, yysize * sizeof (*yyvsp),
1624 &yystacksize);
1626 yyss = yyss1;
1627 yyvs = yyvs1;
1629 #else /* no yyoverflow */
1630 # ifndef YYSTACK_RELOCATE
1631 goto yyexhaustedlab;
1632 # else
1633 /* Extend the stack our own way. */
1634 if (YYMAXDEPTH <= yystacksize)
1635 goto yyexhaustedlab;
1636 yystacksize *= 2;
1637 if (YYMAXDEPTH < yystacksize)
1638 yystacksize = YYMAXDEPTH;
1641 yytype_int16 *yyss1 = yyss;
1642 union yyalloc *yyptr =
1643 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1644 if (! yyptr)
1645 goto yyexhaustedlab;
1646 YYSTACK_RELOCATE (yyss);
1647 YYSTACK_RELOCATE (yyvs);
1649 # undef YYSTACK_RELOCATE
1650 if (yyss1 != yyssa)
1651 YYSTACK_FREE (yyss1);
1653 # endif
1654 #endif /* no yyoverflow */
1656 yyssp = yyss + yysize - 1;
1657 yyvsp = yyvs + yysize - 1;
1660 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1661 (unsigned long int) yystacksize));
1663 if (yyss + yystacksize - 1 <= yyssp)
1664 YYABORT;
1667 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1669 goto yybackup;
1671 /*-----------.
1672 | yybackup. |
1673 `-----------*/
1674 yybackup:
1676 /* Do appropriate processing given the current state. Read a
1677 look-ahead token if we need one and don't already have one. */
1679 /* First try to decide what to do without reference to look-ahead token. */
1680 yyn = yypact[yystate];
1681 if (yyn == YYPACT_NINF)
1682 goto yydefault;
1684 /* Not known => get a look-ahead token if don't already have one. */
1686 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1687 if (yychar == YYEMPTY)
1689 YYDPRINTF ((stderr, "Reading a token: "));
1690 yychar = YYLEX;
1693 if (yychar <= YYEOF)
1695 yychar = yytoken = YYEOF;
1696 YYDPRINTF ((stderr, "Now at end of input.\n"));
1698 else
1700 yytoken = YYTRANSLATE (yychar);
1701 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1704 /* If the proper action on seeing token YYTOKEN is to reduce or to
1705 detect an error, take that action. */
1706 yyn += yytoken;
1707 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1708 goto yydefault;
1709 yyn = yytable[yyn];
1710 if (yyn <= 0)
1712 if (yyn == 0 || yyn == YYTABLE_NINF)
1713 goto yyerrlab;
1714 yyn = -yyn;
1715 goto yyreduce;
1718 if (yyn == YYFINAL)
1719 YYACCEPT;
1721 /* Count tokens shifted since error; after three, turn off error
1722 status. */
1723 if (yyerrstatus)
1724 yyerrstatus--;
1726 /* Shift the look-ahead token. */
1727 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1729 /* Discard the shifted token unless it is eof. */
1730 if (yychar != YYEOF)
1731 yychar = YYEMPTY;
1733 yystate = yyn;
1734 *++yyvsp = yylval;
1736 goto yynewstate;
1739 /*-----------------------------------------------------------.
1740 | yydefault -- do the default action for the current state. |
1741 `-----------------------------------------------------------*/
1742 yydefault:
1743 yyn = yydefact[yystate];
1744 if (yyn == 0)
1745 goto yyerrlab;
1746 goto yyreduce;
1749 /*-----------------------------.
1750 | yyreduce -- Do a reduction. |
1751 `-----------------------------*/
1752 yyreduce:
1753 /* yyn is the number of a rule to reduce with. */
1754 yylen = yyr2[yyn];
1756 /* If YYLEN is nonzero, implement the default value of the action:
1757 `$$ = $1'.
1759 Otherwise, the following line sets YYVAL to garbage.
1760 This behavior is undocumented and Bison
1761 users should not rely upon it. Assigning to YYVAL
1762 unconditionally makes the parser a bit smaller, and it avoids a
1763 GCC warning that YYVAL may be used uninitialized. */
1764 yyval = yyvsp[1-yylen];
1767 YY_REDUCE_PRINT (yyn);
1768 switch (yyn)
1770 case 3:
1771 #line 132 "ftpcmd.y"
1773 fromname = (char *) 0;
1774 restart_point = (off_t) 0;
1776 break;
1778 case 5:
1779 #line 141 "ftpcmd.y"
1781 if ((yyvsp[(5) - (5)].i))
1782 user((yyvsp[(3) - (5)].s));
1783 free((yyvsp[(3) - (5)].s));
1785 break;
1787 case 6:
1788 #line 147 "ftpcmd.y"
1790 if ((yyvsp[(5) - (5)].i))
1791 pass((yyvsp[(3) - (5)].s));
1792 memset ((yyvsp[(3) - (5)].s), 0, strlen((yyvsp[(3) - (5)].s)));
1793 free((yyvsp[(3) - (5)].s));
1795 break;
1797 case 7:
1798 #line 154 "ftpcmd.y"
1800 if ((yyvsp[(5) - (5)].i)) {
1801 usedefault = 0;
1802 if (pdata >= 0) {
1803 close(pdata);
1804 pdata = -1;
1806 reply(200, "PORT command successful.");
1809 break;
1811 case 8:
1812 #line 165 "ftpcmd.y"
1814 if ((yyvsp[(5) - (5)].i))
1815 eprt ((yyvsp[(3) - (5)].s));
1816 free ((yyvsp[(3) - (5)].s));
1818 break;
1820 case 9:
1821 #line 171 "ftpcmd.y"
1823 if((yyvsp[(3) - (3)].i))
1824 pasv ();
1826 break;
1828 case 10:
1829 #line 176 "ftpcmd.y"
1831 if((yyvsp[(3) - (3)].i))
1832 epsv (NULL);
1834 break;
1836 case 11:
1837 #line 181 "ftpcmd.y"
1839 if((yyvsp[(5) - (5)].i))
1840 epsv ((yyvsp[(3) - (5)].s));
1841 free ((yyvsp[(3) - (5)].s));
1843 break;
1845 case 12:
1846 #line 187 "ftpcmd.y"
1848 if ((yyvsp[(5) - (5)].i)) {
1849 switch (cmd_type) {
1851 case TYPE_A:
1852 if (cmd_form == FORM_N) {
1853 reply(200, "Type set to A.");
1854 type = cmd_type;
1855 form = cmd_form;
1856 } else
1857 reply(504, "Form must be N.");
1858 break;
1860 case TYPE_E:
1861 reply(504, "Type E not implemented.");
1862 break;
1864 case TYPE_I:
1865 reply(200, "Type set to I.");
1866 type = cmd_type;
1867 break;
1869 case TYPE_L:
1870 #if NBBY == 8
1871 if (cmd_bytesz == 8) {
1872 reply(200,
1873 "Type set to L (byte size 8).");
1874 type = cmd_type;
1875 } else
1876 reply(504, "Byte size must be 8.");
1877 #else /* NBBY == 8 */
1878 UNIMPLEMENTED for NBBY != 8
1879 #endif /* NBBY == 8 */
1883 break;
1885 case 13:
1886 #line 224 "ftpcmd.y"
1888 if ((yyvsp[(5) - (5)].i)) {
1889 switch ((yyvsp[(3) - (5)].i)) {
1891 case STRU_F:
1892 reply(200, "STRU F ok.");
1893 break;
1895 default:
1896 reply(504, "Unimplemented STRU type.");
1900 break;
1902 case 14:
1903 #line 238 "ftpcmd.y"
1905 if ((yyvsp[(5) - (5)].i)) {
1906 switch ((yyvsp[(3) - (5)].i)) {
1908 case MODE_S:
1909 reply(200, "MODE S ok.");
1910 break;
1912 default:
1913 reply(502, "Unimplemented MODE type.");
1917 break;
1919 case 15:
1920 #line 252 "ftpcmd.y"
1922 if ((yyvsp[(5) - (5)].i)) {
1923 reply(202, "ALLO command ignored.");
1926 break;
1928 case 16:
1929 #line 258 "ftpcmd.y"
1931 if ((yyvsp[(9) - (9)].i)) {
1932 reply(202, "ALLO command ignored.");
1935 break;
1937 case 17:
1938 #line 264 "ftpcmd.y"
1940 char *name = (yyvsp[(3) - (5)].s);
1942 if ((yyvsp[(5) - (5)].i) && name != NULL)
1943 retrieve(0, name);
1944 if (name != NULL)
1945 free(name);
1947 break;
1949 case 18:
1950 #line 273 "ftpcmd.y"
1952 char *name = (yyvsp[(3) - (5)].s);
1954 if ((yyvsp[(5) - (5)].i) && name != NULL)
1955 do_store(name, "w", 0);
1956 if (name != NULL)
1957 free(name);
1959 break;
1961 case 19:
1962 #line 282 "ftpcmd.y"
1964 char *name = (yyvsp[(3) - (5)].s);
1966 if ((yyvsp[(5) - (5)].i) && name != NULL)
1967 do_store(name, "a", 0);
1968 if (name != NULL)
1969 free(name);
1971 break;
1973 case 20:
1974 #line 291 "ftpcmd.y"
1976 if ((yyvsp[(3) - (3)].i))
1977 send_file_list(".");
1979 break;
1981 case 21:
1982 #line 296 "ftpcmd.y"
1984 char *name = (yyvsp[(3) - (5)].s);
1986 if ((yyvsp[(5) - (5)].i) && name != NULL)
1987 send_file_list(name);
1988 if (name != NULL)
1989 free(name);
1991 break;
1993 case 22:
1994 #line 305 "ftpcmd.y"
1996 if((yyvsp[(3) - (3)].i))
1997 list_file(".");
1999 break;
2001 case 23:
2002 #line 310 "ftpcmd.y"
2004 if((yyvsp[(5) - (5)].i))
2005 list_file((yyvsp[(3) - (5)].s));
2006 free((yyvsp[(3) - (5)].s));
2008 break;
2010 case 24:
2011 #line 316 "ftpcmd.y"
2013 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2014 statfilecmd((yyvsp[(3) - (5)].s));
2015 if ((yyvsp[(3) - (5)].s) != NULL)
2016 free((yyvsp[(3) - (5)].s));
2018 break;
2020 case 25:
2021 #line 323 "ftpcmd.y"
2023 if ((yyvsp[(3) - (3)].i))
2024 statcmd();
2026 break;
2028 case 26:
2029 #line 328 "ftpcmd.y"
2031 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2032 do_delete((yyvsp[(3) - (5)].s));
2033 if ((yyvsp[(3) - (5)].s) != NULL)
2034 free((yyvsp[(3) - (5)].s));
2036 break;
2038 case 27:
2039 #line 335 "ftpcmd.y"
2041 if((yyvsp[(5) - (5)].i)){
2042 if (fromname) {
2043 renamecmd(fromname, (yyvsp[(3) - (5)].s));
2044 free(fromname);
2045 fromname = (char *) 0;
2046 } else {
2047 reply(503, "Bad sequence of commands.");
2050 if ((yyvsp[(3) - (5)].s) != NULL)
2051 free((yyvsp[(3) - (5)].s));
2053 break;
2055 case 28:
2056 #line 349 "ftpcmd.y"
2058 if ((yyvsp[(3) - (3)].i))
2059 reply(225, "ABOR command successful.");
2061 break;
2063 case 29:
2064 #line 354 "ftpcmd.y"
2066 if ((yyvsp[(3) - (3)].i))
2067 cwd(pw->pw_dir);
2069 break;
2071 case 30:
2072 #line 359 "ftpcmd.y"
2074 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2075 cwd((yyvsp[(3) - (5)].s));
2076 if ((yyvsp[(3) - (5)].s) != NULL)
2077 free((yyvsp[(3) - (5)].s));
2079 break;
2081 case 31:
2082 #line 366 "ftpcmd.y"
2084 if ((yyvsp[(3) - (3)].i))
2085 help(cmdtab, (char *) 0);
2087 break;
2089 case 32:
2090 #line 371 "ftpcmd.y"
2092 if ((yyvsp[(5) - (5)].i)) {
2093 char *cp = (yyvsp[(3) - (5)].s);
2095 if (strncasecmp(cp, "SITE", 4) == 0) {
2096 cp = (yyvsp[(3) - (5)].s) + 4;
2097 if (*cp == ' ')
2098 cp++;
2099 if (*cp)
2100 help(sitetab, cp);
2101 else
2102 help(sitetab, (char *) 0);
2103 } else
2104 help(cmdtab, (yyvsp[(3) - (5)].s));
2107 break;
2109 case 33:
2110 #line 388 "ftpcmd.y"
2112 if ((yyvsp[(3) - (3)].i))
2113 reply(200, "NOOP command successful.");
2115 break;
2117 case 34:
2118 #line 393 "ftpcmd.y"
2120 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2121 makedir((yyvsp[(3) - (5)].s));
2122 if ((yyvsp[(3) - (5)].s) != NULL)
2123 free((yyvsp[(3) - (5)].s));
2125 break;
2127 case 35:
2128 #line 400 "ftpcmd.y"
2130 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2131 removedir((yyvsp[(3) - (5)].s));
2132 if ((yyvsp[(3) - (5)].s) != NULL)
2133 free((yyvsp[(3) - (5)].s));
2135 break;
2137 case 36:
2138 #line 407 "ftpcmd.y"
2140 if ((yyvsp[(3) - (3)].i))
2141 pwd();
2143 break;
2145 case 37:
2146 #line 412 "ftpcmd.y"
2148 if ((yyvsp[(3) - (3)].i))
2149 cwd("..");
2151 break;
2153 case 38:
2154 #line 417 "ftpcmd.y"
2156 if ((yyvsp[(3) - (3)].i)) {
2157 lreply(211, "Supported features:");
2158 lreply(0, " MDTM");
2159 lreply(0, " REST STREAM");
2160 lreply(0, " SIZE");
2161 reply(211, "End");
2164 break;
2166 case 39:
2167 #line 427 "ftpcmd.y"
2169 if ((yyvsp[(5) - (5)].i))
2170 reply(501, "Bad options");
2171 free ((yyvsp[(3) - (5)].s));
2173 break;
2175 case 40:
2176 #line 434 "ftpcmd.y"
2178 if ((yyvsp[(5) - (5)].i))
2179 help(sitetab, (char *) 0);
2181 break;
2183 case 41:
2184 #line 439 "ftpcmd.y"
2186 if ((yyvsp[(7) - (7)].i))
2187 help(sitetab, (yyvsp[(5) - (7)].s));
2189 break;
2191 case 42:
2192 #line 444 "ftpcmd.y"
2194 if ((yyvsp[(5) - (5)].i)) {
2195 int oldmask = umask(0);
2196 umask(oldmask);
2197 reply(200, "Current UMASK is %03o", oldmask);
2200 break;
2202 case 43:
2203 #line 452 "ftpcmd.y"
2205 if ((yyvsp[(7) - (7)].i)) {
2206 if (((yyvsp[(5) - (7)].i) == -1) || ((yyvsp[(5) - (7)].i) > 0777)) {
2207 reply(501, "Bad UMASK value");
2208 } else {
2209 int oldmask = umask((yyvsp[(5) - (7)].i));
2210 reply(200,
2211 "UMASK set to %03o (was %03o)",
2212 (yyvsp[(5) - (7)].i), oldmask);
2216 break;
2218 case 44:
2219 #line 465 "ftpcmd.y"
2221 if ((yyvsp[(9) - (9)].i) && (yyvsp[(7) - (9)].s) != NULL) {
2222 if ((yyvsp[(5) - (9)].i) > 0777)
2223 reply(501,
2224 "CHMOD: Mode value must be between 0 and 0777");
2225 else if (chmod((yyvsp[(7) - (9)].s), (yyvsp[(5) - (9)].i)) < 0)
2226 perror_reply(550, (yyvsp[(7) - (9)].s));
2227 else
2228 reply(200, "CHMOD command successful.");
2230 if ((yyvsp[(7) - (9)].s) != NULL)
2231 free((yyvsp[(7) - (9)].s));
2233 break;
2235 case 45:
2236 #line 479 "ftpcmd.y"
2238 if ((yyvsp[(5) - (5)].i))
2239 reply(200,
2240 "Current IDLE time limit is %d seconds; max %d",
2241 ftpd_timeout, maxtimeout);
2243 break;
2245 case 46:
2246 #line 486 "ftpcmd.y"
2248 if ((yyvsp[(7) - (7)].i)) {
2249 if ((yyvsp[(5) - (7)].i) < 30 || (yyvsp[(5) - (7)].i) > maxtimeout) {
2250 reply(501,
2251 "Maximum IDLE time must be between 30 and %d seconds",
2252 maxtimeout);
2253 } else {
2254 ftpd_timeout = (yyvsp[(5) - (7)].i);
2255 alarm((unsigned) ftpd_timeout);
2256 reply(200,
2257 "Maximum IDLE time set to %d seconds",
2258 ftpd_timeout);
2262 break;
2264 case 47:
2265 #line 503 "ftpcmd.y"
2267 #ifdef KRB4
2268 char *p;
2270 if(guest)
2271 reply(500, "Can't be done as guest.");
2272 else{
2273 if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s) != NULL){
2274 p = strpbrk((yyvsp[(5) - (7)].s), " \t");
2275 if(p){
2276 *p++ = 0;
2277 kauth((yyvsp[(5) - (7)].s), p + strspn(p, " \t"));
2278 }else
2279 kauth((yyvsp[(5) - (7)].s), NULL);
2282 if((yyvsp[(5) - (7)].s) != NULL)
2283 free((yyvsp[(5) - (7)].s));
2284 #else
2285 reply(500, "Command not implemented.");
2286 #endif
2288 break;
2290 case 48:
2291 #line 526 "ftpcmd.y"
2293 if((yyvsp[(5) - (5)].i))
2294 klist();
2296 break;
2298 case 49:
2299 #line 531 "ftpcmd.y"
2301 #ifdef KRB4
2302 if((yyvsp[(5) - (5)].i))
2303 kdestroy();
2304 #else
2305 reply(500, "Command not implemented.");
2306 #endif
2308 break;
2310 case 50:
2311 #line 540 "ftpcmd.y"
2313 #ifdef KRB4
2314 if(guest)
2315 reply(500, "Can't be done as guest.");
2316 else if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s))
2317 krbtkfile((yyvsp[(5) - (7)].s));
2318 if((yyvsp[(5) - (7)].s))
2319 free((yyvsp[(5) - (7)].s));
2320 #else
2321 reply(500, "Command not implemented.");
2322 #endif
2324 break;
2326 case 51:
2327 #line 553 "ftpcmd.y"
2329 #if defined(KRB4) || defined(KRB5)
2330 if(guest)
2331 reply(500, "Can't be done as guest.");
2332 else if((yyvsp[(5) - (5)].i))
2333 afslog(NULL, 0);
2334 #else
2335 reply(500, "Command not implemented.");
2336 #endif
2338 break;
2340 case 52:
2341 #line 564 "ftpcmd.y"
2343 #if defined(KRB4) || defined(KRB5)
2344 if(guest)
2345 reply(500, "Can't be done as guest.");
2346 else if((yyvsp[(7) - (7)].i))
2347 afslog((yyvsp[(5) - (7)].s), 0);
2348 if((yyvsp[(5) - (7)].s))
2349 free((yyvsp[(5) - (7)].s));
2350 #else
2351 reply(500, "Command not implemented.");
2352 #endif
2354 break;
2356 case 53:
2357 #line 577 "ftpcmd.y"
2359 if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s) != NULL)
2360 find((yyvsp[(5) - (7)].s));
2361 if((yyvsp[(5) - (7)].s) != NULL)
2362 free((yyvsp[(5) - (7)].s));
2364 break;
2366 case 54:
2367 #line 584 "ftpcmd.y"
2369 if ((yyvsp[(5) - (5)].i))
2370 reply(200, "http://www.pdc.kth.se/heimdal/");
2372 break;
2374 case 55:
2375 #line 589 "ftpcmd.y"
2377 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2378 do_store((yyvsp[(3) - (5)].s), "w", 1);
2379 if ((yyvsp[(3) - (5)].s) != NULL)
2380 free((yyvsp[(3) - (5)].s));
2382 break;
2384 case 56:
2385 #line 596 "ftpcmd.y"
2387 if ((yyvsp[(3) - (3)].i)) {
2388 #if !defined(WIN32) && !defined(__EMX__) && !defined(__OS2__) && !defined(__CYGWIN32__)
2389 reply(215, "UNIX Type: L%d", NBBY);
2390 #else
2391 reply(215, "UNKNOWN Type: L%d", NBBY);
2392 #endif
2395 break;
2397 case 57:
2398 #line 614 "ftpcmd.y"
2400 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2401 sizecmd((yyvsp[(3) - (5)].s));
2402 if ((yyvsp[(3) - (5)].s) != NULL)
2403 free((yyvsp[(3) - (5)].s));
2405 break;
2407 case 58:
2408 #line 631 "ftpcmd.y"
2410 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL) {
2411 struct stat stbuf;
2412 if (stat((yyvsp[(3) - (5)].s), &stbuf) < 0)
2413 reply(550, "%s: %s",
2414 (yyvsp[(3) - (5)].s), strerror(errno));
2415 else if (!S_ISREG(stbuf.st_mode)) {
2416 reply(550,
2417 "%s: not a plain file.", (yyvsp[(3) - (5)].s));
2418 } else {
2419 struct tm *t;
2420 time_t mtime = stbuf.st_mtime;
2422 t = gmtime(&mtime);
2423 reply(213,
2424 "%04d%02d%02d%02d%02d%02d",
2425 t->tm_year + 1900,
2426 t->tm_mon + 1,
2427 t->tm_mday,
2428 t->tm_hour,
2429 t->tm_min,
2430 t->tm_sec);
2433 if ((yyvsp[(3) - (5)].s) != NULL)
2434 free((yyvsp[(3) - (5)].s));
2436 break;
2438 case 59:
2439 #line 659 "ftpcmd.y"
2441 if ((yyvsp[(3) - (3)].i)) {
2442 reply(221, "Goodbye.");
2443 dologout(0);
2446 break;
2448 case 60:
2449 #line 666 "ftpcmd.y"
2451 yyerrok;
2453 break;
2455 case 61:
2456 #line 672 "ftpcmd.y"
2458 restart_point = (off_t) 0;
2459 if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s)) {
2460 fromname = renamefrom((yyvsp[(3) - (5)].s));
2461 if (fromname == (char *) 0 && (yyvsp[(3) - (5)].s)) {
2462 free((yyvsp[(3) - (5)].s));
2466 break;
2468 case 62:
2469 #line 682 "ftpcmd.y"
2471 if ((yyvsp[(5) - (5)].i)) {
2472 fromname = (char *) 0;
2473 restart_point = (yyvsp[(3) - (5)].i); /* XXX $3 is only "int" */
2474 reply(350, "Restarting at %ld. %s",
2475 (long)restart_point,
2476 "Send STORE or RETRIEVE to initiate transfer.");
2479 break;
2481 case 63:
2482 #line 692 "ftpcmd.y"
2484 auth((yyvsp[(3) - (4)].s));
2485 free((yyvsp[(3) - (4)].s));
2487 break;
2489 case 64:
2490 #line 697 "ftpcmd.y"
2492 adat((yyvsp[(3) - (4)].s));
2493 free((yyvsp[(3) - (4)].s));
2495 break;
2497 case 65:
2498 #line 702 "ftpcmd.y"
2500 if ((yyvsp[(5) - (5)].i))
2501 pbsz((yyvsp[(3) - (5)].i));
2503 break;
2505 case 66:
2506 #line 707 "ftpcmd.y"
2508 if ((yyvsp[(5) - (5)].i))
2509 prot((yyvsp[(3) - (5)].s));
2511 break;
2513 case 67:
2514 #line 712 "ftpcmd.y"
2516 if ((yyvsp[(3) - (3)].i))
2517 ccc();
2519 break;
2521 case 68:
2522 #line 717 "ftpcmd.y"
2524 mec((yyvsp[(3) - (4)].s), prot_safe);
2525 free((yyvsp[(3) - (4)].s));
2527 break;
2529 case 69:
2530 #line 722 "ftpcmd.y"
2532 mec((yyvsp[(3) - (4)].s), prot_confidential);
2533 free((yyvsp[(3) - (4)].s));
2535 break;
2537 case 70:
2538 #line 727 "ftpcmd.y"
2540 mec((yyvsp[(3) - (4)].s), prot_private);
2541 free((yyvsp[(3) - (4)].s));
2543 break;
2545 case 72:
2546 #line 739 "ftpcmd.y"
2548 (yyval.s) = (char *)calloc(1, sizeof(char));
2550 break;
2552 case 75:
2553 #line 752 "ftpcmd.y"
2555 struct sockaddr_in *sin4 = (struct sockaddr_in *)data_dest;
2557 sin4->sin_family = AF_INET;
2558 sin4->sin_port = htons((yyvsp[(9) - (11)].i) * 256 + (yyvsp[(11) - (11)].i));
2559 sin4->sin_addr.s_addr =
2560 htonl(((yyvsp[(1) - (11)].i) << 24) | ((yyvsp[(3) - (11)].i) << 16) | ((yyvsp[(5) - (11)].i) << 8) | (yyvsp[(7) - (11)].i));
2562 break;
2564 case 76:
2565 #line 764 "ftpcmd.y"
2567 (yyval.i) = FORM_N;
2569 break;
2571 case 77:
2572 #line 768 "ftpcmd.y"
2574 (yyval.i) = FORM_T;
2576 break;
2578 case 78:
2579 #line 772 "ftpcmd.y"
2581 (yyval.i) = FORM_C;
2583 break;
2585 case 79:
2586 #line 779 "ftpcmd.y"
2588 cmd_type = TYPE_A;
2589 cmd_form = FORM_N;
2591 break;
2593 case 80:
2594 #line 784 "ftpcmd.y"
2596 cmd_type = TYPE_A;
2597 cmd_form = (yyvsp[(3) - (3)].i);
2599 break;
2601 case 81:
2602 #line 789 "ftpcmd.y"
2604 cmd_type = TYPE_E;
2605 cmd_form = FORM_N;
2607 break;
2609 case 82:
2610 #line 794 "ftpcmd.y"
2612 cmd_type = TYPE_E;
2613 cmd_form = (yyvsp[(3) - (3)].i);
2615 break;
2617 case 83:
2618 #line 799 "ftpcmd.y"
2620 cmd_type = TYPE_I;
2622 break;
2624 case 84:
2625 #line 803 "ftpcmd.y"
2627 cmd_type = TYPE_L;
2628 cmd_bytesz = NBBY;
2630 break;
2632 case 85:
2633 #line 808 "ftpcmd.y"
2635 cmd_type = TYPE_L;
2636 cmd_bytesz = (yyvsp[(3) - (3)].i);
2638 break;
2640 case 86:
2641 #line 814 "ftpcmd.y"
2643 cmd_type = TYPE_L;
2644 cmd_bytesz = (yyvsp[(2) - (2)].i);
2646 break;
2648 case 87:
2649 #line 822 "ftpcmd.y"
2651 (yyval.i) = STRU_F;
2653 break;
2655 case 88:
2656 #line 826 "ftpcmd.y"
2658 (yyval.i) = STRU_R;
2660 break;
2662 case 89:
2663 #line 830 "ftpcmd.y"
2665 (yyval.i) = STRU_P;
2667 break;
2669 case 90:
2670 #line 837 "ftpcmd.y"
2672 (yyval.i) = MODE_S;
2674 break;
2676 case 91:
2677 #line 841 "ftpcmd.y"
2679 (yyval.i) = MODE_B;
2681 break;
2683 case 92:
2684 #line 845 "ftpcmd.y"
2686 (yyval.i) = MODE_C;
2688 break;
2690 case 93:
2691 #line 852 "ftpcmd.y"
2694 * Problem: this production is used for all pathname
2695 * processing, but only gives a 550 error reply.
2696 * This is a valid reply in some cases but not in others.
2698 if (logged_in && (yyvsp[(1) - (1)].s) && *(yyvsp[(1) - (1)].s) == '~') {
2699 glob_t gl;
2700 int flags =
2701 GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
2703 memset(&gl, 0, sizeof(gl));
2704 if (glob((yyvsp[(1) - (1)].s), flags, NULL, &gl) ||
2705 gl.gl_pathc == 0) {
2706 reply(550, "not found");
2707 (yyval.s) = NULL;
2708 } else {
2709 (yyval.s) = strdup(gl.gl_pathv[0]);
2711 globfree(&gl);
2712 free((yyvsp[(1) - (1)].s));
2713 } else
2714 (yyval.s) = (yyvsp[(1) - (1)].s);
2716 break;
2718 case 95:
2719 #line 884 "ftpcmd.y"
2721 int ret, dec, multby, digit;
2724 * Convert a number that was read as decimal number
2725 * to what it would be if it had been read as octal.
2727 dec = (yyvsp[(1) - (1)].i);
2728 multby = 1;
2729 ret = 0;
2730 while (dec) {
2731 digit = dec%10;
2732 if (digit > 7) {
2733 ret = -1;
2734 break;
2736 ret += digit * multby;
2737 multby *= 8;
2738 dec /= 10;
2740 (yyval.i) = ret;
2742 break;
2744 case 96:
2745 #line 910 "ftpcmd.y"
2747 (yyval.i) = (yyvsp[(1) - (1)].i) && !guest;
2748 if((yyvsp[(1) - (1)].i) && !(yyval.i))
2749 reply(550, "Permission denied");
2751 break;
2753 case 97:
2754 #line 918 "ftpcmd.y"
2756 if((yyvsp[(1) - (1)].i)) {
2757 if(((yyval.i) = logged_in) == 0)
2758 reply(530, "Please login with USER and PASS.");
2759 } else
2760 (yyval.i) = 0;
2762 break;
2764 case 98:
2765 #line 928 "ftpcmd.y"
2767 (yyval.i) = 1;
2768 if(sec_complete && !ccc_passed && !secure_command()) {
2769 (yyval.i) = 0;
2770 reply(533, "Command protection level denied "
2771 "for paranoid reasons.");
2774 break;
2777 /* Line 1267 of yacc.c. */
2778 #line 2778 "ftpcmd.c"
2779 default: break;
2781 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2783 YYPOPSTACK (yylen);
2784 yylen = 0;
2785 YY_STACK_PRINT (yyss, yyssp);
2787 *++yyvsp = yyval;
2790 /* Now `shift' the result of the reduction. Determine what state
2791 that goes to, based on the state we popped back to and the rule
2792 number reduced by. */
2794 yyn = yyr1[yyn];
2796 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2797 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2798 yystate = yytable[yystate];
2799 else
2800 yystate = yydefgoto[yyn - YYNTOKENS];
2802 goto yynewstate;
2805 /*------------------------------------.
2806 | yyerrlab -- here on detecting error |
2807 `------------------------------------*/
2808 yyerrlab:
2809 /* If not already recovering from an error, report this error. */
2810 if (!yyerrstatus)
2812 ++yynerrs;
2813 #if ! YYERROR_VERBOSE
2814 yyerror (YY_("syntax error"));
2815 #else
2817 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2818 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2820 YYSIZE_T yyalloc = 2 * yysize;
2821 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2822 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2823 if (yymsg != yymsgbuf)
2824 YYSTACK_FREE (yymsg);
2825 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2826 if (yymsg)
2827 yymsg_alloc = yyalloc;
2828 else
2830 yymsg = yymsgbuf;
2831 yymsg_alloc = sizeof yymsgbuf;
2835 if (0 < yysize && yysize <= yymsg_alloc)
2837 (void) yysyntax_error (yymsg, yystate, yychar);
2838 yyerror (yymsg);
2840 else
2842 yyerror (YY_("syntax error"));
2843 if (yysize != 0)
2844 goto yyexhaustedlab;
2847 #endif
2852 if (yyerrstatus == 3)
2854 /* If just tried and failed to reuse look-ahead token after an
2855 error, discard it. */
2857 if (yychar <= YYEOF)
2859 /* Return failure if at end of input. */
2860 if (yychar == YYEOF)
2861 YYABORT;
2863 else
2865 yydestruct ("Error: discarding",
2866 yytoken, &yylval);
2867 yychar = YYEMPTY;
2871 /* Else will try to reuse look-ahead token after shifting the error
2872 token. */
2873 goto yyerrlab1;
2876 /*---------------------------------------------------.
2877 | yyerrorlab -- error raised explicitly by YYERROR. |
2878 `---------------------------------------------------*/
2879 yyerrorlab:
2881 /* Pacify compilers like GCC when the user code never invokes
2882 YYERROR and the label yyerrorlab therefore never appears in user
2883 code. */
2884 if (/*CONSTCOND*/ 0)
2885 goto yyerrorlab;
2887 /* Do not reclaim the symbols of the rule which action triggered
2888 this YYERROR. */
2889 YYPOPSTACK (yylen);
2890 yylen = 0;
2891 YY_STACK_PRINT (yyss, yyssp);
2892 yystate = *yyssp;
2893 goto yyerrlab1;
2896 /*-------------------------------------------------------------.
2897 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2898 `-------------------------------------------------------------*/
2899 yyerrlab1:
2900 yyerrstatus = 3; /* Each real token shifted decrements this. */
2902 for (;;)
2904 yyn = yypact[yystate];
2905 if (yyn != YYPACT_NINF)
2907 yyn += YYTERROR;
2908 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2910 yyn = yytable[yyn];
2911 if (0 < yyn)
2912 break;
2916 /* Pop the current state because it cannot handle the error token. */
2917 if (yyssp == yyss)
2918 YYABORT;
2921 yydestruct ("Error: popping",
2922 yystos[yystate], yyvsp);
2923 YYPOPSTACK (1);
2924 yystate = *yyssp;
2925 YY_STACK_PRINT (yyss, yyssp);
2928 if (yyn == YYFINAL)
2929 YYACCEPT;
2931 *++yyvsp = yylval;
2934 /* Shift the error token. */
2935 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2937 yystate = yyn;
2938 goto yynewstate;
2941 /*-------------------------------------.
2942 | yyacceptlab -- YYACCEPT comes here. |
2943 `-------------------------------------*/
2944 yyacceptlab:
2945 yyresult = 0;
2946 goto yyreturn;
2948 /*-----------------------------------.
2949 | yyabortlab -- YYABORT comes here. |
2950 `-----------------------------------*/
2951 yyabortlab:
2952 yyresult = 1;
2953 goto yyreturn;
2955 #ifndef yyoverflow
2956 /*-------------------------------------------------.
2957 | yyexhaustedlab -- memory exhaustion comes here. |
2958 `-------------------------------------------------*/
2959 yyexhaustedlab:
2960 yyerror (YY_("memory exhausted"));
2961 yyresult = 2;
2962 /* Fall through. */
2963 #endif
2965 yyreturn:
2966 if (yychar != YYEOF && yychar != YYEMPTY)
2967 yydestruct ("Cleanup: discarding lookahead",
2968 yytoken, &yylval);
2969 /* Do not reclaim the symbols of the rule which action triggered
2970 this YYABORT or YYACCEPT. */
2971 YYPOPSTACK (yylen);
2972 YY_STACK_PRINT (yyss, yyssp);
2973 while (yyssp != yyss)
2975 yydestruct ("Cleanup: popping",
2976 yystos[*yyssp], yyvsp);
2977 YYPOPSTACK (1);
2979 #ifndef yyoverflow
2980 if (yyss != yyssa)
2981 YYSTACK_FREE (yyss);
2982 #endif
2983 #if YYERROR_VERBOSE
2984 if (yymsg != yymsgbuf)
2985 YYSTACK_FREE (yymsg);
2986 #endif
2987 /* Make sure YYID is used. */
2988 return YYID (yyresult);
2992 #line 938 "ftpcmd.y"
2995 #define CMD 0 /* beginning of command */
2996 #define ARGS 1 /* expect miscellaneous arguments */
2997 #define STR1 2 /* expect SP followed by STRING */
2998 #define STR2 3 /* expect STRING */
2999 #define OSTR 4 /* optional SP then STRING */
3000 #define ZSTR1 5 /* SP then optional STRING */
3001 #define ZSTR2 6 /* optional STRING after SP */
3002 #define SITECMD 7 /* SITE command */
3003 #define NSTR 8 /* Number followed by a string */
3005 struct tab cmdtab[] = { /* In order defined in RFC 765 */
3006 { "USER", USER, STR1, 1, "<sp> username" },
3007 { "PASS", PASS, ZSTR1, 1, "<sp> password" },
3008 { "ACCT", ACCT, STR1, 0, "(specify account)" },
3009 { "SMNT", SMNT, ARGS, 0, "(structure mount)" },
3010 { "REIN", REIN, ARGS, 0, "(reinitialize server state)" },
3011 { "QUIT", QUIT, ARGS, 1, "(terminate service)", },
3012 { "PORT", PORT, ARGS, 1, "<sp> b0, b1, b2, b3, b4" },
3013 { "EPRT", EPRT, STR1, 1, "<sp> string" },
3014 { "PASV", PASV, ARGS, 1, "(set server in passive mode)" },
3015 { "EPSV", EPSV, OSTR, 1, "[<sp> foo]" },
3016 { "TYPE", TYPE, ARGS, 1, "<sp> [ A | E | I | L ]" },
3017 { "STRU", STRU, ARGS, 1, "(specify file structure)" },
3018 { "MODE", MODE, ARGS, 1, "(specify transfer mode)" },
3019 { "RETR", RETR, STR1, 1, "<sp> file-name" },
3020 { "STOR", STOR, STR1, 1, "<sp> file-name" },
3021 { "APPE", APPE, STR1, 1, "<sp> file-name" },
3022 { "MLFL", MLFL, OSTR, 0, "(mail file)" },
3023 { "MAIL", MAIL, OSTR, 0, "(mail to user)" },
3024 { "MSND", MSND, OSTR, 0, "(mail send to terminal)" },
3025 { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" },
3026 { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" },
3027 { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" },
3028 { "MRCP", MRCP, STR1, 0, "(mail recipient)" },
3029 { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" },
3030 { "REST", REST, ARGS, 1, "<sp> offset (restart command)" },
3031 { "RNFR", RNFR, STR1, 1, "<sp> file-name" },
3032 { "RNTO", RNTO, STR1, 1, "<sp> file-name" },
3033 { "ABOR", ABOR, ARGS, 1, "(abort operation)" },
3034 { "DELE", DELE, STR1, 1, "<sp> file-name" },
3035 { "CWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
3036 { "XCWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
3037 { "LIST", LIST, OSTR, 1, "[ <sp> path-name ]" },
3038 { "NLST", NLST, OSTR, 1, "[ <sp> path-name ]" },
3039 { "SITE", SITE, SITECMD, 1, "site-cmd [ <sp> arguments ]" },
3040 { "SYST", SYST, ARGS, 1, "(get type of operating system)" },
3041 { "STAT", sTAT, OSTR, 1, "[ <sp> path-name ]" },
3042 { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
3043 { "NOOP", NOOP, ARGS, 1, "" },
3044 { "MKD", MKD, STR1, 1, "<sp> path-name" },
3045 { "XMKD", MKD, STR1, 1, "<sp> path-name" },
3046 { "RMD", RMD, STR1, 1, "<sp> path-name" },
3047 { "XRMD", RMD, STR1, 1, "<sp> path-name" },
3048 { "PWD", PWD, ARGS, 1, "(return current directory)" },
3049 { "XPWD", PWD, ARGS, 1, "(return current directory)" },
3050 { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" },
3051 { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" },
3052 { "STOU", STOU, STR1, 1, "<sp> file-name" },
3053 { "SIZE", SIZE, OSTR, 1, "<sp> path-name" },
3054 { "MDTM", MDTM, OSTR, 1, "<sp> path-name" },
3056 /* extensions from RFC2228 */
3057 { "AUTH", AUTH, STR1, 1, "<sp> auth-type" },
3058 { "ADAT", ADAT, STR1, 1, "<sp> auth-data" },
3059 { "PBSZ", PBSZ, ARGS, 1, "<sp> buffer-size" },
3060 { "PROT", PROT, STR1, 1, "<sp> prot-level" },
3061 { "CCC", CCC, ARGS, 1, "" },
3062 { "MIC", MIC, STR1, 1, "<sp> integrity command" },
3063 { "CONF", CONF, STR1, 1, "<sp> confidentiality command" },
3064 { "ENC", ENC, STR1, 1, "<sp> privacy command" },
3066 /* RFC2389 */
3067 { "FEAT", FEAT, ARGS, 1, "" },
3068 { "OPTS", OPTS, ARGS, 1, "<sp> command [<sp> options]" },
3070 { NULL, 0, 0, 0, 0 }
3073 struct tab sitetab[] = {
3074 { "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" },
3075 { "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
3076 { "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },
3077 { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
3079 { "KAUTH", KAUTH, STR1, 1, "<sp> principal [ <sp> ticket ]" },
3080 { "KLIST", KLIST, ARGS, 1, "(show ticket file)" },
3081 { "KDESTROY", KDESTROY, ARGS, 1, "(destroy tickets)" },
3082 { "KRBTKFILE", KRBTKFILE, STR1, 1, "<sp> ticket-file" },
3083 { "AFSLOG", AFSLOG, OSTR, 1, "[<sp> cell]" },
3085 { "LOCATE", LOCATE, STR1, 1, "<sp> globexpr" },
3086 { "FIND", LOCATE, STR1, 1, "<sp> globexpr" },
3088 { "URL", URL, ARGS, 1, "?" },
3090 { NULL, 0, 0, 0, 0 }
3093 static struct tab *
3094 lookup(struct tab *p, char *cmd)
3097 for (; p->name != NULL; p++)
3098 if (strcmp(cmd, p->name) == 0)
3099 return (p);
3100 return (0);
3104 * ftpd_getline - a hacked up version of fgets to ignore TELNET escape codes.
3106 char *
3107 ftpd_getline(char *s, int n)
3109 int c;
3110 char *cs;
3112 cs = s;
3114 /* might still be data within the security MIC/CONF/ENC */
3115 if(ftp_command){
3116 strlcpy(s, ftp_command, n);
3117 if (debug)
3118 syslog(LOG_DEBUG, "command: %s", s);
3119 return s;
3121 while ((c = getc(stdin)) != EOF) {
3122 c &= 0377;
3123 if (c == IAC) {
3124 if ((c = getc(stdin)) != EOF) {
3125 c &= 0377;
3126 switch (c) {
3127 case WILL:
3128 case WONT:
3129 c = getc(stdin);
3130 printf("%c%c%c", IAC, DONT, 0377&c);
3131 fflush(stdout);
3132 continue;
3133 case DO:
3134 case DONT:
3135 c = getc(stdin);
3136 printf("%c%c%c", IAC, WONT, 0377&c);
3137 fflush(stdout);
3138 continue;
3139 case IAC:
3140 break;
3141 default:
3142 continue; /* ignore command */
3146 *cs++ = c;
3147 if (--n <= 0 || c == '\n')
3148 break;
3150 if (c == EOF && cs == s)
3151 return (NULL);
3152 *cs++ = '\0';
3153 if (debug) {
3154 if (!guest && strncasecmp("pass ", s, 5) == 0) {
3155 /* Don't syslog passwords */
3156 syslog(LOG_DEBUG, "command: %.5s ???", s);
3157 } else {
3158 char *cp;
3159 int len;
3161 /* Don't syslog trailing CR-LF */
3162 len = strlen(s);
3163 cp = s + len - 1;
3164 while (cp >= s && (*cp == '\n' || *cp == '\r')) {
3165 --cp;
3166 --len;
3168 syslog(LOG_DEBUG, "command: %.*s", len, s);
3171 #ifdef XXX
3172 fprintf(stderr, "%s\n", s);
3173 #endif
3174 return (s);
3177 static RETSIGTYPE
3178 toolong(int signo)
3181 reply(421,
3182 "Timeout (%d seconds): closing control connection.",
3183 ftpd_timeout);
3184 if (logging)
3185 syslog(LOG_INFO, "User %s timed out after %d seconds",
3186 (pw ? pw -> pw_name : "unknown"), ftpd_timeout);
3187 dologout(1);
3188 SIGRETURN(0);
3191 static int
3192 yylex(void)
3194 static int cpos, state;
3195 char *cp, *cp2;
3196 struct tab *p;
3197 int n;
3198 char c;
3200 for (;;) {
3201 switch (state) {
3203 case CMD:
3204 hasyyerrored = 0;
3206 signal(SIGALRM, toolong);
3207 alarm((unsigned) ftpd_timeout);
3208 if (ftpd_getline(cbuf, sizeof(cbuf)-1) == NULL) {
3209 reply(221, "You could at least say goodbye.");
3210 dologout(0);
3212 alarm(0);
3213 #ifdef HAVE_SETPROCTITLE
3214 if (strncasecmp(cbuf, "PASS", 4) != 0)
3215 setproctitle("%s: %s", proctitle, cbuf);
3216 #endif /* HAVE_SETPROCTITLE */
3217 if ((cp = strchr(cbuf, '\r'))) {
3218 *cp++ = '\n';
3219 *cp = '\0';
3221 if ((cp = strpbrk(cbuf, " \n")))
3222 cpos = cp - cbuf;
3223 if (cpos == 0)
3224 cpos = 4;
3225 c = cbuf[cpos];
3226 cbuf[cpos] = '\0';
3227 strupr(cbuf);
3228 p = lookup(cmdtab, cbuf);
3229 cbuf[cpos] = c;
3230 if (p != 0) {
3231 if (p->implemented == 0) {
3232 nack(p->name);
3233 hasyyerrored = 1;
3234 break;
3236 state = p->state;
3237 yylval.s = p->name;
3238 return (p->token);
3240 break;
3242 case SITECMD:
3243 if (cbuf[cpos] == ' ') {
3244 cpos++;
3245 return (SP);
3247 cp = &cbuf[cpos];
3248 if ((cp2 = strpbrk(cp, " \n")))
3249 cpos = cp2 - cbuf;
3250 c = cbuf[cpos];
3251 cbuf[cpos] = '\0';
3252 strupr(cp);
3253 p = lookup(sitetab, cp);
3254 cbuf[cpos] = c;
3255 if (p != 0) {
3256 if (p->implemented == 0) {
3257 state = CMD;
3258 nack(p->name);
3259 hasyyerrored = 1;
3260 break;
3262 state = p->state;
3263 yylval.s = p->name;
3264 return (p->token);
3266 state = CMD;
3267 break;
3269 case OSTR:
3270 if (cbuf[cpos] == '\n') {
3271 state = CMD;
3272 return (CRLF);
3274 /* FALLTHROUGH */
3276 case STR1:
3277 case ZSTR1:
3278 dostr1:
3279 if (cbuf[cpos] == ' ') {
3280 cpos++;
3281 if(state == OSTR)
3282 state = STR2;
3283 else
3284 state++;
3285 return (SP);
3287 break;
3289 case ZSTR2:
3290 if (cbuf[cpos] == '\n') {
3291 state = CMD;
3292 return (CRLF);
3294 /* FALLTHROUGH */
3296 case STR2:
3297 cp = &cbuf[cpos];
3298 n = strlen(cp);
3299 cpos += n - 1;
3301 * Make sure the string is nonempty and \n terminated.
3303 if (n > 1 && cbuf[cpos] == '\n') {
3304 cbuf[cpos] = '\0';
3305 yylval.s = copy(cp);
3306 cbuf[cpos] = '\n';
3307 state = ARGS;
3308 return (STRING);
3310 break;
3312 case NSTR:
3313 if (cbuf[cpos] == ' ') {
3314 cpos++;
3315 return (SP);
3317 if (isdigit((unsigned char)cbuf[cpos])) {
3318 cp = &cbuf[cpos];
3319 while (isdigit((unsigned char)cbuf[++cpos]))
3321 c = cbuf[cpos];
3322 cbuf[cpos] = '\0';
3323 yylval.i = atoi(cp);
3324 cbuf[cpos] = c;
3325 state = STR1;
3326 return (NUMBER);
3328 state = STR1;
3329 goto dostr1;
3331 case ARGS:
3332 if (isdigit((unsigned char)cbuf[cpos])) {
3333 cp = &cbuf[cpos];
3334 while (isdigit((unsigned char)cbuf[++cpos]))
3336 c = cbuf[cpos];
3337 cbuf[cpos] = '\0';
3338 yylval.i = atoi(cp);
3339 cbuf[cpos] = c;
3340 return (NUMBER);
3342 switch (cbuf[cpos++]) {
3344 case '\n':
3345 state = CMD;
3346 return (CRLF);
3348 case ' ':
3349 return (SP);
3351 case ',':
3352 return (COMMA);
3354 case 'A':
3355 case 'a':
3356 return (A);
3358 case 'B':
3359 case 'b':
3360 return (B);
3362 case 'C':
3363 case 'c':
3364 return (C);
3366 case 'E':
3367 case 'e':
3368 return (E);
3370 case 'F':
3371 case 'f':
3372 return (F);
3374 case 'I':
3375 case 'i':
3376 return (I);
3378 case 'L':
3379 case 'l':
3380 return (L);
3382 case 'N':
3383 case 'n':
3384 return (N);
3386 case 'P':
3387 case 'p':
3388 return (P);
3390 case 'R':
3391 case 'r':
3392 return (R);
3394 case 'S':
3395 case 's':
3396 return (S);
3398 case 'T':
3399 case 't':
3400 return (T);
3403 break;
3405 default:
3406 fatal("Unknown state in scanner.");
3408 yyerror(NULL);
3409 state = CMD;
3410 return (0);
3414 /* ARGSUSED */
3415 void
3416 yyerror(char *s)
3418 char *cp;
3420 if (hasyyerrored)
3421 return;
3423 if ((cp = strchr(cbuf,'\n')))
3424 *cp = '\0';
3425 reply(500, "'%s': command not understood.", cbuf);
3426 hasyyerrored = 1;
3429 static char *
3430 copy(char *s)
3432 char *p;
3434 p = strdup(s);
3435 if (p == NULL)
3436 fatal("Ran out of memory.");
3437 return p;
3440 static void
3441 help(struct tab *ctab, char *s)
3443 struct tab *c;
3444 int width, NCMDS;
3445 char *t;
3446 char buf[1024];
3448 if (ctab == sitetab)
3449 t = "SITE ";
3450 else
3451 t = "";
3452 width = 0, NCMDS = 0;
3453 for (c = ctab; c->name != NULL; c++) {
3454 int len = strlen(c->name);
3456 if (len > width)
3457 width = len;
3458 NCMDS++;
3460 width = (width + 8) &~ 7;
3461 if (s == 0) {
3462 int i, j, w;
3463 int columns, lines;
3465 lreply(214, "The following %scommands are recognized %s.",
3466 t, "(* =>'s unimplemented)");
3467 columns = 76 / width;
3468 if (columns == 0)
3469 columns = 1;
3470 lines = (NCMDS + columns - 1) / columns;
3471 for (i = 0; i < lines; i++) {
3472 strlcpy (buf, " ", sizeof(buf));
3473 for (j = 0; j < columns; j++) {
3474 c = ctab + j * lines + i;
3475 snprintf (buf + strlen(buf),
3476 sizeof(buf) - strlen(buf),
3477 "%s%c",
3478 c->name,
3479 c->implemented ? ' ' : '*');
3480 if (c + lines >= &ctab[NCMDS])
3481 break;
3482 w = strlen(c->name) + 1;
3483 while (w < width) {
3484 strlcat (buf,
3485 " ",
3486 sizeof(buf));
3487 w++;
3490 lreply(214, "%s", buf);
3492 reply(214, "Direct comments to kth-krb-bugs@pdc.kth.se");
3493 return;
3495 strupr(s);
3496 c = lookup(ctab, s);
3497 if (c == (struct tab *)0) {
3498 reply(502, "Unknown command %s.", s);
3499 return;
3501 if (c->implemented)
3502 reply(214, "Syntax: %s%s %s", t, c->name, c->help);
3503 else
3504 reply(214, "%s%-*s\t%s; unimplemented.", t, width,
3505 c->name, c->help);
3508 static void
3509 sizecmd(char *filename)
3511 switch (type) {
3512 case TYPE_L:
3513 case TYPE_I: {
3514 struct stat stbuf;
3515 if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
3516 reply(550, "%s: not a plain file.", filename);
3517 else
3518 reply(213, "%lu", (unsigned long)stbuf.st_size);
3519 break;
3521 case TYPE_A: {
3522 FILE *fin;
3523 int c;
3524 size_t count;
3525 struct stat stbuf;
3526 fin = fopen(filename, "r");
3527 if (fin == NULL) {
3528 perror_reply(550, filename);
3529 return;
3531 if (fstat(fileno(fin), &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
3532 reply(550, "%s: not a plain file.", filename);
3533 fclose(fin);
3534 return;
3537 count = 0;
3538 while((c=getc(fin)) != EOF) {
3539 if (c == '\n') /* will get expanded to \r\n */
3540 count++;
3541 count++;
3543 fclose(fin);
3545 reply(213, "%lu", (unsigned long)count);
3546 break;
3548 default:
3549 reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);