From: Art Cancro Date: Thu, 26 Nov 1998 01:48:50 +0000 (+0000) Subject: started to add wholist X-Git-Tag: v7.86~8104 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=994ff2b8ce1fff4545b2bdd2f3794846c4906bbd;p=citadel.git started to add wholist --- diff --git a/webcit/Makefile b/webcit/Makefile index 55021beaf..006292654 100644 --- a/webcit/Makefile +++ b/webcit/Makefile @@ -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 index 000000000..03c8bbee8 --- /dev/null +++ b/webcit/serv_func.c @@ -0,0 +1,53 @@ +#include +#include +#include +#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 index b1405f4ce..000000000 --- a/webcit/testing.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include -#include - -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); - } diff --git a/webcit/webcit.c b/webcit/webcit.c index f85640900..aae07ad08 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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"); diff --git a/webcit/webcit.h b/webcit/webcit.h index 0402eed73..75007821a 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -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 index 000000000..d4bb93e6c --- /dev/null +++ b/webcit/who.c @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include +#include +#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("Who is online?\n"); + + wprintf("
"); + wprintf("Users currently on "); + escputs(serv_info.serv_humannode); + wprintf("
\n"); + + wprintf("
"); + wprintf(""); + wprintf("\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("\n"); + wptr = wlist->next; + free(wlist); + wlist = wptr; + } + } + wprintf("
Session IDUser NameRoomFrom host
%d", wlist->sessionnum); + escputs(wlist->username); + wprintf(""); + escputs(wlist->roomname); + wprintf(""); + escputs(wlist->hostname); + wprintf("
\n"); + printf("\n"); + wDumpContent(); + } + +