* 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
struct urlcontent *urlstrings = NULL;
+static const char *defaulthost = DEFAULT_HOST;
+static const char *defaultport = DEFAULT_PORT;
+
void unescape_input(char *buf)
{
}
}
-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;
output_static(buf);
}
+ else if (!strcasecmp(action, "image")) {
+ output_image();
+ }
+
else if ((!logged_in)&&(!strcasecmp(action, "login"))) {
do_login();
}