fxp_close_recv(pktin);
fxp_close_recv(pktin, rreq);
int sftp_general_put(struct sftp_command *cmd, int restart){    struct fxp_handle *fh;    char *fname, *origoutfname, *outfname;    struct sftp_packet *pktin;    struct sftp_request *req, *rreq;    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("put: expects a filename\n");	return 0;    }    fname = cmd->words[1];    origoutfname = (cmd->nwords == 2 ?		    stripslashes(cmd->words[1], 1) : cmd->words[2]);    outfname = canonify(origoutfname);    if (!outfname) {	printf("%s: %s\n", origoutfname, fxp_error());	return 0;    }    fp = fopen(fname, "rb");    if (!fp) {	printf("local: unable to open %s\n", fname);	sfree(outfname);	return 0;    }    if (restart) {	sftp_register(req = fxp_open_send(outfname, SSH_FXF_WRITE));    } else {	sftp_register(req = fxp_open_send(outfname, SSH_FXF_WRITE |					  SSH_FXF_CREAT | SSH_FXF_TRUNC));    }    rreq = sftp_find_request(pktin = sftp_recv());    assert(rreq == req);    fh = fxp_open_recv(pktin);    if (!fh) {	printf("%s: %s\n", outfname, fxp_error());	sfree(outfname);	return 0;    }    if (restart) {	char decbuf[30];	struct fxp_attrs attrs;	int ret;	sftp_register(req = fxp_fstat_send(fh));	rreq = sftp_find_request(pktin = sftp_recv());	assert(rreq == req);	ret = fxp_fstat_recv(pktin, &attrs);	if (!ret) {	    printf("read size of %s: %s\n", outfname, fxp_error());	    sfree(outfname);	    return 0;	}	if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) {	    printf("read size of %s: size was not given\n", outfname);	    sfree(outfname);	    return 0;	}	offset = attrs.size;	uint64_decimal(offset, decbuf);	printf("reput: restarting at file position %s\n", decbuf);	if (uint64_compare(offset, uint64_make(0, LONG_MAX)) > 0) {	    printf("reput: remote file is larger than we can deal with\n");	    sfree(outfname);	    return 0;	}	if (fseek(fp, offset.lo, SEEK_SET) != 0)	    fseek(fp, 0, SEEK_END);    /* *shrug* */    } else {	offset = uint64_make(0, 0);    }    printf("local:%s => remote:%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, ret;	len = fread(buffer, 1, sizeof(buffer), fp);	if (len == -1) {	    printf("error while reading local file\n");	    ret = 0;	    break;	} else if (len == 0) {	    break;	}	sftp_register(req = fxp_write_send(fh, buffer, offset, len));	rreq = sftp_find_request(pktin = sftp_recv());	assert(rreq == req);	ret = fxp_write_recv(pktin);	if (!ret) {	    printf("error while writing: %s\n", fxp_error());	    ret = 0;	    break;	}	offset = uint64_add32(offset, len);    }    sftp_register(req = fxp_close_send(fh));    rreq = sftp_find_request(pktin = sftp_recv());    assert(rreq == req);    fxp_close_recv(pktin);    fclose(fp);    sfree(outfname);    return ret;}