assume empty pathname means cd to '/', like ncftp (?).
-/* $OpenBSD: cmds.c,v 1.6 1996/11/09 19:53:59 kstailey Exp $ */
+/* $OpenBSD: cmds.c,v 1.7 1996/12/17 02:11:46 michaels Exp $ */
/* $NetBSD: cmds.c,v 1.8 1995/09/08 01:06:05 tls Exp $ */
/*
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.6 1996/11/09 19:53:59 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.7 1996/12/17 02:11:46 michaels Exp $";
#endif
#endif /* not lint */
* Set current working directory
* on remote machine.
*/
-void
+int
cd(argc, argv)
int argc;
char *argv[];
code = -1;
return;
}
- if (command("CWD %s", argv[1]) == ERROR && code == 500) {
- if (verbose)
- printf("CWD command not recognized, trying XCWD\n");
- (void) command("XCWD %s", argv[1]);
+ if (command("CWD %s", argv[1]) == ERROR) {
+ if (code == 500) {
+ if (verbose)
+ printf("CWD command not recognized, "
+ "trying XCWD\n");
+ return(command("XCWD %s", argv[1]));
+ }
+ else
+ return(-1);
}
+ return(0);
}
/*
-/* $OpenBSD: extern.h,v 1.3 1996/09/03 18:00:05 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.4 1996/12/17 02:11:46 michaels Exp $ */
/* $NetBSD: extern.h,v 1.4 1995/09/08 01:06:19 tls Exp $ */
/*-
void account __P((int, char **));
int another __P((int *, char ***, char *));
void blkfree __P((char **));
-void cd __P((int, char **));
+int cd __P((int, char **));
void cdup __P((int, char **));
void changetype __P((int, int));
void cmdabort __P(());
-/* $OpenBSD: main.c,v 1.8 1996/11/09 19:58:59 kstailey Exp $ */
+/* $OpenBSD: main.c,v 1.9 1996/12/17 02:11:45 michaels Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.8 1996/11/09 19:58:59 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.9 1996/12/17 02:11:45 michaels Exp $";
#endif
#endif /* not lint */
home = homedir;
(void) strcpy(home, pw->pw_dir);
}
+
if (argc > 0 && strchr(argv[0], ':')) {
int ret = 0;
anonftp = 1;
extern char *__progname;
char portstr[20], *p, *bufp = NULL;
char *host = NULL, *dir = NULL, *file = NULL;
- int xargc = 2;
+ int xargc = 2, tmp;
if (setjmp(toplevel))
exit(0);
goto bail;
}
- setbinary(NULL, 0);
-
- if (dir) {
+ if (dir != NULL && *dir != '\0') {
xargv[1] = dir;
xargv[2] = NULL;
xargc = 2;
cd(xargc, xargv);
}
+ /*
+ * either "file" is the file user wants, or he wants
+ * to cd to "file" aswell, so try cd first, after
+ * switcing of verbose (already got a CWD from above).
+ */
+ xargv[1] = *file == '\0' ? "/" : file;
+ xargv[2] = NULL;
+ xargc = 2;
+ tmp = verbose;
+ verbose = 0;
+ if (cd(xargc, xargv) == 0) {
+ verbose = tmp;
+ goto CLINE_CD;
+ }
+ verbose = tmp;
+ setbinary(NULL, 0);
/* fetch file */
xargv[1] = file;
}
} while (!connected);
}
+CLINE_CD:
top = setjmp(toplevel) == 0;
if (top) {
(void) signal(SIGINT, intr);