#include #include #include #include "query.h" void setqs() { qs = getenv("QUERY_STRING"); if(!qs){ fprintf(stderr, "no QUERY_STRING\n"); exit(1); } } char * query(char *key) { char *w; int n; for(w = strtok(qs, "&"); w; w = strtok(NULL, "&")){ n = strcspn(w, "="); if(strncmp(w, key, n) == 0) return w + n + (w[n] == '='); } return NULL; }