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
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
--- /dev/null
+/*
+ * 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];
+
+
+
+ }
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.
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;
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;