}
}
-/*
- * Return a pointer to the portion of str that comes after the last
- * slash (or backslash or colon, if `local' is TRUE).
- *
- * This function has the annoying strstr() property of taking a const
- * char * and returning a char *. You should treat it as if it was a
- * pair of overloaded functions, one mapping mutable->mutable and the
- * other const->const :-(
- */
-static char *stripslashes(const char *str, int local)
-{
- char *p;
-
- if (local) {
- p = strchr(str, ':');
- if (p) str = p+1;
- }
-
- p = strrchr(str, '/');
- if (p) str = p+1;
-
- if (local) {
- p = strrchr(str, '\\');
- if (p) str = p+1;
- }
-
- return (char *)str;
-}
-
/*
* qsort comparison routine for fxp_name structures. Sorts by real
* file name.
}
}
-void do_sftp(int mode, int modeflags, char *batchfile)
+int do_sftp(int mode, int modeflags, char *batchfile)
{
FILE *fp;
int ret;
fp = fopen(batchfile, "r");
if (!fp) {
printf("Fatal: unable to open %s\n", batchfile);
- return;
+ return 1;
}
+ ret = 0;
while (1) {
struct sftp_command *cmd;
cmd = sftp_getcmd(fp, mode, modeflags);
}
}
fclose(fp);
-
+ /*
+ * In batch mode, and if exit on command failure is enabled,
+ * any command failure causes the whole of PSFTP to fail.
+ */
+ if (ret == 0 && !(modeflags & 2)) return 2;
}
+ return 0;
}
/* ----------------------------------------------------------------------
printf(" -hostkey aa:bb:cc:...\n");
printf(" manually specify a host key (may be repeated)\n");
printf(" -batch disable all interactive prompts\n");
+ printf(" -sshlog file\n");
+ printf(" -sshrawlog file\n");
+ printf(" log protocol details to a file\n");
cleanup_exit(1);
}
*/
int psftp_main(int argc, char *argv[])
{
- int i;
+ int i, ret;
int portnumber = 0;
char *userhost, *user;
int mode = 0;
" to connect\n");
}
- do_sftp(mode, modeflags, batchfile);
+ ret = do_sftp(mode, modeflags, batchfile);
if (back != NULL && back->connected(backhandle)) {
char ch;
console_provide_logctx(NULL);
sk_cleanup();
- return 0;
+ return ret;
}