Added support for graphics images retrieved from the Citadel server.
authorArt Cancro <ajc@citadel.org>
Thu, 10 Dec 1998 03:13:56 +0000 (03:13 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Dec 1998 03:13:56 +0000 (03:13 +0000)
webcit/ChangeLog
webcit/auth.c
webcit/child.h
webcit/webcit.c

index e470f383ced8d77110ab39fd425b332273197421..2f3ca57a01b5bc29259495a646b0134261eb60c8 100644 (file)
@@ -2,6 +2,7 @@ Wed Dec  9 18:50:46 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * context_loop.c: After fork(), child process closes the HTTP socket
          so when the parent process closes it, it actually _does_ close.
          Otherwise, aIEeeee and possibly other browsers will hang.
+       * Added support for graphics images retrieved from the Citadel server.
 
 1998-12-09 Nathan Bryant <bryant@cs.usm.maine.edu>
        * context_loop.c, webserver.c, webserver.h: SO_LINGER and locking fix
index 800337331973d5ee3399f139966d823b38bce291..436965bba17681bdf9fe4be7c704290822a07fe3 100644 (file)
@@ -32,7 +32,7 @@ void display_login(char *mesg) {
        wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
 
        /* FIX replace with the correct image */
-       wprintf("<IMG SRC=\"/static/velma.gif\">");
+       wprintf("<IMG SRC=\"/image&name=hello\">");
        wprintf("</TD><TD><CENTER>\n");
 
        if (mesg != NULL) {
index ac41cca4985b804ad82c4c894c7701dab5f46784..e19c2efb76aa947f780009ad30715687b945b5be 100644 (file)
@@ -38,3 +38,4 @@ void escputs1(char *strbuf, int nbsp);
 long extract_long(char *source, long int parmnum);
 void dump_vars(void);
 void embed_main_menu(void);
+void serv_read(char *buf, int bytes);
index 0bead1c945f3f217c01999fc87dd6d40f0b1f4a0..4065c07443f07c4887c503b8524e81b9de85da18 100644 (file)
@@ -37,6 +37,9 @@ struct webcontent *wlast = NULL;
 
 struct urlcontent *urlstrings = NULL;
 
+static const char *defaulthost = DEFAULT_HOST;
+static const char *defaultport = DEFAULT_PORT;
+
 
 void unescape_input(char *buf)
 {
@@ -367,10 +370,51 @@ void output_static(char *what) {
                }
        }
 
-static const char *defaulthost = DEFAULT_HOST;
-static const char *defaultport = DEFAULT_PORT;
+void output_image() {
+       char buf[256];
+       char xferbuf[4096];
+       off_t bytes;
+       off_t thisblock;
+       off_t accomplished = 0L;
 
 
+       serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
+       serv_gets(buf);
+       if (buf[0]=='2') {
+               bytes = extract_long(&buf[4], 0);
+               printf("HTTP/1.0 200 OK\n");
+               output_headers();
+               printf("Content-type: image/gif\n");
+               printf("Content-length: %ld\n", bytes);
+               printf("\n");
+
+               while (bytes > (off_t)0) {
+                       thisblock = (off_t)sizeof(xferbuf);
+                       if (thisblock > bytes) thisblock = bytes;
+                       serv_printf("READ %ld|%ld", accomplished, thisblock);
+                       serv_gets(buf);
+                       if (buf[0]=='6') thisblock = extract_long(&buf[4],0);
+                       serv_read(xferbuf, (int)thisblock);
+                       fwrite(xferbuf, thisblock, 1, stdout);
+                       bytes = bytes - thisblock;
+                       accomplished = accomplished + thisblock;
+                       }
+               fflush(stdout);
+               serv_puts("CLOS");
+               serv_gets(buf);
+               }
+       else {
+               printf("HTTP/1.0 404 %s\n", strerror(errno));
+               output_headers();
+               printf("Content-Type: text/plain\n");
+               sprintf(buf, "Error retrieving image\n");
+               printf("Content-length: %d\n", strlen(buf));
+               printf("\n");
+               fwrite(buf, strlen(buf), 1, stdout);
+               }
+
+       }
+
 void extract_action(char *actbuf, char *cmdbuf) {
        int i;
 
@@ -502,6 +546,10 @@ void session_loop(void) {
                output_static(buf);
                }
 
+       else if (!strcasecmp(action, "image")) {
+               output_image();
+               }
+
        else if ((!logged_in)&&(!strcasecmp(action, "login"))) {
                do_login();
                }