From 487c5ce7d2c0f9de7ef44b0024573a4791163e1f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 30 Nov 1998 00:07:47 +0000 Subject: [PATCH] got known rooms list working --- webcit/Makefile | 12 ++++- webcit/serv_func.c | 54 +++++++++++++++++++++ webcit/webcit.c | 115 ++++++++++++++++++++++++++++++++++++++++++++- webcit/webcit.h | 31 ++++++++++-- webcit/who.c | 8 ++-- 5 files changed, 209 insertions(+), 11 deletions(-) diff --git a/webcit/Makefile b/webcit/Makefile index 006292654..b41aed353 100644 --- a/webcit/Makefile +++ b/webcit/Makefile @@ -17,8 +17,10 @@ context_loop.o: context_loop.c webcit.h -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: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ + roomops.o tools.o + cc webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ + tools.o roomops.o -o webcit webcit.o: webcit.c webcit.h cc -c webcit.c @@ -37,3 +39,9 @@ serv_func.o: serv_func.c webcit.h who.o: who.c webcit.h cc -c who.c + +tools.o: tools.c webcit.h + cc -c tools.c + +roomops.o: roomops.c webcit.h + cc -c roomops.c diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 03c8bbee8..8ee2eb456 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -51,3 +51,57 @@ void get_serv_info() { } } + + +/* + * Function to spit out Citadel variformat text in HTML + * If fp is non-null, it is considered to be the file handle to read the + * text from. Otherwise, text is read from the server. + */ +void fmout(fp) +FILE *fp; { + + int intext = 0; + int bq = 0; + int a; + char buf[256]; + + while(1) { + if (fp==NULL) serv_gets(buf); + if (fp!=NULL) { + if (fgets(buf,256,fp)==NULL) strcpy(buf,"000"); + buf[strlen(buf)-1] = 0; + } + if (!strcmp(buf,"000")) { + if (bq==1) wprintf(""); + wprintf("

\n"); + return; + } + if ( (intext==1) && (isspace(buf[0])) ) { + wprintf("
"); + } + intext = 1; + + /* Quoted text should be displayed in italics and in a + * different colour. This code understands both Citadel/UX + * style " >" quotes and FordBoard-style " :-)" quotes. + */ + if ((bq==0)&& + ((!strncmp(buf," >",2))||(!strncmp(buf," :-)",4)))) { + wprintf(""); + bq = 1; + } + else if ((bq==1)&& + (strncmp(buf," >",2))&&(strncmp(buf," :-)",4))) { + wprintf(""); + bq = 0; + } + + /* Activate embedded URL's */ + url(buf); + + escputs(buf); + wprintf("\n"); + } + } + diff --git a/webcit/webcit.c b/webcit/webcit.c index aae07ad08..68385a529 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -174,6 +174,109 @@ void wDumpContent() { wlast = NULL; } + +void escputs1(strbuf,nbsp) +char strbuf[]; +int nbsp; { + int a; + + for (a=0; a') wprintf(">"); + else if (strbuf[a]=='&') wprintf("&"); + else if (strbuf[a]==34) wprintf("""); + else if (strbuf[a]==LB) wprintf("<"); + else if (strbuf[a]==RB) wprintf(">"); + else if (strbuf[a]==QU) wprintf("\""); + else if ((strbuf[a]==32)&&(nbsp==1)) { + wprintf(" "); + } + else { + wprintf("%c", strbuf[a]); + } + } + } + +void escputs(strbuf) +char *strbuf; { + escputs1(strbuf,0); + } + + + +char *urlesc(strbuf) +char strbuf[]; { + int a,b,c; + char *ec = " #&;`'|*?-~<>^()[]{}$\\"; + static char outbuf[512]; + + strcpy(outbuf,""); + + for (a=0; a0)&&(buf[start-1]=='<')) ench = '>'; + if ((start>0)&&(buf[start-1]=='[')) ench = ']'; + if ((start>0)&&(buf[start-1]=='(')) ench = ')'; + if ((start>0)&&(buf[start-1]=='{')) ench = '}'; + + for (pos=strlen(buf); pos>start; --pos) { + if ((buf[pos]==' ')||(buf[pos]==ench)) end = pos; + } + + strncpy(urlbuf,&buf[start],end-start); + urlbuf[end-start] = 0; + + + strncpy(outbuf,buf,start); + sprintf(&outbuf[start],"%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c", + LB,QU,urlbuf,QU,QU,TARGET,QU,RB,urlbuf,LB,RB); + strcat(outbuf,&buf[end]); + strcpy(buf,outbuf); + } + + + + void getz(char *buf) { if (fgets(buf, 256, stdin) == NULL) strcpy(buf, ""); else { @@ -373,8 +476,11 @@ void session_loop() { whobbs(); } - /* When all else fails, display the oops page. */ - else { + else if (!strncasecmp(cmd, "GET /knrooms", 12)) { + list_all_rooms_by_floor(); + } + + else if (!strncasecmp(cmd, "GET /test", 9)) { printf("HTTP/1.0 200 OK\n"); output_headers(); @@ -385,6 +491,11 @@ void session_loop() { wDumpContent(); } + /* When all else fails, display the frameset again. */ + else { + output_frameset(); + } + fflush(stdout); if (content != NULL) { free(content); diff --git a/webcit/webcit.h b/webcit/webcit.h index 75007821a..b3a7cb299 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -1,11 +1,34 @@ #define SLEEPING 180 /* TCP connection timeout */ -#define PORT_NUM 32764 /* port number to listen on */ +#define PORT_NUM 32763 /* port number to listen on */ #define SERVER "WebCit v2.0 (Velma)" /* who's in da house */ #define DEVELOPER_ID 0 #define CLIENT_ID 4 #define CLIENT_VERSION 200 -#define DEFAULT_HOST "uncnsrd.mt-kisco.ny.us" -#define DEFAULT_PORT "504" +#define DEFAULT_HOST "localhost" +#define DEFAULT_PORT "citadel" +#define LB (1) +#define RB (2) +#define QU (3) +#define TARGET "webcit01" + + +#define QR_PERMANENT 1 /* Room does not purge */ +#define QR_INUSE 2 /* Set if in use, clear if avail */ +#define QR_PRIVATE 4 /* Set for any type of private room */ +#define QR_PASSWORDED 8 /* Set if there's a password too */ +#define QR_GUESSNAME 16 /* Set if it's a guessname room */ +#define QR_DIRECTORY 32 /* Directory room */ +#define QR_UPLOAD 64 /* Allowed to upload */ +#define QR_DOWNLOAD 128 /* Allowed to download */ +#define QR_VISDIR 256 /* Visible directory */ +#define QR_ANONONLY 512 /* Anonymous-Only room */ +#define QR_ANONOPT 1024 /* Anonymous-Option room */ +#define QR_NETWORK 2048 /* Shared network room */ +#define QR_PREFONLY 4096 /* Preferred status needed to enter */ +#define QR_READONLY 8192 /* Aide status required to post */ +#define QR_MAILBOX 16384 /* Set if this is a private mailbox */ + + struct webcontent { struct webcontent *next; @@ -43,3 +66,5 @@ extern struct serv_info serv_info; void serv_printf(const char *format, ...); char *bstr(); +char *urlesc(char *); +void urlescputs(char *); diff --git a/webcit/who.c b/webcit/who.c index d4bb93e6c..300e1db91 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -50,17 +50,17 @@ void whobbs() { for (wptr = wlist; wptr != NULL; wptr = wptr -> next) { if (wptr->sessionnum == sess) { foundit = 1; - if (strcasecmp(user, &wptr->username)) { + if (strcasecmp(user, wptr->username)) { sprintf(buf, "%cBR%c%s", LB, RB, user); strcat(wptr->username, buf); } - if (strcasecmp(room, &wptr->roomname)) { + if (strcasecmp(room, wptr->roomname)) { sprintf(buf, "%cBR%c%s", LB, RB, room); strcat(wptr->roomname, buf); } - if (strcasecmp(host, &wptr->hostname)) { + if (strcasecmp(host, wptr->hostname)) { sprintf(buf, "%cBR%c%s", LB, RB, host); strcat(wptr->hostname, buf); @@ -94,7 +94,7 @@ void whobbs() { } } wprintf("\n"); - printf("\n"); + wprintf("\n"); wDumpContent(); } -- 2.39.2