char* readctl(char *key) { char *s, *p; int nkey, n; if(ctlfid == nil) { ctlfid = ixp_open(client, "ctl", OREAD); n = ixp_read(ctlfid, ctl, 1023); ectl = ctl + n; ixp_close(ctlfid); } nkey = strlen(key); p = ctl - 1; do { p++; if(!strncmp(p, key, nkey)) { p += nkey; s = strchr(p, '\n'); n = (s ? s : ectl) - p; s = freelater(emalloc(n + 1)); s[n] = '\0'; return strncpy(s, p, n); } } while((p = strchr(p, '\n'))); return ""; }
XftColor* xftcolor(Image *i, Color *c) { XftColor *xc; xc = emallocz(sizeof *c); *xc = (XftColor) { pixelvalue(i, c), c->red, c->green, c->blue, c->alpha }; return freelater(xc); }