* Final cvs commit for 1998 (an awful year, I'm glad to see it over).
authorArt Cancro <ajc@citadel.org>
Fri, 1 Jan 1999 02:55:26 +0000 (02:55 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 1 Jan 1999 02:55:26 +0000 (02:55 +0000)
        * "Finished" the MIME parser.
        * Got image uploads working.
        * Added "add/edit user photo" screens.

webcit/ChangeLog
webcit/Makefile.in
webcit/child.h
webcit/graphics.c [new file with mode: 0644]
webcit/mime_parser.c
webcit/static/menubar.html
webcit/webcit.c
webcit/webcit.h

index a1e73ad087c686a6c2bce615712af091b25354ab..cd1e633035e07f43fd773839fc92af8f8a45fd5b 100644 (file)
@@ -1,3 +1,9 @@
+Thu Dec 31 21:53:20 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * 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 <ajc@uncnsrd.mt-kisco.ny.us>
        * Wrote mime_parser.c for handling of image uploads.  This will also
          be used in future Citadel MIME projects.
index a207040e38f216d7fd6f92283efdb8b4be3ef0b7..72f57cf1c31a234b420d27300dfa65606582f517 100644 (file)
@@ -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
 
index 435ad3c2cd03704f068b9371b00831daa60e236c..90753141c34712bdc505f3ba66ec6368ca1af5a3 100644 (file)
@@ -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 (file)
index 0000000..1844c05
--- /dev/null
@@ -0,0 +1,84 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#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("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+        wprintf("<B>Set/change %s</B>\n", description);
+        wprintf("</FONT></TD></TR></TABLE>\n");
+
+       wprintf("<CENTER>\n");
+       wprintf("Please select a file to upload:<BR>\n");
+       wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" METHOD=\"POST\">\n", uplurl);
+        wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
+       wprintf("<BR>");
+        wprintf("<INPUT TYPE=\"SUBMIT\" VALUE=\"Upload\">\n");
+        wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
+        wprintf("</FORM>\n");
+       wprintf("<A HREF=\"/display_main_menu\">Cancel</A>\n");
+       wprintf("</CENTER></BODY></HTML>\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;
+               }
+       }
index b205cb175895b2620c621d345dfa3b12df4e3e34..5e4a0aeadb1ffd0b36173797004ed1dff29f8cf4 100644 (file)
@@ -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);
+                       }
                }
 
        }
index 4cd96eb867f98b1d4f48ceed3155ea26ae5f88a3..20881d8379200730400c285d85dddc3cd09fb9e2 100644 (file)
@@ -3,23 +3,26 @@
        <TITLE>MenuBar</TITLE>
 </HEAD>
 <BODY BACKGROUND="/image&name=background" TEXT="#000000" LINK="#004400">
-       <IMG SRC="/static/citadel-logo.jpg" ALT="Citadel/UX"><BR>
        <FONT SIZE=-1>
-       <A HREF="/knrooms" TARGET="bottom">List known rooms<BR>
-       <A HREF="/gotonext" TARGET="top">Goto next room<BR>
-       <A HREF="/skip" TARGET="top">Skip this room<BR>
-       <A HREF="/ungoto" TARGET="top">Ungoto<BR>
+       <IMG SRC="/image&name=hello"><BR>
+       <A HREF="/knrooms" TARGET="bottom">List known rooms</A><BR>
+       <A HREF="/gotonext" TARGET="top">Goto next room</A><BR>
+       <A HREF="/skip" TARGET="top">Skip this room</A><BR>
+       <A HREF="/ungoto" TARGET="top">Ungoto</A><BR>
        <HR>
-       <A HREF="/readnew" TARGET="bottom">Read new messages<BR>
-       <A HREF="/readfwd" TARGET="bottom">Read all messages<BR>
-       <A HREF="/display_enter" TARGET="bottom">Enter a message<BR>
+       <A HREF="/readnew" TARGET="bottom">Read new messages</A><BR>
+       <A HREF="/readfwd" TARGET="bottom">Read all messages</A><BR>
+       <A HREF="/display_enter" TARGET="bottom">Enter a message</A><BR>
        <HR>
-       <A HREF="/whobbs" TARGET="bottom">Who is online?<BR>
-       <A HREF="/userlist" TARGET="bottom">User list<BR>
-       <A HREF="/advanced" TARGET="bottom">Advanced options<BR>
+       <A HREF="/whobbs" TARGET="bottom">Who is online?</A><BR>
+       <A HREF="/userlist" TARGET="bottom">User list</A><BR>
+       <A HREF="/advanced" TARGET="bottom">Advanced options</A><BR>
        <HR>
-       <A HREF="/static/upload.html" TARGET="bottom">upload test<BR>
-       <A HREF="/termquit" TARGET="_top">Log off<BR>
+       <A HREF="/termquit" TARGET="_top">Log off</A><BR>
        </FONT>
+       <HR>
+       <A HREF="http://uncnsrd.mt-kisco.ny.us/citadel" TARGET="aboutcit">
+       <FONT SIZE=-1>Powered by</FONT><BR>
+       <IMG SRC="/static/citadel-logo.jpg" ALT="Citadel/UX"></A><BR>
 </BODY>
 </HTML>
index 9323dea89b934b788c79312da21a7baed9eaa8d0..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)
 {
@@ -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[]) {
index d1740b441680106f1fec5e9d7c6304bd23930cc1..06f18a571d7826d8b1e93eb125bc92f0eeec53b1 100644 (file)
@@ -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;