// Copyright status: this file is in the public domain. #include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_GetPointerMapping PRIV_GetPointerMapping; struct priv_GetPointerMapping { int *nump; unsigned char *mapping; } ; static void done_GetPointerMapping(LX_CONN *xc, const unsigned char *rep, void *pv) { PRIV_GetPointerMapping *p; int n; int i; p = pv; do <"ret"> { n = rep[1]; if (r_card32(rep+4) != (n+3)>>2) { lx__protoerr(xc,"GetPointerMapping response length wrong (%u, expecting %d)",r_card32(rep+4),(n+3)>>2); break <"ret">; } if (p->nump) *p->nump = n; if (p->mapping) { for (i=0;imapping[i] = rep[32+i]; } } } while (0); free(p); } LX_OP *lx_GetPointerMapping(LX_CONN *xc, int *nump, unsigned char *mapping) { unsigned char req[4]; PRIV_GetPointerMapping *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_GetPointerMapping"); return(0); } lx__nochain(xc); p = malloc(sizeof(PRIV_GetPointerMapping)); if (! p) { lx__nomem_fail(xc); return(0); } p->nump = nump; p->mapping = mapping; req[0] = XP_REQ_GetPointerMapping; req[1] = 0; // unused w_card16(&req[2],1); return(lx__expect_reply(xc,&req[0],-1,&done_GetPointerMapping,p)); }