while (1) { struct sftp_command *cmd; cmd = sftp_getcmd(); if (!cmd) break; if (cmd->obey(cmd) < 0) break;
if (mode == 0) {   while (1) { struct sftp_command *cmd; cmd = sftp_getcmd(stdin, 0, 0); if (!cmd) break; if (cmd->obey(cmd) < 0) break; } } else { fp = fopen(batchfile, "r"); if (!fp) { printf("Fatal: unable to open %s\n", batchfile); return; } while (1) { struct sftp_command *cmd; cmd = sftp_getcmd(fp, mode, modeflags); if (!cmd) break; if (cmd->obey(cmd) < 0) break; if (fxp_error() != NULL) { if (!(modeflags & 2)) break; } } fclose(fp);
void do_sftp(void){    /*     * Do protocol initialisation.      */    if (!fxp_init()) {	fprintf(stderr,		"Fatal: unable to initialise SFTP: %s\n", fxp_error());	return;    }    /*     * Find out where our home directory is.     */    homedir = fxp_realpath(".");    if (!homedir) {	fprintf(stderr,		"Warning: failed to resolve home directory: %s\n",		fxp_error());	homedir = dupstr(".");    } else {	printf("Remote working directory is %s\n", homedir);    }    pwd = dupstr(homedir);    /* ------------------------------------------------------------------     * Now we're ready to do Real Stuff.     */    while (1) {	struct sftp_command *cmd;	cmd = sftp_getcmd();	if (!cmd)	    break;	if (cmd->obey(cmd) < 0)	    break;    }}