1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
int main(int argc, char *argv[]){
char *var, *ip, *fq;
Window win, w;
Atom qs;
int cpt;
if (! (dpy = XOpenDisplay(":0.0"))) {
fprintf(stderr, "%s: dispositif %s injoignable\n", argv[0],
XDisplayName(":0.0"));
exit(-1);
}
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
0,0,15,15,0,
BlackPixel(dpy, DefaultScreen(dpy)),
WhitePixel(dpy, DefaultScreen(dpy)) );
var = getenv("QUERY_STRING");
ip = getenv("REMOTE_ADDR");
cpt = (int)(strlen(ip) + strlen(var) + 12);
// -------> ici ca bloque fq = malloc(sizeof(char)* cpt);
strcat(fq,var);
strcat(fq,"&addresseIP=");
strcat(fq,ip);
qs = XInternAtom(dpy, "xhextris_query_string",True);
w = XGetSelectionOwner(dpy,qs);
fprintf(stdout,"Content-Type: text/html\n\n");
fprintf(stdout, "<html><head></head><body>");
fprintf(stdout,"<p>QUERY_STRING : %s</p>",fq);
fprintf(stdout,"</body></html>\n");
XChangeProperty(dpy,w,
qs,
XA_STRING,
8,
PropModeReplace,
(unsigned char *) var,
strlen(var)+1);
XFlush(dpy);
return 0;
} |
Partager