/*
* 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
*/
/*
%{
#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 <sys/types.h>
#include <sys/socket.h>
static int cmd_form;
static int cmd_bytesz;
char cbuf[512];
+char *fromname;
char *index();
%}
cmd_list: /* empty */
| cmd_list cmd
+ = {
+ fromname = (char *) 0;
+ }
+ | cmd_list rcmd
;
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.");
if ($4 != NULL)
free((char *) $4);
}
- | rename_cmd
| HELP CRLF
= {
help((char *) 0);
}
;
+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
;
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)
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++;
c->implemented ? ' ' : '*');
if (c + lines >= &cmdtab[NCMDS])
break;
- w = strlen(c->name);
+ w = strlen(c->name) + 1;
while (w < width) {
putchar(' ');
w++;