do_sftp();
do_sftp(mode, modeflags, batchfile);
int main(int argc, char *argv[]){    int i;    int portnumber = 0;    char *user, *host, *userhost, *realhost;    char *err;    flags = FLAG_STDERR;    ssh_get_line = &get_line;    init_winsock();    sk_init();    userhost = user = NULL;    for (i = 1; i < argc; i++) {	if (argv[i][0] != '-') {	    if (userhost)		usage();	    else		userhost = dupstr(argv[i]);	} else if (strcmp(argv[i], "-v") == 0) {	    verbose = 1, flags |= FLAG_VERBOSE;	} else if (strcmp(argv[i], "-h") == 0 ||		   strcmp(argv[i], "-?") == 0) {	    usage();	} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {	    user = argv[++i];	} else if (strcmp(argv[i], "-P") == 0 && i + 1 < argc) {	    portnumber = atoi(argv[++i]);	} else if (strcmp(argv[i], "-pw") == 0 && i + 1 < argc) {	    password = argv[++i];	} else if (strcmp(argv[i], "--") == 0) {	    i++;	    break;	} else {	    usage();	}    }    argc -= i;    argv += i;    back = NULL;    if (argc > 0 || !userhost)	usage();    /* Separate host and username */    host = userhost;    host = strrchr(host, '@');    if (host == NULL) {	host = userhost;    } else {	*host++ = '\0';	if (user) {	    printf("psftp: multiple usernames specified; using \"%s\"\n",		   user);	} else	    user = userhost;    }    /* 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';    }    if (!cfg.username[0]) {	printf("login as: ");	if (!fgets(cfg.username, sizeof(cfg.username), stdin)) {	    fprintf(stderr, "psftp: aborting\n");	    exit(1);	} else {	    int len = strlen(cfg.username);	    if (cfg.username[len - 1] == '\n')		cfg.username[len - 1] = '\0';	}    }    if (cfg.protocol != PROT_SSH)	cfg.port = 22;    if (portnumber)	cfg.port = portnumber;    /* SFTP uses SSH2 by default always */    cfg.sshprot = 2;    /* Set up subsystem name. FIXME: fudge for SSH1. */    strcpy(cfg.remote_cmd, "sftp");    cfg.ssh_subsys = TRUE;    cfg.nopty = TRUE;    back = &ssh_backend;    err = back->init(cfg.host, cfg.port, &realhost);    if (err != NULL) {	fprintf(stderr, "ssh_init: %s", err);	return 1;    }    ssh_sftp_init();    if (verbose && realhost != NULL)	printf("Connected to %s\n", realhost);    do_sftp();    if (back != NULL && back->socket() != NULL) {	char ch;	back->special(TS_EOF);	sftp_recvdata(&ch, 1);    }    WSACleanup();    random_save_seed();    return 0;}