// Copyright status: this file is in the public domain. #include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_ListProperties PRIV_ListProperties; struct priv_ListProperties { LX_XIDLIST **listp; } ; static void done_ListProperties(LX_CONN *xc, const unsigned char *rep, void *pv) { PRIV_ListProperties *p; LX_XIDLIST *xl; int n; int i; p = pv; do <"ret"> { n = r_card16(rep+8); if (r_card32(rep+4) != n) { lx__protoerr(xc,"ListProperties response length wrong (%u, expecting %d)",r_card32(rep+4),n); break <"ret">; } if (p->listp) { do <"good"> { do <"mem"> { xl = malloc(sizeof(LX_XIDLIST)); if (! xl) break <"mem">; xl->len = n; xl->ids = malloc(n*sizeof(LX_XID)); if (! xl->ids) break <"mem">; for (i=n-1;i>=0;i--) xl->ids[i] = r_card32(rep+32+(4*i)); *p->listp = xl; break <"good">; } while (0); lx__nomem_fail(xc); if (xl) { free(xl->ids); free(xl); } break <"ret">; } while (0); } } while (0); free(p); } LX_OP *lx_ListProperties(LX_CONN *xc, LX_XID window, LX_XIDLIST **listp) { unsigned char req[8]; PRIV_ListProperties *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_ListProperties"); return(0); } lx__nochain(xc); p = malloc(sizeof(PRIV_ListProperties)); if (! p) { lx__nomem_fail(xc); return(0); } p->listp = listp; req[0] = XP_REQ_ListProperties; req[1] = 0; w_card16(&req[2],2); w_card32(&req[4],window); return(lx__expect_reply(xc,&req[0],-1,&done_ListProperties,p)); }