fxp_close_recv(pktin);
fxp_close_recv(pktin, rreq);
void scp_sftp_listdir(char *dirname){    struct fxp_handle *dirh;    struct fxp_names *names;    struct fxp_name *ournames;    struct sftp_packet *pktin;    struct sftp_request *req, *rreq;    int nnames, namesize;    int i;    if (!fxp_init()) {	tell_user(stderr, "unable to initialise SFTP: %s", fxp_error());	errs++;	return;    }    printf("Listing directory %s\n", dirname);    sftp_register(req = fxp_opendir_send(dirname));    rreq = sftp_find_request(pktin = sftp_recv());    assert(rreq == req);    dirh = fxp_opendir_recv(pktin);    if (dirh == NULL) {	printf("Unable to open %s: %s\n", dirname, fxp_error());    } else {	nnames = namesize = 0;	ournames = NULL;	while (1) {	    sftp_register(req = fxp_readdir_send(dirh));	    rreq = sftp_find_request(pktin = sftp_recv());	    assert(rreq == req);	    names = fxp_readdir_recv(pktin);	    if (names == NULL) {		if (fxp_error_type() == SSH_FX_EOF)		    break;		printf("Reading directory %s: %s\n", dirname, fxp_error());		break;	    }	    if (names->nnames == 0) {		fxp_free_names(names);		break;	    }	    if (nnames + names->nnames >= namesize) {		namesize += names->nnames + 128;		ournames = sresize(ournames, namesize, struct fxp_name);	    }	    for (i = 0; i < names->nnames; i++)		ournames[nnames++] = names->names[i];	    names->nnames = 0;	       /* prevent free_names */	    fxp_free_names(names);	}	sftp_register(req = fxp_close_send(dirh));	rreq = sftp_find_request(pktin = sftp_recv());	assert(rreq == req);	fxp_close_recv(pktin);	/*	 * Now we have our filenames. Sort them by actual file	 * name, and then output the longname parts.	 */	qsort(ournames, nnames, sizeof(*ournames), sftp_ls_compare);	/*	 * And print them.	 */	for (i = 0; i < nnames; i++)	    printf("%s\n", ournames[i].longname);    }}