?? ftp.tab.c
字號:
#ifndef lintstatic char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";#endif#define YYBYACC 1#define YYMAJOR 1#define YYMINOR 9#define yyclearin (yychar=(-1))#define yyerrok (yyerrflag=0)#define YYRECOVERING (yyerrflag!=0)#define YYPREFIX "yy"#line 26 "ftp.y"#ifndef lintstatic char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";#endif /* not lint */#include <sys/param.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/ftp.h>#include <stdio.h>#include <signal.h>#include <ctype.h>#include <pwd.h>#include <setjmp.h>#include <syslog.h>#include <sys/stat.h>#include <time.h>extern struct sockaddr_in data_dest;extern int logged_in;extern struct passwd *pw;extern int guest;extern int logging;extern int type;extern int form;extern int debug;extern int timeout;extern int maxtimeout;extern int pdata;extern char hostname[], remotehost[];extern char proctitle[];extern char *globerr;extern int usedefault;extern int transflag;extern char tmpline[];char **glob();static int cmd_type;static int cmd_form;static int cmd_bytesz;char cbuf[512];char *fromname;char *index();#line 60 "ftp.tab.c"#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 LEXERR 319#define YYERRCODE 256short yylhs[] = { -1, 0, 0, 0, 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, 2, 3, 4, 4, 12, 5, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 10, 14, 11, 9,};short yylen[] = { 2, 0, 2, 2, 4, 4, 4, 2, 4, 4, 4, 4, 8, 5, 5, 5, 3, 5, 3, 5, 5, 2, 5, 4, 2, 3, 5, 2, 4, 2, 5, 5, 3, 3, 4, 6, 5, 7, 9, 4, 6, 5, 2, 5, 5, 2, 2, 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, 0,};short yydefred[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 73, 73, 0, 73, 0, 0, 73, 73, 73, 73, 0, 0, 0, 0, 73, 73, 73, 73, 73, 0, 73, 73, 2, 3, 46, 0, 0, 45, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 21, 0, 0, 27, 29, 0, 0, 0, 0, 0, 42, 0, 0, 48, 0, 50, 0, 0, 0, 0, 0, 60, 0, 0, 64, 66, 65, 0, 68, 69, 67, 0, 0, 0, 0, 0, 0, 71, 0, 70, 0, 0, 25, 0, 18, 0, 16, 0, 73, 0, 73, 0, 0, 0, 0, 32, 33, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 51, 63, 8, 9, 10, 0, 0, 0, 0, 11, 0, 23, 0, 0, 0, 0, 0, 34, 0, 0, 39, 0, 0, 28, 0, 0, 0, 0, 0, 0, 55, 53, 54, 57, 59, 62, 13, 14, 15, 0, 47, 22, 26, 19, 17, 0, 0, 36, 0, 0, 20, 30, 31, 41, 43, 44, 0, 0, 35, 72, 0, 40, 0, 0, 0, 37, 0, 0, 12, 0, 0, 38, 0, 0, 0, 52,};short yydgoto[] = { 1, 34, 35, 71, 73, 75, 80, 84, 88, 45, 95, 184, 125, 157, 96,};short yysindex[] = { 0, -224, -247, -239, -236, -232, -222, -204, -200, -181, -177, 0, 0, 0, -166, 0, -161, -199, 0, 0, 0, 0, -160, -159, -264, -158, 0, 0, 0, 0, 0, -157, 0, 0, 0, 0, 0, -167, -162, 0, -156, 0, -250, -198, -165, -155, -154, -153, -151, -150, -152, 0, -145, -252, -229, -217, -302, 0, -144, -146, 0, 0, -142, -141, -140, -139, -137, 0, -136, -135, 0, -134, 0, -133, -132, -130, -131, -128, 0, -249, -127, 0, 0, 0, -126, 0, 0, 0, -125, -152, -152, -152, -205, -152, 0, -124, 0, -152, -152, 0, -152, 0, -143, 0, -173, 0, -171, 0, -152, -123, -152, -152, 0, 0, -152, -152, -152, 0, 0, -138, 0, -164, -164, -122, 0, 0, 0, 0, 0, -121, -120, -118, -148, 0, -117, 0, -116, -115, -114, -113, -112, 0, -163, -111, 0, -110, -109, 0, -107, -106, -105, -104, -103, -129, 0, 0, 0, 0, 0, 0, 0, 0, 0, -101, 0, 0, 0, 0, 0, -100, -102, 0, -98, -102, 0, 0, 0, 0, 0, 0, -99, -97, 0, 0, -95, 0, -96, -94, -92, 0, -152, -93, 0, -91, -90, 0, -88, -87, -86, 0,};short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -81, -80, 0, -158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};short yygindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, -89, -25, 35, 47, 0,};#define YYTABLESIZE 190short yytable[] = { 129, 130, 131, 104, 134, 59, 60, 76, 136, 137, 77, 138, 78, 79, 105, 106, 107, 98, 99, 146, 123, 148, 149, 36, 124, 150, 151, 152, 46, 47, 37, 49, 2, 38, 52, 53, 54, 55, 39, 58, 100, 101, 62, 63, 64, 65, 66, 40, 68, 69, 3, 4, 102, 103, 5, 6, 7, 8, 9, 10, 11, 12, 13, 81, 132, 133, 41, 82, 83, 42, 14, 51, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 43, 31, 32, 33, 44, 85, 86, 154, 140, 141, 143, 144, 155, 193, 87, 48, 156, 70, 170, 171, 50, 56, 72, 57, 61, 67, 89, 90, 91, 74, 163, 93, 94, 142, 92, 145, 97, 108, 109, 110, 111, 139, 112, 113, 114, 115, 116, 153, 117, 118, 121, 119, 120, 122, 180, 126, 127, 128, 135, 147, 186, 160, 161, 124, 162, 164, 165, 166, 167, 168, 159, 173, 169, 174, 172, 175, 176, 177, 178, 179, 181, 158, 182, 183, 185, 190, 187, 189, 188, 191, 192, 195, 194, 196, 0, 0, 198, 197, 73, 199, 49, 56, 58,};short yycheck[] = { 89, 90, 91, 305, 93, 269, 270, 257, 97, 98, 260, 100, 262, 263, 316, 317, 318, 269, 270, 108, 269, 110, 111, 270, 273, 114, 115, 116, 12, 13, 269, 15, 256, 269, 18, 19, 20, 21, 270, 23, 269, 270, 26, 27, 28, 29, 30, 269, 32, 33, 274, 275, 269, 270, 278, 279, 280, 281, 282, 283, 284, 285, 286, 261, 269, 270, 270, 265, 266, 269, 294, 270, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 269, 313, 314, 315, 269, 258, 259, 259, 269, 270, 269, 270, 264, 190, 267, 269, 268, 272, 269, 270, 269, 269, 272, 270, 270, 270, 269, 269, 269, 273, 266, 269, 272, 105, 273, 107, 269, 269, 272, 269, 269, 272, 270, 270, 269, 269, 269, 273, 270, 270, 269, 271, 270, 269, 271, 270, 270, 270, 270, 270, 173, 270, 270, 273, 270, 270, 270, 270, 270, 270, 123, 269, 272, 270, 273, 270, 270, 270, 270, 270, 269, 122, 270, 273, 270, 269, 273, 270, 273, 271, 270, 270, 273, 271, -1, -1, 271, 273, 269, 273, 270, 270, 270,};#define YYFINAL 1#ifndef YYDEBUG#define YYDEBUG 0#endif#define YYMAXTOKEN 319#if YYDEBUGchar *yyname[] = {"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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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","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","LEXERR",};char *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 SP host_port CRLF","cmd : PASV CRLF","cmd : TYPE SP type_code CRLF","cmd : STRU SP struct_code CRLF","cmd : MODE SP mode_code CRLF","cmd : ALLO SP NUMBER CRLF","cmd : ALLO 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 CRLF","cmd : DELE check_login SP pathname CRLF","cmd : RNTO SP pathname CRLF","cmd : ABOR CRLF","cmd : CWD check_login CRLF","cmd : CWD check_login SP pathname CRLF","cmd : HELP CRLF","cmd : HELP SP STRING CRLF","cmd : NOOP 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 SP HELP CRLF","cmd : SITE SP HELP SP STRING CRLF","cmd : SITE SP UMASK check_login CRLF","cmd : SITE SP UMASK check_login SP octal_number CRLF","cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF","cmd : SITE SP IDLE CRLF","cmd : SITE SP IDLE SP NUMBER CRLF","cmd : STOU check_login SP pathname CRLF","cmd : SYST 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","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","octal_number : NUMBER","check_login :",};#endif#ifndef YYSTYPEtypedef int YYSTYPE;#endif#ifdef YYSTACKSIZE#undef YYMAXDEPTH#define YYMAXDEPTH YYSTACKSIZE#else#ifdef YYMAXDEPTH#define YYSTACKSIZE YYMAXDEPTH#else#define YYSTACKSIZE 500#define YYMAXDEPTH 500#endif#endifint yydebug;int yynerrs;int yyerrflag;int yychar;short *yyssp;YYSTYPE *yyvsp;YYSTYPE yyval;YYSTYPE yylval;short yyss[YYSTACKSIZE];YYSTYPE yyvs[YYSTACKSIZE];#define yystacksize YYSTACKSIZE#line 658 "ftp.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 */struct tab { char *name; short token; short state; short implemented; /* 1 if command is implemented */ char *help;};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" }, { "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, 0, "(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> ]" }, { NULL, 0, 0, 0, 0 }};struct tab *lookup(p, cmd) 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 *getline(s, n, iop) char *s; register FILE *iop;{ register c; register char *cs; 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) syslog(LOG_DEBUG, "command: %s", s); tmpline[0] = '\0'; return(s); } if (c == 0) tmpline[0] = '\0'; } while ((c = getc(iop)) != EOF) { c &= 0377; if (c == IAC) { if ((c = getc(iop)) != EOF) { c &= 0377; switch (c) { case WILL: case WONT: c = getc(iop); printf("%c%c%c", IAC, DONT, 0377&c); (void) fflush(stdout); continue; case DO: case DONT: c = getc(iop); 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) return (NULL); *cs++ = '\0'; if (debug) syslog(LOG_DEBUG, "command: %s", s); return (s);}static inttoolong(){ time_t now; extern char *ctime(); extern time_t time(); reply(421, "Timeout (%d seconds): closing control connection.", timeout); (void) time(&now); if (logging) { syslog(LOG_INFO, "User %s timed out after %d seconds at %s", (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); } dologout(1);}yylex(){ static int cpos, state; register char *cp, *cp2; register struct tab *p; int n; char c, *strpbrk(); char *copy(); for (;;) { switch (state) { case CMD: (void) signal(SIGALRM, toolong); (void) alarm((unsigned) timeout); if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { reply(221, "You could at least say goodbye."); dologout(0); } (void) alarm(0);#ifdef SETPROCTITLE if (strncasecmp(cbuf, "PASS", 4) != NULL) setproctitle("%s: %s", proctitle, cbuf);#endif /* SETPROCTITLE */ if ((cp = index(cbuf, '\r'))) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -