/* original parser id follows */
/* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */

#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9

#define YYEMPTY        (-1)
#define yyclearin      (yychar = YYEMPTY)
#define yyerrok        (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#define YYENOMEM       (-2)
#define YYEOF          0
#undef YYBTYACC
#define YYBTYACC 0
#define YYDEBUGSTR YYPREFIX "debug"
#define YYPREFIX "yy"

#define YYPURE 0

#line 32 "ftpcmd.y"

#include "config.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "../support/ftp.h"
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <ctype.h>
#include <pwd.h>
#include <setjmp.h>
#ifdef HAVE_SYS_SYSLOG_H
#include <sys/syslog.h>
#endif
#if defined(HAVE_SYSLOG_H) || (!defined(AUTOCONF) && !defined(HAVE_SYS_SYSLOG_H))
#include <syslog.h>
#endif
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "extensions.h"
#include "pathnames.h"
#include "proto.h"

extern int dolreplies;
#ifndef INTERNAL_LS
extern char ls_long[50];
extern char ls_short[50];
#endif
extern struct sockaddr_in data_dest;
extern struct sockaddr_in his_addr;	/* added.  _H */
extern int logged_in;
extern struct passwd *pw;
extern int anonymous;
extern int logging;
extern int log_commands;
extern int log_security;
extern int type;
extern int form;
extern int debug;
extern unsigned int timeout_idle;
extern unsigned int timeout_maxidle;
extern int pdata;
extern char hostname[], remotehost[], *remoteident;
extern char remoteaddr[];
extern char chroot_path[];
extern char guestpw[], authuser[];	/* added.  _H */
extern char proctitle[];
extern char *globerr;
extern int usedefault;
extern int transflag;
extern char tmpline[];
extern int data;
extern char *home;

off_t restart_point;
int yyerrorcalled;

extern char *strunames[];
extern char *typenames[];
extern char *modenames[];
extern char *formnames[];
extern int restricted_user;	/* global flag indicating if user is restricted to home directory */

#ifdef TRANSFER_COUNT
extern int data_count_total;
extern int data_count_in;
extern int data_count_out;
extern int byte_count_total;
extern int byte_count_in;
extern int byte_count_out;
extern int file_count_total;
extern int file_count_in;
extern int file_count_out;
extern int xfer_count_total;
extern int xfer_count_in;
extern int xfer_count_out;
#endif

extern int retrieve_is_data;

#ifdef VIRTUAL
extern int virtual_mode;
extern int virtual_ftpaccess;
extern char virtual_email[];
#endif

#ifdef IGNORE_NOOP
static int alarm_running = 0;
#endif

static unsigned short cliport = 0;
static struct in_addr cliaddr;
static int cmd_type;
static int cmd_form;
static int cmd_bytesz;
char cbuf[512];
char *fromname;

/* Debian linux bison fix: moved this up, added forward decls */

struct tab {
    char *name;
    short token;
    short state;
    short implemented;		/* 1 if command is implemented */
    char *help;
};

extern struct tab cmdtab[];
extern struct tab sitetab[];

static void toolong(int);
void help(struct tab *ctab, char *s);
struct tab *lookup(register struct tab *p, char *cmd);
int yylex(void);

static char *nullstr = "(null)";
#define CHECKNULL(p) ((p) ? (p) : nullstr)

extern int pasv_allowed(const char *remoteaddr);
extern int port_allowed(const char *remoteaddr);
#ifdef YYSTYPE
#undef  YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#line 181 "ftpcmd.y"
typedef union {
    char *String;
    int Number;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
#line 163 "y.tab.c"

/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif

/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif

#if !(defined(yylex) || defined(YYSTATE))
int YYLEX_DECL();
#endif

/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif

extern int YYPARSE_DECL();

#define A 257
#define B 258
#define C 259
#define E 260
#define F 261
#define I 262
#define L 263
#define N 264
#define P 265
#define R 266
#define S 267
#define T 268
#define SP 269
#define CRLF 270
#define COMMA 271
#define STRING 272
#define NUMBER 273
#define USER 274
#define PASS 275
#define ACCT 276
#define REIN 277
#define QUIT 278
#define PORT 279
#define PASV 280
#define TYPE 281
#define STRU 282
#define MODE 283
#define RETR 284
#define STOR 285
#define APPE 286
#define MLFL 287
#define MAIL 288
#define MSND 289
#define MSOM 290
#define MSAM 291
#define MRSQ 292
#define MRCP 293
#define ALLO 294
#define REST 295
#define RNFR 296
#define RNTO 297
#define ABOR 298
#define DELE 299
#define CWD 300
#define LIST 301
#define NLST 302
#define SITE 303
#define STAT 304
#define HELP 305
#define NOOP 306
#define MKD 307
#define RMD 308
#define PWD 309
#define CDUP 310
#define STOU 311
#define SMNT 312
#define SYST 313
#define SIZE 314
#define MDTM 315
#define UMASK 316
#define IDLE 317
#define CHMOD 318
#define GROUP 319
#define GPASS 320
#define NEWER 321
#define MINFO 322
#define INDEX 323
#define EXEC 324
#define ALIAS 325
#define CDPATH 326
#define GROUPS 327
#define CHECKMETHOD 328
#define CHECKSUM 329
#define LEXERR 330
#define YYERRCODE 256
typedef int YYINT;
static const YYINT yylhs[] = {                           -1,
    0,    0,    0,   12,   12,   12,   12,   12,   12,   12,
   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
   12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
   12,   12,   12,   12,   12,   13,   13,   13,   13,   13,
   13,   13,   13,   13,   13,    4,    1,    1,    6,   14,
    8,    8,    8,   15,   15,   15,   15,   15,   15,   15,
   15,    9,    9,    9,   10,   10,   10,    2,    3,    5,
   11,    7,
};
static const YYINT yylen[] = {                            2,
    0,    2,    2,    4,    4,    5,    3,    5,    5,    5,
    5,    9,    5,    5,    5,    3,    5,    3,    5,    5,
    3,    5,    5,    3,    3,    5,    3,    5,    3,    5,
    5,    3,    3,    5,    7,    5,    7,    9,    5,    7,
    7,    7,    5,    7,    9,    7,    9,    7,    7,    5,
    3,    5,    5,    2,    2,    5,    5,    5,    7,    5,
    5,    7,    5,    7,    5,    1,    0,    1,    1,   11,
    1,    1,    1,    1,    3,    1,    3,    1,    1,    3,
    2,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    1,    0,
};
static const YYINT yydefred[] = {                         1,
    0,    0,    0,    0,    0,   92,   92,   92,   92,   92,
   92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
   92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
   92,   92,   92,   92,    2,    3,   55,    0,    0,   54,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   66,
    0,   68,    0,    0,    7,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,   24,    0,    0,   25,    0,
   18,    0,   16,    0,    0,   21,    0,   27,   29,    0,
    0,   32,   33,    0,   51,    0,    0,    4,    5,    0,
    0,    0,    0,   78,    0,    0,   82,   84,   83,    0,
   86,   87,   85,    0,   89,    0,   88,    0,    0,    0,
   69,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    6,    0,    0,    0,   81,    8,    9,   10,   13,
   14,   15,    0,   11,   57,   56,   23,   22,   26,   19,
   17,    0,   34,    0,   36,    0,   39,    0,    0,    0,
   43,    0,    0,    0,    0,    0,   58,   61,   60,    0,
   63,    0,   65,   20,   28,   30,   31,   50,   52,   53,
    0,   73,   71,   72,   75,   77,   80,    0,    0,   91,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
   90,    0,    0,    0,    0,   35,   37,   40,    0,   41,
   42,    0,   44,    0,   46,   48,   49,   59,   62,   64,
    0,    0,    0,    0,    0,    0,   12,   38,   45,   47,
    0,    0,    0,    0,   70,
};
#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
static const YYINT yystos[] = {                           0,
  332,  256,  274,  275,  278,  279,  280,  281,  282,  283,
  284,  285,  286,  294,  295,  296,  297,  298,  299,  300,
  301,  302,  303,  304,  305,  306,  307,  308,  309,  310,
  311,  313,  314,  315,  344,  345,  270,  269,  269,  270,
  339,  339,  339,  339,  339,  339,  339,  339,  339,  339,
  339,  339,  339,  339,  339,  339,  339,  339,  339,  339,
  339,  339,  339,  339,  339,  339,  339,  339,  339,  272,
  336,  272,  333,  269,  270,  269,  269,  269,  269,  269,
  269,  269,  269,  269,  269,  270,  269,  269,  270,  269,
  270,  269,  270,  269,  269,  270,  269,  270,  270,  269,
  269,  270,  270,  269,  270,  269,  269,  270,  270,  273,
  346,  257,  260,  262,  263,  347,  261,  265,  266,  341,
  258,  259,  267,  342,  272,  334,  335,  334,  334,  273,
  273,  338,  334,  334,  334,  334,  334,  272,  305,  316,
  317,  318,  319,  320,  321,  322,  323,  324,  325,  326,
  327,  328,  329,  334,  272,  334,  334,  334,  334,  334,
  271,  270,  269,  269,  269,  338,  270,  270,  270,  270,
  270,  270,  269,  270,  270,  270,  270,  270,  270,  270,
  270,  269,  270,  269,  270,  269,  270,  269,  269,  269,
  270,  269,  269,  269,  269,  269,  270,  270,  270,  269,
  270,  269,  270,  270,  270,  270,  270,  270,  270,  270,
  273,  259,  264,  268,  340,  340,  338,  266,  272,  273,
  343,  273,  343,  336,  333,  272,  272,  272,  272,  272,
  272,  337,  334,  271,  269,  270,  270,  270,  269,  270,
  270,  269,  270,  269,  270,  270,  270,  270,  270,  270,
  273,  273,  334,  334,  334,  271,  270,  270,  270,  270,
  273,  271,  273,  271,  273,
};
#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
static const YYINT yydgoto[] = {                          1,
   73,  126,  127,   71,  232,  132,   41,  215,  120,  124,
  221,   35,   36,  111,  116,
};
static const YYINT yysindex[] = {                         0,
 -245, -254, -266, -244, -251,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0, -240, -170,    0,
 -241, -224, -148, -122, -121, -120, -119, -118, -117, -116,
 -115, -114, -163, -113, -257, -226, -169, -112, -164, -161,
 -110, -111, -108, -107, -105, -103, -102, -100,  -99,    0,
  -97,    0,  -96, -106,    0, -215, -162, -236, -101, -101,
 -101,  -95,  -94, -101, -101,    0, -101, -101,    0, -101,
    0,  -92,    0, -193, -101,    0,  -91,    0,    0, -101,
 -101,    0,    0, -101,    0, -101, -101,    0,    0,  -89,
  -93,  -86,  -85,    0, -267,  -84,    0,    0,    0,  -83,
    0,    0,    0,  -82,    0,  -81,    0,  -79,  -78, -159,
    0,  -77,  -76,  -75,  -74,  -73,  -72,  -71, -156, -154,
 -152,  -69,  -68, -150,  -67,  -66,  -65,  -64, -132,  -63,
  -62, -130, -128,  -61,  -60,  -59,  -58,  -57,  -56,  -55,
  -88,    0, -250, -250,  -94,    0,    0,    0,    0,    0,
    0,    0,  -90,    0,    0,    0,    0,    0,    0,    0,
    0,  -54,    0,  -53,    0,  -52,    0,  -53, -240, -170,
    0,  -50,  -49,  -48,  -47,  -46,    0,    0,    0,  -45,
    0, -101,    0,    0,    0,    0,    0,    0,    0,    0,
  -43,    0,    0,    0,    0,    0,    0,  -40,  -51,    0,
  -39,  -38,  -36,  -35,  -34, -126, -124,  -33,  -32,  -31,
    0,  -30,  -29,  -28,  -27,    0,    0,    0, -101,    0,
    0, -101,    0, -101,    0,    0,    0,    0,    0,    0,
  -41,  -26,  -23,  -22,  -21,  -20,    0,    0,    0,    0,
  -37,  -19,  -16,  -17,    0,
};
static const YYINT yyrindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,  -18,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  -13,  -12,    0,  -11,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  -18,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,
};
#if YYBTYACC
static const YYINT yycindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,
};
#endif
static const YYINT yygindex[] = {                         0,
  -15,  -80,    0,    1,    0,  -98,   64,    8,    0,    0,
   18,    0,    0,    0,    0,
};
#define YYTABLESIZE 259
static const YYINT yytable[] = {                        128,
  129,  165,   38,  133,  134,  131,  135,  136,  212,  137,
    2,   88,   89,  213,  154,   37,  166,  214,   40,  156,
  157,  121,  122,  158,   39,  159,  160,   74,    3,    4,
  123,   70,    5,    6,    7,    8,    9,   10,   11,   12,
   13,  112,   90,   91,  113,   75,  114,  115,   14,   15,
   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,
   26,   27,   28,   29,   30,   31,  217,   32,   33,   34,
   42,   43,   44,   45,   46,   47,   48,   49,   50,   51,
   52,   53,   54,   55,   56,   57,   58,   59,   60,   61,
   62,   63,   64,   65,   66,   67,   68,   69,  117,   92,
   93,   72,  118,  119,   95,   96,   86,   97,   98,  173,
  174,  139,  182,  183,  184,  185,  186,  187,  190,  191,
   76,  233,  140,  141,  142,  143,  144,  145,  146,  147,
  148,  149,  150,  151,  152,  153,  196,  197,  200,  201,
  202,  203,  242,  243,  244,  245,   77,   78,   79,   80,
   81,   82,   83,   84,   85,   87,   94,  100,  253,   99,
  101,  254,  102,  255,  103,  104,  110,  105,  106,  107,
  125,  216,  108,  109,  225,  218,  162,  130,  131,  138,
  155,  161,  163,  164,  211,  167,  168,  169,  170,  224,
  171,  172,  175,  176,  177,  178,  179,  180,  181,  188,
  189,  192,  193,  194,  195,  223,  198,  199,  204,  205,
  206,  207,  208,  209,  210,    0,    0,  219,  236,  220,
  222,  226,  227,  228,  229,  230,  231,  234,  235,  256,
  237,  238,  239,  262,  240,  241,  246,  247,  248,  249,
  250,    0,    0,  257,  251,  252,  258,  259,  260,    0,
    0,   67,  261,  263,  264,  265,   74,   76,   79,
};
static const YYINT yycheck[] = {                         80,
   81,  269,  269,   84,   85,  273,   87,   88,  259,   90,
  256,  269,  270,  264,   95,  270,  115,  268,  270,  100,
  101,  258,  259,  104,  269,  106,  107,  269,  274,  275,
  267,  272,  278,  279,  280,  281,  282,  283,  284,  285,
  286,  257,  269,  270,  260,  270,  262,  263,  294,  295,
  296,  297,  298,  299,  300,  301,  302,  303,  304,  305,
  306,  307,  308,  309,  310,  311,  165,  313,  314,  315,
    7,    8,    9,   10,   11,   12,   13,   14,   15,   16,
   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
   27,   28,   29,   30,   31,   32,   33,   34,  261,  269,
  270,  272,  265,  266,  269,  270,  270,  269,  270,  269,
  270,  305,  269,  270,  269,  270,  269,  270,  269,  270,
  269,  202,  316,  317,  318,  319,  320,  321,  322,  323,
  324,  325,  326,  327,  328,  329,  269,  270,  269,  270,
  269,  270,  269,  270,  269,  270,  269,  269,  269,  269,
  269,  269,  269,  269,  269,  269,  269,  269,  239,  270,
  269,  242,  270,  244,  270,  269,  273,  270,  269,  269,
  272,  164,  270,  270,  190,  266,  270,  273,  273,  272,
  272,  271,  269,  269,  273,  270,  270,  270,  270,  189,
  270,  270,  270,  270,  270,  270,  270,  270,  270,  269,
  269,  269,  269,  269,  269,  188,  270,  270,  270,  270,
  270,  270,  270,  270,  270,   -1,   -1,  272,  270,  273,
  273,  272,  272,  272,  272,  272,  272,  271,  269,  271,
  270,  270,  269,  271,  270,  270,  270,  270,  270,  270,
  270,   -1,   -1,  270,  273,  273,  270,  270,  270,   -1,
   -1,  270,  273,  273,  271,  273,  270,  270,  270,
};
#if YYBTYACC
static const YYINT yyctable[] = {                        -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
};
#endif
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 330
#define YYUNDFTOKEN 348
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
#if YYDEBUG
static const char *const yyname[] = {

"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","A","B","C","E","F","I","L","N",
"P","R","S","T","SP","CRLF","COMMA","STRING","NUMBER","USER","PASS","ACCT",
"REIN","QUIT","PORT","PASV","TYPE","STRU","MODE","RETR","STOR","APPE","MLFL",
"MAIL","MSND","MSOM","MSAM","MRSQ","MRCP","ALLO","REST","RNFR","RNTO","ABOR",
"DELE","CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP",
"STOU","SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","GROUP","GPASS",
"NEWER","MINFO","INDEX","EXEC","ALIAS","CDPATH","GROUPS","CHECKMETHOD",
"CHECKSUM","LEXERR","$accept","cmd_list","password","pathname","pathstring",
"username","method","byte_size","check_login","form_code","struct_code",
"mode_code","octal_number","cmd","rcmd","host_port","type_code",
"illegal-symbol",
};
static const char *const yyrule[] = {
"$accept : cmd_list",
"cmd_list :",
"cmd_list : cmd_list cmd",
"cmd_list : cmd_list rcmd",
"cmd : USER SP username CRLF",
"cmd : PASS SP password CRLF",
"cmd : PORT check_login SP host_port CRLF",
"cmd : PASV check_login CRLF",
"cmd : TYPE check_login SP type_code CRLF",
"cmd : STRU check_login SP struct_code CRLF",
"cmd : MODE check_login SP mode_code CRLF",
"cmd : ALLO check_login SP NUMBER CRLF",
"cmd : ALLO check_login SP NUMBER SP R SP NUMBER CRLF",
"cmd : RETR check_login SP pathname CRLF",
"cmd : STOR check_login SP pathname CRLF",
"cmd : APPE check_login SP pathname CRLF",
"cmd : NLST check_login CRLF",
"cmd : NLST check_login SP STRING CRLF",
"cmd : LIST check_login CRLF",
"cmd : LIST check_login SP pathname CRLF",
"cmd : STAT check_login SP pathname CRLF",
"cmd : STAT check_login CRLF",
"cmd : DELE check_login SP pathname CRLF",
"cmd : RNTO check_login SP pathname CRLF",
"cmd : ABOR check_login CRLF",
"cmd : CWD check_login CRLF",
"cmd : CWD check_login SP pathname CRLF",
"cmd : HELP check_login CRLF",
"cmd : HELP check_login SP STRING CRLF",
"cmd : NOOP check_login CRLF",
"cmd : MKD check_login SP pathname CRLF",
"cmd : RMD check_login SP pathname CRLF",
"cmd : PWD check_login CRLF",
"cmd : CDUP check_login CRLF",
"cmd : SITE check_login SP HELP CRLF",
"cmd : SITE check_login SP HELP SP STRING CRLF",
"cmd : SITE check_login SP UMASK CRLF",
"cmd : SITE check_login SP UMASK SP octal_number CRLF",
"cmd : SITE check_login SP CHMOD SP octal_number SP pathname CRLF",
"cmd : SITE check_login SP IDLE CRLF",
"cmd : SITE check_login SP IDLE SP NUMBER CRLF",
"cmd : SITE check_login SP GROUP SP username CRLF",
"cmd : SITE check_login SP GPASS SP password CRLF",
"cmd : SITE check_login SP GPASS CRLF",
"cmd : SITE check_login SP NEWER SP STRING CRLF",
"cmd : SITE check_login SP NEWER SP STRING SP pathname CRLF",
"cmd : SITE check_login SP MINFO SP STRING CRLF",
"cmd : SITE check_login SP MINFO SP STRING SP pathname CRLF",
"cmd : SITE check_login SP INDEX SP STRING CRLF",
"cmd : SITE check_login SP EXEC SP STRING CRLF",
"cmd : STOU check_login SP pathname CRLF",
"cmd : SYST check_login CRLF",
"cmd : SIZE check_login SP pathname CRLF",
"cmd : MDTM check_login SP pathname CRLF",
"cmd : QUIT CRLF",
"cmd : error CRLF",
"rcmd : RNFR check_login SP pathname CRLF",
"rcmd : REST check_login SP byte_size CRLF",
"rcmd : SITE check_login SP ALIAS CRLF",
"rcmd : SITE check_login SP ALIAS SP STRING CRLF",
"rcmd : SITE check_login SP GROUPS CRLF",
"rcmd : SITE check_login SP CDPATH CRLF",
"rcmd : SITE check_login SP CHECKMETHOD SP method CRLF",
"rcmd : SITE check_login SP CHECKMETHOD CRLF",
"rcmd : SITE check_login SP CHECKSUM SP pathname CRLF",
"rcmd : SITE check_login SP CHECKSUM CRLF",
"username : STRING",
"password :",
"password : STRING",
"byte_size : NUMBER",
"host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER",
"form_code : N",
"form_code : T",
"form_code : C",
"type_code : A",
"type_code : A SP form_code",
"type_code : E",
"type_code : E SP form_code",
"type_code : I",
"type_code : L",
"type_code : L SP byte_size",
"type_code : L byte_size",
"struct_code : F",
"struct_code : R",
"struct_code : P",
"mode_code : S",
"mode_code : B",
"mode_code : C",
"pathname : pathstring",
"pathstring : STRING",
"method : STRING",
"octal_number : NUMBER",
"check_login :",

};
#endif

#if YYDEBUG
int      yydebug;
#endif

int      yyerrflag;
int      yychar;
YYSTYPE  yyval;
YYSTYPE  yylval;
int      yynerrs;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE  yyloc; /* position returned by actions */
YYLTYPE  yylloc; /* position from the lexer */
#endif

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
#define YYLLOC_DEFAULT(loc, rhs, n) \
do \
{ \
    if (n == 0) \
    { \
        (loc).first_line   = YYRHSLOC(rhs, 0).last_line; \
        (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
        (loc).last_line    = YYRHSLOC(rhs, 0).last_line; \
        (loc).last_column  = YYRHSLOC(rhs, 0).last_column; \
    } \
    else \
    { \
        (loc).first_line   = YYRHSLOC(rhs, 1).first_line; \
        (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
        (loc).last_line    = YYRHSLOC(rhs, n).last_line; \
        (loc).last_column  = YYRHSLOC(rhs, n).last_column; \
    } \
} while (0)
#endif /* YYLLOC_DEFAULT */
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#if YYBTYACC

#ifndef YYLVQUEUEGROWTH
#define YYLVQUEUEGROWTH 32
#endif
#endif /* YYBTYACC */

/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH  YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 10000
#define YYMAXDEPTH  10000
#endif
#endif

#ifndef YYINITSTACKSIZE
#define YYINITSTACKSIZE 200
#endif

typedef struct {
    unsigned stacksize;
    YYINT    *s_base;
    YYINT    *s_mark;
    YYINT    *s_last;
    YYSTYPE  *l_base;
    YYSTYPE  *l_mark;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE  *p_base;
    YYLTYPE  *p_mark;
#endif
} YYSTACKDATA;
#if YYBTYACC

struct YYParseState_s
{
    struct YYParseState_s *save;    /* Previously saved parser state */
    YYSTACKDATA            yystack; /* saved parser stack */
    int                    state;   /* saved parser state */
    int                    errflag; /* saved error recovery status */
    int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
    YYINT                  ctry;    /* saved index in yyctable[] for this conflict */
};
typedef struct YYParseState_s YYParseState;
#endif /* YYBTYACC */
/* variables for the parser stack */
static YYSTACKDATA yystack;
#if YYBTYACC

/* Current parser state */
static YYParseState *yyps = 0;

/* yypath != NULL: do the full parse, starting at *yypath parser state. */
static YYParseState *yypath = 0;

/* Base of the lexical value queue */
static YYSTYPE *yylvals = 0;

/* Current position at lexical value queue */
static YYSTYPE *yylvp = 0;

/* End position of lexical value queue */
static YYSTYPE *yylve = 0;

/* The last allocated position at the lexical value queue */
static YYSTYPE *yylvlim = 0;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* Base of the lexical position queue */
static YYLTYPE *yylpsns = 0;

/* Current position at lexical position queue */
static YYLTYPE *yylpp = 0;

/* End position of lexical position queue */
static YYLTYPE *yylpe = 0;

/* The last allocated position at the lexical position queue */
static YYLTYPE *yylplim = 0;
#endif

/* Current position at lexical token queue */
static YYINT  *yylexp = 0;

static YYINT  *yylexemes = 0;
#endif /* YYBTYACC */
#line 1234 "ftpcmd.y"

extern jmp_buf errcatch;

#define CMD 0			/* beginning of command */
#define ARGS    1		/* expect miscellaneous arguments */
#define STR1    2		/* expect SP followed by STRING */
#define STR2    3		/* expect STRING */
#define OSTR    4		/* optional SP then STRING */
#define ZSTR1   5		/* SP then optional STRING */
#define ZSTR2   6		/* optional STRING after SP */
#define SITECMD 7		/* SITE command */
#define NSTR    8		/* Number followed by a string */
#define STR3    9		/* expect STRING followed by optional SP then STRING */

struct tab cmdtab[] =
{				/* In order defined in RFC 765 */
    {"USER", USER, STR1, 1, "<sp> username"},
    {"PASS", PASS, ZSTR1, 1, "<sp> password"},
    {"ACCT", ACCT, STR1, 0, "(specify account)"},
    {"SMNT", SMNT, ARGS, 0, "(structure mount)"},
    {"REIN", REIN, ARGS, 0, "(reinitialize server state)"},
    {"QUIT", QUIT, ARGS, 1, "(terminate service)",},
    {"PORT", PORT, ARGS, 1, "<sp> b0, b1, b2, b3, b4, b5"},
    {"PASV", PASV, ARGS, 1, "(set server in passive mode)"},
    {"TYPE", TYPE, ARGS, 1, "<sp> [ A | E | I | L ]"},
    {"STRU", STRU, ARGS, 1, "(specify file structure)"},
    {"MODE", MODE, ARGS, 1, "(specify transfer mode)"},
    {"RETR", RETR, STR1, 1, "<sp> file-name"},
    {"STOR", STOR, STR1, 1, "<sp> file-name"},
    {"APPE", APPE, STR1, 1, "<sp> file-name"},
    {"MLFL", MLFL, OSTR, 0, "(mail file)"},
    {"MAIL", MAIL, OSTR, 0, "(mail to user)"},
    {"MSND", MSND, OSTR, 0, "(mail send to terminal)"},
    {"MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)"},
    {"MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)"},
    {"MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)"},
    {"MRCP", MRCP, STR1, 0, "(mail recipient)"},
    {"ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)"},
    {"REST", REST, ARGS, 1, "(restart command)"},
    {"RNFR", RNFR, STR1, 1, "<sp> file-name"},
    {"RNTO", RNTO, STR1, 1, "<sp> file-name"},
    {"ABOR", ABOR, ARGS, 1, "(abort operation)"},
    {"DELE", DELE, STR1, 1, "<sp> file-name"},
    {"CWD", CWD, OSTR, 1, "[ <sp> directory-name ]"},
    {"XCWD", CWD, OSTR, 1, "[ <sp> directory-name ]"},
    {"LIST", LIST, OSTR, 1, "[ <sp> path-name ]"},
    {"NLST", NLST, OSTR, 1, "[ <sp> path-name ]"},
    {"SITE", SITE, SITECMD, 1, "site-cmd [ <sp> arguments ]"},
    {"SYST", SYST, ARGS, 1, "(get type of operating system)"},
    {"STAT", STAT, OSTR, 1, "[ <sp> path-name ]"},
    {"HELP", HELP, OSTR, 1, "[ <sp> <string> ]"},
    {"NOOP", NOOP, ARGS, 1, ""},
    {"MKD", MKD, STR1, 1, "<sp> path-name"},
    {"XMKD", MKD, STR1, 1, "<sp> path-name"},
    {"RMD", RMD, STR1, 1, "<sp> path-name"},
    {"XRMD", RMD, STR1, 1, "<sp> path-name"},
    {"PWD", PWD, ARGS, 1, "(return current directory)"},
    {"XPWD", PWD, ARGS, 1, "(return current directory)"},
    {"CDUP", CDUP, ARGS, 1, "(change to parent directory)"},
    {"XCUP", CDUP, ARGS, 1, "(change to parent directory)"},
    {"STOU", STOU, STR1, 1, "<sp> file-name"},
    {"SIZE", SIZE, OSTR, 1, "<sp> path-name"},
    {"MDTM", MDTM, OSTR, 1, "<sp> path-name"},
    {NULL, 0, 0, 0, 0}
};

struct tab sitetab[] =
{
    {"UMASK", UMASK, ARGS, 1, "[ <sp> umask ]"},
    {"IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]"},
    {"CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name"},
    {"HELP", HELP, OSTR, 1, "[ <sp> <string> ]"},
    {"GROUP", GROUP, STR1, 1, "<sp> access-group"},
    {"GPASS", GPASS, OSTR, 1, "<sp> access-password"},
    {"NEWER", NEWER, STR3, 1, "<sp> YYYYMMDDHHMMSS [ <sp> path-name ]"},
    {"MINFO", MINFO, STR3, 1, "<sp> YYYYMMDDHHMMSS [ <sp> path-name ]"},
    {"INDEX", INDEX, STR1, 1, "<sp> pattern"},
    {"EXEC", EXEC, STR1, 1, "<sp> command [ <sp> arguments ]"},
    {"ALIAS", ALIAS, OSTR, 1, "[ <sp> alias ] "},
    {"CDPATH", CDPATH, OSTR, 1, "[ <sp> ] "},
    {"GROUPS", GROUPS, OSTR, 1, "[ <sp> ] "},
    {"CHECKMETHOD", CHECKMETHOD, OSTR, 1, "[ <sp> method ]"},
    {"CHECKSUM", CHECKSUM, OSTR, 1, "[ <sp> file-name ]"},
    {NULL, 0, 0, 0, 0}
};

struct tab *lookup(register struct tab *p, char *cmd)
{
    for (; p->name != NULL; p++)
	if (strcmp(cmd, p->name) == 0)
	    return (p);
    return (0);
}

#include <arpa/telnet.h>

/*
 * getline - a hacked up version of fgets to ignore TELNET escape codes.
 */
char *wu_getline(char *s, int n, register FILE *iop)
{
    register int c;
    register char *cs;
    char *passtxt = "PASS password\r\n";

    cs = s;
/* tmpline may contain saved command from urgent mode interruption */
    for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
	*cs++ = tmpline[c];
	if (tmpline[c] == '\n') {
	    *cs++ = '\0';
	    if (debug) {
		if (strncasecmp(passtxt, s, 5) == 0)
		    syslog(LOG_DEBUG, "command: %s", passtxt);
		else
		    syslog(LOG_DEBUG, "command: %s", s);
	    }
	    tmpline[0] = '\0';
	    return (s);
	}
	if (c == 0)
	    tmpline[0] = '\0';
    }
  retry:
    while ((c = getc(iop)) != EOF) {
#ifdef TRANSFER_COUNT
	byte_count_total++;
	byte_count_in++;
#endif
	c &= 0377;
	if (c == IAC) {
	    if ((c = getc(iop)) != EOF) {
#ifdef TRANSFER_COUNT
		byte_count_total++;
		byte_count_in++;
#endif
		c &= 0377;
		switch (c) {
		case WILL:
		case WONT:
		    c = getc(iop);
#ifdef TRANSFER_COUNT
		    byte_count_total++;
		    byte_count_in++;
#endif
		    printf("%c%c%c", IAC, DONT, 0377 & c);
		    (void) fflush(stdout);
		    continue;
		case DO:
		case DONT:
		    c = getc(iop);
#ifdef TRANSFER_COUNT
		    byte_count_total++;
		    byte_count_in++;
#endif
		    printf("%c%c%c", IAC, WONT, 0377 & c);
		    (void) fflush(stdout);
		    continue;
		case IAC:
		    break;
		default:
		    continue;	/* ignore command */
		}
	    }
	}
	*cs++ = c;
	if (--n <= 0 || c == '\n')
	    break;
    }

    if (c == EOF && cs == s) {
	if (ferror(iop) && (errno == EINTR))
	    goto retry;
	return (NULL);
    }

    *cs++ = '\0';
    if (debug) {
	if (strncasecmp(passtxt, s, 5) == 0)
	    syslog(LOG_DEBUG, "command: %s", passtxt);
	else
	    syslog(LOG_DEBUG, "command: %s", s);
    }
    return (s);
}

static void toolong(int a) /* signal that caused this function to be called */
{
    time_t now;

    reply(421,
	  "Timeout (%d seconds): closing control connection.", timeout_idle);
    (void) time(&now);
    if (logging) {
	syslog(LOG_INFO,
	       "User %s timed out after %d seconds at %.24s",
	       (pw ? pw->pw_name : "unknown"), timeout_idle, ctime(&now));
    }
    dologout(1);
}

int yylex(void)
{
    static int cpos, state;
    register char *cp, *cp2;
    register struct tab *p;
    int n;
    time_t now;
    char c = '\0';
    extern time_t limit_time;
    extern time_t login_time;

    for (;;) {
	switch (state) {

	case CMD:
	    yyerrorcalled = 0;

	    setproctitle("%s: IDLE", proctitle);

	    if (is_shutdown(!logged_in, 0) != 0) {
		reply(221, "Server shutting down.  Goodbye.");
		dologout(0);
	    }

	    time(&now);
	    if ((limit_time > 0) && (((now - login_time) / 60) > limit_time)) {
		reply(221, "Time limit reached.  Goodbye.");
		dologout(0);
	    }

#ifdef IGNORE_NOOP
	    if (!alarm_running) {
		(void) signal(SIGALRM, toolong);
		(void) alarm((unsigned) timeout_idle);
		alarm_running = 1;
	    }
#else
	    (void) signal(SIGALRM, toolong);
	    (void) alarm((unsigned) timeout_idle);
#endif
	    if (wu_getline(cbuf, sizeof(cbuf) - 1, stdin) == NULL) {
		(void) alarm(0);
		reply(221, "You could at least say goodbye.");
		dologout(0);
	    }
#ifndef IGNORE_NOOP
	    (void) alarm(0);
#endif
	    if ((cp = strchr(cbuf, '\r'))) {
		*cp++ = '\n';
		*cp = '\0';
	    }
	    if ((cp = strpbrk(cbuf, " \n")))
		cpos = cp - cbuf;
	    if (cpos == 0)
		cpos = 4;
	    c = cbuf[cpos];
	    cbuf[cpos] = '\0';
	    upper(cbuf);
#ifdef IGNORE_NOOP
	    if (strncasecmp(cbuf, "NOOP", 4) != 0) {
		(void) alarm(0);
		alarm_running = 0;
	    }
#endif
	    p = lookup(cmdtab, cbuf);
	    cbuf[cpos] = c;
	    if (strncasecmp(cbuf, "PASS", 4) != 0 &&
		strncasecmp(cbuf, "SITE GPASS", 10) != 0) {
		if ((cp = strchr(cbuf, '\n')))
		    *cp = '\0';
		setproctitle("%s: %s", proctitle, cbuf);
		if (cp)
		    *cp = '\n';
	    }
	    if (p != 0) {
		if (p->implemented == 0) {
		    nack(p->name);
		    longjmp(errcatch, 0);
		    /* NOTREACHED */
		}
		state = p->state;
		yylval.String = p->name;
		return (p->token);
	    }
	    break;

	case SITECMD:
	    if (cbuf[cpos] == ' ') {
		cpos++;
		return (SP);
	    }
	    cp = &cbuf[cpos];
	    if ((cp2 = strpbrk(cp, " \n")))
		cpos = cp2 - cbuf;
	    c = cbuf[cpos];
	    cbuf[cpos] = '\0';
	    upper(cp);
	    p = lookup(sitetab, cp);
	    cbuf[cpos] = c;
	    if (p != 0) {
#ifndef PARANOID		/* what GOOD is SITE *, anyways?!  _H */
		if (p->implemented == 0) {
#else
		if (1) {
		    syslog(LOG_WARNING, "refused SITE %s %s from %s of %s",
			   p->name, &cbuf[cpos],
			   anonymous ? guestpw : authuser, remoteident);
#endif /* PARANOID */
		    state = CMD;
		    nack(p->name);
		    longjmp(errcatch, 0);
		    /* NOTREACHED */
		}
		state = p->state;
		yylval.String = p->name;
		return (p->token);
	    }
	    state = CMD;
	    break;

	case OSTR:
	    if (cbuf[cpos] == '\n') {
		state = CMD;
		return (CRLF);
	    }
	    /* FALLTHROUGH */

	case STR1:
	case ZSTR1:
	  dostr1:
	    if (cbuf[cpos] == ' ') {
		cpos++;
		if (state == OSTR)
		    state = STR2;
		else
		    ++state;
		return (SP);
	    }
	    break;

	case ZSTR2:
	    if (cbuf[cpos] == '\n') {
		state = CMD;
		return (CRLF);
	    }
	    /* FALLTHROUGH */

	case STR2:
	    cp = &cbuf[cpos];
	    n = strlen(cp);
	    cpos += n - 1;
	    /*
	     * Make sure the string is nonempty and \n terminated.
	     */
	    if (n > 1 && cbuf[cpos] == '\n') {
		cbuf[cpos] = '\0';
		yylval.String = copy(cp);
		cbuf[cpos] = '\n';
		state = ARGS;
		return (STRING);
	    }
	    break;

	case NSTR:
	    if (cbuf[cpos] == ' ') {
		cpos++;
		return (SP);
	    }
	    if (isdigit(cbuf[cpos])) {
		cp = &cbuf[cpos];
		while (isdigit(cbuf[++cpos]));
		c = cbuf[cpos];
		cbuf[cpos] = '\0';
		yylval.Number = atoi(cp);
		cbuf[cpos] = c;
		state = STR1;
		return (NUMBER);
	    }
	    state = STR1;
	    goto dostr1;

	case STR3:
	    if (cbuf[cpos] == ' ') {
		cpos++;
		return (SP);
	    }

	    cp = &cbuf[cpos];
	    cp2 = strpbrk(cp, " \n");
	    if (cp2 != NULL) {
		c = *cp2;
		*cp2 = '\0';
	    }
	    n = strlen(cp);
	    cpos += n;
	    /*
	     * Make sure the string is nonempty and SP terminated.
	     */
	    if ((cp2 - cp) > 1) {
		yylval.String = copy(cp);
		cbuf[cpos] = c;
		state = OSTR;
		return (STRING);
	    }
	    break;

	case ARGS:
	    if (isdigit(cbuf[cpos])) {
		cp = &cbuf[cpos];
		while (isdigit(cbuf[++cpos]));
		c = cbuf[cpos];
		cbuf[cpos] = '\0';
		yylval.Number = atoi(cp);
		cbuf[cpos] = c;
		return (NUMBER);
	    }
	    switch (cbuf[cpos++]) {

	    case '\n':
		state = CMD;
		return (CRLF);

	    case ' ':
		return (SP);

	    case ',':
		return (COMMA);

	    case 'A':
	    case 'a':
		return (A);

	    case 'B':
	    case 'b':
		return (B);

	    case 'C':
	    case 'c':
		return (C);

	    case 'E':
	    case 'e':
		return (E);

	    case 'F':
	    case 'f':
		return (F);

	    case 'I':
	    case 'i':
		return (I);

	    case 'L':
	    case 'l':
		return (L);

	    case 'N':
	    case 'n':
		return (N);

	    case 'P':
	    case 'p':
		return (P);

	    case 'R':
	    case 'r':
		return (R);

	    case 'S':
	    case 's':
		return (S);

	    case 'T':
	    case 't':
		return (T);

	    }
	    break;

	default:
	    fatal("Unknown state in scanner.");
	}
	if (yyerrorcalled == 0) {
	    if ((cp = strchr(cbuf, '\n')) != NULL)
		*cp = '\0';
	    if (logged_in)
		reply(500, "'%s': command not understood.", cbuf);
	    else
		reply(530, "Please login with USER and PASS.");
	}
	state = CMD;
	longjmp(errcatch, 0);
    }
}

void upper(char *s)
{
    while (*s != '\0') {
	if (islower(*s))
	    *s = toupper(*s);
	s++;
    }
}

char *copy(char *s)
{
    char *p;

    p = (char *) malloc((unsigned) strlen(s) + 1);
    if (p == NULL)
	fatal("Ran out of memory.");
    (void) strcpy(p, s);
    return (p);
}

void help(struct tab *ctab, char *s)
{
    struct aclmember *entry = NULL;
    struct tab *c;
    size_t width, NCMDS;
    char *type;

    if (ctab == sitetab)
	type = "SITE ";
    else
	type = "";
    width = 0, NCMDS = 0;
    for (c = ctab; c->name != NULL; c++) {
	size_t len = strlen(c->name);

	if (len > width)
	    width = len;
	NCMDS++;
    }
    width = (width + 8) & ~7;
    if (s == 0) {
	register size_t i, j, w;
	size_t columns, lines;

	lreply(214, "The following %scommands are recognized %s.",
	       type, "(* =>'s unimplemented)");
	columns = 76 / width;
	if (columns == 0)
	    columns = 1;
	lines = (NCMDS + columns - 1) / columns;
	for (i = 0; i < lines; i++) {
	    char line[BUFSIZ], *ptr = line;
	    strcpy(ptr, "   ");
	    ptr += 3;
	    for (j = 0; j < columns; j++) {
		c = ctab + j * lines + i;
		(void) sprintf(ptr, "%s%c", c->name,
			       c->implemented ? ' ' : '*');
		w = strlen(c->name) + 1;
		ptr += w;
		if (c + lines >= &ctab[NCMDS])
		    break;
		while (w < width) {
		    *(ptr++) = ' ';
		    w++;
		}
	    }
	    *ptr = '\0';
	    lreply(0, "%s", line);
	}
	(void) fflush(stdout);
#ifdef VIRTUAL
	if (virtual_mode && !virtual_ftpaccess && virtual_email[0] != '\0')
	    reply(214, "Direct comments to %s.", virtual_email);
	else
#endif
	if ((getaclentry("email", &entry)) && ARG0)
	    reply(214, "Direct comments to %s.", ARG0);
	else
	    reply(214, "Direct comments to ftp-bugs@%s.", hostname);
	return;
    }
    upper(s);
    c = lookup(ctab, s);
    if (c == (struct tab *) NULL) {
	reply(502, "Unknown command %s.", s);
	return;
    }
    if (c->implemented)
	reply(214, "Syntax: %s%s %s", type, c->name, c->help);
    else
	reply(214, "%s%-*s\t%s; unimplemented.", type, width,
	      c->name, c->help);
}

void sizecmd(char *filename)
{
    switch (type) {
    case TYPE_L:
    case TYPE_I:{
	    struct stat stbuf;
	    if (stat(filename, &stbuf) < 0 ||
		(stbuf.st_mode & S_IFMT) != S_IFREG)
		reply(550, "%s: not a plain file.", filename);
	    else
#if OFFSET_SIZE == 8
		reply(213, "%qu", stbuf.st_size);
#else
#ifdef _AIX42
		reply(213, "%llu", stbuf.st_size);
#else
		reply(213, "%lu", stbuf.st_size);
#endif
#endif
	    break;
	}
    case TYPE_A:{
	    FILE *fin;
	    register int c;
	    register long count;
	    struct stat stbuf;
	    fin = fopen(filename, "r");
	    if (fin == NULL) {
		perror_reply(550, filename);
		return;
	    }
	    if (fstat(fileno(fin), &stbuf) < 0 ||
		(stbuf.st_mode & S_IFMT) != S_IFREG) {
		reply(550, "%s: not a plain file.", filename);
		(void) fclose(fin);
		return;
	    }

	    count = 0;
	    while ((c = getc(fin)) != EOF) {
		if (c == '\n')	/* will get expanded to \r\n */
		    count++;
		count++;
	    }
	    (void) fclose(fin);

	    reply(213, "%ld", count);
	    break;
	}
    default:
	reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
    }
}

void site_exec(char *cmd)
{
#ifdef PARANOID
    syslog(LOG_CRIT, "REFUSED SITE_EXEC (slipped through!!): %s", cmd);
#else
    char buf[MAXPATHLEN];
    char *sp = (char *) strchr(cmd, ' '), *slash, *t;
    FILE *cmdf;


    /* sanitize the command-string */

    if (sp == 0) {
	while ((slash = strchr(cmd, '/')) != 0)
	    cmd = slash + 1;
    }
    else {
	while (sp && (slash = (char *) strchr(cmd, '/'))
	       && (slash < sp))
	    cmd = slash + 1;
    }

    for (t = cmd; *t && !isspace(*t); t++) {
	if (isupper(*t)) {
	    *t = tolower(*t);
	}
    }

    /* build the command */
    if (strlen(_PATH_EXECPATH) + strlen(cmd) + 2 > sizeof(buf))
	return;
    sprintf(buf, "%s/%s", _PATH_EXECPATH, cmd);

    cmdf = ftpd_popen(buf, "r", 0);
    if (!cmdf) {
	perror_reply(550, cmd);
	if (log_commands)
	    syslog(LOG_INFO, "SITE EXEC (FAIL: %m): %s", cmd);
    }
    else {
	int lines = 0;
	int maxlines = 0;
	struct aclmember *entry = NULL;
	char class[1024];
	int maxfound = 0;
	int defmaxlines = 20;
	int which;

	(void) acl_getclass(class);
	while ((getaclentry("site-exec-max-lines", &entry)) && ARG0) {
	    if (ARG1)
		for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
		    if (!strcasecmp(ARG[which], class)) {
			maxlines = atoi(ARG0);
			maxfound = 1;
		    }
		    if (!strcmp(ARG[which], "*"))
			defmaxlines = atoi(ARG0);
		}
	    else
		defmaxlines = atoi(ARG0);
	}
	if (!maxfound)
	    maxlines = defmaxlines;
	lreply(200, "%s", cmd);
	while (fgets(buf, sizeof buf, cmdf)) {
	    size_t len = strlen(buf);

	    if (len > 0 && buf[len - 1] == '\n')
		buf[--len] = '\0';
	    lreply(200, "%s", buf);
	    if (maxlines <= 0)
		++lines;
	    else if (++lines >= maxlines) {
		lreply(200, "*** Truncated ***");
		break;
	    }
	}
	reply(200, " (end of '%s')", cmd);
	if (log_commands)
	    syslog(LOG_INFO, "SITE EXEC (lines: %d): %s", lines, cmd);
	ftpd_pclose(cmdf);
    }
#endif /* PARANOID */
}

void alias(char *s)
{
    struct aclmember *entry = NULL;

    if (s != (char *) NULL) {
	while (getaclentry("alias", &entry) && ARG0 && ARG1 != NULL)
	    if (!strcmp(ARG0, s)) {
		reply(214, "%s is an alias for %s.", ARG0, ARG1);
		return;
	    }
	reply(502, "Unknown alias %s.", s);
	return;
    }

    lreply(214, "The following aliases are available.");

    while (getaclentry("alias", &entry) && ARG0 && ARG1 != NULL)
	lreply(0, "   %-8s %s", ARG0, ARG1);
    (void) fflush(stdout);

    reply(214, "");
}

void cdpath(void)
{
    struct aclmember *entry = NULL;

    lreply(214, "The cdpath is:");
    while (getaclentry("cdpath", &entry) && ARG0 != NULL)
	lreply(0, "  %s", ARG0);
    (void) fflush(stdout);
    reply(214, "");
}

void print_groups(void)
{
    gid_t groups[NGROUPS_MAX];
    int ngroups = 0;

    if ((ngroups = getgroups(NGROUPS_MAX, groups)) < 0) {
	return;
    }

    lreply(214, "Group membership is:");
    ngroups--;

    for (; ngroups >= 0; ngroups--)
	lreply(214, "  %d", groups[ngroups]);

    (void) fflush(stdout);
    reply(214, "");
}
#line 1582 "y.tab.c"

/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
#if YYBTYACC
#define yytrial (yyps->save)
#endif /* YYBTYACC */

#if YYDEBUG
#include <stdio.h>	/* needed for printf */
#endif

#include <stdlib.h>	/* needed for malloc, etc */
#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
    int i;
    unsigned newsize;
    YYINT *newss;
    YYSTYPE *newvs;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE *newps;
#endif

    if ((newsize = data->stacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return YYENOMEM;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;

    i = (int) (data->s_mark - data->s_base);
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    if (newss == 0)
        return YYENOMEM;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    if (newvs == 0)
        return YYENOMEM;

    data->l_base = newvs;
    data->l_mark = newvs + i;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
    if (newps == 0)
        return YYENOMEM;

    data->p_base = newps;
    data->p_mark = newps + i;
#endif

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;

#if YYDEBUG
    if (yydebug)
        fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
#endif
    return 0;
}

#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    free(data->p_base);
#endif
    memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif /* YYPURE || defined(YY_NO_LEAKS) */
#if YYBTYACC

static YYParseState *
yyNewState(unsigned size)
{
    YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
    if (p == NULL) return NULL;

    p->yystack.stacksize = size;
    if (size == 0)
    {
        p->yystack.s_base = NULL;
        p->yystack.l_base = NULL;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        p->yystack.p_base = NULL;
#endif
        return p;
    }
    p->yystack.s_base    = (YYINT *) malloc(size * sizeof(YYINT));
    if (p->yystack.s_base == NULL) return NULL;
    p->yystack.l_base    = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
    if (p->yystack.l_base == NULL) return NULL;
    memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    p->yystack.p_base    = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
    if (p->yystack.p_base == NULL) return NULL;
    memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
#endif

    return p;
}

static void
yyFreeState(YYParseState *p)
{
    yyfreestack(&p->yystack);
    free(p);
}
#endif /* YYBTYACC */

#define YYABORT  goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR  goto yyerrlab
#if YYBTYACC
#define YYVALID        do { if (yyps->save)            goto yyvalid; } while(0)
#define YYVALID_NESTED do { if (yyps->save && \
                                yyps->save->save == 0) goto yyvalid; } while(0)
#endif /* YYBTYACC */

int
YYPARSE_DECL()
{
    int yym, yyn, yystate, yyresult;
#if YYBTYACC
    int yynewerrflag;
    YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE  yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")) != 0)
    {
        yyn = *yys;
        if (yyn >= '0' && yyn <= '9')
            yydebug = yyn - '0';
    }
    if (yydebug)
        fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
#endif

#if YYBTYACC
    yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
    yyps->save = 0;
#endif /* YYBTYACC */
    yym = 0;
    yyn = 0;
    yynerrs = 0;
    yyerrflag = 0;
    yychar = YYEMPTY;
    yystate = 0;

#if YYPURE
    memset(&yystack, 0, sizeof(yystack));
#endif

    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    yystack.s_mark = yystack.s_base;
    yystack.l_mark = yystack.l_base;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark = yystack.p_base;
#endif
    yystate = 0;
    *yystack.s_mark = 0;

yyloop:
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    if (yychar < 0)
    {
#if YYBTYACC
        do {
        if (yylvp < yylve)
        {
            /* we're currently re-reading tokens */
            yylval = *yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylloc = *yylpp++;
#endif
            yychar = *yylexp++;
            break;
        }
        if (yyps->save)
        {
            /* in trial mode; save scanner results for future parse attempts */
            if (yylvp == yylvlim)
            {   /* Enlarge lexical value queue */
                size_t p = (size_t) (yylvp - yylvals);
                size_t s = (size_t) (yylvlim - yylvals);

                s += YYLVQUEUEGROWTH;
                if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
                if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
                yylvp   = yylve = yylvals + p;
                yylvlim = yylvals + s;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp   = yylpe = yylpsns + p;
                yylplim = yylpsns + s;
#endif
                yylexp  = yylexemes + p;
            }
            *yylexp = (YYINT) YYLEX;
            *yylvp++ = yylval;
            yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            *yylpp++ = yylloc;
            yylpe++;
#endif
            yychar = *yylexp++;
            break;
        }
        /* normal operation, no conflict encountered */
#endif /* YYBTYACC */
        yychar = YYLEX;
#if YYBTYACC
        } while (0);
#endif /* YYBTYACC */
        if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
        if (yydebug)
        {
            if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
                            YYDEBUGSTR, yydepth, yystate, yychar, yys);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
            if (!yytrial)
#endif /* YYBTYACC */
                fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
#endif
            fputc('\n', stderr);
        }
#endif
    }
#if YYBTYACC

    /* Do we have a conflict? */
    if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
        yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
        YYINT ctry;

        if (yypath)
        {
            YYParseState *save;
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
                                YYDEBUGSTR, yydepth, yystate);
#endif
            /* Switch to the next conflict context */
            save = yypath;
            yypath = save->save;
            save->save = NULL;
            ctry = save->ctry;
            if (save->state != yystate) YYABORT;
            yyFreeState(save);

        }
        else
        {

            /* Unresolved conflict - start/continue trial parse */
            YYParseState *save;
#if YYDEBUG
            if (yydebug)
            {
                fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
                if (yyps->save)
                    fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
                else
                    fputs("Starting trial parse.\n", stderr);
            }
#endif
            save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
            if (save == NULL) goto yyenomem;
            save->save            = yyps->save;
            save->state           = yystate;
            save->errflag         = yyerrflag;
            save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
            memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
            memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
            memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            ctry                  = yytable[yyn];
            if (yyctable[ctry] == -1)
            {
#if YYDEBUG
                if (yydebug && yychar >= YYEOF)
                    fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
#endif
                ctry++;
            }
            save->ctry = ctry;
            if (yyps->save == NULL)
            {
                /* If this is a first conflict in the stack, start saving lexemes */
                if (!yylexemes)
                {
                    yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
                    if (yylexemes == NULL) goto yyenomem;
                    yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
                    if (yylvals == NULL) goto yyenomem;
                    yylvlim   = yylvals + YYLVQUEUEGROWTH;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
                    if (yylpsns == NULL) goto yyenomem;
                    yylplim   = yylpsns + YYLVQUEUEGROWTH;
#endif
                }
                if (yylvp == yylve)
                {
                    yylvp  = yylve = yylvals;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpp  = yylpe = yylpsns;
#endif
                    yylexp = yylexemes;
                    if (yychar >= YYEOF)
                    {
                        *yylve++ = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                        *yylpe++ = yylloc;
#endif
                        *yylexp  = (YYINT) yychar;
                        yychar   = YYEMPTY;
                    }
                }
            }
            if (yychar >= YYEOF)
            {
                yylvp--;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp--;
#endif
                yylexp--;
                yychar = YYEMPTY;
            }
            save->lexeme = (int) (yylvp - yylvals);
            yyps->save   = save;
        }
        if (yytable[yyn] == ctry)
        {
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                                YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
#endif
            if (yychar < 0)
            {
                yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp++;
#endif
                yylexp++;
            }
            if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
                goto yyoverflow;
            yystate = yyctable[ctry];
            *++yystack.s_mark = (YYINT) yystate;
            *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            *++yystack.p_mark = yylloc;
#endif
            yychar  = YYEMPTY;
            if (yyerrflag > 0) --yyerrflag;
            goto yyloop;
        }
        else
        {
            yyn = yyctable[ctry];
            goto yyreduce;
        }
    } /* End of code dealing with conflicts */
#endif /* YYBTYACC */
    if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
#if YYDEBUG
        if (yydebug)
            fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                            YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
#endif
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
        yystate = yytable[yyn];
        *++yystack.s_mark = yytable[yyn];
        *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        *++yystack.p_mark = yylloc;
#endif
        yychar = YYEMPTY;
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag != 0) goto yyinrecovery;
#if YYBTYACC

    yynewerrflag = 1;
    goto yyerrhandler;
    goto yyerrlab; /* redundant goto avoids 'unused label' warning */

yyerrlab:
    /* explicit YYERROR from an action -- pop the rhs of the rule reduced
     * before looking for error recovery */
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark -= yym;
#endif

    yynewerrflag = 0;
yyerrhandler:
    while (yyps->save)
    {
        int ctry;
        YYParseState *save = yyps->save;
#if YYDEBUG
        if (yydebug)
            fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
                            YYDEBUGSTR, yydepth, yystate, yyps->save->state,
                    (int)(yylvp - yylvals - yyps->save->lexeme));
#endif
        /* Memorize most forward-looking error state in case it's really an error. */
        if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
        {
            /* Free old saved error context state */
            if (yyerrctx) yyFreeState(yyerrctx);
            /* Create and fill out new saved error context state */
            yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
            if (yyerrctx == NULL) goto yyenomem;
            yyerrctx->save           = yyps->save;
            yyerrctx->state          = yystate;
            yyerrctx->errflag        = yyerrflag;
            yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
            memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
            memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
            memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            yyerrctx->lexeme         = (int) (yylvp - yylvals);
        }
        yylvp          = yylvals   + save->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        yylpp          = yylpsns   + save->lexeme;
#endif
        yylexp         = yylexemes + save->lexeme;
        yychar         = YYEMPTY;
        yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
        memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
        yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
        memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
        memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
        ctry           = ++save->ctry;
        yystate        = save->state;
        /* We tried shift, try reduce now */
        if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
        yyps->save     = save->save;
        save->save     = NULL;
        yyFreeState(save);

        /* Nothing left on the stack -- error */
        if (!yyps->save)
        {
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
                                YYPREFIX, yydepth);
#endif
            /* Restore state as it was in the most forward-advanced error */
            yylvp          = yylvals   + yyerrctx->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylpp          = yylpsns   + yyerrctx->lexeme;
#endif
            yylexp         = yylexemes + yyerrctx->lexeme;
            yychar         = yylexp[-1];
            yylval         = yylvp[-1];
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylloc         = yylpp[-1];
#endif
            yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
            memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
            memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
            memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            yystate        = yyerrctx->state;
            yyFreeState(yyerrctx);
            yyerrctx       = NULL;
        }
        yynewerrflag = 1;
    }
    if (yynewerrflag == 0) goto yyinrecovery;
#endif /* YYBTYACC */

    YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif

#if !YYBTYACC
    goto yyerrlab; /* redundant goto avoids 'unused label' warning */
yyerrlab:
#endif
    ++yynerrs;

yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
                                    YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
#endif
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
                yystate = yytable[yyn];
                *++yystack.s_mark = yytable[yyn];
                *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                /* lookahead position is error end position */
                yyerror_loc_range[2] = yylloc;
                YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
                *++yystack.p_mark = yyloc;
#endif
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
                                    YYDEBUGSTR, yydepth, *yystack.s_mark);
#endif
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                /* the current TOS position is the error start position */
                yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
                if (!yytrial)
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    YYDESTRUCT_CALL("error: discarding state",
                                    yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
#else
                    YYDESTRUCT_CALL("error: discarding state",
                                    yystos[*yystack.s_mark], yystack.l_mark);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#endif /* defined(YYDESTRUCT_CALL) */
                --yystack.s_mark;
                --yystack.l_mark;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                --yystack.p_mark;
#endif
            }
        }
    }
    else
    {
        if (yychar == YYEOF) goto yyabort;
#if YYDEBUG
        if (yydebug)
        {
            if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
                            YYDEBUGSTR, yydepth, yystate, yychar, yys);
        }
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
#else
            YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#endif /* defined(YYDESTRUCT_CALL) */
        yychar = YYEMPTY;
        goto yyloop;
    }

yyreduce:
    yym = yylen[yyn];
#if YYDEBUG
    if (yydebug)
    {
        fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
                        YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
            if (yym > 0)
            {
                int i;
                fputc('<', stderr);
                for (i = yym; i > 0; i--)
                {
                    if (i != yym) fputs(", ", stderr);
                    fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
                                           yystack.l_mark[1-i]), stderr);
                }
                fputc('>', stderr);
            }
#endif
        fputc('\n', stderr);
    }
#endif
    if (yym > 0)
        yyval = yystack.l_mark[1-yym];
    else
        memset(&yyval, 0, sizeof yyval);
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)

    /* Perform position reduction */
    memset(&yyloc, 0, sizeof(yyloc));
#if YYBTYACC
    if (!yytrial)
#endif /* YYBTYACC */
    {
        YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
        /* just in case YYERROR is invoked within the action, save
           the start of the rhs as the error start position */
        yyerror_loc_range[1] = yystack.p_mark[1-yym];
    }
#endif

    switch (yyn)
    {
case 2:
#line 196 "ftpcmd.y"
	{
	    fromname = (char *) NULL;
	    restart_point = 0;
	}
break;
case 4:
#line 204 "ftpcmd.y"
	{
	    user(yystack.l_mark[-1].String);
	    if (log_commands)
		syslog(LOG_INFO, "USER %s", yystack.l_mark[-1].String);
	    free(yystack.l_mark[-1].String);
	}
break;
case 5:
#line 211 "ftpcmd.y"
	{
	    if (log_commands)
		if (anonymous)
		    syslog(LOG_INFO, "PASS %s", yystack.l_mark[-1].String);
		else
		    syslog(LOG_INFO, "PASS password");

	    pass(yystack.l_mark[-1].String);
	    free(yystack.l_mark[-1].String);
	}
break;
case 6:
#line 222 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "PORT");
/* H* port fix, part B: admonish the twit.
   Also require login before PORT works */
	    if (yystack.l_mark[-3].Number) {
#ifndef DISABLE_PORT
		if (((cliaddr.s_addr == his_addr.sin_addr.s_addr)
		     || (port_allowed(inet_ntoa(cliaddr))))
		    && (ntohs(cliport) > 1023)) {
		    usedefault = 0;
		    if (pdata >= 0) {
			(void) close(pdata);
			pdata = -1;
		    }
		    data_dest.sin_family = AF_INET;
		    data_dest.sin_addr = cliaddr;
		    data_dest.sin_port = cliport;
		    reply(200, "PORT command successful.");
		}
		else {
#endif
		    memset(&data_dest, 0, sizeof(data_dest));
		    syslog(LOG_WARNING, "refused PORT %s,%d from %s",
			   inet_ntoa(cliaddr), ntohs(cliport), remoteident);
		    reply(500, "Illegal PORT Command");
#ifndef DISABLE_PORT
		}
#endif
	    }
	}
break;
case 7:
#line 254 "ftpcmd.y"
	{
/* Require login for PASV, too.  This actually fixes a bug -- telnet to an
   unfixed wu-ftpd and type PASV first off, and it crashes! */
	    if (log_commands)
		syslog(LOG_INFO, "PASV");
	    if (yystack.l_mark[-1].Number)
#if (defined (DISABLE_PORT) || !defined (DISABLE_PASV))
		passive();
#else
		reply(425, "Cannot open passive connection");
#endif
	}
break;
case 8:
#line 267 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "TYPE %s", typenames[cmd_type]);
	    if (yystack.l_mark[-3].Number)
		switch (cmd_type) {

		case TYPE_A:
		    if (cmd_form == FORM_N) {
			reply(200, "Type set to A.");
			type = cmd_type;
			form = cmd_form;
		    }
		    else
			reply(504, "Form must be N.");
		    break;

		case TYPE_E:
		    reply(504, "Type E not implemented.");
		    break;

		case TYPE_I:
		    reply(200, "Type set to I.");
		    type = cmd_type;
		    break;

		case TYPE_L:
#if NBBY == 8
		    if (cmd_bytesz == 8) {
			reply(200,
			      "Type set to L (byte size 8).");
			type = cmd_type;
		    }
		    else
			reply(504, "Byte size must be 8.");
#else /* NBBY == 8 */
#error UNIMPLEMENTED for NBBY != 8
#endif /* NBBY == 8 */
		}
	}
break;
case 9:
#line 307 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "STRU %s", strunames[yystack.l_mark[-1].Number]);
	    if (yystack.l_mark[-3].Number)
		switch (yystack.l_mark[-1].Number) {

		case STRU_F:
		    reply(200, "STRU F ok.");
		    break;

		default:
		    reply(504, "Unimplemented STRU type.");
		}
	}
break;
case 10:
#line 322 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "MODE %s", modenames[yystack.l_mark[-1].Number]);
	    if (yystack.l_mark[-3].Number)
		switch (yystack.l_mark[-1].Number) {

		case MODE_S:
		    reply(200, "MODE S ok.");
		    break;

		default:
		    reply(502, "Unimplemented MODE type.");
		}
	}
break;
case 11:
#line 337 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "ALLO %d", yystack.l_mark[-1].Number);
	    if (yystack.l_mark[-3].Number)
		reply(202, "ALLO command ignored.");
	}
break;
case 12:
#line 344 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "ALLO %d R %d", yystack.l_mark[-5].Number, yystack.l_mark[-1].Number);
	    if (yystack.l_mark[-7].Number)
		reply(202, "ALLO command ignored.");
	}
break;
case 13:
#line 351 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "RETR %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String)) {
		retrieve_is_data = 1;
		retrieve((char *) NULL, yystack.l_mark[-1].String);
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 14:
#line 362 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "STOR %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		store(yystack.l_mark[-1].String, "w", 0);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 15:
#line 371 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "APPE %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		store(yystack.l_mark[-1].String, "a", 0);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 16:
#line 380 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "NLST");
	    if (yystack.l_mark[-1].Number && !restrict_check("."))
		send_file_list("");
	}
break;
case 17:
#line 387 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "NLST %s", yystack.l_mark[-1].String);
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String))
		send_file_list(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 18:
#line 396 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "LIST");
	    if (yystack.l_mark[-1].Number && !restrict_check(".")) {
		retrieve_is_data = 0;
#ifndef INTERNAL_LS
		if (anonymous && dolreplies)
		    retrieve(ls_long, "");
		else
		    retrieve(ls_short, "");
#else
		ls(NULL, 0);
#endif
	    }
	}
break;
case 19:
#line 412 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "LIST %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_list_check(yystack.l_mark[-1].String)) {
		retrieve_is_data = 0;
#ifndef INTERNAL_LS
		if (anonymous && dolreplies)
		    retrieve(ls_long, yystack.l_mark[-1].String);
		else
		    retrieve(ls_short, yystack.l_mark[-1].String);
#else
		ls(yystack.l_mark[-1].String, 0);
#endif
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 20:
#line 430 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "STAT %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		statfilecmd(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 21:
#line 439 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "STAT");
	    if (yystack.l_mark[-1].Number)
		statcmd();
	}
break;
case 22:
#line 446 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "DELE %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		delete(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 23:
#line 455 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "RNTO %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String)) {
		if (fromname) {
		    renamecmd(fromname, yystack.l_mark[-1].String);
		    free(fromname);
		    fromname = (char *) NULL;
		}
		else {
		    reply(503, "Bad sequence of commands.");
		}
	    }
	    if (yystack.l_mark[-1].String)
		free(yystack.l_mark[-1].String);
	}
break;
case 24:
#line 472 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "ABOR");
	    if (yystack.l_mark[-1].Number)
		reply(225, "ABOR command successful.");
	}
break;
case 25:
#line 479 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "CWD");
	    if (yystack.l_mark[-1].Number && !restrict_check(home))
		cwd(home);
	}
break;
case 26:
#line 486 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "CWD %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		cwd(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 27:
#line 495 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "HELP");
	    if (yystack.l_mark[-1].Number)
		help(cmdtab, (char *) NULL);
	}
break;
case 28:
#line 502 "ftpcmd.y"
	{
	    register char *cp = (char *) yystack.l_mark[-1].String;

	    if (log_commands)
		syslog(LOG_INFO, "HELP %s", yystack.l_mark[-1].String);
	    if (yystack.l_mark[-3].Number)
		if (strncasecmp(cp, "SITE", 4) == 0) {
		    cp = (char *) yystack.l_mark[-1].String + 4;
		    if (*cp == ' ')
			cp++;
		    if (*cp)
			help(sitetab, cp);
		    else
			help(sitetab, (char *) NULL);
		}
		else
		    help(cmdtab, yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 29:
#line 523 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "NOOP");
	    if (yystack.l_mark[-1].Number)
		reply(200, "NOOP command successful.");
	}
break;
case 30:
#line 530 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "MKD %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		makedir(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 31:
#line 539 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "RMD %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String != NULL && !restrict_check(yystack.l_mark[-1].String))
		removedir(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 32:
#line 548 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "PWD");
	    if (yystack.l_mark[-1].Number)
		pwd();
	}
break;
case 33:
#line 555 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "CDUP");
	    if (yystack.l_mark[-1].Number)
		if (!test_restriction(".."))
		    cwd("..");
		else
		    ack("CWD");
	}
break;
case 34:
#line 566 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE HELP");
	    if (yystack.l_mark[-3].Number)
		help(sitetab, (char *) NULL);
	}
break;
case 35:
#line 573 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE HELP %s", yystack.l_mark[-1].String);
	    if (yystack.l_mark[-5].Number)
		help(sitetab, yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 36:
#line 582 "ftpcmd.y"
	{
	    mode_t oldmask;

	    if (log_commands)
		syslog(LOG_INFO, "SITE UMASK");
	    if (yystack.l_mark[-3].Number) {
		oldmask = umask(0);
		(void) umask(oldmask);
		reply(200, "Current UMASK is %03o", oldmask);
	    }
	}
break;
case 37:
#line 594 "ftpcmd.y"
	{
	    mode_t oldmask;
	    struct aclmember *entry = NULL;
	    int ok = 1;

	    if (log_commands)
		syslog(LOG_INFO, "SITE UMASK %03o", yystack.l_mark[-1].Number);
	    if (yystack.l_mark[-5].Number) {
		/* check for umask permission */
		while (getaclentry("umask", &entry) && ARG0 && ARG1 != NULL) {
		    if (type_match(ARG1))
			if (*ARG0 == 'n')
			    ok = 0;
		}
		if (ok && !restricted_user) {
		    if ((yystack.l_mark[-1].Number < 0) || (yystack.l_mark[-1].Number > 0777)) {
			reply(501, "Bad UMASK value");
		    }
		    else {
			oldmask = umask((mode_t) yystack.l_mark[-1].Number);
			reply(200, "UMASK set to %03o (was %03o)", yystack.l_mark[-1].Number, oldmask);
		    }
		}
		else
		    reply(553, "Permission denied on server. (umask)");
	    }
	}
break;
case 38:
#line 622 "ftpcmd.y"
	{
	    struct aclmember *entry = NULL;
	    int ok = (anonymous ? 0 : 1);

	    if (log_commands)
		syslog(LOG_INFO, "SITE CHMOD %03o %s", yystack.l_mark[-3].Number, CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-7].Number && yystack.l_mark[-1].String) {
		/* check for chmod permission */
		while (getaclentry("chmod", &entry) && ARG0 && ARG1 != NULL) {
		    if (type_match(ARG1))
			if (anonymous) {
			    if (*ARG0 == 'y')
				ok = 1;
			}
			else if (*ARG0 == 'n')
			    ok = 0;
		}
		if (ok) {
#ifdef UNRESTRICTED_CHMOD
		    if (chmod(yystack.l_mark[-1].String, (mode_t) yystack.l_mark[-3].Number) < 0)
#else
		    if ((yystack.l_mark[-3].Number < 0) || (yystack.l_mark[-3].Number > 0777))
			reply(501,
			    "CHMOD: Mode value must be between 0 and 0777");
		    else if (chmod(yystack.l_mark[-1].String, (mode_t) yystack.l_mark[-3].Number) < 0)
#endif
			perror_reply(550, yystack.l_mark[-1].String);
		    else {
			char path[MAXPATHLEN];

			wu_realpath(yystack.l_mark[-1].String, path, chroot_path);

			if (log_security)
			    if (anonymous) {
				syslog(LOG_NOTICE, "%s of %s changed permissions for %s", guestpw, remoteident, path);
			    }
			    else {
				syslog(LOG_NOTICE, "%s of %s changed permissions for %s", pw->pw_name,
				       remoteident, path);
			    }
			reply(200, "CHMOD command successful.");
		    }
		}
		else
		    reply(553, "Permission denied on server. (chmod)");
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 39:
#line 672 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE IDLE");
	    if (yystack.l_mark[-3].Number)
		reply(200,
		      "Current IDLE time limit is %d seconds; max %d",
		      timeout_idle, timeout_maxidle);
	}
break;
case 40:
#line 681 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE IDLE %d", yystack.l_mark[-1].Number);
	    if (yystack.l_mark[-5].Number)
		if (yystack.l_mark[-1].Number < 30 || yystack.l_mark[-1].Number > timeout_maxidle) {
		    reply(501,
		      "Maximum IDLE time must be between 30 and %d seconds",
			  timeout_maxidle);
		}
		else {
		    timeout_idle = yystack.l_mark[-1].Number;
		    reply(200, "Maximum IDLE time set to %d seconds", timeout_idle);
		}
	}
break;
case 41:
#line 696 "ftpcmd.y"
	{
#ifndef NO_PRIVATE
	    if (log_commands)
		syslog(LOG_INFO, "SITE GROUP %s", yystack.l_mark[-1].String);
	    if (!restricted_user && yystack.l_mark[-5].Number && yystack.l_mark[-1].String)
		priv_group(yystack.l_mark[-1].String);
	    free(yystack.l_mark[-1].String);
#endif /* !NO_PRIVATE */
	}
break;
case 42:
#line 706 "ftpcmd.y"
	{
#ifndef NO_PRIVATE
	    if (log_commands)
		syslog(LOG_INFO, "SITE GPASS password");
	    if (!restricted_user && yystack.l_mark[-5].Number && yystack.l_mark[-1].String)
		priv_gpass(yystack.l_mark[-1].String);
	    free(yystack.l_mark[-1].String);
#endif /* !NO_PRIVATE */
	}
break;
case 43:
#line 716 "ftpcmd.y"
	{
#ifndef NO_PRIVATE
	    if (log_commands)
		syslog(LOG_INFO, "SITE GPASS");
	    if (!restricted_user && yystack.l_mark[-3].Number)
		priv_gpass(NULL);
#endif /* !NO_PRIVATE */
	}
break;
case 44:
#line 725 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE NEWER %s", yystack.l_mark[-1].String);
#ifdef SITE_NEWER
	    if (yystack.l_mark[-5].Number && yystack.l_mark[-1].String && !restrict_check("."))
		newer(yystack.l_mark[-1].String, ".", 0);
#else
	    reply(500, "Command no longer honored by this server");
#endif
	    free(yystack.l_mark[-1].String);
	}
break;
case 45:
#line 737 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE NEWER %s %s", yystack.l_mark[-3].String,
		       CHECKNULL(yystack.l_mark[-1].String));
#ifdef SITE_NEWER
	    if (yystack.l_mark[-7].Number && yystack.l_mark[-3].String && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String))
		newer(yystack.l_mark[-3].String, yystack.l_mark[-1].String, 0);
#else
	    reply(500, "Command no longer honored by this server");
#endif
	    free(yystack.l_mark[-3].String);
	    if (yystack.l_mark[-1].String)
		free(yystack.l_mark[-1].String);
	}
break;
case 46:
#line 752 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE MINFO %s", yystack.l_mark[-1].String);
#ifdef SITE_NEWER
	    if (yystack.l_mark[-5].Number && yystack.l_mark[-1].String && !restrict_check("."))
		newer(yystack.l_mark[-1].String, ".", 1);
#else
	    reply(500, "Command no longer honored by this server");
#endif
	    free(yystack.l_mark[-1].String);
	}
break;
case 47:
#line 764 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE MINFO %s %s", yystack.l_mark[-3].String,
		       CHECKNULL(yystack.l_mark[-1].String));
#ifdef SITE_NEWER
	    if (yystack.l_mark[-7].Number && yystack.l_mark[-3].String && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String))
		newer(yystack.l_mark[-3].String, yystack.l_mark[-1].String, 1);
#else
	    reply(500, "Command no longer honored by this server");
#endif
	    free(yystack.l_mark[-3].String);
	    if (yystack.l_mark[-1].String)
		free(yystack.l_mark[-1].String);
	}
break;
case 48:
#line 779 "ftpcmd.y"
	{
	    /* this is just for backward compatibility since we
	     * thought of INDEX before we thought of EXEC
	     */
	    if (!restricted_user && yystack.l_mark[-5].Number != 0 && yystack.l_mark[-1].String != NULL) {
		char buf[MAXPATHLEN];
		if (strlen(yystack.l_mark[-1].String) + 7 <= sizeof(buf)) {
		    sprintf(buf, "index %s", (char *) yystack.l_mark[-1].String);
		    (void) site_exec(buf);
		}
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 49:
#line 794 "ftpcmd.y"
	{
	    if (!restricted_user && yystack.l_mark[-5].Number != 0 && yystack.l_mark[-1].String != NULL) {
		(void) site_exec((char *) yystack.l_mark[-1].String);
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 50:
#line 803 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "STOU %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String))
		store(yystack.l_mark[-1].String, "w", 1);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 51:
#line 812 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SYST");
	    if (yystack.l_mark[-1].Number)
#ifdef BSD
		reply(215, "UNIX Type: L%d Version: BSD-%d",
		      NBBY, BSD);
#else /* BSD */
#if defined (unix) || defined (__unix__)
		reply(215, "UNIX Type: L%d", NBBY);
#else /* unix */
		reply(215, "UNKNOWN Type: L%d", NBBY);
#endif /* unix */
#endif /* BSD */
	}
break;
case 52:
#line 836 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SIZE %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String)) {
		sizecmd(yystack.l_mark[-1].String);
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 53:
#line 856 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "MDTM %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String)) {
		struct stat stbuf;

		if (stat(yystack.l_mark[-1].String, &stbuf) < 0)
		    perror_reply(550, yystack.l_mark[-1].String);
		else if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
		    reply(550, "%s: not a plain file.",
			  yystack.l_mark[-1].String);
		}
		else {
		    register struct tm *t;
		    t = gmtime(&stbuf.st_mtime);
		    reply(213,
			  "%04d%02d%02d%02d%02d%02d",
			  t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
			  t->tm_hour, t->tm_min, t->tm_sec);
		}
	    }
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 54:
#line 881 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "QUIT");
#ifdef TRANSFER_COUNT
	    if (logged_in) {
		lreply(221, "You have transferred %d bytes in %d files.", data_count_total, file_count_total);
		lreply(221, "Total traffic for this session was %d bytes in %d transfers.", byte_count_total, xfer_count_total);
		lreply(221, "Thank you for using the FTP service on %s.", hostname);
	    }
#endif /* TRANSFER_COUNT */
	    reply(221, "Goodbye.");
	    dologout(0);
	}
break;
case 55:
#line 895 "ftpcmd.y"
	{
	    yyerrok;
	}
break;
case 56:
#line 901 "ftpcmd.y"
	{

	    if (log_commands)
		syslog(LOG_INFO, "RNFR %s", CHECKNULL(yystack.l_mark[-1].String));
	    if (yystack.l_mark[-3].Number)
		restart_point = (off_t) 0;
	    if (yystack.l_mark[-3].Number && yystack.l_mark[-1].String && !restrict_check(yystack.l_mark[-1].String)) {
		fromname = renamefrom(yystack.l_mark[-1].String);
	    }
	    if (fromname == 0 && yystack.l_mark[-1].String)
		free(yystack.l_mark[-1].String);
	}
break;
case 57:
#line 914 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "REST %d", (int) restart_point);
	    if (yystack.l_mark[-3].Number) {
		fromname = 0;
		restart_point = yystack.l_mark[-1].Number;
		reply(350, "Restarting at %ld. %s", (long) restart_point,
		      "Send STORE or RETRIEVE to initiate transfer.");
	    }
	}
break;
case 58:
#line 926 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE ALIAS");
	    if (yystack.l_mark[-3].Number)
		alias((char *) NULL);
	}
break;
case 59:
#line 933 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE ALIAS %s", yystack.l_mark[-1].String);
	    if (yystack.l_mark[-5].Number)
		alias(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 60:
#line 942 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE GROUPS");
	    if (yystack.l_mark[-3].Number)
		print_groups();
	}
break;
case 61:
#line 949 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE CDPATH");
	    if (yystack.l_mark[-3].Number)
		cdpath();
	}
break;
case 62:
#line 956 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE CHECKMETHOD %s", CHECKNULL(yystack.l_mark[-1].String));
	    if ((yystack.l_mark[-5].Number) && (yystack.l_mark[-1].String != NULL))
		SetCheckMethod(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 63:
#line 965 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE CHECKMETHOD");
	    if (yystack.l_mark[-3].Number)
		ShowCheckMethod();
	}
break;
case 64:
#line 972 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE CHECKSUM %s", CHECKNULL(yystack.l_mark[-1].String));
	    if ((yystack.l_mark[-5].Number) && (yystack.l_mark[-1].String != NULL) && (!restrict_check(yystack.l_mark[-1].String)))
		CheckSum(yystack.l_mark[-1].String);
	    if (yystack.l_mark[-1].String != NULL)
		free(yystack.l_mark[-1].String);
	}
break;
case 65:
#line 981 "ftpcmd.y"
	{
	    if (log_commands)
		syslog(LOG_INFO, "SITE CHECKSUM");
	    if (yystack.l_mark[-3].Number)
		CheckSumLastFile();
	}
break;
case 67:
#line 993 "ftpcmd.y"
	{
	    yyval.String = (char *) malloc(1);
	    yyval.String[0] = '\0';
	}
break;
case 70:
#line 1004 "ftpcmd.y"
	{
	    register char *a, *p;

	    a = (char *) &cliaddr;
	    a[0] = yystack.l_mark[-10].Number;
	    a[1] = yystack.l_mark[-8].Number;
	    a[2] = yystack.l_mark[-6].Number;
	    a[3] = yystack.l_mark[-4].Number;
	    p = (char *) &cliport;
	    p[0] = yystack.l_mark[-2].Number;
	    p[1] = yystack.l_mark[0].Number;
	}
break;
case 71:
#line 1019 "ftpcmd.y"
	{
	    yyval.Number = FORM_N;
	}
break;
case 72:
#line 1023 "ftpcmd.y"
	{
	    yyval.Number = FORM_T;
	}
break;
case 73:
#line 1027 "ftpcmd.y"
	{
	    yyval.Number = FORM_C;
	}
break;
case 74:
#line 1033 "ftpcmd.y"
	{
	    cmd_type = TYPE_A;
	    cmd_form = FORM_N;
	}
break;
case 75:
#line 1038 "ftpcmd.y"
	{
	    cmd_type = TYPE_A;
	    cmd_form = yystack.l_mark[0].Number;
	}
break;
case 76:
#line 1043 "ftpcmd.y"
	{
	    cmd_type = TYPE_E;
	    cmd_form = FORM_N;
	}
break;
case 77:
#line 1048 "ftpcmd.y"
	{
	    cmd_type = TYPE_E;
	    cmd_form = yystack.l_mark[0].Number;
	}
break;
case 78:
#line 1053 "ftpcmd.y"
	{
	    cmd_type = TYPE_I;
	}
break;
case 79:
#line 1057 "ftpcmd.y"
	{
	    cmd_type = TYPE_L;
	    cmd_bytesz = NBBY;
	}
break;
case 80:
#line 1062 "ftpcmd.y"
	{
	    cmd_type = TYPE_L;
	    cmd_bytesz = yystack.l_mark[0].Number;
	}
break;
case 81:
#line 1068 "ftpcmd.y"
	{
	    cmd_type = TYPE_L;
	    cmd_bytesz = yystack.l_mark[0].Number;
	}
break;
case 82:
#line 1075 "ftpcmd.y"
	{
	    yyval.Number = STRU_F;
	}
break;
case 83:
#line 1079 "ftpcmd.y"
	{
	    yyval.Number = STRU_R;
	}
break;
case 84:
#line 1083 "ftpcmd.y"
	{
	    yyval.Number = STRU_P;
	}
break;
case 85:
#line 1089 "ftpcmd.y"
	{
	    yyval.Number = MODE_S;
	}
break;
case 86:
#line 1093 "ftpcmd.y"
	{
	    yyval.Number = MODE_B;
	}
break;
case 87:
#line 1097 "ftpcmd.y"
	{
	    yyval.Number = MODE_C;
	}
break;
case 88:
#line 1103 "ftpcmd.y"
	{
	    /*
	     * Problem: this production is used for all pathname
	     * processing, but only gives a 550 error reply.
	     * This is a valid reply in some cases but not in others.
	     */
	    if (restricted_user && logged_in && yystack.l_mark[0].String && strncmp(yystack.l_mark[0].String, "/", 1) == 0) {
		/*
		 * This remaps the root so it is appearently at the user's home
		 * rather than the real root/chroot.
		 */
		char **globlist;
		char *t = calloc(1 + strlen(yystack.l_mark[0].String) + 1, sizeof(char));
		if (t == NULL) {
		    errno = EAGAIN;
		    perror_reply(550, yystack.l_mark[0].String);
		    yyval.String = NULL;
		}
		else {
		    t[0] = '~';
		    t[1] = '\0';
		    if (strncmp(yystack.l_mark[0].String, "/../", 4) == 0)
			strcpy(t + 1, yystack.l_mark[0].String + 3);
		    else if (strcmp(yystack.l_mark[0].String, "/..") != 0)
			strcpy(t + 1, yystack.l_mark[0].String);
		    globlist = ftpglob(t);
		    if (globerr) {
			reply(550, "%s", globerr);
			yyval.String = NULL;
			if (globlist) {
			    blkfree(globlist);
			    free((char *) globlist);
			}
		    }
		    else if (globlist && *globlist) {
			yyval.String = *globlist;
			blkfree(&globlist[1]);
			free((char *) globlist);
		    }
		    else {
			if (globlist) {
			    blkfree(globlist);
			    free((char *) globlist);
			}
			errno = ENOENT;
			perror_reply(550, yystack.l_mark[0].String);
			yyval.String = NULL;
		    }
		    free(t);
		}
		free(yystack.l_mark[0].String);
	    }
	    else if (logged_in && yystack.l_mark[0].String && strncmp(yystack.l_mark[0].String, "~", 1) == 0) {
		char **globlist;

		globlist = ftpglob(yystack.l_mark[0].String);
		if (globerr) {
		    reply(550, "%s", globerr);
		    yyval.String = NULL;
		    if (globlist) {
			blkfree(globlist);
			free((char *) globlist);
		    }
		}
		else if (globlist && *globlist) {
		    yyval.String = *globlist;
		    blkfree(&globlist[1]);
		    free((char *) globlist);
		}
		else {
		    if (globlist) {
			blkfree(globlist);
			free((char *) globlist);
		    }
		    errno = ENOENT;
		    perror_reply(550, yystack.l_mark[0].String);
		    yyval.String = NULL;
		}
		free(yystack.l_mark[0].String);
	    }
	    else
		yyval.String = yystack.l_mark[0].String;
	}
break;
case 91:
#line 1195 "ftpcmd.y"
	{
	    register int ret, dec, multby, digit;

	    /*
	     * Convert a number that was read as decimal number
	     * to what it would be if it had been read as octal.
	     */
	    dec = yystack.l_mark[0].Number;
	    multby = 1;
	    ret = 0;
	    while (dec) {
		digit = dec % 10;
		if (digit > 7) {
		    ret = -1;
		    break;
		}
		ret += digit * multby;
		multby *= 8;
		dec /= 10;
	    }
	    yyval.Number = ret;
	}
break;
case 92:
#line 1220 "ftpcmd.y"
	{
	    if (logged_in)
		yyval.Number = 1;
	    else {
		if (log_commands)
		    syslog(LOG_INFO, "cmd failure - not logged in");
		reply(530, "Please login with USER and PASS.");
		yyval.Number = 0;
		yyerrorcalled = 1;
	    }
	}
break;
#line 3400 "y.tab.c"
    default:
        break;
    }
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark -= yym;
#endif
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
        {
            fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
            if (!yytrial)
#endif /* YYBTYACC */
                fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
#endif
            fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
        }
#endif
        yystate = YYFINAL;
        *++yystack.s_mark = YYFINAL;
        *++yystack.l_mark = yyval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        *++yystack.p_mark = yyloc;
#endif
        if (yychar < 0)
        {
#if YYBTYACC
            do {
            if (yylvp < yylve)
            {
                /* we're currently re-reading tokens */
                yylval = *yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylloc = *yylpp++;
#endif
                yychar = *yylexp++;
                break;
            }
            if (yyps->save)
            {
                /* in trial mode; save scanner results for future parse attempts */
                if (yylvp == yylvlim)
                {   /* Enlarge lexical value queue */
                    size_t p = (size_t) (yylvp - yylvals);
                    size_t s = (size_t) (yylvlim - yylvals);

                    s += YYLVQUEUEGROWTH;
                    if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
                        goto yyenomem;
                    if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
                        goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
                        goto yyenomem;
#endif
                    yylvp   = yylve = yylvals + p;
                    yylvlim = yylvals + s;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpp   = yylpe = yylpsns + p;
                    yylplim = yylpsns + s;
#endif
                    yylexp  = yylexemes + p;
                }
                *yylexp = (YYINT) YYLEX;
                *yylvp++ = yylval;
                yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                *yylpp++ = yylloc;
                yylpe++;
#endif
                yychar = *yylexp++;
                break;
            }
            /* normal operation, no conflict encountered */
#endif /* YYBTYACC */
            yychar = YYLEX;
#if YYBTYACC
            } while (0);
#endif /* YYBTYACC */
            if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
            if (yydebug)
            {
                if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
                fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
                                YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
            }
#endif
        }
        if (yychar == YYEOF) goto yyaccept;
        goto yyloop;
    }
    if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
    {
        fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
            fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
#endif
        fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
    }
#endif
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    *++yystack.s_mark = (YYINT) yystate;
    *++yystack.l_mark = yyval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    *++yystack.p_mark = yyloc;
#endif
    goto yyloop;
#if YYBTYACC

    /* Reduction declares that this path is valid. Set yypath and do a full parse */
yyvalid:
    if (yypath) YYABORT;
    while (yyps->save)
    {
        YYParseState *save = yyps->save;
        yyps->save = save->save;
        save->save = yypath;
        yypath = save;
    }
#if YYDEBUG
    if (yydebug)
        fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
                        YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
#endif
    if (yyerrctx)
    {
        yyFreeState(yyerrctx);
        yyerrctx = NULL;
    }
    yylvp          = yylvals + yypath->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yylpp          = yylpsns + yypath->lexeme;
#endif
    yylexp         = yylexemes + yypath->lexeme;
    yychar         = YYEMPTY;
    yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
    memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
    yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
    memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
    memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
    yystate        = yypath->state;
    goto yyloop;
#endif /* YYBTYACC */

yyoverflow:
    YYERROR_CALL("yacc stack overflow");
#if YYBTYACC
    goto yyabort_nomem;
yyenomem:
    YYERROR_CALL("memory exhausted");
yyabort_nomem:
#endif /* YYBTYACC */
    yyresult = 2;
    goto yyreturn;

yyabort:
    yyresult = 1;
    goto yyreturn;

yyaccept:
#if YYBTYACC
    if (yyps->save) goto yyvalid;
#endif /* YYBTYACC */
    yyresult = 0;

yyreturn:
#if defined(YYDESTRUCT_CALL)
    if (yychar != YYEOF && yychar != YYEMPTY)
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
#else
        YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */

    {
        YYSTYPE *pv;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        YYLTYPE *pp;

        for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
             YYDESTRUCT_CALL("cleanup: discarding state",
                             yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
#else
        for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
             YYDESTRUCT_CALL("cleanup: discarding state",
                             yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
    }
#endif /* defined(YYDESTRUCT_CALL) */

#if YYBTYACC
    if (yyerrctx)
    {
        yyFreeState(yyerrctx);
        yyerrctx = NULL;
    }
    while (yyps)
    {
        YYParseState *save = yyps;
        yyps = save->save;
        save->save = NULL;
        yyFreeState(save);
    }
    while (yypath)
    {
        YYParseState *save = yypath;
        yypath = save->save;
        save->save = NULL;
        yyFreeState(save);
    }
#endif /* YYBTYACC */
    yyfreestack(&yystack);
    return (yyresult);
}
