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++)
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;
}
extern int select_result(WPARAM, LPARAM);
/*
+ * In psftp, all agent requests should be synchronous, so this is a
+ * never-called stub.
+ */
+void agent_schedule_callback(void (*callback)(void *, void *, int),
+ void *callback_ctx, void *data, int len)
+{
+ assert(!"We shouldn't be here");
+}
+
+/*
* Receive a block of data from the SSH link. Block until all data
* is available.
*
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;
static int psftp_connect(char *userhost, char *user, int portnumber)
{
char *host, *realhost;
- char *err;
+ const char *err;
/* Separate host and username */
host = userhost;
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);
char *batchfile = NULL;
int errors = 0;
- flags = FLAG_STDERR | FLAG_INTERACTIVE;
+ flags = FLAG_STDERR | FLAG_INTERACTIVE | FLAG_SYNCAGENT;
cmdline_tooltype = TOOLTYPE_FILETRANSFER;
ssh_get_line = &console_get_line;
init_winsock();