chiark / gitweb /
Typo fix.
[disorder] / server / cgi.c
index 5e475edb025c1b22a4c832387114a224ad2dc5e5..095611ab81dee8269e19b89228827616e6f1a6c5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2006, 2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -152,13 +152,14 @@ static void cgi_parse_multipart(const char *boundary) {
 }
 
 static void cgi_parse_post(void) {
-  const char *ct;
-  char *q, *type, *pname, *pvalue;
+  const char *ct, *boundary;
+  char *q, *type;
   size_t n;
+  struct kvp *k;
 
   if(!(ct = getenv("CONTENT_TYPE")))
     ct = "application/x-www-form-urlencoded";
-  if(mime_content_type(ct, &type, &pname, &pvalue))
+  if(mime_content_type(ct, &type, &k))
     fatal(0, "invalid content type '%s'", ct);
   if(!strcmp(type, "application/x-www-form-urlencoded")) {
     cgi_input(&q, &n);
@@ -166,10 +167,9 @@ static void cgi_parse_post(void) {
     return;
   }
   if(!strcmp(type, "multipart/form-data")) {
-    if(!pname || strcmp(pname, "boundary"))
-      fatal(0, "expected a boundary parameter, found %s",
-           pname ? pname : "nothing");
-    cgi_parse_multipart(pvalue);
+    if(!(boundary = kvp_get(k, "boundary")))
+      fatal(0, "no boundary parameter found");
+    cgi_parse_multipart(boundary);
     return;
   }
   fatal(0, "unrecognized content type '%s'", type);
@@ -603,6 +603,11 @@ const char *cgi_label(const char *key) {
   return label;
 }
 
+int cgi_label_exists(const char *key) {
+  read_options();
+  return kvp_get(labels, key) ? 1 : 0;
+}
+
 char **cgi_columns(const char *name, int *ncolumns) {
   struct column *c;