fh = fxp_open_recv(pktin);
fh = fxp_open_recv(pktin, rreq);
int sftp_general_get(struct sftp_command *cmd, int restart){    struct fxp_handle *fh;    struct sftp_packet *pktin;    struct sftp_request *req, *rreq;    char *fname, *outfname;    uint64 offset;    FILE *fp;    int ret;    if (back == NULL) {	printf("psftp: not connected to a host; use \"open host.name\"\n");	return 0;    }    if (cmd->nwords < 2) {	printf("get: expects a filename\n");	return 0;    }    fname = canonify(cmd->words[1]);    if (!fname) {	printf("%s: %s\n", cmd->words[1], fxp_error());	return 0;    }    outfname = (cmd->nwords == 2 ?		stripslashes(cmd->words[1], 0) : cmd->words[2]);    sftp_register(req = fxp_open_send(fname, SSH_FXF_READ));    rreq = sftp_find_request(pktin = sftp_recv());    assert(rreq == req);    fh = fxp_open_recv(pktin);    if (!fh) {	printf("%s: %s\n", fname, fxp_error());	sfree(fname);	return 0;    }    if (restart) {	fp = fopen(outfname, "rb+");    } else {	fp = fopen(outfname, "wb");    }    if (!fp) {	printf("local: unable to open %s\n", outfname);	sftp_register(req = fxp_close_send(fh));	rreq = sftp_find_request(pktin = sftp_recv());	assert(rreq == req);	fxp_close_recv(pktin);	sfree(fname);	return 0;    }    if (restart) {	long posn;	fseek(fp, 0L, SEEK_END);	posn = ftell(fp);	printf("reget: restarting at file position %ld\n", posn);	offset = uint64_make(0, posn);    } else {	offset = uint64_make(0, 0);    }    printf("remote:%s => local:%s\n", fname, outfname);    /*     * FIXME: we can use FXP_FSTAT here to get the file size, and     * thus put up a progress bar.     */    ret = 1;    while (1) {	char buffer[4096];	int len;	int wpos, wlen;	sftp_register(req = fxp_read_send(fh, offset, sizeof(buffer)));	rreq = sftp_find_request(pktin = sftp_recv());	assert(rreq == req);	len = fxp_read_recv(pktin, buffer, sizeof(buffer));	if ((len == -1 && fxp_error_type() == SSH_FX_EOF) || len == 0)	    break;	if (len == -1) {	    printf("error while reading: %s\n", fxp_error());	    ret = 0;	    break;	}	wpos = 0;	while (wpos < len) {	    wlen = fwrite(buffer, 1, len - wpos, fp);	    if (wlen <= 0) {		printf("error while writing local file\n");		ret = 0;		break;	    }	    wpos += wlen;	}	if (wpos < len) {	       /* we had an error */	    ret = 0;	    break;	}	offset = uint64_add32(offset, len);    }    fclose(fp);    sftp_register(req = fxp_close_send(fh));    rreq = sftp_find_request(pktin = sftp_recv());    assert(rreq == req);    fxp_close_recv(pktin);    sfree(fname);    return ret;}