📄 ftpcmd.c
字号:
while (i-- > 0) *t++ = *f++;}#else /* __cplusplus *//* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */static void__yy_memcpy (char *to, char *from, unsigned int count){ register char *t = to; register char *f = from; register int i = count; while (i-- > 0) *t++ = *f++;}#endif#endif#line 217 "/usr/share/bison.simple"/* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */#ifdef YYPARSE_PARAM#ifdef __cplusplus#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM#define YYPARSE_PARAM_DECL#else /* not __cplusplus */#define YYPARSE_PARAM_ARG YYPARSE_PARAM#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;#endif /* not __cplusplus */#else /* not YYPARSE_PARAM */#define YYPARSE_PARAM_ARG#define YYPARSE_PARAM_DECL#endif /* not YYPARSE_PARAM *//* Prevent warning if -Wstrict-prototypes. */#ifdef __GNUC__#ifdef YYPARSE_PARAMint yyparse (void *);#elseint yyparse (void);#endif#endifintyyparse(YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL{ register int yystate; register int yyn; register short *yyssp; register YYSTYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1 = 0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */#ifdef YYLSP_NEEDED YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ YYLTYPE *yyls = yylsa; YYLTYPE *yylsp;#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)#else#define YYPOPSTACK (yyvsp--, yyssp--)#endif int yystacksize = YYINITDEPTH; int yyfree_stacks = 0;#ifdef YYPURE int yychar; YYSTYPE yylval; int yynerrs;#ifdef YYLSP_NEEDED YYLTYPE yylloc;#endif#endif YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen;#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n");#endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs;#ifdef YYLSP_NEEDED yylsp = yyls;#endif/* Push a new state, which is found in yystate . *//* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss;#ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls;#endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1;#ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */#ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize);#else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize);#endif yyss = yyss1; yyvs = yyvs1;#ifdef YYLSP_NEEDED yyls = yyls1;#endif#else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); if (yyfree_stacks) { free (yyss); free (yyvs);#ifdef YYLSP_NEEDED free (yyls);#endif } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH;#ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1;#endif yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * (unsigned int) sizeof (*yyssp)); yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * (unsigned int) sizeof (*yyvsp));#ifdef YYLSP_NEEDED yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp));#endif#endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1;#ifdef YYLSP_NEEDED yylsp = yyls + size - 1;#endif#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize);#endif if (yyssp >= yyss + yystacksize - 1) YYABORT; }#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate);#endif goto yybackup; yybackup:/* Do appropriate processing given the current state. *//* Read a lookahead token if we need one and don't already have one. *//* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) {#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: ");#endif yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n");#endif } else { yychar1 = YYTRANSLATE(yychar);#if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */#ifdef YYPRINT YYPRINT (stderr, yychar, yylval);#endif fprintf (stderr, ")\n"); }#endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);#endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval;#ifdef YYLSP_NEEDED *++yylsp = yylloc;#endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate;/* Do the default action for the current state. */yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab;/* Do a reduction. yyn is the number of a rule to reduce with. */yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */#if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); }#endif switch (yyn) {case 2:#line 154 "ftpcmd.y"{ if (fromname != NULL) free (fromname); fromname = (char *) 0; restart_point = (off_t) 0; ; break;}case 4:#line 165 "ftpcmd.y"{ user(yyvsp[-1].s); free(yyvsp[-1].s); ; break;}case 5:#line 170 "ftpcmd.y"{ pass(yyvsp[-1].s); memset (yyvsp[-1].s, 0, strlen (yyvsp[-1].s)); free(yyvsp[-1].s); ; break;}case 6:#line 176 "ftpcmd.y"{ usedefault = 0; if (pdata >= 0) { close(pdata); pdata = -1; } if (yyvsp[-3].i) { if (memcmp (&his_addr.sin_addr, &data_dest.sin_addr, sizeof (data_dest.sin_addr)) == 0 && ntohs (data_dest.sin_port) > IPPORT_RESERVED) { reply (200, "PORT command sucessful."); } else { memset (&data_dest, 0, sizeof (data_dest)); reply(500, "Illegal PORT Command"); } } ; break;}case 7:#line 198 "ftpcmd.y"{ if (yyvsp[-1].i) passive(); ; break;}case 8:#line 203 "ftpcmd.y"{ 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 defined (NBBY) && 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 */ UNIMPLEMENTED for NBBY != 8#endif /* NBBY == 8 */ } ; break;}case 9:#line 238 "ftpcmd.y"{ switch (yyvsp[-1].i) { case STRU_F: reply(200, "STRU F ok."); break; default: reply(504, "Unimplemented STRU type."); } ; break;}case 10:#line 250 "ftpcmd.y"{ switch (yyvsp[-1].i) { case MODE_S: reply(200, "MODE S ok."); break; default: reply(502, "Unimplemented MODE type."); } ; break;}case 11:#line 262 "ftpcmd.y"{ reply(202, "ALLO command ignored."); ; break;}case 12:#line 266 "ftpcmd.y"{ reply(202, "ALLO command ignored."); ; break;}case 13:#line 270 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) retrieve((char *) 0, yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 14:#line 277 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) store(yyvsp[-1].s, "w", 0); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 15:#line 284 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) store(yyvsp[-1].s, "a", 0); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 16:#line 291 "ftpcmd.y"{ if (yyvsp[-1].i) send_file_list("."); ; break;}case 17:#line 296 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) send_file_list(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 18:#line 303 "ftpcmd.y"{ if (yyvsp[-1].i) retrieve("/bin/ls -lgA", ""); ; break;}case 19:#line 308 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) retrieve("/bin/ls -lgA %s", yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 20:#line 315 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) statfilecmd(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 21:#line 322 "ftpcmd.y"{ statcmd(); ; break;}case 22:#line 326 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) delete(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 23:#line 333 "ftpcmd.y"{ if (yyvsp[-3].i) { if (fromname) { renamecmd(fromname, yyvsp[-1].s); free(fromname); fromname = (char *) 0; } else { reply(503, "Bad sequence of commands."); } } free (yyvsp[-1].s); ; break;}case 24:#line 346 "ftpcmd.y"{ reply(225, "ABOR command successful."); ; break;}case 25:#line 350 "ftpcmd.y"{ if (yyvsp[-1].i) cwd(cred.homedir); ; break;}case 26:#line 355 "ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) cwd(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); ; break;}case 27:#line 362 "ftpcmd.y"{ help(cmdtab, (char *) 0); ; break;}case 28:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -