strncpy(cfg.remote_cmd, cmd, sizeof(cfg.remote_cmd)); cfg.remote_cmd[sizeof(cfg.remote_cmd) - 1] = '\0';
strcpy(cfg.remote_cmd, "sftp"); cfg.ssh_subsys = TRUE; cfg.remote_cmd_ptr2 = cmd; cfg.ssh_subsys2 = FALSE;
static void do_cmd(char *host, char *user, char *cmd){    char *err, *realhost;    DWORD namelen;    if (host == NULL || host[0] == '\0')	bump("Empty host name");    /* Try to load settings for this host */    do_defaults(host, &cfg);    if (cfg.host[0] == '\0') {	/* No settings for this host; use defaults */	do_defaults(NULL, &cfg);	strncpy(cfg.host, host, sizeof(cfg.host) - 1);	cfg.host[sizeof(cfg.host) - 1] = '\0';	cfg.port = 22;    }    /* Set username */    if (user != NULL && user[0] != '\0') {	strncpy(cfg.username, user, sizeof(cfg.username) - 1);	cfg.username[sizeof(cfg.username) - 1] = '\0';    } else if (cfg.username[0] == '\0') {	namelen = 0;	if (GetUserName(user, &namelen) == FALSE)	    bump("Empty user name");	user = smalloc(namelen * sizeof(char));	GetUserName(user, &namelen);	if (verbose)	    tell_user(stderr, "Guessing user name: %s", user);	strncpy(cfg.username, user, sizeof(cfg.username) - 1);	cfg.username[sizeof(cfg.username) - 1] = '\0';	free(user);    }    if (cfg.protocol != PROT_SSH)	cfg.port = 22;    if (portnumber)	cfg.port = portnumber;    strncpy(cfg.remote_cmd, cmd, sizeof(cfg.remote_cmd));    cfg.remote_cmd[sizeof(cfg.remote_cmd) - 1] = '\0';    cfg.nopty = TRUE;    back = &ssh_backend;    err = back->init(cfg.host, cfg.port, &realhost);    if (err != NULL)	bump("ssh_init: %s", err);    ssh_scp_init();    if (verbose && realhost != NULL)	tell_user(stderr, "Connected to %s\n", realhost);    sfree(realhost);}