if (!pktin) { fxp_internal_error("did not receive a valid SFTP packet\n"); return NULL; }
struct fxp_names *fxp_readdir(struct fxp_handle *handle){    struct sftp_packet *pktin, *pktout;    int id;    pktout = sftp_pkt_init(SSH_FXP_READDIR);    sftp_pkt_adduint32(pktout, 0xABC); /* request id */    sftp_pkt_addstring_start(pktout);    sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);    sftp_send(pktout);    pktin = sftp_recv();    id = sftp_pkt_getuint32(pktin);    if (id != 0xABC) {	fxp_internal_error("request ID mismatch\n");	return NULL;    }    if (pktin->type == SSH_FXP_NAME) {	struct fxp_names *ret;	int i;	ret = smalloc(sizeof(struct fxp_names));	ret->nnames = sftp_pkt_getuint32(pktin);	ret->names = smalloc(ret->nnames * sizeof(struct fxp_name));	for (i = 0; i < ret->nnames; i++) {	    char *str;	    int len;	    sftp_pkt_getstring(pktin, &str, &len);	    ret->names[i].filename = mkstr(str, len);	    sftp_pkt_getstring(pktin, &str, &len);	    ret->names[i].longname = mkstr(str, len);	    ret->names[i].attrs = sftp_pkt_getattrs(pktin);	}	return ret;    } else {	fxp_got_status(pktin);	return NULL;    }}