projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Miscellaneous fixes to finish up `remove-statics'. rlogin.c had a
[u/mdw/putty]
/
psftp.c
diff --git
a/psftp.c
b/psftp.c
index
93fa33f
..
2dc6e4c
100644
(file)
--- a/
psftp.c
+++ b/
psftp.c
@@
-34,6
+34,7
@@
static int do_sftp_init(void);
char *pwd, *homedir;
static Backend *back;
static void *backhandle;
char *pwd, *homedir;
static Backend *back;
static void *backhandle;
+static Config cfg;
/* ----------------------------------------------------------------------
* Higher-level helper functions used in commands.
/* ----------------------------------------------------------------------
* Higher-level helper functions used in commands.
@@
-832,7
+833,7
@@
int sftp_cmd_chmod(struct sftp_command *cmd)
if (!(subset & 06777) && (perms &~ subset)) {
printf("chmod: file mode '%.*s' contains no user/group/other"
" specifier and permissions other than 't' \n",
if (!(subset & 06777) && (perms &~ subset)) {
printf("chmod: file mode '%.*s' contains no user/group/other"
" specifier and permissions other than 't' \n",
- strcspn(modebegin, ","), modebegin
, *mode
);
+ strcspn(modebegin, ","), modebegin);
return 0;
}
perms &= subset;
return 0;
}
perms &= subset;
@@
-1448,40
+1449,43
@@
static int verbose = 0;
*/
void fatalbox(char *fmt, ...)
{
*/
void fatalbox(char *fmt, ...)
{
- char
str[0x100]; /* Make the size big enough */
+ char
*str, *str2;
va_list ap;
va_start(ap, fmt);
va_list ap;
va_start(ap, fmt);
- strcpy(str, "Fatal:");
- vsprintf(str + strlen(str), fmt, ap);
+ str = dupvprintf(fmt, ap);
+ str2 = dupcat("Fatal: ", str, "\n", NULL);
+ sfree(str);
va_end(ap);
va_end(ap);
-
strcat(str, "\n"
);
-
fputs(str, stderr
);
+
fputs(str2, stderr
);
+
sfree(str2
);
cleanup_exit(1);
}
void modalfatalbox(char *fmt, ...)
{
cleanup_exit(1);
}
void modalfatalbox(char *fmt, ...)
{
- char
str[0x100]; /* Make the size big enough */
+ char
*str, *str2;
va_list ap;
va_start(ap, fmt);
va_list ap;
va_start(ap, fmt);
- strcpy(str, "Fatal:");
- vsprintf(str + strlen(str), fmt, ap);
+ str = dupvprintf(fmt, ap);
+ str2 = dupcat("Fatal: ", str, "\n", NULL);
+ sfree(str);
va_end(ap);
va_end(ap);
-
strcat(str, "\n"
);
-
fputs(str, stderr
);
+
fputs(str2, stderr
);
+
sfree(str2
);
cleanup_exit(1);
}
void connection_fatal(void *frontend, char *fmt, ...)
{
cleanup_exit(1);
}
void connection_fatal(void *frontend, char *fmt, ...)
{
- char
str[0x100]; /* Make the size big enough */
+ char
*str, *str2;
va_list ap;
va_start(ap, fmt);
va_list ap;
va_start(ap, fmt);
- strcpy(str, "Fatal:");
- vsprintf(str + strlen(str), fmt, ap);
+ str = dupvprintf(fmt, ap);
+ str2 = dupcat("Fatal: ", str, "\n", NULL);
+ sfree(str);
va_end(ap);
va_end(ap);
-
strcat(str, "\n"
);
-
fputs(str, stderr
);
+
fputs(str2, stderr
);
+
sfree(str2
);
cleanup_exit(1);
}
cleanup_exit(1);
}
@@
-1719,7
+1723,7
@@
static int psftp_connect(char *userhost, char *user, int portnumber)
/*
* Enact command-line overrides.
*/
/*
* Enact command-line overrides.
*/
- cmdline_run_saved();
+ cmdline_run_saved(
&cfg
);
/*
* Trim leading whitespace off the hostname if it's there.
/*
* Trim leading whitespace off the hostname if it's there.
@@
-1825,12
+1829,12
@@
static int psftp_connect(char *userhost, char *user, int portnumber)
back = &ssh_backend;
back = &ssh_backend;
- err = back->init(NULL, &backhandle,
cfg.host, cfg.port, &realhost,
0);
+ err = back->init(NULL, &backhandle,
&cfg, cfg.host, cfg.port, &realhost,
0);
if (err != NULL) {
fprintf(stderr, "ssh_init: %s\n", err);
return 1;
}
if (err != NULL) {
fprintf(stderr, "ssh_init: %s\n", err);
return 1;
}
- logctx = log_init(NULL);
+ logctx = log_init(NULL
, &cfg
);
back->provide_logctx(backhandle, logctx);
ssh_sftp_init();
if (verbose && realhost != NULL)
back->provide_logctx(backhandle, logctx);
ssh_sftp_init();
if (verbose && realhost != NULL)
@@
-1841,11
+1845,11
@@
static int psftp_connect(char *userhost, char *user, int portnumber)
void cmdline_error(char *p, ...)
{
va_list ap;
void cmdline_error(char *p, ...)
{
va_list ap;
- fprintf(stderr, "ps
c
p: ");
+ fprintf(stderr, "ps
ft
p: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
- fp
utc('\n', stderr
);
+ fp
rintf(stderr, "\n try typing \"psftp -h\" for help\n"
);
exit(1);
}
exit(1);
}
@@
-1860,6
+1864,7
@@
int main(int argc, char *argv[])
int mode = 0;
int modeflags = 0;
char *batchfile = NULL;
int mode = 0;
int modeflags = 0;
char *batchfile = NULL;
+ int errors = 0;
flags = FLAG_STDERR | FLAG_INTERACTIVE;
cmdline_tooltype = TOOLTYPE_FILETRANSFER;
flags = FLAG_STDERR | FLAG_INTERACTIVE;
cmdline_tooltype = TOOLTYPE_FILETRANSFER;
@@
-1869,6
+1874,7
@@
int main(int argc, char *argv[])
userhost = user = NULL;
userhost = user = NULL;
+ errors = 0;
for (i = 1; i < argc; i++) {
int ret;
if (argv[i][0] != '-') {
for (i = 1; i < argc; i++) {
int ret;
if (argv[i][0] != '-') {
@@
-1878,7
+1884,7
@@
int main(int argc, char *argv[])
userhost = dupstr(argv[i]);
continue;
}
userhost = dupstr(argv[i]);
continue;
}
- ret = cmdline_process_param(argv[i], i+1<argc?argv[i+1]:NULL, 1);
+ ret = cmdline_process_param(argv[i], i+1<argc?argv[i+1]:NULL, 1
, &cfg
);
if (ret == -2) {
cmdline_error("option \"%s\" requires an argument", argv[i]);
} else if (ret == 2) {
if (ret == -2) {
cmdline_error("option \"%s\" requires an argument", argv[i]);
} else if (ret == 2) {
@@
-1903,7
+1909,7
@@
int main(int argc, char *argv[])
i++;
break;
} else {
i++;
break;
} else {
-
usage(
);
+
cmdline_error("unknown option \"%s\"", argv[i]
);
}
}
argc -= i;
}
}
argc -= i;