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