got known rooms list working
authorArt Cancro <ajc@citadel.org>
Mon, 30 Nov 1998 00:07:47 +0000 (00:07 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Nov 1998 00:07:47 +0000 (00:07 +0000)
webcit/Makefile
webcit/serv_func.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 006292654397a8b98f4f2daac933ecb2936ae33c..b41aed353823795749f77a093a118d232a08f5ef 100644 (file)
@@ -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
index 03c8bbee848d5ea00b0ebfa631f70aad573efc31..8ee2eb456a0bffddebc7a8e8194dfe4eb1c23cb1 100644 (file)
@@ -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("</I>");
+                       wprintf("<P>\n");
+                       return;
+                       }
+               if ( (intext==1) && (isspace(buf[0])) ) {
+                       wprintf("<BR>");
+                       }
+               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("<FONT COLOR=\"000044\"><I>");
+                       bq = 1;
+                       }
+               else if ((bq==1)&&
+                    (strncmp(buf," >",2))&&(strncmp(buf," :-)",4))) {
+                       wprintf("</FONT></I>");
+                       bq = 0;
+                       }
+
+               /* Activate embedded URL's */
+               url(buf);
+
+               escputs(buf);
+               wprintf("\n");
+               }
+       }
+
index aae07ad08f77a2999aa76cf708509277fa06fd7c..68385a529d759417af4d578d4c142df92200c6fa 100644 (file)
@@ -174,6 +174,109 @@ void wDumpContent() {
        wlast = NULL;
        }
 
+
+void escputs1(strbuf,nbsp)
+char strbuf[];
+int nbsp; {
+       int a;
+
+       for (a=0; a<strlen(strbuf); ++a) {
+               if (strbuf[a]=='<') wprintf("&lt;");
+               else if (strbuf[a]=='>') wprintf("&gt;");
+               else if (strbuf[a]=='&') wprintf("&amp;");
+               else if (strbuf[a]==34) wprintf("&quot;");
+               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("&nbsp;");
+                       }
+               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; a<strlen(strbuf); ++a) {
+               c = 0;
+               for (b=0; b<strlen(ec); ++b) {
+                       if (strbuf[a]==ec[b]) c=1;
+                       }
+               b = strlen(outbuf);
+               if (c==1) sprintf(&outbuf[b],"%%%02x",strbuf[a]);
+               else sprintf(&outbuf[b],"%c",strbuf[a]);
+               }
+       return(outbuf);
+       }
+
+void urlescputs(strbuf)
+char strbuf[]; {
+       wprintf("%s",urlesc(strbuf));
+       }
+
+
+/*
+ * Look for URL's embedded in a buffer and make them linkable.  We use a
+ * target window in order to keep the BBS session in its own window.
+ */
+void url(buf)
+char buf[]; {
+
+       int pos;
+       int start,end;
+       char ench;
+       char urlbuf[256];
+       char outbuf[256];
+
+       start = (-1);
+       end = strlen(buf);
+       ench = 0;
+
+       for (pos=0; pos<strlen(buf); ++pos) {
+               if (!strncasecmp(&buf[pos],"http://",7)) start = pos;
+               if (!strncasecmp(&buf[pos],"ftp://",6)) start = pos;
+               }
+
+       if (start<0) return;
+
+       if ((start>0)&&(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);
index 75007821ac23c5f1a987f68186a7381c31dd5e60..b3a7cb29980b0042f0c5271c68f1f58f63cab5c7 100644 (file)
@@ -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 *);
index d4bb93e6c1ce04efd594f3a6e25293d9c013f0ed..300e1db914665cba998b1ea808ab9448ad3c77bc 100644 (file)
@@ -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("</TABLE></CENTER>\n");
-        printf("</BODY></HTML>\n");
+        wprintf("</BODY></HTML>\n");
         wDumpContent();
        }