diff options
author | John Ankarström <john@ankarstrom.se> | 2021-09-17 11:20:43 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-09-17 11:20:43 +0200 |
commit | 38f8e2242353711d5c87c58f3831306934d2e6b7 (patch) | |
tree | 92ec8e297731fb1de90b0e465bb52207bbe5c037 /query.c | |
parent | 4b0e767fd645687e8d2a5ded778c57b8cf42bc4a (diff) | |
download | cforum-38f8e2242353711d5c87c58f3831306934d2e6b7.tar.gz |
Compartmentalize
Diffstat (limited to 'query.c')
-rw-r--r-- | query.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#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; +}
\ No newline at end of file |