]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* Final cvs commit for 1998 (an awful year, I'm glad to see it over).
[citadel.git] / webcit / webcit.c
index 0ec817ec4623974988e3b5174dfde2dbff283b2b..5f6703083ad67a2f6c905aa142c94d6fed024b3d 100644 (file)
@@ -41,6 +41,9 @@ struct urlcontent *urlstrings = NULL;
 static const char *defaulthost = DEFAULT_HOST;
 static const char *defaultport = DEFAULT_PORT;
 
+int upload_length = 0;
+char *upload;
+
 
 void unescape_input(char *buf)
 {
@@ -463,8 +466,8 @@ void session_loop(void) {
        char buf[256];
        int a, b;
        int ContentLength = 0;
+       char ContentType[512];
        char *content;
-FILE *fp;
 
        /* We stuff these with the values coming from the client cookies,
         * so we can use them to reconnect a timed out session if we have to.
@@ -481,6 +484,9 @@ FILE *fp;
        strcpy(c_password, "");
        strcpy(c_roomname, "");
 
+       upload_length = 0;
+       upload = NULL;
+
        getz(cmd);
        extract_action(action, cmd);
 
@@ -497,11 +503,12 @@ FILE *fp;
                        strcpy(c_password, &buf[20]);
                if (!strncasecmp(buf, "Cookie: wc_roomname=", 20))
                        strcpy(c_roomname, &buf[20]);
-
                if (!strncasecmp(buf, "Content-length: ", 16)) {
                        ContentLength = atoi(&buf[16]);
                        }
-
+               if (!strncasecmp(buf, "Content-type: ", 14)) {
+                       strcpy(ContentType, &buf[14]);
+                       }
                } while(strlen(buf)>0);
 
        ++TransactionCount;
@@ -509,11 +516,16 @@ FILE *fp;
        if (ContentLength > 0) {
                content = malloc(ContentLength+1);
                fread(content, ContentLength, 1, stdin);
-fp = fopen("content", "wb");
-fwrite(content, ContentLength, 1, fp);
-fclose(fp);
+
                content[ContentLength] = 0;
-               addurls(content);
+
+               if (!strncasecmp(ContentType,
+                  "application/x-www-form-urlencoded", 33)) {
+                       addurls(content);
+                       }
+               else if (!strncasecmp(ContentType, "multipart", 9)) {
+                       mime_parser(content, ContentLength, ContentType);
+                       }
                }
        else {
                content = NULL;
@@ -753,6 +765,16 @@ fclose(fp);
                validate();
                }
 
+       else if (!strcasecmp(action, "display_editpic")) {
+               display_graphics_upload("your photo",
+                                       "UIMG 0|_userpic_",
+                                       "/editpic");
+               }
+
+       else if (!strcasecmp(action, "editpic")) {
+               do_graphics_upload("UIMG 1|_userpic_");
+               }
+
        /* When all else fails... */
        else {
                printf("HTTP/1.0 200 OK\n");
@@ -776,6 +798,10 @@ fclose(fp);
                content = NULL;
                }
        free_urls();
+       if (upload_length > 0) {
+               free(upload);
+               upload_length = 0;
+               }
        }
 
 int main(int argc, char *argv[]) {