char *pwd, *homedir;
static Backend *back;
static void *backhandle;
+static Config cfg;
/* ----------------------------------------------------------------------
* Higher-level helper functions used in commands.
if (nnames + names->nnames >= namesize) {
namesize += names->nnames + 128;
- ournames =
- srealloc(ournames, namesize * sizeof(*ournames));
+ ournames = sresize(ournames, namesize, struct fxp_name *);
}
for (i = 0; i < names->nnames; i++)
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;
}
- currdir = smalloc(256);
+ currdir = snewn(256, char);
len = GetCurrentDirectory(256, currdir);
if (len > 256)
- currdir = srealloc(currdir, len);
+ currdir = sresize(currdir, len, char);
GetCurrentDirectory(len, currdir);
printf("New local directory is %s\n", currdir);
sfree(currdir);
char *currdir;
int len;
- currdir = smalloc(256);
+ currdir = snewn(256, char);
len = GetCurrentDirectory(256, currdir);
if (len > 256)
- currdir = srealloc(currdir, len);
+ currdir = sresize(currdir, len, char);
GetCurrentDirectory(len, currdir);
printf("Current local directory is %s\n", currdir);
sfree(currdir);
}
fflush(stdout);
- cmd = smalloc(sizeof(struct sftp_command));
+ cmd = snew(struct sftp_command);
cmd->words = NULL;
cmd->nwords = 0;
cmd->wordssize = 0;
char *ret;
linesize += 512;
- line = srealloc(line, linesize);
+ line = sresize(line, linesize, char);
ret = fgets(line + linelen, linesize - linelen, fp);
if (!ret || (linelen == 0 && line[0] == '\0')) {
* containing everything else on the line.
*/
cmd->nwords = cmd->wordssize = 2;
- cmd->words = srealloc(cmd->words, cmd->wordssize * sizeof(char *));
+ cmd->words = sresize(cmd->words, cmd->wordssize, char *);
cmd->words[0] = "!";
cmd->words[1] = p+1;
} else {
*r = '\0';
if (cmd->nwords >= cmd->wordssize) {
cmd->wordssize = cmd->nwords + 16;
- cmd->words =
- srealloc(cmd->words, cmd->wordssize * sizeof(char *));
+ cmd->words = sresize(cmd->words, cmd->wordssize, char *);
}
cmd->words[cmd->nwords++] = q;
}
static unsigned outlen; /* how much data required */
static unsigned char *pending = NULL; /* any spare data */
static unsigned pendlen = 0, pendsize = 0; /* length and phys. size of buffer */
-int from_backend(void *frontend, int is_stderr, char *data, int datalen)
+int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
{
unsigned char *p = (unsigned char *) data;
unsigned len = (unsigned) datalen;
if (len > 0) {
if (pendsize < pendlen + len) {
pendsize = pendlen + len + 4096;
- pending = (pending ? srealloc(pending, pendsize) :
- smalloc(pendsize));
- if (!pending)
- fatalbox("Out of memory");
+ pending = sresize(pending, pendsize, unsigned char);
}
memcpy(pending + pendlen, p, len);
pendlen += len;
/*
* Enact command-line overrides.
*/
- cmdline_run_saved();
+ cmdline_run_saved(&cfg);
/*
* Trim leading whitespace off the hostname if it's there.
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;
}
- logctx = log_init(NULL);
+ logctx = log_init(NULL, &cfg);
back->provide_logctx(backhandle, logctx);
+ console_provide_logctx(logctx);
ssh_sftp_init();
if (verbose && realhost != NULL)
printf("Connected to %s\n", realhost);
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) {