X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/95f51977ddc18faa2e212f30c00a39540b39f325..ca67e7b465996afb3821d6a075c4dc6a7f0f5d52:/usr/src/etc/ftpd/ftpcmd.y diff --git a/usr/src/etc/ftpd/ftpcmd.y b/usr/src/etc/ftpd/ftpcmd.y index a910075cb5..726d4f4902 100644 --- a/usr/src/etc/ftpd/ftpcmd.y +++ b/usr/src/etc/ftpd/ftpcmd.y @@ -1,7 +1,20 @@ /* * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)ftpcmd.y 5.11 (Berkeley) 6/18/88 */ /* @@ -12,8 +25,8 @@ %{ #ifndef lint -static char sccsid[] = "@(#)ftpcmd.y 5.7 (Berkeley) 5/28/86"; -#endif +static char sccsid[] = "@(#)ftpcmd.y 5.11 (Berkeley) 6/18/88"; +#endif /* not lint */ #include #include @@ -51,6 +64,7 @@ static int cmd_type; static int cmd_form; static int cmd_bytesz; char cbuf[512]; +char *fromname; char *index(); %} @@ -77,6 +91,10 @@ char *index(); cmd_list: /* empty */ | cmd_list cmd + = { + fromname = (char *) 0; + } + | cmd_list rcmd ; cmd: USER SP username CRLF @@ -237,6 +255,17 @@ cmd: USER SP username CRLF if ($4 != NULL) free((char *) $4); } + | RNTO SP pathname CRLF + = { + if (fromname) { + renamecmd(fromname, (char *) $3); + free(fromname); + fromname = (char *) 0; + } else { + reply(503, "Bad sequence of commands."); + } + free((char *) $3); + } | ABOR CRLF = { reply(225, "ABOR command successful."); @@ -253,7 +282,6 @@ cmd: USER SP username CRLF if ($4 != NULL) free((char *) $4); } - | rename_cmd | HELP CRLF = { help((char *) 0); @@ -311,6 +339,19 @@ cmd: USER SP username CRLF } ; +rcmd: RNFR check_login SP pathname CRLF + = { + char *renamefrom(); + + if ($2 && $4) { + fromname = renamefrom((char *) $4); + if (fromname == (char *) 0 && $4) { + free((char *) $4); + } + } + } + ; + username: STRING ; @@ -439,37 +480,6 @@ pathname: pathstring pathstring: STRING ; -rename_cmd: rename_from rename_to - = { - if ($1 && $2) - renamecmd((char *) $1, (char *) $2); - else - reply(503, "Bad sequence of commands."); - if ($1) - free((char *) $1); - if ($2) - free((char *) $2); - } - ; - -rename_from: RNFR check_login SP pathname CRLF - = { - char *from = 0, *renamefrom(); - - if ($2 && $4) - from = renamefrom((char *) $4); - if (from == 0 && $4) - free((char *) $4); - $$ = (int)from; - } - ; - -rename_to: RNTO SP pathname CRLF - = { - $$ = $3; - } - ; - check_login: /* empty */ = { if (logged_in) @@ -831,10 +841,8 @@ help(s) width = 0, NCMDS = 0; for (c = cmdtab; c->name != NULL; c++) { - int len = strlen(c->name); + int len = strlen(c->name) + 1; - if (c->implemented == 0) - len++; if (len > width) width = len; NCMDS++; @@ -858,7 +866,7 @@ help(s) c->implemented ? ' ' : '*'); if (c + lines >= &cmdtab[NCMDS]) break; - w = strlen(c->name); + w = strlen(c->name) + 1; while (w < width) { putchar(' '); w++;