aboutsummaryrefslogtreecommitdiff
path: root/query.c
diff options
context:
space:
mode:
Diffstat (limited to 'query.c')
-rw-r--r--query.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/query.c b/query.c
new file mode 100644
index 0000000..09e7578
--- /dev/null
+++ b/query.c
@@ -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