From ab3adeab1edd32e80bc226554ef08eb1cfe353f3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 1 Jan 1999 02:55:26 +0000 Subject: [PATCH] * Final cvs commit for 1998 (an awful year, I'm glad to see it over). * "Finished" the MIME parser. * Got image uploads working. * Added "add/edit user photo" screens. --- webcit/ChangeLog | 6 +++ webcit/Makefile.in | 7 +++- webcit/child.h | 12 ++++++ webcit/graphics.c | 84 ++++++++++++++++++++++++++++++++++++++ webcit/mime_parser.c | 6 ++- webcit/static/menubar.html | 29 +++++++------ webcit/webcit.c | 20 +++++++++ webcit/webcit.h | 2 + 8 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 webcit/graphics.c diff --git a/webcit/ChangeLog b/webcit/ChangeLog index a1e73ad08..cd1e63303 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,9 @@ +Thu Dec 31 21:53:20 EST 1998 Art Cancro + * Final cvs commit for 1998 (an awful year, I'm glad to see it over). + * "Finished" the MIME parser. + * Got image uploads working. + * Added "add/edit user photo" screens. + Wed Dec 30 20:36:13 EST 1998 Art Cancro * Wrote mime_parser.c for handling of image uploads. This will also be used in future Citadel MIME projects. diff --git a/webcit/Makefile.in b/webcit/Makefile.in index a207040e3..72f57cf1c 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -36,10 +36,10 @@ 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 \ - mime_parser.o + mime_parser.o graphics.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 \ - mime_parser.o -o webcit + mime_parser.o graphics.o -o webcit webcit.o: webcit.c webcit.h child.h $(CC) $(CFLAGS) $(DEFS) -c webcit.c @@ -71,6 +71,9 @@ roomops.o: roomops.c webcit.h child.h messages.o: messages.c webcit.h child.h $(CC) $(CFLAGS) $(DEFS) -c messages.c +graphics.o: graphics.c webcit.h child.h + $(CC) $(CFLAGS) $(DEFS) -c graphics.c + paging.o: paging.c webcit.h child.h $(CC) $(CFLAGS) $(DEFS) -c paging.c diff --git a/webcit/child.h b/webcit/child.h index 435ad3c2c..90753141c 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -72,3 +72,15 @@ void delete_room(void); void validate(void); void mime_parser(char *, int, char *); void handle_multipart(char *, int, char *); +void display_graphics_upload(char *description, char *check_cmd, char *uplurl); +void do_graphics_upload(char *upl_cmd); +void serv_read(char *buf, int bytes); +void serv_gets(char *strbuf); +void serv_write(char *buf, int nbytes); +void serv_puts(char *string); +void serv_printf(const char *format, ...); + + + + + diff --git a/webcit/graphics.c b/webcit/graphics.c new file mode 100644 index 000000000..1844c0581 --- /dev/null +++ b/webcit/graphics.c @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "child.h" + + +void display_graphics_upload(char *description, char *check_cmd, char *uplurl) { + char buf[256]; + + serv_puts(check_cmd); + serv_gets(buf); + if (buf[0] != '2') { + display_error(&buf[4]); + return; + } + + printf("HTTP/1.0 200 OK\n"); + output_headers(1); + wprintf("
"); + wprintf("Set/change %s\n", description); + wprintf("
\n"); + + wprintf("
\n"); + wprintf("Please select a file to upload:
\n"); + wprintf("
\n", uplurl); + wprintf("\n"); + wprintf("
"); + wprintf("\n"); + wprintf("\n"); + wprintf("
\n"); + wprintf("Cancel\n"); + wprintf("
\n"); + wDumpContent(); + } + +void do_graphics_upload(char *upl_cmd) { + char buf[256]; + int bytes_remaining; + int pos = 0; + int thisblock; + + if (upload_length == 0) { + display_error("You didn't upload a file.\n"); + return; + } + + serv_puts(upl_cmd); + serv_gets(buf); + if (buf[0] != '2') { + display_error(&buf[4]); + return; + } + + bytes_remaining = upload_length; + while (bytes_remaining) { + thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining); + serv_printf("WRIT %d", thisblock); + serv_gets(buf); + if (buf[0] != '7') { + display_error(&buf[4]); + serv_puts("UCLS 0"); + serv_gets(buf); + return; + } + thisblock = extract_int(&buf[4], 0); + serv_write(&upload[pos], thisblock); + pos = pos + thisblock; + bytes_remaining = bytes_remaining - thisblock; + } + + serv_puts("UCLS 1"); + serv_gets(buf); + /* FIX display something other than an error if it's ok */ + if (buf[0] != 'x') { + display_error(&buf[4]); + return; + } + } diff --git a/webcit/mime_parser.c b/webcit/mime_parser.c index b205cb175..5e4a0aead 100644 --- a/webcit/mime_parser.c +++ b/webcit/mime_parser.c @@ -60,7 +60,11 @@ void do_something_with_it(char *content, int length, char *content_type, */ else if (strlen(name)>0) { - + upload = malloc(length); + if (upload != NULL) { + upload_length = length; + memcpy(upload, content, length); + } } } diff --git a/webcit/static/menubar.html b/webcit/static/menubar.html index 4cd96eb86..20881d837 100644 --- a/webcit/static/menubar.html +++ b/webcit/static/menubar.html @@ -3,23 +3,26 @@ MenuBar - Citadel/UX
- List known rooms
-
Goto next room
-
Skip this room
-
Ungoto
+
+
List known rooms
+ Goto next room
+ Skip this room
+ Ungoto

- Read new messages
-
Read all messages
-
Enter a message
+
Read new messages
+ Read all messages
+ Enter a message

- Who is online?
-
User list
-
Advanced options
+
Who is online?
+ User list
+ Advanced options

- upload test
-
Log off
+
Log off
+
+ + Powered by
+ Citadel/UX

diff --git a/webcit/webcit.c b/webcit/webcit.c index 9323dea89..5f6703083 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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) { @@ -481,6 +484,9 @@ void session_loop(void) { strcpy(c_password, ""); strcpy(c_roomname, ""); + upload_length = 0; + upload = NULL; + getz(cmd); extract_action(action, cmd); @@ -759,6 +765,16 @@ void session_loop(void) { 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"); @@ -782,6 +798,10 @@ void session_loop(void) { content = NULL; } free_urls(); + if (upload_length > 0) { + free(upload); + upload_length = 0; + } } int main(int argc, char *argv[]) { diff --git a/webcit/webcit.h b/webcit/webcit.h index d1740b441..06f18a571 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -74,3 +74,5 @@ extern unsigned room_flags; extern char ugname[128]; extern long uglsn; extern char *axdefs[]; +extern int upload_length; +extern char *upload; -- 2.39.2