From: Art Cancro Date: Thu, 31 Dec 1998 01:36:40 +0000 (+0000) Subject: uuuughhhh... added mime_parser.c to prepare for uploads X-Git-Tag: v7.86~7976 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=fe73bb6a184a9f39ded8dec6da316a182db9b13a;p=citadel.git uuuughhhh... added mime_parser.c to prepare for uploads --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index b7574632c..9a4e49b08 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,6 @@ +Wed Dec 30 20:36:13 EST 1998 Art Cancro + * uuuughhhh... added mime_parser.c to prepare for uploads + Tue Dec 29 23:25:50 EST 1998 Art Cancro * Fixed a bug in the room banner display code * Added "delete room" diff --git a/webcit/Makefile.in b/webcit/Makefile.in index a9ecdd2fa..a207040e3 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -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 diff --git a/webcit/child.h b/webcit/child.h index fa68906ca..bb8dce7ba 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -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 index 000000000..522f11ff7 --- /dev/null +++ b/webcit/mime_parser.c @@ -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 +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "child.h" + +void mime_parser(char *content, int ContentLength, char *ContentType) { + char boundary[256]; + + + + } diff --git a/webcit/webcit.c b/webcit/webcit.c index 0ec817ec4..9323dea89 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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;