* webcit.c: added to getz() the ability to return an error code;
authorArt Cancro <ajc@citadel.org>
Sun, 7 Mar 1999 00:59:02 +0000 (00:59 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 7 Mar 1999 00:59:02 +0000 (00:59 +0000)
          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)

webcit/ChangeLog
webcit/auth.c
webcit/context_loop.c
webcit/static/braindamage [new file with mode: 0644]
webcit/static/frameset.html
webcit/webcit.c
webcit/webcit.h

index b5de25e55603508153be2844b5ee804f500e9c0e..ec5a6f0d152299081335b66bb24f254c435bfe92 100644 (file)
@@ -1,3 +1,9 @@
+Sat Mar  6 19:56:07 EST 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * 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 <bryant@cs.usm.maine.edu>
        * context_loop.c: warning fix
        * webcit.c: off_t is a 64-bit `long long' on BSDI (eek!)
index fff1347282a8b3cc62b61f39d9fc472130afcc1f..3588631fc222cb63a27efc7a8486ebc0e8e7af0f 100644 (file)
@@ -67,7 +67,7 @@ void display_login(char *mesg) {
         wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
        
        wprintf("<BR><INPUT TYPE=\"checkbox\" NAME=\"noframes\">");
-       wprintf("<FONT SIZE=-1>Check here to disable frames</FONT>\n");
+       wprintf("<FONT SIZE=-1>&nbsp;Check here to disable frames</FONT>\n");
         wprintf("</FORM></CENTER>\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.\"<BR><LI>");
        wprintf("<EM>Please log off properly when finished.</EM>");
-       wprintf("<LI>You must use a browser that supports <i>frames</i> ");
-       wprintf("and <i>cookies</i>.\n");
+       wprintf("<LI>You must use a browser that supports <i>cookies</i>.<BR>\n");
+       wprintf("<LI>Your browser is: ");
+       escputs(browser);
        wprintf("</EM></UL>\n");
 
        wDumpContent(1);
index 9d9ed49d6a6a3299abbbcae85f3e1f0bb9ea1673..be6c646c80609ca06561f504af1ed5a3d96f7afa 100644 (file)
@@ -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 (file)
index 0000000..302586f
--- /dev/null
@@ -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    *
index 7f4b1e042e0c8dea3b79df65345732b851140a2b..adfafe461f7ae2cdbf4ef017022bd5cd3aeb0c3e 100644 (file)
@@ -12,8 +12,9 @@
                <NOFRAMES>
                        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>
                </NOFRAMES>
        </FRAMESET>
 </HTML>
index bd9e525aba1f612f0da14a132d8f737d005d8aa9..407c4a92bbd865a9da1906dd0e59ad7a79a71327 100644 (file)
@@ -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]);
index 2798b7ab44507c8d6d94c593f3e92c77970eaf4e..8968551aaa92e860f35ed6455392b2530055c4e2 100644 (file)
@@ -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 *);