* canonification fails, at least fall back to returning a _valid_
* pathname (though it may be ugly, eg /home/simon/../foobar).
*/
-char *canonify(char *name)
+char *canonify(const char *name)
{
char *fullname, *canonname;
struct sftp_packet *pktin;
if (name[0] == '/') {
fullname = dupstr(name);
} else {
- char *slash;
+ const char *slash;
if (pwd[strlen(pwd) - 1] == '/')
slash = "";
else
}
}
-/*
- * Return a pointer to the portion of str that comes after the last
- * slash (or backslash or colon, if `local' is TRUE).
- */
-static char *stripslashes(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 str;
-}
-
/*
* qsort comparison routine for fxp_name structures. Sorts by real
* file name.
xfer = xfer_download_init(fh, offset);
while (!xfer_done(xfer)) {
void *vbuf;
- int ret, len;
+ int len;
int wpos, wlen;
xfer_download_queue(xfer);
struct sftp_request *req;
uint64 offset;
RFile *file;
- int ret, err, eof;
+ int err = 0, eof;
struct fxp_attrs attrs;
long permissions;
if (restart) {
char decbuf[30];
struct fxp_attrs attrs;
+ int ret;
req = fxp_fstat_send(fh);
pktin = sftp_wait_for_reply(req);
if (!ret) {
printf("read size of %s: %s\n", outfname, fxp_error());
+ err = 1;
goto cleanup;
}
if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) {
printf("read size of %s: size was not given\n", outfname);
- ret = 0;
+ err = 1;
goto cleanup;
}
offset = attrs.size;
* FIXME: we can use FXP_FSTAT here to get the file size, and
* thus put up a progress bar.
*/
- ret = 1;
xfer = xfer_upload_init(fh, offset);
- err = eof = 0;
+ eof = 0;
while ((!err && !eof) || !xfer_done(xfer)) {
char buffer[4096];
int len, ret;
cleanup:
req = fxp_close_send(fh);
pktin = sftp_wait_for_reply(req);
- fxp_close_recv(pktin, req);
+ if (!fxp_close_recv(pktin, req)) {
+ if (!err) {
+ printf("error while closing: %s", fxp_error());
+ err = 1;
+ }
+ }
close_rfile(file);
- return ret;
+ return (err == 0) ? 1 : 0;
}
/* ----------------------------------------------------------------------
struct fxp_names *names;
struct fxp_name **ournames;
int nnames, namesize;
- char *dir, *cdir, *unwcdir, *wildcard;
+ const char *dir;
+ char *cdir, *unwcdir, *wildcard;
struct sftp_packet *pktin;
struct sftp_request *req;
int i;
if (dirh == NULL) {
printf("Unable to open %s: %s\n", dir, fxp_error());
+ return 0;
} else {
nnames = namesize = 0;
ournames = NULL;
static int sftp_cmd_help(struct sftp_command *cmd);
static struct sftp_cmd_lookup {
- char *name;
+ const char *name;
/*
* For help purposes, there are two kinds of command:
*
* contains the help that should double up for this command.
*/
int listed; /* do we list this in primary help? */
- char *shorthelp;
- char *longhelp;
+ const char *shorthelp;
+ const char *longhelp;
int (*obey) (struct sftp_command *);
} sftp_lookup[] = {
/*
}
};
-const struct sftp_cmd_lookup *lookup_command(char *name)
+const struct sftp_cmd_lookup *lookup_command(const char *name)
{
int i, j, k, cmp;
/*
* Print an error message and perform a fatal exit.
*/
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
cleanup_exit(1);
}
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
cleanup_exit(1);
}
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
fputs(str2, stderr);
sfree(str2);
}
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
{
char *str, *str2;
va_list ap;
cleanup_exit(1);
}
-void ldisc_send(void *handle, char *buf, int len, int interactive)
-{
- /*
- * This is only here because of the calls to ldisc_send(NULL,
- * 0) in ssh.c. Nothing in PSFTP actually needs to use the
- * ldisc as an ldisc. So if we get called with any real data, I
- * want to know about it.
- */
- assert(len == 0);
-}
+void ldisc_echoedit_update(void *handle) { }
/*
* In psftp, all agent requests should be synchronous, so this is a
back->send(backhandle, buf, len);
return 1;
}
+int sftp_sendbuffer(void)
+{
+ return back->sendbuffer(backhandle);
+}
/*
* Short description of parameters.
printf(" -hostkey aa:bb:cc:...\n");
printf(" manually specify a host key (may be repeated)\n");
printf(" -batch disable all interactive prompts\n");
+ printf(" -proxycmd command\n");
+ printf(" use 'command' as local proxy\n");
printf(" -sshlog file\n");
printf(" -sshrawlog file\n");
printf(" log protocol details to a file\n");
static void version(void)
{
- printf("psftp: %s\n", ver);
- cleanup_exit(1);
+ char *buildinfo_text = buildinfo("\n");
+ printf("psftp: %s\n%s\n", ver, buildinfo_text);
+ sfree(buildinfo_text);
+ exit(0);
}
/*
back = &ssh_backend;
+ logctx = log_init(NULL, conf);
+ console_provide_logctx(logctx);
+
+ platform_psftp_pre_conn_setup();
+
err = back->init(NULL, &backhandle, conf,
conf_get_str(conf, CONF_host),
conf_get_int(conf, CONF_port),
fprintf(stderr, "ssh_init: %s\n", err);
return 1;
}
- logctx = log_init(NULL, conf);
back->provide_logctx(backhandle, logctx);
- console_provide_logctx(logctx);
while (!back->sendok(backhandle)) {
if (back->exitcode(backhandle) >= 0)
return 1;
return 0;
}
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "psftp: ");