uuuughhhh... added mime_parser.c to prepare for uploads
authorArt Cancro <ajc@citadel.org>
Thu, 31 Dec 1998 01:36:40 +0000 (01:36 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 31 Dec 1998 01:36:40 +0000 (01:36 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/child.h
webcit/mime_parser.c [new file with mode: 0644]
webcit/webcit.c

index b7574632ce88467addbda5094fd3b5645240bda9..9a4e49b08d154cea8c3d3125473a7bfa597d0a4b 100644 (file)
@@ -1,3 +1,6 @@
+Wed Dec 30 20:36:13 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * uuuughhhh... added mime_parser.c to prepare for uploads
+
 Tue Dec 29 23:25:50 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Fixed a bug in the room banner display code
        * Added "delete room"
index a9ecdd2fa31cde9f7db705792f3798cc4b7f761f..a207040e38f216d7fd6f92283efdb8b4be3ef0b7 100644 (file)
@@ -35,9 +35,11 @@ snprintf.o: snprintf.c
 
 
 webcit: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
-       roomops.o tools.o messages.o userlist.o paging.o sysmsgs.o
+       roomops.o tools.o messages.o userlist.o paging.o sysmsgs.o \
+       mime_parser.o
        $(CC) webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
-       tools.o roomops.o messages.o userlist.o paging.o sysmsgs.o -o webcit
+       tools.o roomops.o messages.o userlist.o paging.o sysmsgs.o \
+       mime_parser.o -o webcit
 
 webcit.o: webcit.c webcit.h child.h
        $(CC) $(CFLAGS) $(DEFS) -c webcit.c
@@ -75,6 +77,9 @@ paging.o: paging.c webcit.h child.h
 sysmsgs.o: sysmsgs.c webcit.h child.h
        $(CC) $(CFLAGS) $(DEFS) -c sysmsgs.c
 
+mime_parser.o: mime_parser.c webcit.h child.h
+       $(CC) $(CFLAGS) $(DEFS) -c mime_parser.c
+
 Makefile: $(srcdir)/Makefile.in config.status
        CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
 
index fa68906ca247669ff63408024fd1ccf6001cd5ce..bb8dce7baf39a4c6d89ca4f0f6016bee28a83cf2 100644 (file)
@@ -70,3 +70,4 @@ void gotoroom(char *gname, int display_name);
 void confirm_delete_room(void);
 void delete_room(void);
 void validate(void);
+void mime_parser(char *content, int ContentLength, char *ContentType);
diff --git a/webcit/mime_parser.c b/webcit/mime_parser.c
new file mode 100644 (file)
index 0000000..522f11f
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * mime_parser.c
+ *
+ * This is a really bad attempt at writing a parser to handle multipart
+ * messages -- in the case of WebCit, a form containing uploaded files.
+ */
+
+
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include "webcit.h"
+#include "child.h"
+
+void mime_parser(char *content, int ContentLength, char *ContentType) {
+       char boundary[256];
+
+
+
+       }
index 0ec817ec4623974988e3b5174dfde2dbff283b2b..9323dea89b934b788c79312da21a7baed9eaa8d0 100644 (file)
@@ -463,8 +463,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.
@@ -497,11 +497,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 +510,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;