📄 ftpcmd.c
字号:
/* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); 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 */ YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yychar1 = YYTRANSLATE (yychar);#if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { YYFPRINTF (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 YYFPRINTF (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. */ YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval;#if YYLSP_NEEDED *++yylsp = yylloc;#endif /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate;/*-----------------------------------------------------------.| yydefault -- do the default action for the current state. |`-----------------------------------------------------------*/yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce;/*-----------------------------.| yyreduce -- Do a reduction. |`-----------------------------*/yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to the semantic value of the lookahead token. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen];#if YYLSP_NEEDED /* Similarly for the default location. Let the user run additional commands if for instance locations are ranges. */ yyloc = yylsp[1-yylen]; YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);#endif#if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { int yyi; YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); }#endif switch (yyn) {case 2:#line 154 "../../inetutils/ftpd/ftpcmd.y"{ if (fromname != NULL) free (fromname); fromname = (char *) 0; restart_point = (off_t) 0; } break;case 4:#line 165 "../../inetutils/ftpd/ftpcmd.y"{ user(yyvsp[-1].s); free(yyvsp[-1].s); } break;case 5:#line 170 "../../inetutils/ftpd/ftpcmd.y"{ pass(yyvsp[-1].s); memset (yyvsp[-1].s, 0, strlen (yyvsp[-1].s)); free(yyvsp[-1].s); } break;case 6:#line 176 "../../inetutils/ftpd/ftpcmd.y"{ usedefault = 0; if (pdata >= 0) { (void) 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 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) passive(); } break;case 8:#line 203 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ reply(202, "ALLO command ignored."); } break;case 12:#line 266 "../../inetutils/ftpd/ftpcmd.y"{ reply(202, "ALLO command ignored."); } break;case 13:#line 270 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) send_file_list("."); } break;case 17:#line 296 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) retrieve("/bin/ls -lgA", ""); } break;case 19:#line 308 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ statcmd(); } break;case 22:#line 326 "../../inetutils/ftpd/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 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ reply(225, "ABOR command successful."); } break;case 25:#line 350 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) cwd(cred.homedir); } break;case 26:#line 355 "../../inetutils/ftpd/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 "../../inetutils/ftpd/ftpcmd.y"{ help(cmdtab, (char *) 0); } break;case 28:#line 366 "../../inetutils/ftpd/ftpcmd.y"{ char *cp = yyvsp[-1].s; if (strncasecmp(cp, "SITE", 4) == 0) { cp = yyvsp[-1].s + 4; if (*cp == ' ') cp++; if (*cp) help(sitetab, cp); else help(sitetab, (char *) 0); } else help(cmdtab, yyvsp[-1].s); if (yyvsp[-1].s != NULL) free (yyvsp[-1].s); } break;case 29:#line 383 "../../inetutils/ftpd/ftpcmd.y"{ reply(200, "NOOP command successful."); } break;case 30:#line 387 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) makedir(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 31:#line 394 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) removedir(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 32:#line 401 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) pwd(); } break;case 33:#line 406 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-1].i) cwd(".."); } break;case 34:#line 411 "../../inetutils/ftpd/ftpcmd.y"{ help(sitetab, (char *) 0); } break;case 35:#line 415 "../../inetutils/ftpd/ftpcmd.y"{ help(sitetab, yyvsp[-1].s); if (yyvsp[-1].s != NULL) free (yyvsp[-1].s); } break;case 36:#line 421 "../../inetutils/ftpd/ftpcmd.y"{ int oldmask; if (yyvsp[-1].i) { oldmask = umask(0); (void) umask(oldmask); reply(200, "Current UMASK is %03o", oldmask); } } break;case 37:#line 431 "../../inetutils/ftpd/ftpcmd.y"{ int oldmask; if (yyvsp[-3].i) { if ((yyvsp[-1].i == -1) || (yyvsp[-1].i > 0777)) { reply(501, "Bad UMASK value"); } else { oldmask = umask(yyvsp[-1].i); reply(200, "UMASK set to %03o (was %03o)", yyvsp[-1].i, oldmask); } } } break;case 38:#line 446 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-5].i && (yyvsp[-1].s != NULL)) { if (yyvsp[-3].i > 0777)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -