From: Art Cancro Date: Sun, 7 Mar 1999 00:59:02 +0000 (+0000) Subject: * webcit.c: added to getz() the ability to return an error code; X-Git-Tag: v7.86~7851 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=05b7980adba4f517c3fc30d3ce97adb5c337c750;p=citadel.git * webcit.c: added to getz() the ability to return an error code; implemented this in the main loop, hopefully fixing problems * Added "braindamage" file (frames/JS browser compatibility list) * Added HTTP "User-agent:" detection (still need to DO SOMETHING) --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index b5de25e55..ec5a6f0d1 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,9 @@ +Sat Mar 6 19:56:07 EST 1999 Art Cancro + * webcit.c: added to getz() the ability to return an error code; + implemented this in the main loop, hopefully fixing problems + * Added "braindamage" file (frames/JS browser compatibility list) + * Added HTTP "User-agent:" detection (still need to DO SOMETHING) + 1999-02-24 Nathan Bryant * context_loop.c: warning fix * webcit.c: off_t is a 64-bit `long long' on BSDI (eek!) diff --git a/webcit/auth.c b/webcit/auth.c index fff134728..3588631fc 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -67,7 +67,7 @@ void display_login(char *mesg) { wprintf("\n"); wprintf("
"); - wprintf("Check here to disable frames\n"); + wprintf(" Check here to disable frames\n"); wprintf("\n"); /* Da instructions */ @@ -79,8 +79,9 @@ void display_login(char *mesg) { wprintf("enter the name and password you wish to use, and click\n"); wprintf("\"New User.\"
  • "); wprintf("Please log off properly when finished."); - wprintf("
  • You must use a browser that supports frames "); - wprintf("and cookies.\n"); + wprintf("
  • You must use a browser that supports cookies.
    \n"); + wprintf("
  • Your browser is: "); + escputs(browser); wprintf("\n"); wDumpContent(1); diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 9d9ed49d6..be6c646c8 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -228,6 +228,7 @@ void *context_loop(int sock) { char (*req)[256]; char buf[256], hold[256]; char browser_host[256]; + char browser[256]; int num_lines = 0; int a; int f; @@ -247,6 +248,7 @@ void *context_loop(int sock) { } bzero(req, sizeof(char[256][256])); /* clear it out */ + strcpy(browser, "unknown"); printf("Reading request from socket %d\n", sock); @@ -262,6 +264,9 @@ void *context_loop(int sock) { if (!strncasecmp(buf, "Content-length: ", 16)) { ContentLength = atoi(&buf[16]); } + if (!strncasecmp(buf, "User-agent: ", 12)) { + strcpy(browser, &buf[12]); + } strcpy(&req[num_lines++][0], buf); } while(strlen(buf)>0); @@ -329,7 +334,7 @@ void *context_loop(int sock) { /* Run the actual WebCit session */ execlp("./webcit", "webcit", str_session, defaulthost, - defaultport, browser_host, NULL); + defaultport, browser_host, browser, NULL); /* Simple page to display if exec fails */ printf("HTTP/1.0 404 WebCit Failure\n\n"); diff --git a/webcit/static/braindamage b/webcit/static/braindamage new file mode 100644 index 000000000..302586f5a --- /dev/null +++ b/webcit/static/braindamage @@ -0,0 +1,51 @@ +# braindamage +# +# This file contains a list of browsers which are known to support +# or not support various functions. +# +# The list is parsed from the top down. When a match is made, parsing +# immediately stops. This implies that records at the top of the list +# take precedence over records towards the bottom. +# +# Each record must start with a key value: +# YES = This browser implements frame sets and JavaScript compatibly +# enough to run WebCit in its full functionality. +# NO = This browser is brain damaged, so WebCit must run in its +# non-frames, non-JavaScript mode. +# ASK = We don't know, so ask the user. + + +# Look for Internet Explorer first, because the morons at Microsoft decided +# to make life difficult by calling their user-agent "Mozilla" as well, and +# put the 'MSIE' in parentheses. + +# Any version of Internet Explorer earlier than 4.0 is utter trash. +# Version 4 and 5 appear to be ok. +NO Mozilla*MSIE 1.* +NO Mozilla*MSIE 2.* +NO Mozilla*MSIE 3.* +YES Mozilla*MSIE 4.* +YES Mozilla*MSIE 5.* + + +# Opera is untested, and some versions of Opera also use a user-agent string +# starting with "Mozilla" (arrgh...) +ASK *Opera* + +# Anything else starting with "Mozilla" is assumed to be a genuine +# Netscape browser. Use the full frames/JavaScript mode starting with +# version 3. +NO Mozilla/1.* +NO Mozilla/2.* +YES Mozilla/3.* +YES Mozilla/4.* +YES Mozilla/5.* + +# Lynx is a text-mode browser. Forget it. +NO *Lynx* + +# Konqueror (also known as kfm), the KDE browser/filemanager. Nope. +NO Konqueror* + +# The default... +ASK * diff --git a/webcit/static/frameset.html b/webcit/static/frameset.html index 7f4b1e042..adfafe461 100644 --- a/webcit/static/frameset.html +++ b/webcit/static/frameset.html @@ -12,8 +12,9 @@ Your browser doesn't support frames.<BR> This site uses frames.<BR> - Please log in again, and check the "do not use - frames" option.<BR> + Please log in again, and select the + &quot;Check here to disable frames&quot; + option.<BR> diff --git a/webcit/webcit.c b/webcit/webcit.c index bd9e525ab..407c4a92b 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -26,6 +26,7 @@ int wc_session; char wc_username[256]; char wc_password[256]; char wc_roomname[256]; +char browser[256]; int TransactionCount = 0; int connected = 0; int logged_in = 0; @@ -267,12 +268,16 @@ void urlescputs(char *strbuf) } -void getz(char *buf) { +char *getz(char *buf) { bzero(buf, 256); - if (fgets(buf, 256, stdin) == NULL) strcpy(buf, ""); + if (fgets(buf, 256, stdin) == NULL) { + strcpy(buf, ""); + return NULL; + } else { while ((strlen(buf)>0)&&(!isprint(buf[strlen(buf)-1]))) buf[strlen(buf)-1] = 0; + return buf; } } @@ -544,11 +549,11 @@ void session_loop(char *browser_host) { upload_length = 0; upload = NULL; - getz(cmd); + if (getz(cmd)==NULL) return; extract_action(action, cmd); do { - getz(buf); + if (getz(buf)==NULL) return; if (!strncasecmp(buf, "Cookie: webcit=", 15)) { strcpy(cookie, &buf[15]); @@ -968,9 +973,9 @@ void session_loop(char *browser_host) { int main(int argc, char *argv[]) { - if (argc != 5) { + if (argc != 6) { fprintf(stderr, - "webcit: usage error (argc must be 5, not %d)\n", + "webcit: usage error (argc must be 6, not %d)\n", argc); return 1; } @@ -982,6 +987,7 @@ int main(int argc, char *argv[]) { strcpy(wc_username, ""); strcpy(wc_password, ""); strcpy(wc_roomname, ""); + strcpy(browser, argv[5]); while (1) { session_loop(argv[4]); diff --git a/webcit/webcit.h b/webcit/webcit.h index 2798b7ab4..8968551aa 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -76,6 +76,7 @@ extern int upload_length; extern char *upload; extern char floorlist[128][256]; extern int noframes; +extern char browser[256]; void stuff_to_cookie(char *, int, char *, char *, char *, int); void cookie_to_stuff(char *, int *, char *, char *, char *, int *);