ftpcmd.c revision 178826
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"
245RCSID("$Id: ftpcmd.y 15677 2005-07-19 18:33:08Z lha $");
246
247off_t	restart_point;
248
249static	int hasyyerrored;
250
251
252static	int cmd_type;
253static	int cmd_form;
254static	int cmd_bytesz;
255char	cbuf[64*1024];
256char	*fromname;
257
258struct tab {
259	char	*name;
260	short	token;
261	short	state;
262	short	implemented;	/* 1 if command is implemented */
263	char	*help;
264};
265
266extern struct tab cmdtab[];
267extern struct tab sitetab[];
268
269static char		*copy (char *);
270static void		 help (struct tab *, char *);
271static struct tab *
272			 lookup (struct tab *, char *);
273static void		 sizecmd (char *);
274static RETSIGTYPE	 toolong (int);
275static 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
304typedef 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
331typedef YYTYPE_UINT8 yytype_uint8;
332#else
333typedef unsigned char yytype_uint8;
334#endif
335
336#ifdef YYTYPE_INT8
337typedef YYTYPE_INT8 yytype_int8;
338#elif (defined __STDC__ || defined __C99__FUNC__ \
339     || defined __cplusplus || defined _MSC_VER)
340typedef signed char yytype_int8;
341#else
342typedef short int yytype_int8;
343#endif
344
345#ifdef YYTYPE_UINT16
346typedef YYTYPE_UINT16 yytype_uint16;
347#else
348typedef unsigned short int yytype_uint16;
349#endif
350
351#ifdef YYTYPE_INT16
352typedef YYTYPE_INT16 yytype_int16;
353#else
354typedef 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)
398static int
399YYID (int i)
400#else
401static int
402YYID (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)
466void *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)
473void 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.  */
485union 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.  */
558static 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.  */
599static 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.  */
614static 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.  */
666static const yytype_uint16 yyrline[] =
667{
668       0,   129,   129,   131,   136,   140,   146,   153,   164,   170,
669     175,   180,   186,   223,   237,   251,   257,   263,   272,   281,
670     290,   295,   304,   309,   315,   322,   327,   334,   348,   353,
671     358,   365,   370,   387,   392,   399,   406,   411,   416,   426,
672     433,   438,   443,   451,   464,   478,   485,   502,   525,   530,
673     539,   552,   563,   576,   583,   588,   595,   613,   630,   658,
674     665,   671,   681,   691,   696,   701,   706,   711,   716,   721,
675     726,   734,   739,   742,   746,   750,   763,   767,   771,   778,
676     783,   788,   793,   798,   802,   807,   813,   821,   825,   829,
677     836,   840,   844,   851,   879,   883,   909,   917,   928
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.  */
684static 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.  */
705static 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.  */
720static 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.  */
735static 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.  */
752static 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].  */
789static 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
798static 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].  */
835static 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
846static 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
883static 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.  */
922static 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)					\
977do								\
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    }								\
991while (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)			\
1057do {						\
1058  if (yydebug)					\
1059    YYFPRINTF Args;				\
1060} while (YYID (0))
1061
1062# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
1063do {									  \
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)
1081static void
1082yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1083#else
1084static void
1085yy_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)
1113static void
1114yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1115#else
1116static void
1117yy_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)
1139static void
1140yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1141#else
1142static void
1143yy_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)				\
1155do {								\
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)
1167static void
1168yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1169#else
1170static void
1171yy_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)		\
1193do {					\
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.  */
1200int 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)
1236static YYSIZE_T
1237yystrlen (const char *yystr)
1238#else
1239static YYSIZE_T
1240yystrlen (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)
1260static char *
1261yystpcpy (char *yydest, const char *yysrc)
1262#else
1263static char *
1264yystpcpy (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.  */
1288static YYSIZE_T
1289yytnamerr (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.  */
1335static YYSIZE_T
1336yysyntax_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)
1445static void
1446yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1447#else
1448static void
1449yydestruct (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
1474int yyparse (void *YYPARSE_PARAM);
1475#else
1476int yyparse ();
1477#endif
1478#else /* ! YYPARSE_PARAM */
1479#if defined __STDC__ || defined __cplusplus
1480int yyparse (void);
1481#else
1482int yyparse ();
1483#endif
1484#endif /* ! YYPARSE_PARAM */
1485
1486
1487
1488/* The look-ahead symbol.  */
1489int yychar;
1490
1491/* The semantic value of the look-ahead symbol.  */
1492YYSTYPE yylval;
1493
1494/* Number of syntax errors so far.  */
1495int 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)
1506int
1507yyparse (void *YYPARSE_PARAM)
1508#else
1509int
1510yyparse (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)
1516int
1517yyparse (void)
1518#else
1519int
1520yyparse ()
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`-----------*/
1673yybackup:
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`-----------------------------------------------------------*/
1741yydefault:
1742  yyn = yydefact[yystate];
1743  if (yyn == 0)
1744    goto yyerrlab;
1745  goto yyreduce;
1746
1747
1748/*-----------------------------.
1749| yyreduce -- Do a reduction.  |
1750`-----------------------------*/
1751yyreduce:
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 154 "ftpcmd.y"
1798    {
1799		    if ((yyvsp[(5) - (5)].i)) {
1800			usedefault = 0;
1801			if (pdata >= 0) {
1802				close(pdata);
1803				pdata = -1;
1804			}
1805			reply(200, "PORT command successful.");
1806		    }
1807		}
1808    break;
1809
1810  case 8:
1811#line 165 "ftpcmd.y"
1812    {
1813		    if ((yyvsp[(5) - (5)].i))
1814			eprt ((yyvsp[(3) - (5)].s));
1815		    free ((yyvsp[(3) - (5)].s));
1816		}
1817    break;
1818
1819  case 9:
1820#line 171 "ftpcmd.y"
1821    {
1822		    if((yyvsp[(3) - (3)].i))
1823			pasv ();
1824		}
1825    break;
1826
1827  case 10:
1828#line 176 "ftpcmd.y"
1829    {
1830		    if((yyvsp[(3) - (3)].i))
1831			epsv (NULL);
1832		}
1833    break;
1834
1835  case 11:
1836#line 181 "ftpcmd.y"
1837    {
1838		    if((yyvsp[(5) - (5)].i))
1839			epsv ((yyvsp[(3) - (5)].s));
1840		    free ((yyvsp[(3) - (5)].s));
1841		}
1842    break;
1843
1844  case 12:
1845#line 187 "ftpcmd.y"
1846    {
1847		    if ((yyvsp[(5) - (5)].i)) {
1848			switch (cmd_type) {
1849
1850			case TYPE_A:
1851				if (cmd_form == FORM_N) {
1852					reply(200, "Type set to A.");
1853					type = cmd_type;
1854					form = cmd_form;
1855				} else
1856					reply(504, "Form must be N.");
1857				break;
1858
1859			case TYPE_E:
1860				reply(504, "Type E not implemented.");
1861				break;
1862
1863			case TYPE_I:
1864				reply(200, "Type set to I.");
1865				type = cmd_type;
1866				break;
1867
1868			case TYPE_L:
1869#if NBBY == 8
1870				if (cmd_bytesz == 8) {
1871					reply(200,
1872					    "Type set to L (byte size 8).");
1873					type = cmd_type;
1874				} else
1875					reply(504, "Byte size must be 8.");
1876#else /* NBBY == 8 */
1877				UNIMPLEMENTED for NBBY != 8
1878#endif /* NBBY == 8 */
1879			}
1880		    }
1881		}
1882    break;
1883
1884  case 13:
1885#line 224 "ftpcmd.y"
1886    {
1887		    if ((yyvsp[(5) - (5)].i)) {
1888			switch ((yyvsp[(3) - (5)].i)) {
1889
1890			case STRU_F:
1891				reply(200, "STRU F ok.");
1892				break;
1893
1894			default:
1895				reply(504, "Unimplemented STRU type.");
1896			}
1897		    }
1898		}
1899    break;
1900
1901  case 14:
1902#line 238 "ftpcmd.y"
1903    {
1904		    if ((yyvsp[(5) - (5)].i)) {
1905			switch ((yyvsp[(3) - (5)].i)) {
1906
1907			case MODE_S:
1908				reply(200, "MODE S ok.");
1909				break;
1910
1911			default:
1912				reply(502, "Unimplemented MODE type.");
1913			}
1914		    }
1915		}
1916    break;
1917
1918  case 15:
1919#line 252 "ftpcmd.y"
1920    {
1921		    if ((yyvsp[(5) - (5)].i)) {
1922			reply(202, "ALLO command ignored.");
1923		    }
1924		}
1925    break;
1926
1927  case 16:
1928#line 258 "ftpcmd.y"
1929    {
1930		    if ((yyvsp[(9) - (9)].i)) {
1931			reply(202, "ALLO command ignored.");
1932		    }
1933		}
1934    break;
1935
1936  case 17:
1937#line 264 "ftpcmd.y"
1938    {
1939			char *name = (yyvsp[(3) - (5)].s);
1940
1941			if ((yyvsp[(5) - (5)].i) && name != NULL)
1942				retrieve(0, name);
1943			if (name != NULL)
1944				free(name);
1945		}
1946    break;
1947
1948  case 18:
1949#line 273 "ftpcmd.y"
1950    {
1951			char *name = (yyvsp[(3) - (5)].s);
1952
1953			if ((yyvsp[(5) - (5)].i) && name != NULL)
1954				do_store(name, "w", 0);
1955			if (name != NULL)
1956				free(name);
1957		}
1958    break;
1959
1960  case 19:
1961#line 282 "ftpcmd.y"
1962    {
1963			char *name = (yyvsp[(3) - (5)].s);
1964
1965			if ((yyvsp[(5) - (5)].i) && name != NULL)
1966				do_store(name, "a", 0);
1967			if (name != NULL)
1968				free(name);
1969		}
1970    break;
1971
1972  case 20:
1973#line 291 "ftpcmd.y"
1974    {
1975			if ((yyvsp[(3) - (3)].i))
1976				send_file_list(".");
1977		}
1978    break;
1979
1980  case 21:
1981#line 296 "ftpcmd.y"
1982    {
1983			char *name = (yyvsp[(3) - (5)].s);
1984
1985			if ((yyvsp[(5) - (5)].i) && name != NULL)
1986				send_file_list(name);
1987			if (name != NULL)
1988				free(name);
1989		}
1990    break;
1991
1992  case 22:
1993#line 305 "ftpcmd.y"
1994    {
1995		    if((yyvsp[(3) - (3)].i))
1996			list_file(".");
1997		}
1998    break;
1999
2000  case 23:
2001#line 310 "ftpcmd.y"
2002    {
2003		    if((yyvsp[(5) - (5)].i))
2004			list_file((yyvsp[(3) - (5)].s));
2005		    free((yyvsp[(3) - (5)].s));
2006		}
2007    break;
2008
2009  case 24:
2010#line 316 "ftpcmd.y"
2011    {
2012			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2013				statfilecmd((yyvsp[(3) - (5)].s));
2014			if ((yyvsp[(3) - (5)].s) != NULL)
2015				free((yyvsp[(3) - (5)].s));
2016		}
2017    break;
2018
2019  case 25:
2020#line 323 "ftpcmd.y"
2021    {
2022		    if ((yyvsp[(3) - (3)].i))
2023			statcmd();
2024		}
2025    break;
2026
2027  case 26:
2028#line 328 "ftpcmd.y"
2029    {
2030			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2031				do_delete((yyvsp[(3) - (5)].s));
2032			if ((yyvsp[(3) - (5)].s) != NULL)
2033				free((yyvsp[(3) - (5)].s));
2034		}
2035    break;
2036
2037  case 27:
2038#line 335 "ftpcmd.y"
2039    {
2040			if((yyvsp[(5) - (5)].i)){
2041				if (fromname) {
2042					renamecmd(fromname, (yyvsp[(3) - (5)].s));
2043					free(fromname);
2044					fromname = (char *) 0;
2045				} else {
2046					reply(503, "Bad sequence of commands.");
2047				}
2048			}
2049			if ((yyvsp[(3) - (5)].s) != NULL)
2050				free((yyvsp[(3) - (5)].s));
2051		}
2052    break;
2053
2054  case 28:
2055#line 349 "ftpcmd.y"
2056    {
2057		    if ((yyvsp[(3) - (3)].i))
2058			reply(225, "ABOR command successful.");
2059		}
2060    break;
2061
2062  case 29:
2063#line 354 "ftpcmd.y"
2064    {
2065			if ((yyvsp[(3) - (3)].i))
2066				cwd(pw->pw_dir);
2067		}
2068    break;
2069
2070  case 30:
2071#line 359 "ftpcmd.y"
2072    {
2073			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2074				cwd((yyvsp[(3) - (5)].s));
2075			if ((yyvsp[(3) - (5)].s) != NULL)
2076				free((yyvsp[(3) - (5)].s));
2077		}
2078    break;
2079
2080  case 31:
2081#line 366 "ftpcmd.y"
2082    {
2083		    if ((yyvsp[(3) - (3)].i))
2084			help(cmdtab, (char *) 0);
2085		}
2086    break;
2087
2088  case 32:
2089#line 371 "ftpcmd.y"
2090    {
2091		    if ((yyvsp[(5) - (5)].i)) {
2092			char *cp = (yyvsp[(3) - (5)].s);
2093
2094			if (strncasecmp(cp, "SITE", 4) == 0) {
2095				cp = (yyvsp[(3) - (5)].s) + 4;
2096				if (*cp == ' ')
2097					cp++;
2098				if (*cp)
2099					help(sitetab, cp);
2100				else
2101					help(sitetab, (char *) 0);
2102			} else
2103				help(cmdtab, (yyvsp[(3) - (5)].s));
2104		    }
2105		}
2106    break;
2107
2108  case 33:
2109#line 388 "ftpcmd.y"
2110    {
2111		    if ((yyvsp[(3) - (3)].i))
2112			reply(200, "NOOP command successful.");
2113		}
2114    break;
2115
2116  case 34:
2117#line 393 "ftpcmd.y"
2118    {
2119			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2120				makedir((yyvsp[(3) - (5)].s));
2121			if ((yyvsp[(3) - (5)].s) != NULL)
2122				free((yyvsp[(3) - (5)].s));
2123		}
2124    break;
2125
2126  case 35:
2127#line 400 "ftpcmd.y"
2128    {
2129			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2130				removedir((yyvsp[(3) - (5)].s));
2131			if ((yyvsp[(3) - (5)].s) != NULL)
2132				free((yyvsp[(3) - (5)].s));
2133		}
2134    break;
2135
2136  case 36:
2137#line 407 "ftpcmd.y"
2138    {
2139			if ((yyvsp[(3) - (3)].i))
2140				pwd();
2141		}
2142    break;
2143
2144  case 37:
2145#line 412 "ftpcmd.y"
2146    {
2147			if ((yyvsp[(3) - (3)].i))
2148				cwd("..");
2149		}
2150    break;
2151
2152  case 38:
2153#line 417 "ftpcmd.y"
2154    {
2155		    if ((yyvsp[(3) - (3)].i)) {
2156			lreply(211, "Supported features:");
2157			lreply(0, " MDTM");
2158			lreply(0, " REST STREAM");
2159			lreply(0, " SIZE");
2160			reply(211, "End");
2161		    }
2162		}
2163    break;
2164
2165  case 39:
2166#line 427 "ftpcmd.y"
2167    {
2168		    if ((yyvsp[(5) - (5)].i))
2169			reply(501, "Bad options");
2170		    free ((yyvsp[(3) - (5)].s));
2171		}
2172    break;
2173
2174  case 40:
2175#line 434 "ftpcmd.y"
2176    {
2177		    if ((yyvsp[(5) - (5)].i))
2178			help(sitetab, (char *) 0);
2179		}
2180    break;
2181
2182  case 41:
2183#line 439 "ftpcmd.y"
2184    {
2185		    if ((yyvsp[(7) - (7)].i))
2186			help(sitetab, (yyvsp[(5) - (7)].s));
2187		}
2188    break;
2189
2190  case 42:
2191#line 444 "ftpcmd.y"
2192    {
2193			if ((yyvsp[(5) - (5)].i)) {
2194				int oldmask = umask(0);
2195				umask(oldmask);
2196				reply(200, "Current UMASK is %03o", oldmask);
2197			}
2198		}
2199    break;
2200
2201  case 43:
2202#line 452 "ftpcmd.y"
2203    {
2204			if ((yyvsp[(7) - (7)].i)) {
2205				if (((yyvsp[(5) - (7)].i) == -1) || ((yyvsp[(5) - (7)].i) > 0777)) {
2206					reply(501, "Bad UMASK value");
2207				} else {
2208					int oldmask = umask((yyvsp[(5) - (7)].i));
2209					reply(200,
2210					      "UMASK set to %03o (was %03o)",
2211					      (yyvsp[(5) - (7)].i), oldmask);
2212				}
2213			}
2214		}
2215    break;
2216
2217  case 44:
2218#line 465 "ftpcmd.y"
2219    {
2220			if ((yyvsp[(9) - (9)].i) && (yyvsp[(7) - (9)].s) != NULL) {
2221				if ((yyvsp[(5) - (9)].i) > 0777)
2222					reply(501,
2223				"CHMOD: Mode value must be between 0 and 0777");
2224				else if (chmod((yyvsp[(7) - (9)].s), (yyvsp[(5) - (9)].i)) < 0)
2225					perror_reply(550, (yyvsp[(7) - (9)].s));
2226				else
2227					reply(200, "CHMOD command successful.");
2228			}
2229			if ((yyvsp[(7) - (9)].s) != NULL)
2230				free((yyvsp[(7) - (9)].s));
2231		}
2232    break;
2233
2234  case 45:
2235#line 479 "ftpcmd.y"
2236    {
2237		    if ((yyvsp[(5) - (5)].i))
2238			reply(200,
2239			    "Current IDLE time limit is %d seconds; max %d",
2240				ftpd_timeout, maxtimeout);
2241		}
2242    break;
2243
2244  case 46:
2245#line 486 "ftpcmd.y"
2246    {
2247		    if ((yyvsp[(7) - (7)].i)) {
2248			if ((yyvsp[(5) - (7)].i) < 30 || (yyvsp[(5) - (7)].i) > maxtimeout) {
2249				reply(501,
2250			"Maximum IDLE time must be between 30 and %d seconds",
2251				    maxtimeout);
2252			} else {
2253				ftpd_timeout = (yyvsp[(5) - (7)].i);
2254				alarm((unsigned) ftpd_timeout);
2255				reply(200,
2256				    "Maximum IDLE time set to %d seconds",
2257				    ftpd_timeout);
2258			}
2259		    }
2260		}
2261    break;
2262
2263  case 47:
2264#line 503 "ftpcmd.y"
2265    {
2266#ifdef KRB4
2267			char *p;
2268
2269			if(guest)
2270				reply(500, "Can't be done as guest.");
2271			else{
2272				if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s) != NULL){
2273				    p = strpbrk((yyvsp[(5) - (7)].s), " \t");
2274				    if(p){
2275					*p++ = 0;
2276					kauth((yyvsp[(5) - (7)].s), p + strspn(p, " \t"));
2277				    }else
2278					kauth((yyvsp[(5) - (7)].s), NULL);
2279				}
2280			}
2281			if((yyvsp[(5) - (7)].s) != NULL)
2282			    free((yyvsp[(5) - (7)].s));
2283#else
2284			reply(500, "Command not implemented.");
2285#endif
2286		}
2287    break;
2288
2289  case 48:
2290#line 526 "ftpcmd.y"
2291    {
2292		    if((yyvsp[(5) - (5)].i))
2293			klist();
2294		}
2295    break;
2296
2297  case 49:
2298#line 531 "ftpcmd.y"
2299    {
2300#ifdef KRB4
2301		    if((yyvsp[(5) - (5)].i))
2302			kdestroy();
2303#else
2304		    reply(500, "Command not implemented.");
2305#endif
2306		}
2307    break;
2308
2309  case 50:
2310#line 540 "ftpcmd.y"
2311    {
2312#ifdef KRB4
2313		    if(guest)
2314			reply(500, "Can't be done as guest.");
2315		    else if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s))
2316			krbtkfile((yyvsp[(5) - (7)].s));
2317		    if((yyvsp[(5) - (7)].s))
2318			free((yyvsp[(5) - (7)].s));
2319#else
2320		    reply(500, "Command not implemented.");
2321#endif
2322		}
2323    break;
2324
2325  case 51:
2326#line 553 "ftpcmd.y"
2327    {
2328#if defined(KRB4) || defined(KRB5)
2329		    if(guest)
2330			reply(500, "Can't be done as guest.");
2331		    else if((yyvsp[(5) - (5)].i))
2332			afslog(NULL, 0);
2333#else
2334		    reply(500, "Command not implemented.");
2335#endif
2336		}
2337    break;
2338
2339  case 52:
2340#line 564 "ftpcmd.y"
2341    {
2342#if defined(KRB4) || defined(KRB5)
2343		    if(guest)
2344			reply(500, "Can't be done as guest.");
2345		    else if((yyvsp[(7) - (7)].i))
2346			afslog((yyvsp[(5) - (7)].s), 0);
2347		    if((yyvsp[(5) - (7)].s))
2348			free((yyvsp[(5) - (7)].s));
2349#else
2350		    reply(500, "Command not implemented.");
2351#endif
2352		}
2353    break;
2354
2355  case 53:
2356#line 577 "ftpcmd.y"
2357    {
2358		    if((yyvsp[(7) - (7)].i) && (yyvsp[(5) - (7)].s) != NULL)
2359			find((yyvsp[(5) - (7)].s));
2360		    if((yyvsp[(5) - (7)].s) != NULL)
2361			free((yyvsp[(5) - (7)].s));
2362		}
2363    break;
2364
2365  case 54:
2366#line 584 "ftpcmd.y"
2367    {
2368		    if ((yyvsp[(5) - (5)].i))
2369			reply(200, "http://www.pdc.kth.se/heimdal/");
2370		}
2371    break;
2372
2373  case 55:
2374#line 589 "ftpcmd.y"
2375    {
2376			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2377				do_store((yyvsp[(3) - (5)].s), "w", 1);
2378			if ((yyvsp[(3) - (5)].s) != NULL)
2379				free((yyvsp[(3) - (5)].s));
2380		}
2381    break;
2382
2383  case 56:
2384#line 596 "ftpcmd.y"
2385    {
2386		    if ((yyvsp[(3) - (3)].i)) {
2387#if !defined(WIN32) && !defined(__EMX__) && !defined(__OS2__) && !defined(__CYGWIN32__)
2388			reply(215, "UNIX Type: L%d", NBBY);
2389#else
2390			reply(215, "UNKNOWN Type: L%d", NBBY);
2391#endif
2392		    }
2393		}
2394    break;
2395
2396  case 57:
2397#line 614 "ftpcmd.y"
2398    {
2399			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL)
2400				sizecmd((yyvsp[(3) - (5)].s));
2401			if ((yyvsp[(3) - (5)].s) != NULL)
2402				free((yyvsp[(3) - (5)].s));
2403		}
2404    break;
2405
2406  case 58:
2407#line 631 "ftpcmd.y"
2408    {
2409			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s) != NULL) {
2410				struct stat stbuf;
2411				if (stat((yyvsp[(3) - (5)].s), &stbuf) < 0)
2412					reply(550, "%s: %s",
2413					    (yyvsp[(3) - (5)].s), strerror(errno));
2414				else if (!S_ISREG(stbuf.st_mode)) {
2415					reply(550,
2416					      "%s: not a plain file.", (yyvsp[(3) - (5)].s));
2417				} else {
2418					struct tm *t;
2419					time_t mtime = stbuf.st_mtime;
2420
2421					t = gmtime(&mtime);
2422					reply(213,
2423					      "%04d%02d%02d%02d%02d%02d",
2424					      t->tm_year + 1900,
2425					      t->tm_mon + 1,
2426					      t->tm_mday,
2427					      t->tm_hour,
2428					      t->tm_min,
2429					      t->tm_sec);
2430				}
2431			}
2432			if ((yyvsp[(3) - (5)].s) != NULL)
2433				free((yyvsp[(3) - (5)].s));
2434		}
2435    break;
2436
2437  case 59:
2438#line 659 "ftpcmd.y"
2439    {
2440		    if ((yyvsp[(3) - (3)].i)) {
2441			reply(221, "Goodbye.");
2442			dologout(0);
2443		    }
2444		}
2445    break;
2446
2447  case 60:
2448#line 666 "ftpcmd.y"
2449    {
2450			yyerrok;
2451		}
2452    break;
2453
2454  case 61:
2455#line 672 "ftpcmd.y"
2456    {
2457			restart_point = (off_t) 0;
2458			if ((yyvsp[(5) - (5)].i) && (yyvsp[(3) - (5)].s)) {
2459				fromname = renamefrom((yyvsp[(3) - (5)].s));
2460				if (fromname == (char *) 0 && (yyvsp[(3) - (5)].s)) {
2461					free((yyvsp[(3) - (5)].s));
2462				}
2463			}
2464		}
2465    break;
2466
2467  case 62:
2468#line 682 "ftpcmd.y"
2469    {
2470		    if ((yyvsp[(5) - (5)].i)) {
2471			fromname = (char *) 0;
2472			restart_point = (yyvsp[(3) - (5)].i);	/* XXX $3 is only "int" */
2473			reply(350, "Restarting at %ld. %s",
2474			      (long)restart_point,
2475			      "Send STORE or RETRIEVE to initiate transfer.");
2476		    }
2477		}
2478    break;
2479
2480  case 63:
2481#line 692 "ftpcmd.y"
2482    {
2483			auth((yyvsp[(3) - (4)].s));
2484			free((yyvsp[(3) - (4)].s));
2485		}
2486    break;
2487
2488  case 64:
2489#line 697 "ftpcmd.y"
2490    {
2491			adat((yyvsp[(3) - (4)].s));
2492			free((yyvsp[(3) - (4)].s));
2493		}
2494    break;
2495
2496  case 65:
2497#line 702 "ftpcmd.y"
2498    {
2499		    if ((yyvsp[(5) - (5)].i))
2500			pbsz((yyvsp[(3) - (5)].i));
2501		}
2502    break;
2503
2504  case 66:
2505#line 707 "ftpcmd.y"
2506    {
2507		    if ((yyvsp[(5) - (5)].i))
2508			prot((yyvsp[(3) - (5)].s));
2509		}
2510    break;
2511
2512  case 67:
2513#line 712 "ftpcmd.y"
2514    {
2515		    if ((yyvsp[(3) - (3)].i))
2516			ccc();
2517		}
2518    break;
2519
2520  case 68:
2521#line 717 "ftpcmd.y"
2522    {
2523			mec((yyvsp[(3) - (4)].s), prot_safe);
2524			free((yyvsp[(3) - (4)].s));
2525		}
2526    break;
2527
2528  case 69:
2529#line 722 "ftpcmd.y"
2530    {
2531			mec((yyvsp[(3) - (4)].s), prot_confidential);
2532			free((yyvsp[(3) - (4)].s));
2533		}
2534    break;
2535
2536  case 70:
2537#line 727 "ftpcmd.y"
2538    {
2539			mec((yyvsp[(3) - (4)].s), prot_private);
2540			free((yyvsp[(3) - (4)].s));
2541		}
2542    break;
2543
2544  case 72:
2545#line 739 "ftpcmd.y"
2546    {
2547			(yyval.s) = (char *)calloc(1, sizeof(char));
2548		}
2549    break;
2550
2551  case 75:
2552#line 752 "ftpcmd.y"
2553    {
2554			struct sockaddr_in *sin4 = (struct sockaddr_in *)data_dest;
2555
2556			sin4->sin_family = AF_INET;
2557			sin4->sin_port = htons((yyvsp[(9) - (11)].i) * 256 + (yyvsp[(11) - (11)].i));
2558			sin4->sin_addr.s_addr =
2559			    htonl(((yyvsp[(1) - (11)].i) << 24) | ((yyvsp[(3) - (11)].i) << 16) | ((yyvsp[(5) - (11)].i) << 8) | (yyvsp[(7) - (11)].i));
2560		}
2561    break;
2562
2563  case 76:
2564#line 764 "ftpcmd.y"
2565    {
2566			(yyval.i) = FORM_N;
2567		}
2568    break;
2569
2570  case 77:
2571#line 768 "ftpcmd.y"
2572    {
2573			(yyval.i) = FORM_T;
2574		}
2575    break;
2576
2577  case 78:
2578#line 772 "ftpcmd.y"
2579    {
2580			(yyval.i) = FORM_C;
2581		}
2582    break;
2583
2584  case 79:
2585#line 779 "ftpcmd.y"
2586    {
2587			cmd_type = TYPE_A;
2588			cmd_form = FORM_N;
2589		}
2590    break;
2591
2592  case 80:
2593#line 784 "ftpcmd.y"
2594    {
2595			cmd_type = TYPE_A;
2596			cmd_form = (yyvsp[(3) - (3)].i);
2597		}
2598    break;
2599
2600  case 81:
2601#line 789 "ftpcmd.y"
2602    {
2603			cmd_type = TYPE_E;
2604			cmd_form = FORM_N;
2605		}
2606    break;
2607
2608  case 82:
2609#line 794 "ftpcmd.y"
2610    {
2611			cmd_type = TYPE_E;
2612			cmd_form = (yyvsp[(3) - (3)].i);
2613		}
2614    break;
2615
2616  case 83:
2617#line 799 "ftpcmd.y"
2618    {
2619			cmd_type = TYPE_I;
2620		}
2621    break;
2622
2623  case 84:
2624#line 803 "ftpcmd.y"
2625    {
2626			cmd_type = TYPE_L;
2627			cmd_bytesz = NBBY;
2628		}
2629    break;
2630
2631  case 85:
2632#line 808 "ftpcmd.y"
2633    {
2634			cmd_type = TYPE_L;
2635			cmd_bytesz = (yyvsp[(3) - (3)].i);
2636		}
2637    break;
2638
2639  case 86:
2640#line 814 "ftpcmd.y"
2641    {
2642			cmd_type = TYPE_L;
2643			cmd_bytesz = (yyvsp[(2) - (2)].i);
2644		}
2645    break;
2646
2647  case 87:
2648#line 822 "ftpcmd.y"
2649    {
2650			(yyval.i) = STRU_F;
2651		}
2652    break;
2653
2654  case 88:
2655#line 826 "ftpcmd.y"
2656    {
2657			(yyval.i) = STRU_R;
2658		}
2659    break;
2660
2661  case 89:
2662#line 830 "ftpcmd.y"
2663    {
2664			(yyval.i) = STRU_P;
2665		}
2666    break;
2667
2668  case 90:
2669#line 837 "ftpcmd.y"
2670    {
2671			(yyval.i) = MODE_S;
2672		}
2673    break;
2674
2675  case 91:
2676#line 841 "ftpcmd.y"
2677    {
2678			(yyval.i) = MODE_B;
2679		}
2680    break;
2681
2682  case 92:
2683#line 845 "ftpcmd.y"
2684    {
2685			(yyval.i) = MODE_C;
2686		}
2687    break;
2688
2689  case 93:
2690#line 852 "ftpcmd.y"
2691    {
2692			/*
2693			 * Problem: this production is used for all pathname
2694			 * processing, but only gives a 550 error reply.
2695			 * This is a valid reply in some cases but not in others.
2696			 */
2697			if (logged_in && (yyvsp[(1) - (1)].s) && *(yyvsp[(1) - (1)].s) == '~') {
2698				glob_t gl;
2699				int flags =
2700				 GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
2701
2702				memset(&gl, 0, sizeof(gl));
2703				if (glob((yyvsp[(1) - (1)].s), flags, NULL, &gl) ||
2704				    gl.gl_pathc == 0) {
2705					reply(550, "not found");
2706					(yyval.s) = NULL;
2707				} else {
2708					(yyval.s) = strdup(gl.gl_pathv[0]);
2709				}
2710				globfree(&gl);
2711				free((yyvsp[(1) - (1)].s));
2712			} else
2713				(yyval.s) = (yyvsp[(1) - (1)].s);
2714		}
2715    break;
2716
2717  case 95:
2718#line 884 "ftpcmd.y"
2719    {
2720			int ret, dec, multby, digit;
2721
2722			/*
2723			 * Convert a number that was read as decimal number
2724			 * to what it would be if it had been read as octal.
2725			 */
2726			dec = (yyvsp[(1) - (1)].i);
2727			multby = 1;
2728			ret = 0;
2729			while (dec) {
2730				digit = dec%10;
2731				if (digit > 7) {
2732					ret = -1;
2733					break;
2734				}
2735				ret += digit * multby;
2736				multby *= 8;
2737				dec /= 10;
2738			}
2739			(yyval.i) = ret;
2740		}
2741    break;
2742
2743  case 96:
2744#line 910 "ftpcmd.y"
2745    {
2746			(yyval.i) = (yyvsp[(1) - (1)].i) && !guest;
2747			if((yyvsp[(1) - (1)].i) && !(yyval.i))
2748				reply(550, "Permission denied");
2749		}
2750    break;
2751
2752  case 97:
2753#line 918 "ftpcmd.y"
2754    {
2755		    if((yyvsp[(1) - (1)].i)) {
2756			if(((yyval.i) = logged_in) == 0)
2757			    reply(530, "Please login with USER and PASS.");
2758		    } else
2759			(yyval.i) = 0;
2760		}
2761    break;
2762
2763  case 98:
2764#line 928 "ftpcmd.y"
2765    {
2766		    (yyval.i) = 1;
2767		    if(sec_complete && !ccc_passed && !secure_command()) {
2768			(yyval.i) = 0;
2769			reply(533, "Command protection level denied "
2770			      "for paranoid reasons.");
2771		    }
2772		}
2773    break;
2774
2775
2776/* Line 1267 of yacc.c.  */
2777#line 2778 "ftpcmd.c"
2778      default: break;
2779    }
2780  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2781
2782  YYPOPSTACK (yylen);
2783  yylen = 0;
2784  YY_STACK_PRINT (yyss, yyssp);
2785
2786  *++yyvsp = yyval;
2787
2788
2789  /* Now `shift' the result of the reduction.  Determine what state
2790     that goes to, based on the state we popped back to and the rule
2791     number reduced by.  */
2792
2793  yyn = yyr1[yyn];
2794
2795  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2796  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2797    yystate = yytable[yystate];
2798  else
2799    yystate = yydefgoto[yyn - YYNTOKENS];
2800
2801  goto yynewstate;
2802
2803
2804/*------------------------------------.
2805| yyerrlab -- here on detecting error |
2806`------------------------------------*/
2807yyerrlab:
2808  /* If not already recovering from an error, report this error.  */
2809  if (!yyerrstatus)
2810    {
2811      ++yynerrs;
2812#if ! YYERROR_VERBOSE
2813      yyerror (YY_("syntax error"));
2814#else
2815      {
2816	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2817	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2818	  {
2819	    YYSIZE_T yyalloc = 2 * yysize;
2820	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2821	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
2822	    if (yymsg != yymsgbuf)
2823	      YYSTACK_FREE (yymsg);
2824	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2825	    if (yymsg)
2826	      yymsg_alloc = yyalloc;
2827	    else
2828	      {
2829		yymsg = yymsgbuf;
2830		yymsg_alloc = sizeof yymsgbuf;
2831	      }
2832	  }
2833
2834	if (0 < yysize && yysize <= yymsg_alloc)
2835	  {
2836	    (void) yysyntax_error (yymsg, yystate, yychar);
2837	    yyerror (yymsg);
2838	  }
2839	else
2840	  {
2841	    yyerror (YY_("syntax error"));
2842	    if (yysize != 0)
2843	      goto yyexhaustedlab;
2844	  }
2845      }
2846#endif
2847    }
2848
2849
2850
2851  if (yyerrstatus == 3)
2852    {
2853      /* If just tried and failed to reuse look-ahead token after an
2854	 error, discard it.  */
2855
2856      if (yychar <= YYEOF)
2857	{
2858	  /* Return failure if at end of input.  */
2859	  if (yychar == YYEOF)
2860	    YYABORT;
2861	}
2862      else
2863	{
2864	  yydestruct ("Error: discarding",
2865		      yytoken, &yylval);
2866	  yychar = YYEMPTY;
2867	}
2868    }
2869
2870  /* Else will try to reuse look-ahead token after shifting the error
2871     token.  */
2872  goto yyerrlab1;
2873
2874
2875/*---------------------------------------------------.
2876| yyerrorlab -- error raised explicitly by YYERROR.  |
2877`---------------------------------------------------*/
2878yyerrorlab:
2879
2880  /* Pacify compilers like GCC when the user code never invokes
2881     YYERROR and the label yyerrorlab therefore never appears in user
2882     code.  */
2883  if (/*CONSTCOND*/ 0)
2884     goto yyerrorlab;
2885
2886  /* Do not reclaim the symbols of the rule which action triggered
2887     this YYERROR.  */
2888  YYPOPSTACK (yylen);
2889  yylen = 0;
2890  YY_STACK_PRINT (yyss, yyssp);
2891  yystate = *yyssp;
2892  goto yyerrlab1;
2893
2894
2895/*-------------------------------------------------------------.
2896| yyerrlab1 -- common code for both syntax error and YYERROR.  |
2897`-------------------------------------------------------------*/
2898yyerrlab1:
2899  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
2900
2901  for (;;)
2902    {
2903      yyn = yypact[yystate];
2904      if (yyn != YYPACT_NINF)
2905	{
2906	  yyn += YYTERROR;
2907	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2908	    {
2909	      yyn = yytable[yyn];
2910	      if (0 < yyn)
2911		break;
2912	    }
2913	}
2914
2915      /* Pop the current state because it cannot handle the error token.  */
2916      if (yyssp == yyss)
2917	YYABORT;
2918
2919
2920      yydestruct ("Error: popping",
2921		  yystos[yystate], yyvsp);
2922      YYPOPSTACK (1);
2923      yystate = *yyssp;
2924      YY_STACK_PRINT (yyss, yyssp);
2925    }
2926
2927  if (yyn == YYFINAL)
2928    YYACCEPT;
2929
2930  *++yyvsp = yylval;
2931
2932
2933  /* Shift the error token.  */
2934  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2935
2936  yystate = yyn;
2937  goto yynewstate;
2938
2939
2940/*-------------------------------------.
2941| yyacceptlab -- YYACCEPT comes here.  |
2942`-------------------------------------*/
2943yyacceptlab:
2944  yyresult = 0;
2945  goto yyreturn;
2946
2947/*-----------------------------------.
2948| yyabortlab -- YYABORT comes here.  |
2949`-----------------------------------*/
2950yyabortlab:
2951  yyresult = 1;
2952  goto yyreturn;
2953
2954#ifndef yyoverflow
2955/*-------------------------------------------------.
2956| yyexhaustedlab -- memory exhaustion comes here.  |
2957`-------------------------------------------------*/
2958yyexhaustedlab:
2959  yyerror (YY_("memory exhausted"));
2960  yyresult = 2;
2961  /* Fall through.  */
2962#endif
2963
2964yyreturn:
2965  if (yychar != YYEOF && yychar != YYEMPTY)
2966     yydestruct ("Cleanup: discarding lookahead",
2967		 yytoken, &yylval);
2968  /* Do not reclaim the symbols of the rule which action triggered
2969     this YYABORT or YYACCEPT.  */
2970  YYPOPSTACK (yylen);
2971  YY_STACK_PRINT (yyss, yyssp);
2972  while (yyssp != yyss)
2973    {
2974      yydestruct ("Cleanup: popping",
2975		  yystos[*yyssp], yyvsp);
2976      YYPOPSTACK (1);
2977    }
2978#ifndef yyoverflow
2979  if (yyss != yyssa)
2980    YYSTACK_FREE (yyss);
2981#endif
2982#if YYERROR_VERBOSE
2983  if (yymsg != yymsgbuf)
2984    YYSTACK_FREE (yymsg);
2985#endif
2986  /* Make sure YYID is used.  */
2987  return YYID (yyresult);
2988}
2989
2990
2991#line 938 "ftpcmd.y"
2992
2993
2994#define	CMD	0	/* beginning of command */
2995#define	ARGS	1	/* expect miscellaneous arguments */
2996#define	STR1	2	/* expect SP followed by STRING */
2997#define	STR2	3	/* expect STRING */
2998#define	OSTR	4	/* optional SP then STRING */
2999#define	ZSTR1	5	/* SP then optional STRING */
3000#define	ZSTR2	6	/* optional STRING after SP */
3001#define	SITECMD	7	/* SITE command */
3002#define	NSTR	8	/* Number followed by a string */
3003
3004struct tab cmdtab[] = {		/* In order defined in RFC 765 */
3005	{ "USER", USER, STR1, 1,	"<sp> username" },
3006	{ "PASS", PASS, ZSTR1, 1,	"<sp> password" },
3007	{ "ACCT", ACCT, STR1, 0,	"(specify account)" },
3008	{ "SMNT", SMNT, ARGS, 0,	"(structure mount)" },
3009	{ "REIN", REIN, ARGS, 0,	"(reinitialize server state)" },
3010	{ "QUIT", QUIT, ARGS, 1,	"(terminate service)", },
3011	{ "PORT", PORT, ARGS, 1,	"<sp> b0, b1, b2, b3, b4" },
3012	{ "EPRT", EPRT, STR1, 1,	"<sp> string" },
3013	{ "PASV", PASV, ARGS, 1,	"(set server in passive mode)" },
3014	{ "EPSV", EPSV, OSTR, 1,	"[<sp> foo]" },
3015	{ "TYPE", TYPE, ARGS, 1,	"<sp> [ A | E | I | L ]" },
3016	{ "STRU", STRU, ARGS, 1,	"(specify file structure)" },
3017	{ "MODE", MODE, ARGS, 1,	"(specify transfer mode)" },
3018	{ "RETR", RETR, STR1, 1,	"<sp> file-name" },
3019	{ "STOR", STOR, STR1, 1,	"<sp> file-name" },
3020	{ "APPE", APPE, STR1, 1,	"<sp> file-name" },
3021	{ "MLFL", MLFL, OSTR, 0,	"(mail file)" },
3022	{ "MAIL", MAIL, OSTR, 0,	"(mail to user)" },
3023	{ "MSND", MSND, OSTR, 0,	"(mail send to terminal)" },
3024	{ "MSOM", MSOM, OSTR, 0,	"(mail send to terminal or mailbox)" },
3025	{ "MSAM", MSAM, OSTR, 0,	"(mail send to terminal and mailbox)" },
3026	{ "MRSQ", MRSQ, OSTR, 0,	"(mail recipient scheme question)" },
3027	{ "MRCP", MRCP, STR1, 0,	"(mail recipient)" },
3028	{ "ALLO", ALLO, ARGS, 1,	"allocate storage (vacuously)" },
3029	{ "REST", REST, ARGS, 1,	"<sp> offset (restart command)" },
3030	{ "RNFR", RNFR, STR1, 1,	"<sp> file-name" },
3031	{ "RNTO", RNTO, STR1, 1,	"<sp> file-name" },
3032	{ "ABOR", ABOR, ARGS, 1,	"(abort operation)" },
3033	{ "DELE", DELE, STR1, 1,	"<sp> file-name" },
3034	{ "CWD",  CWD,  OSTR, 1,	"[ <sp> directory-name ]" },
3035	{ "XCWD", CWD,	OSTR, 1,	"[ <sp> directory-name ]" },
3036	{ "LIST", LIST, OSTR, 1,	"[ <sp> path-name ]" },
3037	{ "NLST", NLST, OSTR, 1,	"[ <sp> path-name ]" },
3038	{ "SITE", SITE, SITECMD, 1,	"site-cmd [ <sp> arguments ]" },
3039	{ "SYST", SYST, ARGS, 1,	"(get type of operating system)" },
3040	{ "STAT", sTAT, OSTR, 1,	"[ <sp> path-name ]" },
3041	{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
3042	{ "NOOP", NOOP, ARGS, 1,	"" },
3043	{ "MKD",  MKD,  STR1, 1,	"<sp> path-name" },
3044	{ "XMKD", MKD,  STR1, 1,	"<sp> path-name" },
3045	{ "RMD",  RMD,  STR1, 1,	"<sp> path-name" },
3046	{ "XRMD", RMD,  STR1, 1,	"<sp> path-name" },
3047	{ "PWD",  PWD,  ARGS, 1,	"(return current directory)" },
3048	{ "XPWD", PWD,  ARGS, 1,	"(return current directory)" },
3049	{ "CDUP", CDUP, ARGS, 1,	"(change to parent directory)" },
3050	{ "XCUP", CDUP, ARGS, 1,	"(change to parent directory)" },
3051	{ "STOU", STOU, STR1, 1,	"<sp> file-name" },
3052	{ "SIZE", SIZE, OSTR, 1,	"<sp> path-name" },
3053	{ "MDTM", MDTM, OSTR, 1,	"<sp> path-name" },
3054
3055	/* extensions from RFC2228 */
3056	{ "AUTH", AUTH,	STR1, 1,	"<sp> auth-type" },
3057	{ "ADAT", ADAT,	STR1, 1,	"<sp> auth-data" },
3058	{ "PBSZ", PBSZ,	ARGS, 1,	"<sp> buffer-size" },
3059	{ "PROT", PROT,	STR1, 1,	"<sp> prot-level" },
3060	{ "CCC",  CCC,	ARGS, 1,	"" },
3061	{ "MIC",  MIC,	STR1, 1,	"<sp> integrity command" },
3062	{ "CONF", CONF,	STR1, 1,	"<sp> confidentiality command" },
3063	{ "ENC",  ENC,	STR1, 1,	"<sp> privacy command" },
3064
3065	/* RFC2389 */
3066	{ "FEAT", FEAT, ARGS, 1,	"" },
3067	{ "OPTS", OPTS, ARGS, 1,	"<sp> command [<sp> options]" },
3068
3069	{ NULL,   0,    0,    0,	0 }
3070};
3071
3072struct tab sitetab[] = {
3073	{ "UMASK", UMASK, ARGS, 1,	"[ <sp> umask ]" },
3074	{ "IDLE", IDLE, ARGS, 1,	"[ <sp> maximum-idle-time ]" },
3075	{ "CHMOD", CHMOD, NSTR, 1,	"<sp> mode <sp> file-name" },
3076	{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
3077
3078	{ "KAUTH", KAUTH, STR1, 1,	"<sp> principal [ <sp> ticket ]" },
3079	{ "KLIST", KLIST, ARGS, 1,	"(show ticket file)" },
3080	{ "KDESTROY", KDESTROY, ARGS, 1, "(destroy tickets)" },
3081	{ "KRBTKFILE", KRBTKFILE, STR1, 1, "<sp> ticket-file" },
3082	{ "AFSLOG", AFSLOG, OSTR, 1,	"[<sp> cell]" },
3083
3084	{ "LOCATE", LOCATE, STR1, 1,	"<sp> globexpr" },
3085	{ "FIND", LOCATE, STR1, 1,	"<sp> globexpr" },
3086
3087	{ "URL",  URL,  ARGS, 1,	"?" },
3088
3089	{ NULL,   0,    0,    0,	0 }
3090};
3091
3092static struct tab *
3093lookup(struct tab *p, char *cmd)
3094{
3095
3096	for (; p->name != NULL; p++)
3097		if (strcmp(cmd, p->name) == 0)
3098			return (p);
3099	return (0);
3100}
3101
3102/*
3103 * ftpd_getline - a hacked up version of fgets to ignore TELNET escape codes.
3104 */
3105char *
3106ftpd_getline(char *s, int n)
3107{
3108	int c;
3109	char *cs;
3110
3111	cs = s;
3112
3113	/* might still be data within the security MIC/CONF/ENC */
3114	if(ftp_command){
3115	    strlcpy(s, ftp_command, n);
3116	    if (debug)
3117		syslog(LOG_DEBUG, "command: %s", s);
3118	    return s;
3119	}
3120	while ((c = getc(stdin)) != EOF) {
3121		c &= 0377;
3122		if (c == IAC) {
3123		    if ((c = getc(stdin)) != EOF) {
3124			c &= 0377;
3125			switch (c) {
3126			case WILL:
3127			case WONT:
3128				c = getc(stdin);
3129				printf("%c%c%c", IAC, DONT, 0377&c);
3130				fflush(stdout);
3131				continue;
3132			case DO:
3133			case DONT:
3134				c = getc(stdin);
3135				printf("%c%c%c", IAC, WONT, 0377&c);
3136				fflush(stdout);
3137				continue;
3138			case IAC:
3139				break;
3140			default:
3141				continue;	/* ignore command */
3142			}
3143		    }
3144		}
3145		*cs++ = c;
3146		if (--n <= 0 || c == '\n')
3147			break;
3148	}
3149	if (c == EOF && cs == s)
3150		return (NULL);
3151	*cs++ = '\0';
3152	if (debug) {
3153		if (!guest && strncasecmp("pass ", s, 5) == 0) {
3154			/* Don't syslog passwords */
3155			syslog(LOG_DEBUG, "command: %.5s ???", s);
3156		} else {
3157			char *cp;
3158			int len;
3159
3160			/* Don't syslog trailing CR-LF */
3161			len = strlen(s);
3162			cp = s + len - 1;
3163			while (cp >= s && (*cp == '\n' || *cp == '\r')) {
3164				--cp;
3165				--len;
3166			}
3167			syslog(LOG_DEBUG, "command: %.*s", len, s);
3168		}
3169	}
3170#ifdef XXX
3171	fprintf(stderr, "%s\n", s);
3172#endif
3173	return (s);
3174}
3175
3176static RETSIGTYPE
3177toolong(int signo)
3178{
3179
3180	reply(421,
3181	    "Timeout (%d seconds): closing control connection.",
3182	      ftpd_timeout);
3183	if (logging)
3184		syslog(LOG_INFO, "User %s timed out after %d seconds",
3185		    (pw ? pw -> pw_name : "unknown"), ftpd_timeout);
3186	dologout(1);
3187	SIGRETURN(0);
3188}
3189
3190static int
3191yylex(void)
3192{
3193	static int cpos, state;
3194	char *cp, *cp2;
3195	struct tab *p;
3196	int n;
3197	char c;
3198
3199	for (;;) {
3200		switch (state) {
3201
3202		case CMD:
3203			hasyyerrored = 0;
3204
3205			signal(SIGALRM, toolong);
3206			alarm((unsigned) ftpd_timeout);
3207			if (ftpd_getline(cbuf, sizeof(cbuf)-1) == NULL) {
3208				reply(221, "You could at least say goodbye.");
3209				dologout(0);
3210			}
3211			alarm(0);
3212#ifdef HAVE_SETPROCTITLE
3213			if (strncasecmp(cbuf, "PASS", 4) != 0)
3214				setproctitle("%s: %s", proctitle, cbuf);
3215#endif /* HAVE_SETPROCTITLE */
3216			if ((cp = strchr(cbuf, '\r'))) {
3217				*cp++ = '\n';
3218				*cp = '\0';
3219			}
3220			if ((cp = strpbrk(cbuf, " \n")))
3221				cpos = cp - cbuf;
3222			if (cpos == 0)
3223				cpos = 4;
3224			c = cbuf[cpos];
3225			cbuf[cpos] = '\0';
3226			strupr(cbuf);
3227			p = lookup(cmdtab, cbuf);
3228			cbuf[cpos] = c;
3229			if (p != 0) {
3230				if (p->implemented == 0) {
3231					nack(p->name);
3232					hasyyerrored = 1;
3233					break;
3234				}
3235				state = p->state;
3236				yylval.s = p->name;
3237				return (p->token);
3238			}
3239			break;
3240
3241		case SITECMD:
3242			if (cbuf[cpos] == ' ') {
3243				cpos++;
3244				return (SP);
3245			}
3246			cp = &cbuf[cpos];
3247			if ((cp2 = strpbrk(cp, " \n")))
3248				cpos = cp2 - cbuf;
3249			c = cbuf[cpos];
3250			cbuf[cpos] = '\0';
3251			strupr(cp);
3252			p = lookup(sitetab, cp);
3253			cbuf[cpos] = c;
3254			if (p != 0) {
3255				if (p->implemented == 0) {
3256					state = CMD;
3257					nack(p->name);
3258					hasyyerrored = 1;
3259					break;
3260				}
3261				state = p->state;
3262				yylval.s = p->name;
3263				return (p->token);
3264			}
3265			state = CMD;
3266			break;
3267
3268		case OSTR:
3269			if (cbuf[cpos] == '\n') {
3270				state = CMD;
3271				return (CRLF);
3272			}
3273			/* FALLTHROUGH */
3274
3275		case STR1:
3276		case ZSTR1:
3277		dostr1:
3278			if (cbuf[cpos] == ' ') {
3279				cpos++;
3280				if(state == OSTR)
3281				    state = STR2;
3282				else
3283				    state++;
3284				return (SP);
3285			}
3286			break;
3287
3288		case ZSTR2:
3289			if (cbuf[cpos] == '\n') {
3290				state = CMD;
3291				return (CRLF);
3292			}
3293			/* FALLTHROUGH */
3294
3295		case STR2:
3296			cp = &cbuf[cpos];
3297			n = strlen(cp);
3298			cpos += n - 1;
3299			/*
3300			 * Make sure the string is nonempty and \n terminated.
3301			 */
3302			if (n > 1 && cbuf[cpos] == '\n') {
3303				cbuf[cpos] = '\0';
3304				yylval.s = copy(cp);
3305				cbuf[cpos] = '\n';
3306				state = ARGS;
3307				return (STRING);
3308			}
3309			break;
3310
3311		case NSTR:
3312			if (cbuf[cpos] == ' ') {
3313				cpos++;
3314				return (SP);
3315			}
3316			if (isdigit((unsigned char)cbuf[cpos])) {
3317				cp = &cbuf[cpos];
3318				while (isdigit((unsigned char)cbuf[++cpos]))
3319					;
3320				c = cbuf[cpos];
3321				cbuf[cpos] = '\0';
3322				yylval.i = atoi(cp);
3323				cbuf[cpos] = c;
3324				state = STR1;
3325				return (NUMBER);
3326			}
3327			state = STR1;
3328			goto dostr1;
3329
3330		case ARGS:
3331			if (isdigit((unsigned char)cbuf[cpos])) {
3332				cp = &cbuf[cpos];
3333				while (isdigit((unsigned char)cbuf[++cpos]))
3334					;
3335				c = cbuf[cpos];
3336				cbuf[cpos] = '\0';
3337				yylval.i = atoi(cp);
3338				cbuf[cpos] = c;
3339				return (NUMBER);
3340			}
3341			switch (cbuf[cpos++]) {
3342
3343			case '\n':
3344				state = CMD;
3345				return (CRLF);
3346
3347			case ' ':
3348				return (SP);
3349
3350			case ',':
3351				return (COMMA);
3352
3353			case 'A':
3354			case 'a':
3355				return (A);
3356
3357			case 'B':
3358			case 'b':
3359				return (B);
3360
3361			case 'C':
3362			case 'c':
3363				return (C);
3364
3365			case 'E':
3366			case 'e':
3367				return (E);
3368
3369			case 'F':
3370			case 'f':
3371				return (F);
3372
3373			case 'I':
3374			case 'i':
3375				return (I);
3376
3377			case 'L':
3378			case 'l':
3379				return (L);
3380
3381			case 'N':
3382			case 'n':
3383				return (N);
3384
3385			case 'P':
3386			case 'p':
3387				return (P);
3388
3389			case 'R':
3390			case 'r':
3391				return (R);
3392
3393			case 'S':
3394			case 's':
3395				return (S);
3396
3397			case 'T':
3398			case 't':
3399				return (T);
3400
3401			}
3402			break;
3403
3404		default:
3405			fatal("Unknown state in scanner.");
3406		}
3407		yyerror(NULL);
3408		state = CMD;
3409		return (0);
3410	}
3411}
3412
3413/* ARGSUSED */
3414void
3415yyerror(char *s)
3416{
3417	char *cp;
3418
3419	if (hasyyerrored)
3420	    return;
3421
3422	if ((cp = strchr(cbuf,'\n')))
3423		*cp = '\0';
3424	reply(500, "'%s': command not understood.", cbuf);
3425	hasyyerrored = 1;
3426}
3427
3428static char *
3429copy(char *s)
3430{
3431	char *p;
3432
3433	p = strdup(s);
3434	if (p == NULL)
3435		fatal("Ran out of memory.");
3436	return p;
3437}
3438
3439static void
3440help(struct tab *ctab, char *s)
3441{
3442	struct tab *c;
3443	int width, NCMDS;
3444	char *t;
3445	char buf[1024];
3446
3447	if (ctab == sitetab)
3448		t = "SITE ";
3449	else
3450		t = "";
3451	width = 0, NCMDS = 0;
3452	for (c = ctab; c->name != NULL; c++) {
3453		int len = strlen(c->name);
3454
3455		if (len > width)
3456			width = len;
3457		NCMDS++;
3458	}
3459	width = (width + 8) &~ 7;
3460	if (s == 0) {
3461		int i, j, w;
3462		int columns, lines;
3463
3464		lreply(214, "The following %scommands are recognized %s.",
3465		    t, "(* =>'s unimplemented)");
3466		columns = 76 / width;
3467		if (columns == 0)
3468			columns = 1;
3469		lines = (NCMDS + columns - 1) / columns;
3470		for (i = 0; i < lines; i++) {
3471		    strlcpy (buf, "   ", sizeof(buf));
3472		    for (j = 0; j < columns; j++) {
3473			c = ctab + j * lines + i;
3474			snprintf (buf + strlen(buf),
3475				  sizeof(buf) - strlen(buf),
3476				  "%s%c",
3477				  c->name,
3478				  c->implemented ? ' ' : '*');
3479			if (c + lines >= &ctab[NCMDS])
3480			    break;
3481			w = strlen(c->name) + 1;
3482			while (w < width) {
3483			    strlcat (buf,
3484					     " ",
3485					     sizeof(buf));
3486			    w++;
3487			}
3488		    }
3489		    lreply(214, "%s", buf);
3490		}
3491		reply(214, "Direct comments to kth-krb-bugs@pdc.kth.se");
3492		return;
3493	}
3494	strupr(s);
3495	c = lookup(ctab, s);
3496	if (c == (struct tab *)0) {
3497		reply(502, "Unknown command %s.", s);
3498		return;
3499	}
3500	if (c->implemented)
3501		reply(214, "Syntax: %s%s %s", t, c->name, c->help);
3502	else
3503		reply(214, "%s%-*s\t%s; unimplemented.", t, width,
3504		    c->name, c->help);
3505}
3506
3507static void
3508sizecmd(char *filename)
3509{
3510	switch (type) {
3511	case TYPE_L:
3512	case TYPE_I: {
3513		struct stat stbuf;
3514		if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
3515			reply(550, "%s: not a plain file.", filename);
3516		else
3517			reply(213, "%lu", (unsigned long)stbuf.st_size);
3518		break;
3519	}
3520	case TYPE_A: {
3521		FILE *fin;
3522		int c;
3523		size_t count;
3524		struct stat stbuf;
3525		fin = fopen(filename, "r");
3526		if (fin == NULL) {
3527			perror_reply(550, filename);
3528			return;
3529		}
3530		if (fstat(fileno(fin), &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
3531			reply(550, "%s: not a plain file.", filename);
3532			fclose(fin);
3533			return;
3534		}
3535
3536		count = 0;
3537		while((c=getc(fin)) != EOF) {
3538			if (c == '\n')	/* will get expanded to \r\n */
3539				count++;
3540			count++;
3541		}
3542		fclose(fin);
3543
3544		reply(213, "%lu", (unsigned long)count);
3545		break;
3546	}
3547	default:
3548		reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
3549	}
3550}
3551
3552