-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
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
}
}
+
+
+/*
+ * 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");
+ }
+ }
+
wlast = NULL;
}
+
+void escputs1(strbuf,nbsp)
+char strbuf[];
+int nbsp; {
+ int a;
+
+ for (a=0; a<strlen(strbuf); ++a) {
+ if (strbuf[a]=='<') wprintf("<");
+ else if (strbuf[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; 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 {
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();
wDumpContent();
}
+ /* When all else fails, display the frameset again. */
+ else {
+ output_frameset();
+ }
+
fflush(stdout);
if (content != NULL) {
free(content);
#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;
void serv_printf(const char *format, ...);
char *bstr();
+char *urlesc(char *);
+void urlescputs(char *);
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);
}
}
wprintf("</TABLE></CENTER>\n");
- printf("</BODY></HTML>\n");
+ wprintf("</BODY></HTML>\n");
wDumpContent();
}