-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
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
--- /dev/null
+#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;
+ }
+ }
+
+++ /dev/null
-#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);
- }
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();
}
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");
#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];
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();
--- /dev/null
+#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();
+ }
+
+