BSD 4_3_Net_2 release
[unix-history] / usr / src / libexec / ftpd / ftpcmd.y
index e25f049..ac4b3bd 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1985, 1988 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1985, 1988 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)ftpcmd.y    5.24 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ftpcmd.y    5.24 (Berkeley) 2/25/91
  */
 
 /*
  */
 
 /*
@@ -15,7 +41,7 @@
 %{
 
 #ifndef lint
 %{
 
 #ifndef lint
-static char sccsid[] = "@(#)ftpcmd.y   5.24 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftpcmd.y   5.24 (Berkeley) 2/25/91";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -53,6 +79,8 @@ extern  int transflag;
 extern  char tmpline[];
 char   **ftpglob();
 
 extern  char tmpline[];
 char   **ftpglob();
 
+off_t  restart_point;
+
 static int cmd_type;
 static int cmd_form;
 static int cmd_bytesz;
 static int cmd_type;
 static int cmd_form;
 static int cmd_bytesz;
@@ -87,6 +115,7 @@ cmd_list:    /* empty */
        |       cmd_list cmd
                = {
                        fromname = (char *) 0;
        |       cmd_list cmd
                = {
                        fromname = (char *) 0;
+                       restart_point = (off_t) 0;
                }
        |       cmd_list rcmd
        ;
                }
        |       cmd_list rcmd
        ;
@@ -466,6 +495,7 @@ rcmd:               RNFR check_login SP pathname CRLF
                = {
                        char *renamefrom();
 
                = {
                        char *renamefrom();
 
+                       restart_point = (off_t) 0;
                        if ($2 && $4) {
                                fromname = renamefrom((char *) $4);
                                if (fromname == (char *) 0 && $4) {
                        if ($2 && $4) {
                                fromname = renamefrom((char *) $4);
                                if (fromname == (char *) 0 && $4) {
@@ -473,6 +503,15 @@ rcmd:              RNFR check_login SP pathname CRLF
                                }
                        }
                }
                                }
                        }
                }
+       |       REST SP byte_size CRLF
+               = {
+                       long atol();
+
+                       fromname = (char *) 0;
+                       restart_point = $3;
+                       reply(350, "Restarting at %ld. %s", restart_point,
+                           "Send STORE or RETRIEVE to initiate transfer.");
+               }
        ;
                
 username:      STRING
        ;
                
 username:      STRING
@@ -688,7 +727,7 @@ struct tab cmdtab[] = {             /* In order defined in RFC 765 */
        { "MRSQ", MRSQ, OSTR, 0,        "(mail recipient scheme question)" },
        { "MRCP", MRCP, STR1, 0,        "(mail recipient)" },
        { "ALLO", ALLO, ARGS, 1,        "allocate storage (vacuously)" },
        { "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)" },
+       { "REST", REST, ARGS, 1,        "(restart command)" },
        { "RNFR", RNFR, STR1, 1,        "<sp> file-name" },
        { "RNTO", RNTO, STR1, 1,        "<sp> file-name" },
        { "ABOR", ABOR, ARGS, 1,        "(abort operation)" },
        { "RNFR", RNFR, STR1, 1,        "<sp> file-name" },
        { "RNTO", RNTO, STR1, 1,        "<sp> file-name" },
        { "ABOR", ABOR, ARGS, 1,        "(abort operation)" },