#include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_GetScreenSaver PRIV_GetScreenSaver; struct priv_GetScreenSaver { LX_SCREENSAVER *ss; } ; static void done_GetScreenSaver(LX_OP *op, const unsigned char *rep) { PRIV_GetScreenSaver *p; unsigned int tmo; unsigned int intvl; LX_SSBLANKING b; LX_SSEXPOSURES e; p = op->reqpriv; do <"ret"> { if (r_card32(rep+4) != 0) { lx__protoerr(op->conn,"GetScreenSaver response length wrong (%u, expecting 0)",r_card32(rep+4)); break <"ret">; } tmo = r_card16(rep+8); intvl = r_card16(rep+10); b = lx__proto_to_ssblanking(rep[12]); if (b == LX__SSBLANKING_Error) { lx__protoerr(op->conn,"GetScreenSaver reply has invalid prefer-blanking value %d",rep[12]); break <"ret">; } e = lx__proto_to_ssexposures(rep[13]); if (b == LX__SSEXPOSURES_Error) { lx__protoerr(op->conn,"GetScreenSaver reply has invalid allow-exposures value %d",rep[13]); break <"ret">; } if (p->ss) { p->ss->timeout = tmo; p->ss->interval = intvl; p->ss->prefer_blanking = b; p->ss->allow_exposures = e; } } while (0); op->reqpriv = 0; free(p); } LX_OP *lx_GetScreenSaver(LX_CONN *xc, LX_SCREENSAVER *ss) { unsigned char req[4]; PRIV_GetScreenSaver *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_GetScreenSaver"); return(0); } p = malloc(sizeof(PRIV_GetScreenSaver)); if (! p) { lx__nomem_fail(xc); return(0); } p->ss = ss; req[0] = XP_REQ_GetScreenSaver; req[1] = 0; w_card16(&req[2],1); return(lx__expect_reply(xc,&req[0],4,&done_GetScreenSaver,p,0)); }