140081Sbostic #ifndef lint
2*60322Sbostic static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
340081Sbostic #endif
4*60322Sbostic #define YYBYACC 1
5*60322Sbostic #define YYMAJOR 1
6*60322Sbostic #define YYMINOR 9
7*60322Sbostic #define yyclearin (yychar=(-1))
8*60322Sbostic #define yyerrok (yyerrflag=0)
9*60322Sbostic #define YYRECOVERING (yyerrflag!=0)
10*60322Sbostic #define YYPREFIX "yy"
11*60322Sbostic #line 26 "ftp.y"
12*60322Sbostic
13*60322Sbostic #ifndef lint
14*60322Sbostic static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";
15*60322Sbostic #endif /* not lint */
16*60322Sbostic
17*60322Sbostic #include <sys/param.h>
18*60322Sbostic #include <sys/socket.h>
19*60322Sbostic
20*60322Sbostic #include <netinet/in.h>
21*60322Sbostic
22*60322Sbostic #include <arpa/ftp.h>
23*60322Sbostic
24*60322Sbostic #include <stdio.h>
25*60322Sbostic #include <signal.h>
26*60322Sbostic #include <ctype.h>
27*60322Sbostic #include <pwd.h>
28*60322Sbostic #include <setjmp.h>
29*60322Sbostic #include <syslog.h>
30*60322Sbostic #include <sys/stat.h>
31*60322Sbostic #include <time.h>
32*60322Sbostic
33*60322Sbostic extern struct sockaddr_in data_dest;
34*60322Sbostic extern int logged_in;
35*60322Sbostic extern struct passwd *pw;
36*60322Sbostic extern int guest;
37*60322Sbostic extern int logging;
38*60322Sbostic extern int type;
39*60322Sbostic extern int form;
40*60322Sbostic extern int debug;
41*60322Sbostic extern int timeout;
42*60322Sbostic extern int maxtimeout;
43*60322Sbostic extern int pdata;
44*60322Sbostic extern char hostname[], remotehost[];
45*60322Sbostic extern char proctitle[];
46*60322Sbostic extern char *globerr;
47*60322Sbostic extern int usedefault;
48*60322Sbostic extern int transflag;
49*60322Sbostic extern char tmpline[];
50*60322Sbostic char **glob();
51*60322Sbostic
52*60322Sbostic static int cmd_type;
53*60322Sbostic static int cmd_form;
54*60322Sbostic static int cmd_bytesz;
55*60322Sbostic char cbuf[512];
56*60322Sbostic char *fromname;
57*60322Sbostic
58*60322Sbostic char *index();
59*60322Sbostic #line 60 "ftp.tab.c"
6040081Sbostic #define A 257
6140081Sbostic #define B 258
6240081Sbostic #define C 259
6340081Sbostic #define E 260
6440081Sbostic #define F 261
6540081Sbostic #define I 262
6640081Sbostic #define L 263
6740081Sbostic #define N 264
6840081Sbostic #define P 265
6940081Sbostic #define R 266
7040081Sbostic #define S 267
7140081Sbostic #define T 268
7240081Sbostic #define SP 269
7340081Sbostic #define CRLF 270
7440081Sbostic #define COMMA 271
7540081Sbostic #define STRING 272
7640081Sbostic #define NUMBER 273
7740081Sbostic #define USER 274
7840081Sbostic #define PASS 275
7940081Sbostic #define ACCT 276
8040081Sbostic #define REIN 277
8140081Sbostic #define QUIT 278
8240081Sbostic #define PORT 279
8340081Sbostic #define PASV 280
8440081Sbostic #define TYPE 281
8540081Sbostic #define STRU 282
8640081Sbostic #define MODE 283
8740081Sbostic #define RETR 284
8840081Sbostic #define STOR 285
8940081Sbostic #define APPE 286
9040081Sbostic #define MLFL 287
9140081Sbostic #define MAIL 288
9240081Sbostic #define MSND 289
9340081Sbostic #define MSOM 290
9440081Sbostic #define MSAM 291
9540081Sbostic #define MRSQ 292
9640081Sbostic #define MRCP 293
9740081Sbostic #define ALLO 294
9840081Sbostic #define REST 295
9940081Sbostic #define RNFR 296
10040081Sbostic #define RNTO 297
10140081Sbostic #define ABOR 298
10240081Sbostic #define DELE 299
10340081Sbostic #define CWD 300
10440081Sbostic #define LIST 301
10540081Sbostic #define NLST 302
10640081Sbostic #define SITE 303
10740081Sbostic #define STAT 304
10840081Sbostic #define HELP 305
10940081Sbostic #define NOOP 306
11040081Sbostic #define MKD 307
11140081Sbostic #define RMD 308
11240081Sbostic #define PWD 309
11340081Sbostic #define CDUP 310
11440081Sbostic #define STOU 311
11540081Sbostic #define SMNT 312
11640081Sbostic #define SYST 313
11740081Sbostic #define SIZE 314
11840081Sbostic #define MDTM 315
11940081Sbostic #define UMASK 316
12040081Sbostic #define IDLE 317
12140081Sbostic #define CHMOD 318
12240081Sbostic #define LEXERR 319
12340081Sbostic #define YYERRCODE 256
12440084Sbostic short yylhs[] = { -1,
12540081Sbostic 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
12640081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
12740081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
12840081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
12940081Sbostic 1, 1, 1, 1, 1, 1, 2, 3, 4, 4,
13040081Sbostic 12, 5, 13, 13, 13, 6, 6, 6, 6, 6,
13140081Sbostic 6, 6, 6, 7, 7, 7, 8, 8, 8, 10,
13240081Sbostic 14, 11, 9,
13340081Sbostic };
13440084Sbostic short yylen[] = { 2,
13540081Sbostic 0, 2, 2, 4, 4, 4, 2, 4, 4, 4,
13640081Sbostic 4, 8, 5, 5, 5, 3, 5, 3, 5, 5,
13740081Sbostic 2, 5, 4, 2, 3, 5, 2, 4, 2, 5,
13840081Sbostic 5, 3, 3, 4, 6, 5, 7, 9, 4, 6,
13940081Sbostic 5, 2, 5, 5, 2, 2, 5, 1, 0, 1,
14040081Sbostic 1, 11, 1, 1, 1, 1, 3, 1, 3, 1,
14140081Sbostic 1, 3, 2, 1, 1, 1, 1, 1, 1, 1,
14240081Sbostic 1, 1, 0,
14340081Sbostic };
14440084Sbostic short yydefred[] = { 1,
14540081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14640081Sbostic 73, 73, 73, 0, 73, 0, 0, 73, 73, 73,
14740081Sbostic 73, 0, 0, 0, 0, 73, 73, 73, 73, 73,
14840081Sbostic 0, 73, 73, 2, 3, 46, 0, 0, 45, 0,
14940081Sbostic 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15040081Sbostic 24, 0, 0, 0, 0, 0, 21, 0, 0, 27,
15140081Sbostic 29, 0, 0, 0, 0, 0, 42, 0, 0, 48,
15240081Sbostic 0, 50, 0, 0, 0, 0, 0, 60, 0, 0,
15340081Sbostic 64, 66, 65, 0, 68, 69, 67, 0, 0, 0,
15440081Sbostic 0, 0, 0, 71, 0, 70, 0, 0, 25, 0,
15540081Sbostic 18, 0, 16, 0, 73, 0, 73, 0, 0, 0,
15640081Sbostic 0, 32, 33, 0, 0, 0, 4, 5, 0, 6,
15740081Sbostic 0, 0, 0, 51, 63, 8, 9, 10, 0, 0,
15840081Sbostic 0, 0, 11, 0, 23, 0, 0, 0, 0, 0,
15940081Sbostic 34, 0, 0, 39, 0, 0, 28, 0, 0, 0,
16040081Sbostic 0, 0, 0, 55, 53, 54, 57, 59, 62, 13,
16140081Sbostic 14, 15, 0, 47, 22, 26, 19, 17, 0, 0,
16240081Sbostic 36, 0, 0, 20, 30, 31, 41, 43, 44, 0,
16340081Sbostic 0, 35, 72, 0, 40, 0, 0, 0, 37, 0,
16440081Sbostic 0, 12, 0, 0, 38, 0, 0, 0, 52,
16540081Sbostic };
16640084Sbostic short yydgoto[] = { 1,
16740081Sbostic 34, 35, 71, 73, 75, 80, 84, 88, 45, 95,
16840081Sbostic 184, 125, 157, 96,
16940081Sbostic };
17040084Sbostic short yysindex[] = { 0,
17140081Sbostic -224, -247, -239, -236, -232, -222, -204, -200, -181, -177,
17240081Sbostic 0, 0, 0, -166, 0, -161, -199, 0, 0, 0,
17340081Sbostic 0, -160, -159, -264, -158, 0, 0, 0, 0, 0,
17440081Sbostic -157, 0, 0, 0, 0, 0, -167, -162, 0, -156,
17540081Sbostic 0, -250, -198, -165, -155, -154, -153, -151, -150, -152,
17640081Sbostic 0, -145, -252, -229, -217, -302, 0, -144, -146, 0,
17740081Sbostic 0, -142, -141, -140, -139, -137, 0, -136, -135, 0,
17840081Sbostic -134, 0, -133, -132, -130, -131, -128, 0, -249, -127,
17940081Sbostic 0, 0, 0, -126, 0, 0, 0, -125, -152, -152,
18040081Sbostic -152, -205, -152, 0, -124, 0, -152, -152, 0, -152,
18140081Sbostic 0, -143, 0, -173, 0, -171, 0, -152, -123, -152,
18240081Sbostic -152, 0, 0, -152, -152, -152, 0, 0, -138, 0,
18340081Sbostic -164, -164, -122, 0, 0, 0, 0, 0, -121, -120,
18440081Sbostic -118, -148, 0, -117, 0, -116, -115, -114, -113, -112,
18540081Sbostic 0, -163, -111, 0, -110, -109, 0, -107, -106, -105,
18640081Sbostic -104, -103, -129, 0, 0, 0, 0, 0, 0, 0,
18740081Sbostic 0, 0, -101, 0, 0, 0, 0, 0, -100, -102,
18840081Sbostic 0, -98, -102, 0, 0, 0, 0, 0, 0, -99,
18940081Sbostic -97, 0, 0, -95, 0, -96, -94, -92, 0, -152,
19040081Sbostic -93, 0, -91, -90, 0, -88, -87, -86, 0,
19140081Sbostic };
19240084Sbostic short yyrindex[] = { 0,
19340081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19440081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19540081Sbostic 0, 0, -83, 0, 0, 0, 0, 0, 0, 0,
19640081Sbostic 0, 0, 0, 0, 0, 0, 0, -82, 0, 0,
19740081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19840081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19940081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20040081Sbostic 0, 0, 0, 0, 0, -81, -80, 0, -158, 0,
20140081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20240081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20340081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20440081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20540081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20640081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20740081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20840081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20940081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21040081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21140081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21240081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0,
21340081Sbostic };
21440084Sbostic short yygindex[] = { 0,
21540081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 16, -89,
21640081Sbostic -25, 35, 47, 0,
21740081Sbostic };
21840084Sbostic #define YYTABLESIZE 190
21940084Sbostic short yytable[] = { 129,
22040081Sbostic 130, 131, 104, 134, 59, 60, 76, 136, 137, 77,
22140081Sbostic 138, 78, 79, 105, 106, 107, 98, 99, 146, 123,
22240081Sbostic 148, 149, 36, 124, 150, 151, 152, 46, 47, 37,
22340081Sbostic 49, 2, 38, 52, 53, 54, 55, 39, 58, 100,
22440081Sbostic 101, 62, 63, 64, 65, 66, 40, 68, 69, 3,
22540081Sbostic 4, 102, 103, 5, 6, 7, 8, 9, 10, 11,
22640081Sbostic 12, 13, 81, 132, 133, 41, 82, 83, 42, 14,
22740081Sbostic 51, 15, 16, 17, 18, 19, 20, 21, 22, 23,
22840081Sbostic 24, 25, 26, 27, 28, 29, 30, 43, 31, 32,
22940081Sbostic 33, 44, 85, 86, 154, 140, 141, 143, 144, 155,
23040081Sbostic 193, 87, 48, 156, 70, 170, 171, 50, 56, 72,
23140081Sbostic 57, 61, 67, 89, 90, 91, 74, 163, 93, 94,
23240081Sbostic 142, 92, 145, 97, 108, 109, 110, 111, 139, 112,
23340081Sbostic 113, 114, 115, 116, 153, 117, 118, 121, 119, 120,
23440081Sbostic 122, 180, 126, 127, 128, 135, 147, 186, 160, 161,
23540081Sbostic 124, 162, 164, 165, 166, 167, 168, 159, 173, 169,
23640081Sbostic 174, 172, 175, 176, 177, 178, 179, 181, 158, 182,
23740081Sbostic 183, 185, 190, 187, 189, 188, 191, 192, 195, 194,
23840081Sbostic 196, 0, 0, 198, 197, 73, 199, 49, 56, 58,
23940081Sbostic };
24040084Sbostic short yycheck[] = { 89,
24140081Sbostic 90, 91, 305, 93, 269, 270, 257, 97, 98, 260,
24240081Sbostic 100, 262, 263, 316, 317, 318, 269, 270, 108, 269,
24340081Sbostic 110, 111, 270, 273, 114, 115, 116, 12, 13, 269,
24440081Sbostic 15, 256, 269, 18, 19, 20, 21, 270, 23, 269,
24540081Sbostic 270, 26, 27, 28, 29, 30, 269, 32, 33, 274,
24640081Sbostic 275, 269, 270, 278, 279, 280, 281, 282, 283, 284,
24740081Sbostic 285, 286, 261, 269, 270, 270, 265, 266, 269, 294,
24840081Sbostic 270, 296, 297, 298, 299, 300, 301, 302, 303, 304,
24940081Sbostic 305, 306, 307, 308, 309, 310, 311, 269, 313, 314,
25040081Sbostic 315, 269, 258, 259, 259, 269, 270, 269, 270, 264,
25140081Sbostic 190, 267, 269, 268, 272, 269, 270, 269, 269, 272,
25240081Sbostic 270, 270, 270, 269, 269, 269, 273, 266, 269, 272,
25340081Sbostic 105, 273, 107, 269, 269, 272, 269, 269, 272, 270,
25440081Sbostic 270, 269, 269, 269, 273, 270, 270, 269, 271, 270,
25540081Sbostic 269, 271, 270, 270, 270, 270, 270, 173, 270, 270,
25640081Sbostic 273, 270, 270, 270, 270, 270, 270, 123, 269, 272,
25740081Sbostic 270, 273, 270, 270, 270, 270, 270, 269, 122, 270,
25840081Sbostic 273, 270, 269, 273, 270, 273, 271, 270, 270, 273,
25940081Sbostic 271, -1, -1, 271, 273, 269, 273, 270, 270, 270,
26040081Sbostic };
26140081Sbostic #define YYFINAL 1
26240081Sbostic #ifndef YYDEBUG
26340081Sbostic #define YYDEBUG 0
26440081Sbostic #endif
26540081Sbostic #define YYMAXTOKEN 319
26640081Sbostic #if YYDEBUG
26740084Sbostic char *yyname[] = {
26840081Sbostic "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26940081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27040081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27140081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27240081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27340081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27440081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"A","B","C","E","F","I","L","N",
27540081Sbostic "P","R","S","T","SP","CRLF","COMMA","STRING","NUMBER","USER","PASS","ACCT",
27640081Sbostic "REIN","QUIT","PORT","PASV","TYPE","STRU","MODE","RETR","STOR","APPE","MLFL",
27740081Sbostic "MAIL","MSND","MSOM","MSAM","MRSQ","MRCP","ALLO","REST","RNFR","RNTO","ABOR",
27840081Sbostic "DELE","CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP",
27940081Sbostic "STOU","SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","LEXERR",
28040081Sbostic };
28140084Sbostic char *yyrule[] = {
28240081Sbostic "$accept : cmd_list",
28340081Sbostic "cmd_list :",
28440081Sbostic "cmd_list : cmd_list cmd",
28540081Sbostic "cmd_list : cmd_list rcmd",
28640081Sbostic "cmd : USER SP username CRLF",
28740081Sbostic "cmd : PASS SP password CRLF",
28840081Sbostic "cmd : PORT SP host_port CRLF",
28940081Sbostic "cmd : PASV CRLF",
29040081Sbostic "cmd : TYPE SP type_code CRLF",
29140081Sbostic "cmd : STRU SP struct_code CRLF",
29240081Sbostic "cmd : MODE SP mode_code CRLF",
29340081Sbostic "cmd : ALLO SP NUMBER CRLF",
29440081Sbostic "cmd : ALLO SP NUMBER SP R SP NUMBER CRLF",
29540081Sbostic "cmd : RETR check_login SP pathname CRLF",
29640081Sbostic "cmd : STOR check_login SP pathname CRLF",
29740081Sbostic "cmd : APPE check_login SP pathname CRLF",
29840081Sbostic "cmd : NLST check_login CRLF",
29940081Sbostic "cmd : NLST check_login SP STRING CRLF",
30040081Sbostic "cmd : LIST check_login CRLF",
30140081Sbostic "cmd : LIST check_login SP pathname CRLF",
30240081Sbostic "cmd : STAT check_login SP pathname CRLF",
30340081Sbostic "cmd : STAT CRLF",
30440081Sbostic "cmd : DELE check_login SP pathname CRLF",
30540081Sbostic "cmd : RNTO SP pathname CRLF",
30640081Sbostic "cmd : ABOR CRLF",
30740081Sbostic "cmd : CWD check_login CRLF",
30840081Sbostic "cmd : CWD check_login SP pathname CRLF",
30940081Sbostic "cmd : HELP CRLF",
31040081Sbostic "cmd : HELP SP STRING CRLF",
31140081Sbostic "cmd : NOOP CRLF",
31240081Sbostic "cmd : MKD check_login SP pathname CRLF",
31340081Sbostic "cmd : RMD check_login SP pathname CRLF",
31440081Sbostic "cmd : PWD check_login CRLF",
31540081Sbostic "cmd : CDUP check_login CRLF",
31640081Sbostic "cmd : SITE SP HELP CRLF",
31740081Sbostic "cmd : SITE SP HELP SP STRING CRLF",
31840081Sbostic "cmd : SITE SP UMASK check_login CRLF",
31940081Sbostic "cmd : SITE SP UMASK check_login SP octal_number CRLF",
32040081Sbostic "cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF",
32140081Sbostic "cmd : SITE SP IDLE CRLF",
32240081Sbostic "cmd : SITE SP IDLE SP NUMBER CRLF",
32340081Sbostic "cmd : STOU check_login SP pathname CRLF",
32440081Sbostic "cmd : SYST CRLF",
32540081Sbostic "cmd : SIZE check_login SP pathname CRLF",
32640081Sbostic "cmd : MDTM check_login SP pathname CRLF",
32740081Sbostic "cmd : QUIT CRLF",
32840081Sbostic "cmd : error CRLF",
32940081Sbostic "rcmd : RNFR check_login SP pathname CRLF",
33040081Sbostic "username : STRING",
33140081Sbostic "password :",
33240081Sbostic "password : STRING",
33340081Sbostic "byte_size : NUMBER",
33440081Sbostic "host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER",
33540081Sbostic "form_code : N",
33640081Sbostic "form_code : T",
33740081Sbostic "form_code : C",
33840081Sbostic "type_code : A",
33940081Sbostic "type_code : A SP form_code",
34040081Sbostic "type_code : E",
34140081Sbostic "type_code : E SP form_code",
34240081Sbostic "type_code : I",
34340081Sbostic "type_code : L",
34440081Sbostic "type_code : L SP byte_size",
34540081Sbostic "type_code : L byte_size",
34640081Sbostic "struct_code : F",
34740081Sbostic "struct_code : R",
34840081Sbostic "struct_code : P",
34940081Sbostic "mode_code : S",
35040081Sbostic "mode_code : B",
35140081Sbostic "mode_code : C",
35240081Sbostic "pathname : pathstring",
35340081Sbostic "pathstring : STRING",
35440081Sbostic "octal_number : NUMBER",
35540081Sbostic "check_login :",
35640081Sbostic };
35740081Sbostic #endif
35840081Sbostic #ifndef YYSTYPE
35940081Sbostic typedef int YYSTYPE;
36040081Sbostic #endif
361*60322Sbostic #ifdef YYSTACKSIZE
362*60322Sbostic #undef YYMAXDEPTH
363*60322Sbostic #define YYMAXDEPTH YYSTACKSIZE
364*60322Sbostic #else
36540081Sbostic #ifdef YYMAXDEPTH
36640081Sbostic #define YYSTACKSIZE YYMAXDEPTH
36740081Sbostic #else
368*60322Sbostic #define YYSTACKSIZE 500
369*60322Sbostic #define YYMAXDEPTH 500
37040081Sbostic #endif
37140081Sbostic #endif
37240081Sbostic int yydebug;
37340081Sbostic int yynerrs;
37440081Sbostic int yyerrflag;
37540081Sbostic int yychar;
37640081Sbostic short *yyssp;
37740081Sbostic YYSTYPE *yyvsp;
37840081Sbostic YYSTYPE yyval;
37940081Sbostic YYSTYPE yylval;
38040081Sbostic short yyss[YYSTACKSIZE];
38140081Sbostic YYSTYPE yyvs[YYSTACKSIZE];
382*60322Sbostic #define yystacksize YYSTACKSIZE
38340081Sbostic #line 658 "ftp.y"
38440081Sbostic
38540081Sbostic extern jmp_buf errcatch;
38640081Sbostic
38740081Sbostic #define CMD 0 /* beginning of command */
38840081Sbostic #define ARGS 1 /* expect miscellaneous arguments */
38940081Sbostic #define STR1 2 /* expect SP followed by STRING */
39040081Sbostic #define STR2 3 /* expect STRING */
39140081Sbostic #define OSTR 4 /* optional SP then STRING */
39240081Sbostic #define ZSTR1 5 /* SP then optional STRING */
39340081Sbostic #define ZSTR2 6 /* optional STRING after SP */
39440081Sbostic #define SITECMD 7 /* SITE command */
39540081Sbostic #define NSTR 8 /* Number followed by a string */
39640081Sbostic
39740081Sbostic struct tab {
39840081Sbostic char *name;
39940081Sbostic short token;
40040081Sbostic short state;
40140081Sbostic short implemented; /* 1 if command is implemented */
40240081Sbostic char *help;
40340081Sbostic };
40440081Sbostic
40540081Sbostic struct tab cmdtab[] = { /* In order defined in RFC 765 */
40640081Sbostic { "USER", USER, STR1, 1, "<sp> username" },
40740081Sbostic { "PASS", PASS, ZSTR1, 1, "<sp> password" },
40840081Sbostic { "ACCT", ACCT, STR1, 0, "(specify account)" },
40940081Sbostic { "SMNT", SMNT, ARGS, 0, "(structure mount)" },
41040081Sbostic { "REIN", REIN, ARGS, 0, "(reinitialize server state)" },
41140081Sbostic { "QUIT", QUIT, ARGS, 1, "(terminate service)", },
41240081Sbostic { "PORT", PORT, ARGS, 1, "<sp> b0, b1, b2, b3, b4" },
41340081Sbostic { "PASV", PASV, ARGS, 1, "(set server in passive mode)" },
41440081Sbostic { "TYPE", TYPE, ARGS, 1, "<sp> [ A | E | I | L ]" },
41540081Sbostic { "STRU", STRU, ARGS, 1, "(specify file structure)" },
41640081Sbostic { "MODE", MODE, ARGS, 1, "(specify transfer mode)" },
41740081Sbostic { "RETR", RETR, STR1, 1, "<sp> file-name" },
41840081Sbostic { "STOR", STOR, STR1, 1, "<sp> file-name" },
41940081Sbostic { "APPE", APPE, STR1, 1, "<sp> file-name" },
42040081Sbostic { "MLFL", MLFL, OSTR, 0, "(mail file)" },
42140081Sbostic { "MAIL", MAIL, OSTR, 0, "(mail to user)" },
42240081Sbostic { "MSND", MSND, OSTR, 0, "(mail send to terminal)" },
42340081Sbostic { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" },
42440081Sbostic { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" },
42540081Sbostic { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" },
42640081Sbostic { "MRCP", MRCP, STR1, 0, "(mail recipient)" },
42740081Sbostic { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" },
42840081Sbostic { "REST", REST, ARGS, 0, "(restart command)" },
42940081Sbostic { "RNFR", RNFR, STR1, 1, "<sp> file-name" },
43040081Sbostic { "RNTO", RNTO, STR1, 1, "<sp> file-name" },
43140081Sbostic { "ABOR", ABOR, ARGS, 1, "(abort operation)" },
43240081Sbostic { "DELE", DELE, STR1, 1, "<sp> file-name" },
43340081Sbostic { "CWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
43440081Sbostic { "XCWD", CWD, OSTR, 1, "[ <sp> directory-name ]" },
43540081Sbostic { "LIST", LIST, OSTR, 1, "[ <sp> path-name ]" },
43640081Sbostic { "NLST", NLST, OSTR, 1, "[ <sp> path-name ]" },
43740081Sbostic { "SITE", SITE, SITECMD, 1, "site-cmd [ <sp> arguments ]" },
43840081Sbostic { "SYST", SYST, ARGS, 1, "(get type of operating system)" },
43940081Sbostic { "STAT", STAT, OSTR, 1, "[ <sp> path-name ]" },
44040081Sbostic { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
44140081Sbostic { "NOOP", NOOP, ARGS, 1, "" },
44240081Sbostic { "MKD", MKD, STR1, 1, "<sp> path-name" },
44340081Sbostic { "XMKD", MKD, STR1, 1, "<sp> path-name" },
44440081Sbostic { "RMD", RMD, STR1, 1, "<sp> path-name" },
44540081Sbostic { "XRMD", RMD, STR1, 1, "<sp> path-name" },
44640081Sbostic { "PWD", PWD, ARGS, 1, "(return current directory)" },
44740081Sbostic { "XPWD", PWD, ARGS, 1, "(return current directory)" },
44840081Sbostic { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" },
44940081Sbostic { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" },
45040081Sbostic { "STOU", STOU, STR1, 1, "<sp> file-name" },
45140081Sbostic { "SIZE", SIZE, OSTR, 1, "<sp> path-name" },
45240081Sbostic { "MDTM", MDTM, OSTR, 1, "<sp> path-name" },
45340081Sbostic { NULL, 0, 0, 0, 0 }
45440081Sbostic };
45540081Sbostic
45640081Sbostic struct tab sitetab[] = {
45740081Sbostic { "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" },
45840081Sbostic { "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
45940081Sbostic { "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },
46040081Sbostic { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
46140081Sbostic { NULL, 0, 0, 0, 0 }
46240081Sbostic };
46340081Sbostic
46440081Sbostic struct tab *
lookup(p,cmd)46540081Sbostic lookup(p, cmd)
46640081Sbostic register struct tab *p;
46740081Sbostic char *cmd;
46840081Sbostic {
46940081Sbostic
47040081Sbostic for (; p->name != NULL; p++)
47140081Sbostic if (strcmp(cmd, p->name) == 0)
47240081Sbostic return (p);
47340081Sbostic return (0);
47440081Sbostic }
47540081Sbostic
47640081Sbostic #include <arpa/telnet.h>
47740081Sbostic
47840081Sbostic /*
47940081Sbostic * getline - a hacked up version of fgets to ignore TELNET escape codes.
48040081Sbostic */
48140081Sbostic char *
getline(s,n,iop)48240081Sbostic getline(s, n, iop)
48340081Sbostic char *s;
48440081Sbostic register FILE *iop;
48540081Sbostic {
48640081Sbostic register c;
48740081Sbostic register char *cs;
48840081Sbostic
48940081Sbostic cs = s;
49040081Sbostic /* tmpline may contain saved command from urgent mode interruption */
49140081Sbostic for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
49240081Sbostic *cs++ = tmpline[c];
49340081Sbostic if (tmpline[c] == '\n') {
49440081Sbostic *cs++ = '\0';
49540081Sbostic if (debug)
49640081Sbostic syslog(LOG_DEBUG, "command: %s", s);
49740081Sbostic tmpline[0] = '\0';
49840081Sbostic return(s);
49940081Sbostic }
50040081Sbostic if (c == 0)
50140081Sbostic tmpline[0] = '\0';
50240081Sbostic }
50340081Sbostic while ((c = getc(iop)) != EOF) {
50440081Sbostic c &= 0377;
50540081Sbostic if (c == IAC) {
50640081Sbostic if ((c = getc(iop)) != EOF) {
50740081Sbostic c &= 0377;
50840081Sbostic switch (c) {
50940081Sbostic case WILL:
51040081Sbostic case WONT:
51140081Sbostic c = getc(iop);
51240081Sbostic printf("%c%c%c", IAC, DONT, 0377&c);
51340081Sbostic (void) fflush(stdout);
51440081Sbostic continue;
51540081Sbostic case DO:
51640081Sbostic case DONT:
51740081Sbostic c = getc(iop);
51840081Sbostic printf("%c%c%c", IAC, WONT, 0377&c);
51940081Sbostic (void) fflush(stdout);
52040081Sbostic continue;
52140081Sbostic case IAC:
52240081Sbostic break;
52340081Sbostic default:
52440081Sbostic continue; /* ignore command */
52540081Sbostic }
52640081Sbostic }
52740081Sbostic }
52840081Sbostic *cs++ = c;
52940081Sbostic if (--n <= 0 || c == '\n')
53040081Sbostic break;
53140081Sbostic }
53240081Sbostic if (c == EOF && cs == s)
53340081Sbostic return (NULL);
53440081Sbostic *cs++ = '\0';
53540081Sbostic if (debug)
53640081Sbostic syslog(LOG_DEBUG, "command: %s", s);
53740081Sbostic return (s);
53840081Sbostic }
53940081Sbostic
54040081Sbostic static int
toolong()54140081Sbostic toolong()
54240081Sbostic {
54340081Sbostic time_t now;
54440081Sbostic extern char *ctime();
54540081Sbostic extern time_t time();
54640081Sbostic
54740081Sbostic reply(421,
54840081Sbostic "Timeout (%d seconds): closing control connection.", timeout);
54940081Sbostic (void) time(&now);
55040081Sbostic if (logging) {
55140081Sbostic syslog(LOG_INFO,
55240081Sbostic "User %s timed out after %d seconds at %s",
55340081Sbostic (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now));
55440081Sbostic }
55540081Sbostic dologout(1);
55640081Sbostic }
55740081Sbostic
yylex()55840081Sbostic yylex()
55940081Sbostic {
56040081Sbostic static int cpos, state;
56140081Sbostic register char *cp, *cp2;
56240081Sbostic register struct tab *p;
56340081Sbostic int n;
56440081Sbostic char c, *strpbrk();
56540081Sbostic char *copy();
56640081Sbostic
56740081Sbostic for (;;) {
56840081Sbostic switch (state) {
56940081Sbostic
57040081Sbostic case CMD:
57140081Sbostic (void) signal(SIGALRM, toolong);
57240081Sbostic (void) alarm((unsigned) timeout);
57340081Sbostic if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) {
57440081Sbostic reply(221, "You could at least say goodbye.");
57540081Sbostic dologout(0);
57640081Sbostic }
57740081Sbostic (void) alarm(0);
57840081Sbostic #ifdef SETPROCTITLE
57940081Sbostic if (strncasecmp(cbuf, "PASS", 4) != NULL)
58040081Sbostic setproctitle("%s: %s", proctitle, cbuf);
58140081Sbostic #endif /* SETPROCTITLE */
58240081Sbostic if ((cp = index(cbuf, '\r'))) {
58340081Sbostic *cp++ = '\n';
58440081Sbostic *cp = '\0';
58540081Sbostic }
58640081Sbostic if ((cp = strpbrk(cbuf, " \n")))
58740081Sbostic cpos = cp - cbuf;
58840081Sbostic if (cpos == 0)
58940081Sbostic cpos = 4;
59040081Sbostic c = cbuf[cpos];
59140081Sbostic cbuf[cpos] = '\0';
59240081Sbostic upper(cbuf);
59340081Sbostic p = lookup(cmdtab, cbuf);
59440081Sbostic cbuf[cpos] = c;
59540081Sbostic if (p != 0) {
59640081Sbostic if (p->implemented == 0) {
59740081Sbostic nack(p->name);
59840081Sbostic longjmp(errcatch,0);
59940081Sbostic /* NOTREACHED */
60040081Sbostic }
60140081Sbostic state = p->state;
60240081Sbostic *(char **)&yylval = p->name;
60340081Sbostic return (p->token);
60440081Sbostic }
60540081Sbostic break;
60640081Sbostic
60740081Sbostic case SITECMD:
60840081Sbostic if (cbuf[cpos] == ' ') {
60940081Sbostic cpos++;
61040081Sbostic return (SP);
61140081Sbostic }
61240081Sbostic cp = &cbuf[cpos];
61340081Sbostic if ((cp2 = strpbrk(cp, " \n")))
61440081Sbostic cpos = cp2 - cbuf;
61540081Sbostic c = cbuf[cpos];
61640081Sbostic cbuf[cpos] = '\0';
61740081Sbostic upper(cp);
61840081Sbostic p = lookup(sitetab, cp);
61940081Sbostic cbuf[cpos] = c;
62040081Sbostic if (p != 0) {
62140081Sbostic if (p->implemented == 0) {
62240081Sbostic state = CMD;
62340081Sbostic nack(p->name);
62440081Sbostic longjmp(errcatch,0);
62540081Sbostic /* NOTREACHED */
62640081Sbostic }
62740081Sbostic state = p->state;
62840081Sbostic *(char **)&yylval = p->name;
62940081Sbostic return (p->token);
63040081Sbostic }
63140081Sbostic state = CMD;
63240081Sbostic break;
63340081Sbostic
63440081Sbostic case OSTR:
63540081Sbostic if (cbuf[cpos] == '\n') {
63640081Sbostic state = CMD;
63740081Sbostic return (CRLF);
63840081Sbostic }
63940081Sbostic /* FALLTHROUGH */
64040081Sbostic
64140081Sbostic case STR1:
64240081Sbostic case ZSTR1:
64340081Sbostic dostr1:
64440081Sbostic if (cbuf[cpos] == ' ') {
64540081Sbostic cpos++;
64640081Sbostic state = state == OSTR ? STR2 : ++state;
64740081Sbostic return (SP);
64840081Sbostic }
64940081Sbostic break;
65040081Sbostic
65140081Sbostic case ZSTR2:
65240081Sbostic if (cbuf[cpos] == '\n') {
65340081Sbostic state = CMD;
65440081Sbostic return (CRLF);
65540081Sbostic }
65640081Sbostic /* FALLTHROUGH */
65740081Sbostic
65840081Sbostic case STR2:
65940081Sbostic cp = &cbuf[cpos];
66040081Sbostic n = strlen(cp);
66140081Sbostic cpos += n - 1;
66240081Sbostic /*
66340081Sbostic * Make sure the string is nonempty and \n terminated.
66440081Sbostic */
66540081Sbostic if (n > 1 && cbuf[cpos] == '\n') {
66640081Sbostic cbuf[cpos] = '\0';
66740081Sbostic *(char **)&yylval = copy(cp);
66840081Sbostic cbuf[cpos] = '\n';
66940081Sbostic state = ARGS;
67040081Sbostic return (STRING);
67140081Sbostic }
67240081Sbostic break;
67340081Sbostic
67440081Sbostic case NSTR:
67540081Sbostic if (cbuf[cpos] == ' ') {
67640081Sbostic cpos++;
67740081Sbostic return (SP);
67840081Sbostic }
67940081Sbostic if (isdigit(cbuf[cpos])) {
68040081Sbostic cp = &cbuf[cpos];
68140081Sbostic while (isdigit(cbuf[++cpos]))
68240081Sbostic ;
68340081Sbostic c = cbuf[cpos];
68440081Sbostic cbuf[cpos] = '\0';
68540081Sbostic yylval = atoi(cp);
68640081Sbostic cbuf[cpos] = c;
68740081Sbostic state = STR1;
68840081Sbostic return (NUMBER);
68940081Sbostic }
69040081Sbostic state = STR1;
69140081Sbostic goto dostr1;
69240081Sbostic
69340081Sbostic case ARGS:
69440081Sbostic if (isdigit(cbuf[cpos])) {
69540081Sbostic cp = &cbuf[cpos];
69640081Sbostic while (isdigit(cbuf[++cpos]))
69740081Sbostic ;
69840081Sbostic c = cbuf[cpos];
69940081Sbostic cbuf[cpos] = '\0';
70040081Sbostic yylval = atoi(cp);
70140081Sbostic cbuf[cpos] = c;
70240081Sbostic return (NUMBER);
70340081Sbostic }
70440081Sbostic switch (cbuf[cpos++]) {
70540081Sbostic
70640081Sbostic case '\n':
70740081Sbostic state = CMD;
70840081Sbostic return (CRLF);
70940081Sbostic
71040081Sbostic case ' ':
71140081Sbostic return (SP);
71240081Sbostic
71340081Sbostic case ',':
71440081Sbostic return (COMMA);
71540081Sbostic
71640081Sbostic case 'A':
71740081Sbostic case 'a':
71840081Sbostic return (A);
71940081Sbostic
72040081Sbostic case 'B':
72140081Sbostic case 'b':
72240081Sbostic return (B);
72340081Sbostic
72440081Sbostic case 'C':
72540081Sbostic case 'c':
72640081Sbostic return (C);
72740081Sbostic
72840081Sbostic case 'E':
72940081Sbostic case 'e':
73040081Sbostic return (E);
73140081Sbostic
73240081Sbostic case 'F':
73340081Sbostic case 'f':
73440081Sbostic return (F);
73540081Sbostic
73640081Sbostic case 'I':
73740081Sbostic case 'i':
73840081Sbostic return (I);
73940081Sbostic
74040081Sbostic case 'L':
74140081Sbostic case 'l':
74240081Sbostic return (L);
74340081Sbostic
74440081Sbostic case 'N':
74540081Sbostic case 'n':
74640081Sbostic return (N);
74740081Sbostic
74840081Sbostic case 'P':
74940081Sbostic case 'p':
75040081Sbostic return (P);
75140081Sbostic
75240081Sbostic case 'R':
75340081Sbostic case 'r':
75440081Sbostic return (R);
75540081Sbostic
75640081Sbostic case 'S':
75740081Sbostic case 's':
75840081Sbostic return (S);
75940081Sbostic
76040081Sbostic case 'T':
76140081Sbostic case 't':
76240081Sbostic return (T);
76340081Sbostic
76440081Sbostic }
76540081Sbostic break;
76640081Sbostic
76740081Sbostic default:
76840081Sbostic fatal("Unknown state in scanner.");
76940081Sbostic }
77040081Sbostic yyerror((char *) 0);
77140081Sbostic state = CMD;
77240081Sbostic longjmp(errcatch,0);
77340081Sbostic }
77440081Sbostic }
77540081Sbostic
upper(s)77640081Sbostic upper(s)
77740081Sbostic register char *s;
77840081Sbostic {
77940081Sbostic while (*s != '\0') {
78040081Sbostic if (islower(*s))
78140081Sbostic *s = toupper(*s);
78240081Sbostic s++;
78340081Sbostic }
78440081Sbostic }
78540081Sbostic
78640081Sbostic char *
copy(s)78740081Sbostic copy(s)
78840081Sbostic char *s;
78940081Sbostic {
79040081Sbostic char *p;
79140081Sbostic extern char *malloc(), *strcpy();
79240081Sbostic
79340081Sbostic p = malloc((unsigned) strlen(s) + 1);
79440081Sbostic if (p == NULL)
79540081Sbostic fatal("Ran out of memory.");
79640081Sbostic (void) strcpy(p, s);
79740081Sbostic return (p);
79840081Sbostic }
79940081Sbostic
80040081Sbostic help(ctab, s)
80140081Sbostic struct tab *ctab;
80240081Sbostic char *s;
80340081Sbostic {
80440081Sbostic register struct tab *c;
80540081Sbostic register int width, NCMDS;
80640081Sbostic char *type;
80740081Sbostic
80840081Sbostic if (ctab == sitetab)
80940081Sbostic type = "SITE ";
81040081Sbostic else
81140081Sbostic type = "";
81240081Sbostic width = 0, NCMDS = 0;
81340081Sbostic for (c = ctab; c->name != NULL; c++) {
81440081Sbostic int len = strlen(c->name);
81540081Sbostic
81640081Sbostic if (len > width)
81740081Sbostic width = len;
81840081Sbostic NCMDS++;
81940081Sbostic }
82040081Sbostic width = (width + 8) &~ 7;
82140081Sbostic if (s == 0) {
82240081Sbostic register int i, j, w;
82340081Sbostic int columns, lines;
82440081Sbostic
82540081Sbostic lreply(214, "The following %scommands are recognized %s.",
82640081Sbostic type, "(* =>'s unimplemented)");
82740081Sbostic columns = 76 / width;
82840081Sbostic if (columns == 0)
82940081Sbostic columns = 1;
83040081Sbostic lines = (NCMDS + columns - 1) / columns;
83140081Sbostic for (i = 0; i < lines; i++) {
83240081Sbostic printf(" ");
83340081Sbostic for (j = 0; j < columns; j++) {
83440081Sbostic c = ctab + j * lines + i;
83540081Sbostic printf("%s%c", c->name,
83640081Sbostic c->implemented ? ' ' : '*');
83740081Sbostic if (c + lines >= &ctab[NCMDS])
83840081Sbostic break;
83940081Sbostic w = strlen(c->name) + 1;
84040081Sbostic while (w < width) {
84140081Sbostic putchar(' ');
84240081Sbostic w++;
84340081Sbostic }
84440081Sbostic }
84540081Sbostic printf("\r\n");
84640081Sbostic }
84740081Sbostic (void) fflush(stdout);
84840081Sbostic reply(214, "Direct comments to ftp-bugs@%s.", hostname);
84940081Sbostic return;
85040081Sbostic }
85140081Sbostic upper(s);
85240081Sbostic c = lookup(ctab, s);
85340081Sbostic if (c == (struct tab *)0) {
85440081Sbostic reply(502, "Unknown command %s.", s);
85540081Sbostic return;
85640081Sbostic }
85740081Sbostic if (c->implemented)
85840081Sbostic reply(214, "Syntax: %s%s %s", type, c->name, c->help);
85940081Sbostic else
86040081Sbostic reply(214, "%s%-*s\t%s; unimplemented.", type, width,
86140081Sbostic c->name, c->help);
86240081Sbostic }
86340081Sbostic
sizecmd(filename)86440081Sbostic sizecmd(filename)
86540081Sbostic char *filename;
86640081Sbostic {
86740081Sbostic switch (type) {
86840081Sbostic case TYPE_L:
86940081Sbostic case TYPE_I: {
87040081Sbostic struct stat stbuf;
87140081Sbostic if (stat(filename, &stbuf) < 0 ||
87240081Sbostic (stbuf.st_mode&S_IFMT) != S_IFREG)
87340081Sbostic reply(550, "%s: not a plain file.", filename);
87440081Sbostic else
87540081Sbostic reply(213, "%lu", stbuf.st_size);
87640081Sbostic break;}
87740081Sbostic case TYPE_A: {
87840081Sbostic FILE *fin;
87940081Sbostic register int c, count;
88040081Sbostic struct stat stbuf;
88140081Sbostic fin = fopen(filename, "r");
88240081Sbostic if (fin == NULL) {
88340081Sbostic perror_reply(550, filename);
88440081Sbostic return;
88540081Sbostic }
88640081Sbostic if (fstat(fileno(fin), &stbuf) < 0 ||
88740081Sbostic (stbuf.st_mode&S_IFMT) != S_IFREG) {
88840081Sbostic reply(550, "%s: not a plain file.", filename);
88940081Sbostic (void) fclose(fin);
89040081Sbostic return;
89140081Sbostic }
89240081Sbostic
89340081Sbostic count = 0;
89440081Sbostic while((c=getc(fin)) != EOF) {
89540081Sbostic if (c == '\n') /* will get expanded to \r\n */
89640081Sbostic count++;
89740081Sbostic count++;
89840081Sbostic }
89940081Sbostic (void) fclose(fin);
90040081Sbostic
90140081Sbostic reply(213, "%ld", count);
90240081Sbostic break;}
90340081Sbostic default:
90440081Sbostic reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
90540081Sbostic }
90640081Sbostic }
907*60322Sbostic #line 908 "ftp.tab.c"
90840084Sbostic #define YYABORT goto yyabort
909*60322Sbostic #define YYREJECT goto yyabort
91040081Sbostic #define YYACCEPT goto yyaccept
91140081Sbostic #define YYERROR goto yyerrlab
91240081Sbostic int
yyparse()91340081Sbostic yyparse()
91440081Sbostic {
91540081Sbostic register int yym, yyn, yystate;
91640081Sbostic #if YYDEBUG
91740081Sbostic register char *yys;
91840081Sbostic extern char *getenv();
91940081Sbostic
92040081Sbostic if (yys = getenv("YYDEBUG"))
92140081Sbostic {
92240081Sbostic yyn = *yys;
923*60322Sbostic if (yyn >= '0' && yyn <= '9')
92440081Sbostic yydebug = yyn - '0';
92540081Sbostic }
92640081Sbostic #endif
92740081Sbostic
92840081Sbostic yynerrs = 0;
92940081Sbostic yyerrflag = 0;
93040081Sbostic yychar = (-1);
93140081Sbostic
93240081Sbostic yyssp = yyss;
93340081Sbostic yyvsp = yyvs;
93440081Sbostic *yyssp = yystate = 0;
93540081Sbostic
93640081Sbostic yyloop:
93740081Sbostic if (yyn = yydefred[yystate]) goto yyreduce;
93840081Sbostic if (yychar < 0)
93940081Sbostic {
94040081Sbostic if ((yychar = yylex()) < 0) yychar = 0;
94140081Sbostic #if YYDEBUG
94240081Sbostic if (yydebug)
94340081Sbostic {
94440081Sbostic yys = 0;
94540081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
94640081Sbostic if (!yys) yys = "illegal-symbol";
947*60322Sbostic printf("%sdebug: state %d, reading %d (%s)\n",
948*60322Sbostic YYPREFIX, yystate, yychar, yys);
94940081Sbostic }
95040081Sbostic #endif
95140081Sbostic }
95240081Sbostic if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
95340081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
95440081Sbostic {
95540081Sbostic #if YYDEBUG
95640081Sbostic if (yydebug)
957*60322Sbostic printf("%sdebug: state %d, shifting to state %d\n",
958*60322Sbostic YYPREFIX, yystate, yytable[yyn]);
95940081Sbostic #endif
96040081Sbostic if (yyssp >= yyss + yystacksize - 1)
96140081Sbostic {
96240081Sbostic goto yyoverflow;
96340081Sbostic }
96440081Sbostic *++yyssp = yystate = yytable[yyn];
96540081Sbostic *++yyvsp = yylval;
96640081Sbostic yychar = (-1);
96740081Sbostic if (yyerrflag > 0) --yyerrflag;
96840081Sbostic goto yyloop;
96940081Sbostic }
97040081Sbostic if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
97140081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
97240081Sbostic {
97340081Sbostic yyn = yytable[yyn];
97440081Sbostic goto yyreduce;
97540081Sbostic }
97640081Sbostic if (yyerrflag) goto yyinrecovery;
97740084Sbostic #ifdef lint
97840084Sbostic goto yynewerror;
97940084Sbostic #endif
98040081Sbostic yynewerror:
98140081Sbostic yyerror("syntax error");
98240084Sbostic #ifdef lint
98340084Sbostic goto yyerrlab;
98440084Sbostic #endif
98540081Sbostic yyerrlab:
98640081Sbostic ++yynerrs;
98740081Sbostic yyinrecovery:
98840081Sbostic if (yyerrflag < 3)
98940081Sbostic {
99040081Sbostic yyerrflag = 3;
99140081Sbostic for (;;)
99240081Sbostic {
99340081Sbostic if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
99440081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
99540081Sbostic {
99640081Sbostic #if YYDEBUG
99740081Sbostic if (yydebug)
998*60322Sbostic printf("%sdebug: state %d, error recovery shifting\
999*60322Sbostic to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
100040081Sbostic #endif
100140081Sbostic if (yyssp >= yyss + yystacksize - 1)
100240081Sbostic {
100340081Sbostic goto yyoverflow;
100440081Sbostic }
100540081Sbostic *++yyssp = yystate = yytable[yyn];
100640081Sbostic *++yyvsp = yylval;
100740081Sbostic goto yyloop;
100840081Sbostic }
100940081Sbostic else
101040081Sbostic {
101140081Sbostic #if YYDEBUG
101240081Sbostic if (yydebug)
1013*60322Sbostic printf("%sdebug: error recovery discarding state %d\n",
1014*60322Sbostic YYPREFIX, *yyssp);
101540081Sbostic #endif
101640081Sbostic if (yyssp <= yyss) goto yyabort;
101740081Sbostic --yyssp;
101840081Sbostic --yyvsp;
101940081Sbostic }
102040081Sbostic }
102140081Sbostic }
102240081Sbostic else
102340081Sbostic {
102440081Sbostic if (yychar == 0) goto yyabort;
102540081Sbostic #if YYDEBUG
102640081Sbostic if (yydebug)
102740081Sbostic {
102840081Sbostic yys = 0;
102940081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
103040081Sbostic if (!yys) yys = "illegal-symbol";
1031*60322Sbostic printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1032*60322Sbostic YYPREFIX, yystate, yychar, yys);
103340081Sbostic }
103440081Sbostic #endif
103540081Sbostic yychar = (-1);
103640081Sbostic goto yyloop;
103740081Sbostic }
103840081Sbostic yyreduce:
103940081Sbostic #if YYDEBUG
104040081Sbostic if (yydebug)
1041*60322Sbostic printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1042*60322Sbostic YYPREFIX, yystate, yyn, yyrule[yyn]);
104340081Sbostic #endif
104440081Sbostic yym = yylen[yyn];
104540081Sbostic yyval = yyvsp[1-yym];
104640081Sbostic switch (yyn)
104740081Sbostic {
104840081Sbostic case 2:
104940081Sbostic #line 99 "ftp.y"
105040081Sbostic {
105140081Sbostic fromname = (char *) 0;
105240081Sbostic }
105340081Sbostic break;
105440081Sbostic case 4:
105540081Sbostic #line 106 "ftp.y"
105640081Sbostic {
105740081Sbostic user((char *) yyvsp[-1]);
105840081Sbostic free((char *) yyvsp[-1]);
105940081Sbostic }
106040081Sbostic break;
106140081Sbostic case 5:
106240081Sbostic #line 111 "ftp.y"
106340081Sbostic {
106440081Sbostic pass((char *) yyvsp[-1]);
106540081Sbostic free((char *) yyvsp[-1]);
106640081Sbostic }
106740081Sbostic break;
106840081Sbostic case 6:
106940081Sbostic #line 116 "ftp.y"
107040081Sbostic {
107140081Sbostic usedefault = 0;
107240081Sbostic if (pdata >= 0) {
107340081Sbostic (void) close(pdata);
107440081Sbostic pdata = -1;
107540081Sbostic }
107640081Sbostic reply(200, "PORT command successful.");
107740081Sbostic }
107840081Sbostic break;
107940081Sbostic case 7:
108040081Sbostic #line 125 "ftp.y"
108140081Sbostic {
108240081Sbostic passive();
108340081Sbostic }
108440081Sbostic break;
108540081Sbostic case 8:
108640081Sbostic #line 129 "ftp.y"
108740081Sbostic {
108840081Sbostic switch (cmd_type) {
108940081Sbostic
109040081Sbostic case TYPE_A:
109140081Sbostic if (cmd_form == FORM_N) {
109240081Sbostic reply(200, "Type set to A.");
109340081Sbostic type = cmd_type;
109440081Sbostic form = cmd_form;
109540081Sbostic } else
109640081Sbostic reply(504, "Form must be N.");
109740081Sbostic break;
109840081Sbostic
109940081Sbostic case TYPE_E:
110040081Sbostic reply(504, "Type E not implemented.");
110140081Sbostic break;
110240081Sbostic
110340081Sbostic case TYPE_I:
110440081Sbostic reply(200, "Type set to I.");
110540081Sbostic type = cmd_type;
110640081Sbostic break;
110740081Sbostic
110840081Sbostic case TYPE_L:
110940081Sbostic #if NBBY == 8
111040081Sbostic if (cmd_bytesz == 8) {
111140081Sbostic reply(200,
111240081Sbostic "Type set to L (byte size 8).");
111340081Sbostic type = cmd_type;
111440081Sbostic } else
111540081Sbostic reply(504, "Byte size must be 8.");
111640081Sbostic #else /* NBBY == 8 */
111740081Sbostic UNIMPLEMENTED for NBBY != 8
111840081Sbostic #endif /* NBBY == 8 */
111940081Sbostic }
112040081Sbostic }
112140081Sbostic break;
112240081Sbostic case 9:
112340081Sbostic #line 164 "ftp.y"
112440081Sbostic {
112540081Sbostic switch (yyvsp[-1]) {
112640081Sbostic
112740081Sbostic case STRU_F:
112840081Sbostic reply(200, "STRU F ok.");
112940081Sbostic break;
113040081Sbostic
113140081Sbostic default:
113240081Sbostic reply(504, "Unimplemented STRU type.");
113340081Sbostic }
113440081Sbostic }
113540081Sbostic break;
113640081Sbostic case 10:
113740081Sbostic #line 176 "ftp.y"
113840081Sbostic {
113940081Sbostic switch (yyvsp[-1]) {
114040081Sbostic
114140081Sbostic case MODE_S:
114240081Sbostic reply(200, "MODE S ok.");
114340081Sbostic break;
114440081Sbostic
114540081Sbostic default:
114640081Sbostic reply(502, "Unimplemented MODE type.");
114740081Sbostic }
114840081Sbostic }
114940081Sbostic break;
115040081Sbostic case 11:
115140081Sbostic #line 188 "ftp.y"
115240081Sbostic {
115340081Sbostic reply(202, "ALLO command ignored.");
115440081Sbostic }
115540081Sbostic break;
115640081Sbostic case 12:
115740081Sbostic #line 192 "ftp.y"
115840081Sbostic {
115940081Sbostic reply(202, "ALLO command ignored.");
116040081Sbostic }
116140081Sbostic break;
116240081Sbostic case 13:
116340081Sbostic #line 196 "ftp.y"
116440081Sbostic {
116540081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
116640081Sbostic retrieve((char *) 0, (char *) yyvsp[-1]);
116740081Sbostic if (yyvsp[-1] != NULL)
116840081Sbostic free((char *) yyvsp[-1]);
116940081Sbostic }
117040081Sbostic break;
117140081Sbostic case 14:
117240081Sbostic #line 203 "ftp.y"
117340081Sbostic {
117440081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
117540081Sbostic store((char *) yyvsp[-1], "w", 0);
117640081Sbostic if (yyvsp[-1] != NULL)
117740081Sbostic free((char *) yyvsp[-1]);
117840081Sbostic }
117940081Sbostic break;
118040081Sbostic case 15:
118140081Sbostic #line 210 "ftp.y"
118240081Sbostic {
118340081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
118440081Sbostic store((char *) yyvsp[-1], "a", 0);
118540081Sbostic if (yyvsp[-1] != NULL)
118640081Sbostic free((char *) yyvsp[-1]);
118740081Sbostic }
118840081Sbostic break;
118940081Sbostic case 16:
119040081Sbostic #line 217 "ftp.y"
119140081Sbostic {
119240081Sbostic if (yyvsp[-1])
119340081Sbostic send_file_list(".");
119440081Sbostic }
119540081Sbostic break;
119640081Sbostic case 17:
119740081Sbostic #line 222 "ftp.y"
119840081Sbostic {
119940081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
120040081Sbostic send_file_list((char *) yyvsp[-1]);
120140081Sbostic if (yyvsp[-1] != NULL)
120240081Sbostic free((char *) yyvsp[-1]);
120340081Sbostic }
120440081Sbostic break;
120540081Sbostic case 18:
120640081Sbostic #line 229 "ftp.y"
120740081Sbostic {
120840081Sbostic if (yyvsp[-1])
120940081Sbostic retrieve("/bin/ls -lgA", "");
121040081Sbostic }
121140081Sbostic break;
121240081Sbostic case 19:
121340081Sbostic #line 234 "ftp.y"
121440081Sbostic {
121540081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
121640081Sbostic retrieve("/bin/ls -lgA %s", (char *) yyvsp[-1]);
121740081Sbostic if (yyvsp[-1] != NULL)
121840081Sbostic free((char *) yyvsp[-1]);
121940081Sbostic }
122040081Sbostic break;
122140081Sbostic case 20:
122240081Sbostic #line 241 "ftp.y"
122340081Sbostic {
122440081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
122540081Sbostic statfilecmd((char *) yyvsp[-1]);
122640081Sbostic if (yyvsp[-1] != NULL)
122740081Sbostic free((char *) yyvsp[-1]);
122840081Sbostic }
122940081Sbostic break;
123040081Sbostic case 21:
123140081Sbostic #line 248 "ftp.y"
123240081Sbostic {
123340081Sbostic statcmd();
123440081Sbostic }
123540081Sbostic break;
123640081Sbostic case 22:
123740081Sbostic #line 252 "ftp.y"
123840081Sbostic {
123940081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
124040081Sbostic delete((char *) yyvsp[-1]);
124140081Sbostic if (yyvsp[-1] != NULL)
124240081Sbostic free((char *) yyvsp[-1]);
124340081Sbostic }
124440081Sbostic break;
124540081Sbostic case 23:
124640081Sbostic #line 259 "ftp.y"
124740081Sbostic {
124840081Sbostic if (fromname) {
124940081Sbostic renamecmd(fromname, (char *) yyvsp[-1]);
125040081Sbostic free(fromname);
125140081Sbostic fromname = (char *) 0;
125240081Sbostic } else {
125340081Sbostic reply(503, "Bad sequence of commands.");
125440081Sbostic }
125540081Sbostic free((char *) yyvsp[-1]);
125640081Sbostic }
125740081Sbostic break;
125840081Sbostic case 24:
125940081Sbostic #line 270 "ftp.y"
126040081Sbostic {
126140081Sbostic reply(225, "ABOR command successful.");
126240081Sbostic }
126340081Sbostic break;
126440081Sbostic case 25:
126540081Sbostic #line 274 "ftp.y"
126640081Sbostic {
126740081Sbostic if (yyvsp[-1])
126840081Sbostic cwd(pw->pw_dir);
126940081Sbostic }
127040081Sbostic break;
127140081Sbostic case 26:
127240081Sbostic #line 279 "ftp.y"
127340081Sbostic {
127440081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
127540081Sbostic cwd((char *) yyvsp[-1]);
127640081Sbostic if (yyvsp[-1] != NULL)
127740081Sbostic free((char *) yyvsp[-1]);
127840081Sbostic }
127940081Sbostic break;
128040081Sbostic case 27:
128140081Sbostic #line 286 "ftp.y"
128240081Sbostic {
128340081Sbostic help(cmdtab, (char *) 0);
128440081Sbostic }
128540081Sbostic break;
128640081Sbostic case 28:
128740081Sbostic #line 290 "ftp.y"
128840081Sbostic {
128940081Sbostic register char *cp = (char *)yyvsp[-1];
129040081Sbostic
129140081Sbostic if (strncasecmp(cp, "SITE", 4) == 0) {
129240081Sbostic cp = (char *)yyvsp[-1] + 4;
129340081Sbostic if (*cp == ' ')
129440081Sbostic cp++;
129540081Sbostic if (*cp)
129640081Sbostic help(sitetab, cp);
129740081Sbostic else
129840081Sbostic help(sitetab, (char *) 0);
129940081Sbostic } else
130040081Sbostic help(cmdtab, (char *) yyvsp[-1]);
130140081Sbostic }
130240081Sbostic break;
130340081Sbostic case 29:
130440081Sbostic #line 305 "ftp.y"
130540081Sbostic {
130640081Sbostic reply(200, "NOOP command successful.");
130740081Sbostic }
130840081Sbostic break;
130940081Sbostic case 30:
131040081Sbostic #line 309 "ftp.y"
131140081Sbostic {
131240081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
131340081Sbostic makedir((char *) yyvsp[-1]);
131440081Sbostic if (yyvsp[-1] != NULL)
131540081Sbostic free((char *) yyvsp[-1]);
131640081Sbostic }
131740081Sbostic break;
131840081Sbostic case 31:
131940081Sbostic #line 316 "ftp.y"
132040081Sbostic {
132140081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
132240081Sbostic removedir((char *) yyvsp[-1]);
132340081Sbostic if (yyvsp[-1] != NULL)
132440081Sbostic free((char *) yyvsp[-1]);
132540081Sbostic }
132640081Sbostic break;
132740081Sbostic case 32:
132840081Sbostic #line 323 "ftp.y"
132940081Sbostic {
133040081Sbostic if (yyvsp[-1])
133140081Sbostic pwd();
133240081Sbostic }
133340081Sbostic break;
133440081Sbostic case 33:
133540081Sbostic #line 328 "ftp.y"
133640081Sbostic {
133740081Sbostic if (yyvsp[-1])
133840081Sbostic cwd("..");
133940081Sbostic }
134040081Sbostic break;
134140081Sbostic case 34:
134240081Sbostic #line 333 "ftp.y"
134340081Sbostic {
134440081Sbostic help(sitetab, (char *) 0);
134540081Sbostic }
134640081Sbostic break;
134740081Sbostic case 35:
134840081Sbostic #line 337 "ftp.y"
134940081Sbostic {
135040081Sbostic help(sitetab, (char *) yyvsp[-1]);
135140081Sbostic }
135240081Sbostic break;
135340081Sbostic case 36:
135440081Sbostic #line 341 "ftp.y"
135540081Sbostic {
135640081Sbostic int oldmask;
135740081Sbostic
135840081Sbostic if (yyvsp[-1]) {
135940081Sbostic oldmask = umask(0);
136040081Sbostic (void) umask(oldmask);
136140081Sbostic reply(200, "Current UMASK is %03o", oldmask);
136240081Sbostic }
136340081Sbostic }
136440081Sbostic break;
136540081Sbostic case 37:
136640081Sbostic #line 351 "ftp.y"
136740081Sbostic {
136840081Sbostic int oldmask;
136940081Sbostic
137040081Sbostic if (yyvsp[-3]) {
137140081Sbostic if ((yyvsp[-1] == -1) || (yyvsp[-1] > 0777)) {
137240081Sbostic reply(501, "Bad UMASK value");
137340081Sbostic } else {
137440081Sbostic oldmask = umask(yyvsp[-1]);
137540081Sbostic reply(200,
137640081Sbostic "UMASK set to %03o (was %03o)",
137740081Sbostic yyvsp[-1], oldmask);
137840081Sbostic }
137940081Sbostic }
138040081Sbostic }
138140081Sbostic break;
138240081Sbostic case 38:
138340081Sbostic #line 366 "ftp.y"
138440081Sbostic {
138540081Sbostic if (yyvsp[-5] && (yyvsp[-1] != NULL)) {
138640081Sbostic if (yyvsp[-3] > 0777)
138740081Sbostic reply(501,
138840081Sbostic "CHMOD: Mode value must be between 0 and 0777");
138940081Sbostic else if (chmod((char *) yyvsp[-1], yyvsp[-3]) < 0)
139040081Sbostic perror_reply(550, (char *) yyvsp[-1]);
139140081Sbostic else
139240081Sbostic reply(200, "CHMOD command successful.");
139340081Sbostic }
139440081Sbostic if (yyvsp[-1] != NULL)
139540081Sbostic free((char *) yyvsp[-1]);
139640081Sbostic }
139740081Sbostic break;
139840081Sbostic case 39:
139940081Sbostic #line 380 "ftp.y"
140040081Sbostic {
140140081Sbostic reply(200,
140240081Sbostic "Current IDLE time limit is %d seconds; max %d",
140340081Sbostic timeout, maxtimeout);
140440081Sbostic }
140540081Sbostic break;
140640081Sbostic case 40:
140740081Sbostic #line 386 "ftp.y"
140840081Sbostic {
140940081Sbostic if (yyvsp[-1] < 30 || yyvsp[-1] > maxtimeout) {
141040081Sbostic reply(501,
141140081Sbostic "Maximum IDLE time must be between 30 and %d seconds",
141240081Sbostic maxtimeout);
141340081Sbostic } else {
141440081Sbostic timeout = yyvsp[-1];
141540081Sbostic (void) alarm((unsigned) timeout);
141640081Sbostic reply(200,
141740081Sbostic "Maximum IDLE time set to %d seconds",
141840081Sbostic timeout);
141940081Sbostic }
142040081Sbostic }
142140081Sbostic break;
142240081Sbostic case 41:
142340081Sbostic #line 400 "ftp.y"
142440081Sbostic {
142540081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
142640081Sbostic store((char *) yyvsp[-1], "w", 1);
142740081Sbostic if (yyvsp[-1] != NULL)
142840081Sbostic free((char *) yyvsp[-1]);
142940081Sbostic }
143040081Sbostic break;
143140081Sbostic case 42:
143240081Sbostic #line 407 "ftp.y"
143340081Sbostic {
143440081Sbostic #ifdef unix
143540081Sbostic #ifdef BSD
143640081Sbostic reply(215, "UNIX Type: L%d Version: BSD-%d",
143740081Sbostic NBBY, BSD);
143840081Sbostic #else /* BSD */
143940081Sbostic reply(215, "UNIX Type: L%d", NBBY);
144040081Sbostic #endif /* BSD */
144140081Sbostic #else /* unix */
144240081Sbostic reply(215, "UNKNOWN Type: L%d", NBBY);
144340081Sbostic #endif /* unix */
144440081Sbostic }
144540081Sbostic break;
144640081Sbostic case 43:
144740081Sbostic #line 428 "ftp.y"
144840081Sbostic {
144940081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL)
145040081Sbostic sizecmd((char *) yyvsp[-1]);
145140081Sbostic if (yyvsp[-1] != NULL)
145240081Sbostic free((char *) yyvsp[-1]);
145340081Sbostic }
145440081Sbostic break;
145540081Sbostic case 44:
145640081Sbostic #line 445 "ftp.y"
145740081Sbostic {
145840081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) {
145940081Sbostic struct stat stbuf;
146040081Sbostic if (stat((char *) yyvsp[-1], &stbuf) < 0)
146140081Sbostic perror_reply(550, "%s", (char *) yyvsp[-1]);
146240081Sbostic else if ((stbuf.st_mode&S_IFMT) != S_IFREG) {
146340081Sbostic reply(550, "%s: not a plain file.",
146440081Sbostic (char *) yyvsp[-1]);
146540081Sbostic } else {
146640081Sbostic register struct tm *t;
146740081Sbostic struct tm *gmtime();
146840081Sbostic t = gmtime(&stbuf.st_mtime);
146940081Sbostic reply(213,
147040081Sbostic "19%02d%02d%02d%02d%02d%02d",
147140081Sbostic t->tm_year, t->tm_mon+1, t->tm_mday,
147240081Sbostic t->tm_hour, t->tm_min, t->tm_sec);
147340081Sbostic }
147440081Sbostic }
147540081Sbostic if (yyvsp[-1] != NULL)
147640081Sbostic free((char *) yyvsp[-1]);
147740081Sbostic }
147840081Sbostic break;
147940081Sbostic case 45:
148040081Sbostic #line 467 "ftp.y"
148140081Sbostic {
148240081Sbostic reply(221, "Goodbye.");
148340081Sbostic dologout(0);
148440081Sbostic }
148540081Sbostic break;
148640081Sbostic case 46:
148740081Sbostic #line 472 "ftp.y"
148840081Sbostic {
148940081Sbostic yyerrok;
149040081Sbostic }
149140081Sbostic break;
149240081Sbostic case 47:
149340081Sbostic #line 477 "ftp.y"
149440081Sbostic {
149540081Sbostic char *renamefrom();
149640081Sbostic
149740081Sbostic if (yyvsp[-3] && yyvsp[-1]) {
149840081Sbostic fromname = renamefrom((char *) yyvsp[-1]);
149940081Sbostic if (fromname == (char *) 0 && yyvsp[-1]) {
150040081Sbostic free((char *) yyvsp[-1]);
150140081Sbostic }
150240081Sbostic }
150340081Sbostic }
150440081Sbostic break;
150540081Sbostic case 49:
150640081Sbostic #line 493 "ftp.y"
150740081Sbostic {
1508*60322Sbostic *(char **)&(yyval) = "";
150940081Sbostic }
151040081Sbostic break;
151140081Sbostic case 52:
151240081Sbostic #line 504 "ftp.y"
151340081Sbostic {
151440081Sbostic register char *a, *p;
151540081Sbostic
151640081Sbostic a = (char *)&data_dest.sin_addr;
151740081Sbostic a[0] = yyvsp[-10]; a[1] = yyvsp[-8]; a[2] = yyvsp[-6]; a[3] = yyvsp[-4];
151840081Sbostic p = (char *)&data_dest.sin_port;
151940081Sbostic p[0] = yyvsp[-2]; p[1] = yyvsp[0];
152040081Sbostic data_dest.sin_family = AF_INET;
152140081Sbostic }
152240081Sbostic break;
152340081Sbostic case 53:
152440081Sbostic #line 516 "ftp.y"
152540081Sbostic {
1526*60322Sbostic yyval = FORM_N;
152740081Sbostic }
152840081Sbostic break;
152940081Sbostic case 54:
153040081Sbostic #line 520 "ftp.y"
153140081Sbostic {
1532*60322Sbostic yyval = FORM_T;
153340081Sbostic }
153440081Sbostic break;
153540081Sbostic case 55:
153640081Sbostic #line 524 "ftp.y"
153740081Sbostic {
1538*60322Sbostic yyval = FORM_C;
153940081Sbostic }
154040081Sbostic break;
154140081Sbostic case 56:
154240081Sbostic #line 530 "ftp.y"
154340081Sbostic {
154440081Sbostic cmd_type = TYPE_A;
154540081Sbostic cmd_form = FORM_N;
154640081Sbostic }
154740081Sbostic break;
154840081Sbostic case 57:
154940081Sbostic #line 535 "ftp.y"
155040081Sbostic {
155140081Sbostic cmd_type = TYPE_A;
155240081Sbostic cmd_form = yyvsp[0];
155340081Sbostic }
155440081Sbostic break;
155540081Sbostic case 58:
155640081Sbostic #line 540 "ftp.y"
155740081Sbostic {
155840081Sbostic cmd_type = TYPE_E;
155940081Sbostic cmd_form = FORM_N;
156040081Sbostic }
156140081Sbostic break;
156240081Sbostic case 59:
156340081Sbostic #line 545 "ftp.y"
156440081Sbostic {
156540081Sbostic cmd_type = TYPE_E;
156640081Sbostic cmd_form = yyvsp[0];
156740081Sbostic }
156840081Sbostic break;
156940081Sbostic case 60:
157040081Sbostic #line 550 "ftp.y"
157140081Sbostic {
157240081Sbostic cmd_type = TYPE_I;
157340081Sbostic }
157440081Sbostic break;
157540081Sbostic case 61:
157640081Sbostic #line 554 "ftp.y"
157740081Sbostic {
157840081Sbostic cmd_type = TYPE_L;
157940081Sbostic cmd_bytesz = NBBY;
158040081Sbostic }
158140081Sbostic break;
158240081Sbostic case 62:
158340081Sbostic #line 559 "ftp.y"
158440081Sbostic {
158540081Sbostic cmd_type = TYPE_L;
158640081Sbostic cmd_bytesz = yyvsp[0];
158740081Sbostic }
158840081Sbostic break;
158940081Sbostic case 63:
159040081Sbostic #line 565 "ftp.y"
159140081Sbostic {
159240081Sbostic cmd_type = TYPE_L;
159340081Sbostic cmd_bytesz = yyvsp[0];
159440081Sbostic }
159540081Sbostic break;
159640081Sbostic case 64:
159740081Sbostic #line 572 "ftp.y"
159840081Sbostic {
1599*60322Sbostic yyval = STRU_F;
160040081Sbostic }
160140081Sbostic break;
160240081Sbostic case 65:
160340081Sbostic #line 576 "ftp.y"
160440081Sbostic {
1605*60322Sbostic yyval = STRU_R;
160640081Sbostic }
160740081Sbostic break;
160840081Sbostic case 66:
160940081Sbostic #line 580 "ftp.y"
161040081Sbostic {
1611*60322Sbostic yyval = STRU_P;
161240081Sbostic }
161340081Sbostic break;
161440081Sbostic case 67:
161540081Sbostic #line 586 "ftp.y"
161640081Sbostic {
1617*60322Sbostic yyval = MODE_S;
161840081Sbostic }
161940081Sbostic break;
162040081Sbostic case 68:
162140081Sbostic #line 590 "ftp.y"
162240081Sbostic {
1623*60322Sbostic yyval = MODE_B;
162440081Sbostic }
162540081Sbostic break;
162640081Sbostic case 69:
162740081Sbostic #line 594 "ftp.y"
162840081Sbostic {
1629*60322Sbostic yyval = MODE_C;
163040081Sbostic }
163140081Sbostic break;
163240081Sbostic case 70:
163340081Sbostic #line 600 "ftp.y"
163440081Sbostic {
163540081Sbostic /*
163640084Sbostic * Problem: this production is used for all pathname
163740084Sbostic * processing, but only gives a 550 error reply.
163840084Sbostic * This is a valid reply in some cases but not in others.
163940084Sbostic */
164040081Sbostic if (logged_in && yyvsp[0] && strncmp((char *) yyvsp[0], "~", 1) == 0) {
1641*60322Sbostic *(char **)&(yyval) = *glob((char *) yyvsp[0]);
164240081Sbostic if (globerr != NULL) {
164340081Sbostic reply(550, globerr);
1644*60322Sbostic yyval = NULL;
164540081Sbostic }
164640081Sbostic free((char *) yyvsp[0]);
164740081Sbostic } else
1648*60322Sbostic yyval = yyvsp[0];
164940081Sbostic }
165040081Sbostic break;
165140081Sbostic case 72:
165240081Sbostic #line 622 "ftp.y"
165340081Sbostic {
165440081Sbostic register int ret, dec, multby, digit;
165540081Sbostic
165640081Sbostic /*
165740084Sbostic * Convert a number that was read as decimal number
165840084Sbostic * to what it would be if it had been read as octal.
165940084Sbostic */
166040081Sbostic dec = yyvsp[0];
166140081Sbostic multby = 1;
166240081Sbostic ret = 0;
166340081Sbostic while (dec) {
166440081Sbostic digit = dec%10;
166540081Sbostic if (digit > 7) {
166640081Sbostic ret = -1;
166740081Sbostic break;
166840081Sbostic }
166940081Sbostic ret += digit * multby;
167040081Sbostic multby *= 8;
167140081Sbostic dec /= 10;
167240081Sbostic }
1673*60322Sbostic yyval = ret;
167440081Sbostic }
167540081Sbostic break;
167640081Sbostic case 73:
167740081Sbostic #line 647 "ftp.y"
167840081Sbostic {
167940081Sbostic if (logged_in)
1680*60322Sbostic yyval = 1;
168140081Sbostic else {
168240081Sbostic reply(530, "Please login with USER and PASS.");
1683*60322Sbostic yyval = 0;
168440081Sbostic }
168540081Sbostic }
168640081Sbostic break;
1687*60322Sbostic #line 1688 "ftp.tab.c"
168840081Sbostic }
168940081Sbostic yyssp -= yym;
169040081Sbostic yystate = *yyssp;
169140081Sbostic yyvsp -= yym;
169240081Sbostic yym = yylhs[yyn];
169340081Sbostic if (yystate == 0 && yym == 0)
169440081Sbostic {
1695*60322Sbostic #if YYDEBUG
169640081Sbostic if (yydebug)
1697*60322Sbostic printf("%sdebug: after reduction, shifting from state 0 to\
1698*60322Sbostic state %d\n", YYPREFIX, YYFINAL);
169940081Sbostic #endif
170040081Sbostic yystate = YYFINAL;
170140081Sbostic *++yyssp = YYFINAL;
170240081Sbostic *++yyvsp = yyval;
170340081Sbostic if (yychar < 0)
170440081Sbostic {
170540081Sbostic if ((yychar = yylex()) < 0) yychar = 0;
170640081Sbostic #if YYDEBUG
170740081Sbostic if (yydebug)
170840081Sbostic {
170940081Sbostic yys = 0;
171040081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
171140081Sbostic if (!yys) yys = "illegal-symbol";
1712*60322Sbostic printf("%sdebug: state %d, reading %d (%s)\n",
1713*60322Sbostic YYPREFIX, YYFINAL, yychar, yys);
171440081Sbostic }
171540081Sbostic #endif
171640081Sbostic }
171740081Sbostic if (yychar == 0) goto yyaccept;
171840081Sbostic goto yyloop;
171940081Sbostic }
172040081Sbostic if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
172140081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
172240081Sbostic yystate = yytable[yyn];
172340081Sbostic else
172440081Sbostic yystate = yydgoto[yym];
1725*60322Sbostic #if YYDEBUG
172640081Sbostic if (yydebug)
1727*60322Sbostic printf("%sdebug: after reduction, shifting from state %d \
1728*60322Sbostic to state %d\n", YYPREFIX, *yyssp, yystate);
172940081Sbostic #endif
173040081Sbostic if (yyssp >= yyss + yystacksize - 1)
173140081Sbostic {
173240081Sbostic goto yyoverflow;
173340081Sbostic }
173440081Sbostic *++yyssp = yystate;
173540081Sbostic *++yyvsp = yyval;
173640081Sbostic goto yyloop;
173740081Sbostic yyoverflow:
173840081Sbostic yyerror("yacc stack overflow");
173940081Sbostic yyabort:
174040081Sbostic return (1);
174140081Sbostic yyaccept:
174240081Sbostic return (0);
174340081Sbostic }
1744