started to add wholist
authorArt Cancro <ajc@citadel.org>
Thu, 26 Nov 1998 01:48:50 +0000 (01:48 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 26 Nov 1998 01:48:50 +0000 (01:48 +0000)
webcit/Makefile
webcit/serv_func.c [new file with mode: 0644]
webcit/testing.c [deleted file]
webcit/webcit.c
webcit/webcit.h
webcit/who.c [new file with mode: 0644]

index 55021beaf13448298d3bb6addcc8d3f0773425f0..006292654397a8b98f4f2daac933ecb2936ae33c 100644 (file)
@@ -17,8 +17,8 @@ context_loop.o: context_loop.c webcit.h
 
 
 
-webcit: webcit.o auth.o tcp_sockets.o mainmenu.o
-       cc webcit.o auth.o tcp_sockets.o mainmenu.o -o webcit
+webcit: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o
+       cc webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o -o webcit
 
 webcit.o: webcit.c webcit.h
        cc -c webcit.c
@@ -31,3 +31,9 @@ tcp_sockets.o: tcp_sockets.c webcit.h
 
 mainmenu.o: mainmenu.c webcit.h
        cc -c mainmenu.c
+
+serv_func.o: serv_func.c webcit.h
+       cc -c serv_func.c
+
+who.o: who.c webcit.h
+       cc -c who.c
diff --git a/webcit/serv_func.c b/webcit/serv_func.c
new file mode 100644 (file)
index 0000000..03c8bbe
--- /dev/null
@@ -0,0 +1,53 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "webcit.h"
+
+struct serv_info serv_info;
+
+/*
+ * get info about the server we've connected to
+ */
+void get_serv_info() {
+       char buf[256];
+       int a;
+
+       serv_printf("IDEN %d|%d|%d|%s|%s",
+               DEVELOPER_ID,
+               CLIENT_ID,
+               CLIENT_VERSION,
+               SERVER,
+               ""              /* FIX find out where the user is */
+               );
+       serv_gets(buf);
+
+       serv_puts("INFO");
+       serv_gets(buf);
+       if (buf[0]!='1') return;
+
+       a = 0;
+       while(serv_gets(buf), strcmp(buf,"000")) {
+           switch(a) {
+               case 0:         serv_info.serv_pid = atoi(buf);
+                               break;
+               case 1:         strcpy(serv_info.serv_nodename,buf);
+                               break;
+               case 2:         strcpy(serv_info.serv_humannode,buf);
+                               break;
+               case 3:         strcpy(serv_info.serv_fqdn,buf);
+                               break;
+               case 4:         strcpy(serv_info.serv_software,buf);
+                               break;
+               case 5:         serv_info.serv_rev_level = atoi(buf);
+                               break;
+               case 6:         strcpy(serv_info.serv_bbs_city,buf);
+                               break;
+               case 7:         strcpy(serv_info.serv_sysadm,buf);
+                               break;
+               case 9:         strcpy(serv_info.serv_moreprompt,buf);
+                               break;
+               }
+           ++a;
+           }
+       }
+
diff --git a/webcit/testing.c b/webcit/testing.c
deleted file mode 100644 (file)
index b1405f4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-main() {
-       int fdin, fdout;
-       char buf[256];
-
-       fdin = open("/dev/tty10", O_RDONLY);
-       fdout = open("/dev/tty10", O_WRONLY);
-       dup2(fdin, 0);
-       dup2(fdout, 1);
-       printf("Hello world: ");
-       gets(buf);
-       printf("Ok then... %s\n", buf);
-       exit(0);
-       }
index f856409000d01a9c0deb121a3191443f0a9be2db..aae07ad08f77a2999aa76cf708509277fa06fd7c 100644 (file)
@@ -309,15 +309,7 @@ void session_loop() {
                serv_gets(buf); /* get the server welcome message */
                strcpy(wc_host, c_host);
                strcpy(wc_port, c_port);
-               serv_printf("IDEN %d|%d|%d|%s|%s",
-                       DEVELOPER_ID,
-                       CLIENT_ID,
-                       CLIENT_VERSION,
-                       SERVER,
-                       ""
-                       );
-               serv_gets(buf);
-               /* FIX find out where the user is */
+               get_serv_info();
                }
 
 
@@ -377,6 +369,10 @@ void session_loop() {
                display_main_menu();
                }
 
+       else if (!strncasecmp(cmd, "GET /whobbs", 11)) {
+               whobbs();
+               }
+
        /* When all else fails, display the oops page. */
        else {
                printf("HTTP/1.0 200 OK\n");
index 0402eed737dc4c31e87f68c512b779dbbe5f5145..75007821ac23c5f1a987f68186a7381c31dd5e60 100644 (file)
@@ -7,15 +7,6 @@
 #define DEFAULT_HOST   "uncnsrd.mt-kisco.ny.us"
 #define DEFAULT_PORT   "504"
 
-extern char wc_host[256];
-extern char wc_port[256];
-extern char wc_username[256];
-extern char wc_password[256];
-extern char wc_roomname[256];
-extern int connected;
-extern int logged_in;
-extern int serv_sock;
-
 struct webcontent {
        struct webcontent *next;
        char w_data[256];
@@ -27,5 +18,28 @@ struct urlcontent {
        char *url_data;
        };
 
+struct serv_info {
+       int serv_pid;
+       char serv_nodename[32];
+       char serv_humannode[64];
+       char serv_fqdn[64];
+       char serv_software[64];
+       int serv_rev_level;
+       char serv_bbs_city[64];
+       char serv_sysadm[64];
+       char serv_moreprompt[256];
+       int serv_ok_floors;
+       };
+
+extern char wc_host[256];
+extern char wc_port[256];
+extern char wc_username[256];
+extern char wc_password[256];
+extern char wc_roomname[256];
+extern int connected;
+extern int logged_in;
+extern int serv_sock;
+extern struct serv_info serv_info;
+
 void serv_printf(const char *format, ...);
 char *bstr();
diff --git a/webcit/who.c b/webcit/who.c
new file mode 100644 (file)
index 0000000..d4bb93e
--- /dev/null
@@ -0,0 +1,101 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include "webcit.h"
+
+struct whouser {
+       struct whouser *next;
+       int sessionnum;
+       char username[256];
+       char roomname[256];
+       char hostname[256];
+       char clientsoftware[256];
+       };
+       
+/*
+ * who is on?
+ */
+void whobbs() {
+       struct whouser *wlist = NULL;
+       struct whouser *wptr = NULL;
+       char buf[256],sess,user[256],room[256],host[256];
+       int foundit;
+
+        printf("HTTP/1.0 200 OK\n");
+        output_headers();
+        wprintf("<HTML><HEAD><TITLE>Who is online?</TITLE></HEAD><BODY>\n");
+
+        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Users currently on ");
+       escputs(serv_info.serv_humannode);
+        wprintf("</B></FONT></TD></TR></TABLE>\n");
+
+       wprintf("<CENTER><TABLE border><TR>");
+       wprintf("<TH>Session ID</TH><TH>User Name</TH><TH>Room</TH>");
+       wprintf("<TH>From host</TH></TR>\n");
+       serv_puts("RWHO");
+       serv_gets(buf);
+       if (buf[0]=='1') {
+               while(serv_gets(buf), strcmp(buf,"000")) {
+                       sess = extract_int(buf, 0);
+                       extract(user, buf, 1);
+                       extract(room, buf, 2);
+                       extract(host, buf, 3);
+
+                       foundit = 0;
+                       for (wptr = wlist; wptr != NULL; wptr = wptr -> next) {
+                               if (wptr->sessionnum == sess) {
+                                       foundit = 1;
+                                       if (strcasecmp(user, &wptr->username)) {
+                                               sprintf(buf, "%cBR%c%s", 
+                                                       LB, RB, user);
+                                               strcat(wptr->username, buf);
+                                               }
+                                       if (strcasecmp(room, &wptr->roomname)) {
+                                               sprintf(buf, "%cBR%c%s", 
+                                                       LB, RB, room);
+                                               strcat(wptr->roomname, buf);
+                                               }
+                                       if (strcasecmp(host, &wptr->hostname)) {
+                                               sprintf(buf, "%cBR%c%s", 
+                                                       LB, RB, host);
+                                               strcat(wptr->hostname, buf);
+                                               }
+                                       }
+                               }
+
+                       if (foundit == 0) {
+                               wptr = (struct whouser *)
+                                       malloc(sizeof(struct whouser));
+                               wptr->next = wlist;
+                               wlist = wptr;
+                               strcpy(wlist->username, user);
+                               strcpy(wlist->roomname, room);
+                               strcpy(wlist->hostname, host);
+                               wlist->sessionnum = sess;
+                               }
+                       }
+
+               while (wlist != NULL) {
+                       wprintf("<TR><TD>%d</TD><TD>", wlist->sessionnum);
+                       escputs(wlist->username);
+                       wprintf("</TD><TD>");
+                       escputs(wlist->roomname);
+                       wprintf("</TD><TD>");
+                       escputs(wlist->hostname);
+                       wprintf("</TD></TR>\n");
+                       wptr = wlist->next;
+                       free(wlist);
+                       wlist = wptr;
+                       }
+               }
+       wprintf("</TABLE></CENTER>\n");
+        printf("</BODY></HTML>\n");
+        wDumpContent();
+       }
+
+