* Started moving all of the global variables into a struct, to facilitate
authorArt Cancro <ajc@citadel.org>
Fri, 26 Nov 1999 03:33:00 +0000 (03:33 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 26 Nov 1999 03:33:00 +0000 (03:33 +0000)
  multithreaded server.

13 files changed:
webcit/ChangeLog
webcit/auth.c
webcit/graphics.c
webcit/mainmenu.c
webcit/messages.c
webcit/paging.c
webcit/roomops.c
webcit/serv_func.c
webcit/sysmsgs.c
webcit/tcp_sockets.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 23b0524be297645a5e5f89a3e8fae1ab3b0e5a2e..ac5917297ab74804b094ab913363d065de9ce69c 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 1.107  1999/11/26 03:32:59  ajc
+* Started moving all of the global variables into a struct, to facilitate
+  multithreaded server.
+
 Revision 1.106  1999/11/26 01:28:10  ajc
 * 2.01 release
 
@@ -312,4 +316,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index cdb23a9d3738a3e797e9f3bb3797899807cdbb98..28d89efba3319e3e89520b954307fb8c47002afc 100644 (file)
@@ -91,12 +91,12 @@ void display_login(char *mesg)
  */
 void become_logged_in(char *user, char *pass, char *serv_response)
 {
-       logged_in = 1;
-       extract(wc_username, &serv_response[4], 0);
-       strcpy(wc_password, pass);
-       axlevel = extract_int(&serv_response[4], 1);
-       if (axlevel >= 6)
-               is_aide = 1;
+       WC->logged_in = 1;
+       extract(WC->wc_username, &serv_response[4], 0);
+       strcpy(WC->wc_password, pass);
+       WC->axlevel = extract_int(&serv_response[4], 1);
+       if (WC->axlevel >= 6)
+               WC->is_aide = 1;
 }
 
 
@@ -139,13 +139,13 @@ void do_login(void)
                        return;
                }
        }
-       if (logged_in) {
+       if (WC->logged_in) {
                serv_puts("CHEK");
                serv_gets(buf);
                if (buf[0] == '2') {
-                       new_mail = extract_int(&buf[4], 0);
+                       WC->new_mail = extract_int(&buf[4], 0);
                        need_regi = extract_int(&buf[4], 1);
-                       need_vali = extract_int(&buf[4], 2);
+                       WC->need_vali = extract_int(&buf[4], 2);
                }
                if (need_regi) {
                        display_reg(1);
@@ -168,9 +168,9 @@ void do_logout(void)
 {
        char buf[256];
 
-       strcpy(wc_username, "");
-       strcpy(wc_password, "");
-       strcpy(wc_roomname, "");
+       strcpy(WC->wc_username, "");
+       strcpy(WC->wc_password, "");
+       strcpy(WC->wc_roomname, "");
 
        printf("HTTP/1.0 200 OK\n");
        output_headers(2);      /* note "2" causes cookies to be unset */
@@ -209,8 +209,8 @@ void validate(void)
 
        strcpy(buf, bstr("user"));
        if (strlen(buf) > 0)
-               if (strlen(bstr("axlevel")) > 0) {
-                       serv_printf("VALI %s|%s", buf, bstr("axlevel"));
+               if (strlen(bstr("WC->axlevel")) > 0) {
+                       serv_printf("VALI %s|%s", buf, bstr("WC->axlevel"));
                        serv_gets(buf);
                        if (buf[0] != '2') {
                                wprintf("<EM>%s</EM><BR>\n", &buf[4]);
@@ -261,7 +261,7 @@ void validate(void)
        wprintf("</CAPTION><TR>");
        for (a = 0; a <= 6; ++a) {
                wprintf(
-                              "<TD><A HREF=\"/validate&user=%s&axlevel=%d\">%s</A></TD>\n",
+                              "<TD><A HREF=\"/validate&user=%s&WC->axlevel=%d\">%s</A></TD>\n",
                               urlesc(user), a, axdefs[a]);
        }
        wprintf("</TR></TABLE><CENTER><BR>\n");
index 31887c8401f3bc2d96ebc2f80021e567db2d11d1..56c4ceebe9f4522aa250595bbf358c65a3fec5a4 100644 (file)
@@ -52,7 +52,7 @@ void do_graphics_upload(char *upl_cmd)
        int pos = 0;
        int thisblock;
 
-       if (upload_length == 0) {
+       if (WC->upload_length == 0) {
                display_error("You didn't upload a file.\n");
                return;
        }
@@ -62,7 +62,7 @@ void do_graphics_upload(char *upl_cmd)
                display_error(&buf[4]);
                return;
        }
-       bytes_remaining = upload_length;
+       bytes_remaining = WC->upload_length;
        while (bytes_remaining) {
                thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
                serv_printf("WRIT %d", thisblock);
@@ -74,7 +74,7 @@ void do_graphics_upload(char *upl_cmd)
                        return;
                }
                thisblock = extract_int(&buf[4], 0);
-               serv_write(&upload[pos], thisblock);
+               serv_write(&WC->upload[pos], thisblock);
                pos = pos + thisblock;
                bytes_remaining = bytes_remaining - thisblock;
        }
index 66f7593b61770f61993f0c39d275ec79d0b2f800..8713620f46809bc4f9b270c6f9c48d69182f4aa8 100644 (file)
@@ -35,10 +35,10 @@ void embed_main_menu(void)
        wprintf("Skip to next room</B></A><BR>\n");
        wprintf("(come back here later)</LI>\n");
 
-       if ((strlen(ugname) > 0) && (strcasecmp(ugname, wc_roomname))) {
+       if ((strlen(WC->ugname) > 0) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
                wprintf("<LI><B><A HREF=\"/ungoto\">\n");
                wprintf("Ungoto</B></A><BR>\n");
-               wprintf("(oops! Back to %s)</LI>\n", ugname);
+               wprintf("(oops! Back to %s)</LI>\n", WC->ugname);
        }
        wprintf("</UL>\n");
 
@@ -140,7 +140,7 @@ void embed_advanced_menu(void)
        wprintf("Create a new room</A>\n");
 
        wprintf("<LI><A HREF=\"/display_zap\">");
-       wprintf("Zap (forget) this room (%s)</A>\n", wc_roomname);
+       wprintf("Zap (forget) this room (%s)</A>\n", WC->wc_roomname);
 
        wprintf("<LI><A HREF=\"/zapped_list\">");
        wprintf("List all forgotten rooms</A>\n");
@@ -149,7 +149,7 @@ void embed_advanced_menu(void)
 
        wprintf("</TD><TD>");
 
-       if ((axlevel >= 6) || (is_room_aide)) {
+       if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
                wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007777><TR><TD>");
                wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
                wprintf("<B>Administrative functions</B>\n");
@@ -162,7 +162,7 @@ void embed_advanced_menu(void)
                wprintf("<LI><A HREF=\"/display_siteconfig\">\n");
                wprintf("Edit site-wide configuration</A>\n");
 
-               if (axlevel >= 6) {
+               if (WC->axlevel >= 6) {
                        wprintf("<LI><A HREF=\"/validate\">\n");
                        wprintf("Validate new users</A>\n");
 
index 0b8aabaadd213def6366fa5f5c7ef9c538c14c17..0af37486a4b4669a5fdb1da3407819107825fcda 100644 (file)
@@ -110,11 +110,11 @@ char *oper;
                    && (strcasecmp(&buf[5], serv_info.serv_humannode)))
                        wprintf("(%s) ", &buf[5]);
                if ((!strncasecmp(buf, "room=", 5))
-                   && (strcasecmp(&buf[5], wc_roomname)))
+                   && (strcasecmp(&buf[5], WC->wc_roomname)))
                        wprintf("in %s> ", &buf[5]);
 
                if (!strncasecmp(buf, "node=", 5)) {
-                       if ((room_flags & QR_NETWORK)
+                       if ((WC->room_flags & QR_NETWORK)
                        || ((strcasecmp(&buf[5], serv_info.serv_nodename)
                        && (strcasecmp(&buf[5], serv_info.serv_fqdn))))) {
                                wprintf("@%s ", &buf[5]);
@@ -142,7 +142,7 @@ char *oper;
                wprintf("****");
        wprintf("</FONT></TD>");
 
-       if (is_room_aide) {
+       if (WC->is_room_aide) {
                wprintf("<TD ALIGN=RIGHT NOWRAP><FONT FACE=\"Arial,Helvetica,sans-serif\" COLOR=\"FFFF00\"><B>");
 
                wprintf("<A HREF=\"/confirm_move_msg");
@@ -224,7 +224,7 @@ void readloop(char *oper)
        printf("HTTP/1.0 200 OK\n");
        output_headers(1);
 
-       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><CENTER><B>%s - ", wc_roomname);
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><CENTER><B>%s - ", WC->wc_roomname);
        if (!strcmp(oper, "readnew")) {
                strcpy(cmd, "MSGS NEW");
                wprintf("new messages");
@@ -370,10 +370,10 @@ void display_enter(void)
        buf[strlen(buf) - 1] = 0;
        strcpy(&buf[16], &buf[19]);
        wprintf("</CENTER><FONT COLOR=\"440000\"><B> %s ", &buf[4]);
-       wprintf("from %s ", wc_username);
+       wprintf("from %s ", WC->wc_username);
        if (strlen(bstr("recp")) > 0)
                wprintf("to %s ", bstr("recp"));
-       wprintf("in %s&gt; ", wc_roomname);
+       wprintf("in %s&gt; ", WC->wc_roomname);
        wprintf("</B></FONT><BR><CENTER>\n");
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\">\n");
index 50d63772012f25f4a9a17761bd31a2649762da6e..828b934527113cc0a54af53121aef4b0e964eb5b 100644 (file)
@@ -117,8 +117,8 @@ void do_chat(void)
 
        wprintf("<applet codebase=\"/static\" ");
        wprintf("code=\"wcchat\" width=2 height=2>\n");
-       wprintf("<PARAM NAME=username VALUE=\"%s\">\n", wc_username);
-       wprintf("<PARAM NAME=password VALUE=\"%s\">\n", wc_password);
+       wprintf("<PARAM NAME=username VALUE=\"%s\">\n", WC->wc_username);
+       wprintf("<PARAM NAME=password VALUE=\"%s\">\n", WC->wc_password);
        wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
        wprintf("so you won't be able to access Chat.  Sorry.\n");
        wprintf("</applet>\n");
index 52204caeb5b32b282c61543157a55b9af094d7d4..bf47eaa509d18f57c955ccd05d5b70304771d88a 100644 (file)
@@ -36,11 +36,6 @@ struct roomlisting {
 
 
 char floorlist[128][256];
-char ugname[128];
-long uglsn = (-1L);
-unsigned room_flags;
-int is_aide = 0;
-int is_room_aide = 0;
 
 struct march *march = NULL;
 
@@ -325,22 +320,22 @@ void embed_room_banner(char *got) {
         * If it isn't supplied, we fake it by issuing our own GOTO.
         */
        if (got == NULL) {
-               serv_printf("GOTO %s", wc_roomname);
+               serv_printf("GOTO %s", WC->wc_roomname);
                serv_gets(fakegot);
                got = fakegot;
        }
 
        /* Check for new mail. */
-       new_mail = extract_int(&got[4], 9);
+       WC->new_mail = extract_int(&got[4], 9);
 
        /* Now start spewing HTML. */
        wprintf("<CENTER><TABLE border=0><TR>");
 
-       if ((strlen(ugname) > 0) && (strcasecmp(ugname, wc_roomname))) {
+       if ((strlen(WC->ugname) > 0) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
                wprintf("<TD VALIGN=TOP><A HREF=\"/ungoto\">");
                wprintf("<IMG SRC=\"/static/back.gif\" BORDER=0></A></TD>");
        }
-       wprintf("<TD VALIGN=TOP><FONT FACE=\"Arial,Helvetica,sans-serif\"><FONT SIZE=+2>%s</FONT><BR>", wc_roomname);
+       wprintf("<TD VALIGN=TOP><FONT FACE=\"Arial,Helvetica,sans-serif\"><FONT SIZE=+2>%s</FONT><BR>", WC->wc_roomname);
        wprintf("%d new of %d messages</FONT></TD>\n",
                extract_int(&got[4], 1),
                extract_int(&got[4], 2));
@@ -355,7 +350,7 @@ void embed_room_banner(char *got) {
        if (buf[0] == '2') {
                wprintf("<TD><FONT FACE=\"Arial,Helvetica,sans-serif\">");
                wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
-               urlescputs(wc_roomname);
+               urlescputs(WC->wc_roomname);
                wprintf("\"></FONT></TD>");
                serv_puts("CLOS");
                serv_gets(buf);
@@ -365,12 +360,12 @@ void embed_room_banner(char *got) {
        wprintf("</FONT></TD>");
 
        /* Let the user know if new mail has arrived */
-       if ( (new_mail > remember_new_mail) && (new_mail>0) ) {
+       if ( (WC->new_mail > remember_new_mail) && (WC->new_mail>0) ) {
                wprintf("<TD VALIGN=TOP>"
                        "<IMG SRC=\"/static/mail.gif\" border=0 "
                        "ALT=\"You have new mail\">"
-                       "<BR><BLINK>%d</BLINK></TD>", new_mail);
-               remember_new_mail = new_mail;
+                       "<BR><BLINK>%d</BLINK></TD>", WC->new_mail);
+               remember_new_mail = WC->new_mail;
        }
 
        wprintf("<TD VALIGN=TOP><A HREF=\"/gotonext\">");
@@ -408,8 +403,8 @@ void gotoroom(char *gname, int display_name)
        }
        if (display_name != 2) {
                /* store ungoto information */
-               strcpy(ugname, wc_roomname);
-               uglsn = ls;
+               strcpy(WC->ugname, WC->wc_roomname);
+               WC->uglsn = ls;
        }
        /* move to the new room */
        serv_printf("GOTO %s", gname);
@@ -425,19 +420,19 @@ void gotoroom(char *gname, int display_name)
                }
                return;
        }
-       extract(wc_roomname, &buf[4], 0);
-       room_flags = extract_int(&buf[4], 4);
+       extract(WC->wc_roomname, &buf[4], 0);
+       WC->room_flags = extract_int(&buf[4], 4);
        /* highest_msg_read = extract_int(&buf[4],6);
           maxmsgnum = extract_int(&buf[4],5);
           is_mail = (char) extract_int(&buf[4],7); */
        ls = extract_long(&buf[4], 6);
 
-       if (is_aide)
-               is_room_aide = is_aide;
+       if (WC->is_aide)
+               WC->is_room_aide = WC->is_aide;
        else
-               is_room_aide = (char) extract_int(&buf[4], 8);
+               WC->is_room_aide = (char) extract_int(&buf[4], 8);
 
-       remove_march(wc_roomname);
+       remove_march(WC->wc_roomname);
        if (!strcasecmp(gname, "_BASEROOM_"))
                remove_march(gname);
 
@@ -446,7 +441,7 @@ void gotoroom(char *gname, int display_name)
                embed_room_banner(buf);
                wDumpContent(1);
        }
-       strcpy(wc_roomname, wc_roomname);
+       strcpy(WC->wc_roomname, WC->wc_roomname);
 }
 
 
@@ -543,7 +538,7 @@ void gotonext(void)
  * ...and remove the room we're currently in, so a <G>oto doesn't make us
  * walk around in circles
  */
-               remove_march(wc_roomname);
+               remove_march(WC->wc_roomname);
        }
        if (march != NULL) {
                strcpy(next_room, pop_march(-1));
@@ -587,22 +582,22 @@ void ungoto(void)
 {
        char buf[256];
 
-       if (!strcmp(ugname, "")) {
-               smart_goto(wc_roomname);
+       if (!strcmp(WC->ugname, "")) {
+               smart_goto(WC->wc_roomname);
                return;
        }
-       serv_printf("GOTO %s", ugname);
+       serv_printf("GOTO %s", WC->ugname);
        serv_gets(buf);
        if (buf[0] != '2') {
-               smart_goto(wc_roomname);
+               smart_goto(WC->wc_roomname);
                return;
        }
-       if (uglsn >= 0L) {
-               serv_printf("SLRP %ld", uglsn);
+       if (WC->uglsn >= 0L) {
+               serv_printf("SLRP %ld", WC->uglsn);
                serv_gets(buf);
        }
-       strcpy(buf, ugname);
-       strcpy(ugname, "");
+       strcpy(buf, WC->ugname);
+       strcpy(WC->ugname, "");
        smart_goto(buf);
 }
 
@@ -1080,7 +1075,7 @@ void goto_private(void)
                display_main_menu();
                return;
        }
-       strcpy(hold_rm, wc_roomname);
+       strcpy(hold_rm, WC->wc_roomname);
        strcpy(buf, "GOTO ");
        strcat(buf, bstr("gr_name"));
        strcat(buf, "|");
@@ -1117,7 +1112,7 @@ void display_zap(void)
        wprintf("<B>Zap (forget) the current room</B>\n");
        wprintf("</FONT></TD></TR></TABLE>\n");
 
-       wprintf("If you select this option, <em>%s</em> will ", wc_roomname);
+       wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
        wprintf("disappear from your room list.  Is this what you wish ");
        wprintf("to do?<BR>\n");
 
@@ -1140,10 +1135,10 @@ void zap(void)
        /* If the forget-room routine fails for any reason, we fall back
         * to the current room; otherwise, we go to the Lobby
         */
-       strcpy(final_destination, wc_roomname);
+       strcpy(final_destination, WC->wc_roomname);
 
        if (!strcasecmp(bstr("sc"), "OK")) {
-               serv_printf("GOTO %s", wc_roomname);
+               serv_printf("GOTO %s", WC->wc_roomname);
                serv_gets(buf);
                if (buf[0] != '2') {
                        ExpressMessageCat(&buf[4]);
@@ -1187,7 +1182,7 @@ void confirm_delete_room(void)
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
 
        wprintf("Are you sure you want to delete <FONT SIZE=+1>");
-       escputs(wc_roomname);
+       escputs(WC->wc_roomname);
        wprintf("</FONT>?<BR>\n");
 
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
index 823fb5f85db67eaee12286a66d621c6916e0ecfe..750ec7d2f4fbb0506731b82c37ab98580dabef70 100644 (file)
@@ -13,7 +13,7 @@
 struct serv_info serv_info;
 
 /*
- * get info about the server we've connected to
+ * get info about the server we've WC->connected to
  */
 void get_serv_info(char *browser_host, char *user_agent)
 {
index 5fa17c05b4c5244ea1dd4389fc904e57ab1f2c6c..526068129cbb6abfb789d43713b0934097450436 100644 (file)
@@ -76,7 +76,7 @@ void save_edit(char *description, char *enter_cmd, int regoto)
        serv_puts("000");
 
        if (regoto) {
-               smart_goto(wc_roomname);
+               smart_goto(WC->wc_roomname);
        } else {
                printf("HTTP/1.0 200 OK\n");
                output_headers(1);
index bafeea9b5bef56578c1e0105764f50586037dfdd..d7ec10712e545c5abecb64f565c4911529e45ff4 100644 (file)
@@ -29,9 +29,6 @@ char server_is_local = 0;
 
 extern int errno;
 
-int serv_sock;
-
-
 RETSIGTYPE timeout(int signum)
 {
        fprintf(stderr, "Connection timed out.\n");
@@ -105,12 +102,12 @@ void serv_read(char *buf, int bytes)
 
        len = 0;
        while (len < bytes) {
-               rlen = read(serv_sock, &buf[len], bytes - len);
+               rlen = read(WC->serv_sock, &buf[len], bytes - len);
                if (rlen < 1) {
                        fprintf(stderr, "Server connection broken: %s\n",
                                strerror(errno));
-                       connected = 0;
-                       logged_in = 0;
+                       WC->connected = 0;
+                       WC->logged_in = 0;
                        return;
                }
                len = len + rlen;
@@ -147,13 +144,13 @@ void serv_write(char *buf, int nbytes)
        int bytes_written = 0;
        int retval;
        while (bytes_written < nbytes) {
-               retval = write(serv_sock, &buf[bytes_written],
+               retval = write(WC->serv_sock, &buf[bytes_written],
                               nbytes - bytes_written);
                if (retval < 1) {
                        fprintf(stderr, "Server connection broken: %s\n",
                                strerror(errno));
-                       connected = 0;
-                       logged_in = 0;
+                       WC->connected = 0;
+                       WC->logged_in = 0;
                        return;
                }
                bytes_written = bytes_written + retval;
index 90ca7cf297125da06d16e96b383739df638aa082..10819551a92fabfbad9d91e0515dafd897dab479 100644 (file)
 #include "child.h"
 #include "mime_parser.h"
 
-int wc_session;
-char wc_username[256];
-char wc_password[256];
-char wc_roomname[256];
 int TransactionCount = 0;
-int connected = 0;
-int logged_in = 0;
-int axlevel;
 char *ExpressMessages = NULL;
-int new_mail = 0;
-int need_vali = 0;
 
 /* This variable is set to 1 if the room banner and menubar have been
  * displayed, and we need to close the <TABLE> tags.
@@ -47,10 +38,10 @@ struct urlcontent *urlstrings = NULL;
 static const char *defaulthost = DEFAULT_HOST;
 static const char *defaultport = DEFAULT_PORT;
 
-int upload_length = 0;
-char *upload;
 
 
+struct wcsession *WC = NULL;   /* FIX take this out when multithreaded */
+
 void unescape_input(char *buf)
 {
        int a, b;
@@ -371,8 +362,8 @@ void output_headers(int print_standard_html_head)
                printf("Pragma: no-cache\n");
                printf("Cache-Control: no-store\n");
        }
-       stuff_to_cookie(cookie, wc_session, wc_username,
-                       wc_password, wc_roomname);
+       stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
+                       WC->wc_password, WC->wc_roomname);
        if (print_standard_html_head == 2) {
                printf("X-WebCit-Session: close\n");
                printf("Set-cookie: webcit=%s\n", unset);
@@ -628,10 +619,10 @@ void upload_handler(char *name, char *filename, char *encoding,
        fprintf(stderr, "  length = %d\n", length);
 
        if (strlen(name) > 0) {
-               upload = malloc(length);
-               if (upload != NULL) {
-                       upload_length = length;
-                       memcpy(upload, content, length);
+               WC->upload = malloc(length);
+               if (WC->upload != NULL) {
+                       WC->upload_length = length;
+                       memcpy(WC->upload, content, length);
                }
        }
 }
@@ -663,8 +654,8 @@ void session_loop(char *browser_host, char *user_agent)
        strcpy(c_password, "");
        strcpy(c_roomname, "");
 
-       upload_length = 0;
-       upload = NULL;
+       WC->upload_length = 0;
+       WC->upload = NULL;
 
        if (getz(cmd) == NULL)
                return;
@@ -716,21 +707,21 @@ void session_loop(char *browser_host, char *user_agent)
                        cmd[a] = 0;
                }
        /*
-        * If we're not connected to a Citadel server, try to hook up the
+        * If we're not WC->connected to a Citadel server, try to hook up the
         * connection now.  Preference is given to the host and port specified
         * by browser cookies, if cookies have been supplied.
         */
-       if (!connected) {
+       if (!WC->connected) {
                if (strlen(bstr("host")) > 0)
                        strcpy(c_host, bstr("host"));
                if (strlen(bstr("port")) > 0)
                        strcpy(c_port, bstr("port"));
-               serv_sock = connectsock(c_host, c_port, "tcp");
-               if (serv_sock < 0) {
+               WC->serv_sock = connectsock(c_host, c_port, "tcp");
+               if (WC->serv_sock < 0) {
                        do_logout();
                }
 
-               connected = 1;
+               WC->connected = 1;
                serv_gets(buf); /* get the server welcome message */
                get_serv_info(browser_host, user_agent);
        }
@@ -740,7 +731,7 @@ void session_loop(char *browser_host, char *user_agent)
         * If we're not logged in, but we have username and password cookies
         * supplied by the browser, try using them to log in.
         */
-       if ((!logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
+       if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
                serv_printf("USER %s", c_username);
                serv_gets(buf);
                if (buf[0] == '3') {
@@ -755,11 +746,11 @@ void session_loop(char *browser_host, char *user_agent)
         * If we don't have a current room, but a cookie specifying the
         * current room is supplied, make an effort to go there.
         */
-       if ((strlen(wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
+       if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
                serv_printf("GOTO %s", c_roomname);
                serv_gets(buf);
                if (buf[0] == '2') {
-                       strcpy(wc_roomname, c_roomname);
+                       strcpy(WC->wc_roomname, c_roomname);
                }
        }
        if (!strcasecmp(action, "static")) {
@@ -770,9 +761,9 @@ void session_loop(char *browser_host, char *user_agent)
                output_static(buf);
        } else if (!strcasecmp(action, "image")) {
                output_image();
-       } else if ((!logged_in) && (!strcasecmp(action, "login"))) {
+       } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
                do_login();
-       } else if (!logged_in) {
+       } else if (!WC->logged_in) {
                display_login(NULL);
        }
        /* Various commands... */
@@ -850,7 +841,7 @@ void session_loop(char *browser_host, char *user_agent)
        } else if (!strcasecmp(action, "editinfo")) {
                save_edit("Room info", "EINF 1", 1);
        } else if (!strcasecmp(action, "display_editbio")) {
-               sprintf(buf, "RBIO %s", wc_username);
+               sprintf(buf, "RBIO %s", WC->wc_username);
                display_edit("Your bio", "NOOP", buf, "editbio");
        } else if (!strcasecmp(action, "editbio")) {
                save_edit("Your bio", "EBIO", 0);
@@ -932,7 +923,7 @@ void session_loop(char *browser_host, char *user_agent)
                output_headers(1);
 
                wprintf("TransactionCount is %d<BR>\n", TransactionCount);
-               wprintf("You're in session %d<HR>\n", wc_session);
+               wprintf("You're in session %d<HR>\n", WC->wc_session);
                wprintf("Command: <BR><PRE>\n");
                escputs(cmd);
                wprintf("</PRE><HR>\n");
@@ -952,9 +943,9 @@ void session_loop(char *browser_host, char *user_agent)
                content = NULL;
        }
        free_urls();
-       if (upload_length > 0) {
-               free(upload);
-               upload_length = 0;
+       if (WC->upload_length > 0) {
+               free(WC->upload);
+               WC->upload_length = 0;
        }
 }
 
@@ -971,13 +962,18 @@ int main(int argc, char *argv[])
                return 1;
        }
 
-       wc_session = atoi(argv[1]);
+       WC = (struct wcsession *) malloc(sizeof(struct wcsession));
+       memset(WC, 0, sizeof(struct wcsession));
+
+
+
+       WC->wc_session = atoi(argv[1]);
        defaulthost = argv[2];
        defaultport = argv[3];
 
-       strcpy(wc_username, "");
-       strcpy(wc_password, "");
-       strcpy(wc_roomname, "");
+       strcpy(WC->wc_username, "");
+       strcpy(WC->wc_password, "");
+       strcpy(WC->wc_roomname, "");
 
        /* Clear out serv_info and temporarily set the value of serv_humannode
         * to a default value, because it'll be used in HTML page titles
index a078d222e02c43c6a810a939542d84fd405f6fa9..a831ec92f9aba7fd86e5fad7811c485ed7c3937c 100644 (file)
@@ -66,25 +66,32 @@ struct serv_info {
        int serv_ok_floors;
 };
 
-extern char wc_username[256];
-extern char wc_password[256];
-extern char wc_roomname[256];
-extern int connected;
-extern int logged_in;
-extern int axlevel;
-extern int is_aide;
-extern int is_room_aide;
-extern int serv_sock;
-extern struct serv_info serv_info;
-extern unsigned room_flags;
-extern char ugname[128];
-extern long uglsn;
-extern char *axdefs[];
-extern int upload_length;
-extern char *upload;
+struct wcsession {
+       int wc_session;
+       char wc_username[256];
+       char wc_password[256];
+       char wc_roomname[256];
+       int connected;
+       int logged_in;
+       int axlevel;
+       int is_aide;
+       int is_room_aide;
+       int serv_sock;
+       struct serv_info serv_info;
+       unsigned room_flags;
+       char ugname[128];
+       long uglsn;
+       int upload_length;
+       char *upload;
+       int new_mail;
+       int need_vali;
+};
+
+extern struct wcsession *WC;
+
+struct serv_info serv_info;
 extern char floorlist[128][256];
-extern int new_mail;
-extern int need_vali;
+extern char *axdefs[];
 
 void stuff_to_cookie(char *, int, char *, char *, char *);
 void cookie_to_stuff(char *, int *, char *, char *, char *);
index 2b8dd0155e945823abe45fbe0f8660fc0ea8f069..c71ce66a4895376065aaab0b412b93f80000fd8b 100644 (file)
@@ -89,7 +89,7 @@ void whobbs(void)
 
                while (wlist != NULL) {
                        wprintf("<TR>\n\t<TD ALIGN=center><FONT FACE=\"Arial,Helvetica,sans-serif\">%d", wlist->sessionnum);
-                       if ((is_aide) &&
+                       if ((WC->is_aide) &&
                            (wlist->sessionnum != serv_info.serv_pid)) {
                                wprintf(" <A HREF=\"/terminate_session&which_session=%d&session_owner=", wlist->sessionnum);
                                urlescputs(wlist->username);
@@ -230,7 +230,7 @@ void edit_me(void)
                wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Change host name\">");
                wprintf("</FONT></TD>\n</TR>\n");
 
-               if (is_aide) {
+               if (WC->is_aide) {
                        wprintf("<TR><TD><FONT FACE=\"Arial,Helvetica,sans-serif\"><B>User name:</B></FONT></TD><TD>");
                        wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><INPUT TYPE=\"text\" NAME=\"fake_username\" MAXLENGTH=\"64\">\n");
                        wprintf("</FONT></TD>\n<TD ALIGN=center>");