From: Art Cancro Date: Sat, 12 Dec 1998 05:44:05 +0000 (+0000) Subject: * Brought over message reading and entry functions from old WebCit X-Git-Tag: v7.86~8024 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=ba79b6433024687dd457f83213db3583be9ba2e4;p=citadel.git * Brought over message reading and entry functions from old WebCit --- diff --git a/webcit/.cvsignore b/webcit/.cvsignore index 31918c35b..9e4963171 100644 --- a/webcit/.cvsignore +++ b/webcit/.cvsignore @@ -7,3 +7,4 @@ config.h.in configure webcit webserver +content diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 7fd4d9bd9..694c874fa 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,5 +1,5 @@ Fri Dec 11 21:14:36 EST 1998 Art Cancro - * Brought over message reading functions from old WebCit + * Brought over message reading and entry functions from old WebCit 1998-12-10 Nathan Bryant * context_loop.c: really fix the SO_LINGER stuff diff --git a/webcit/child.h b/webcit/child.h index 5d3b69eb9..d4b5c85cc 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -41,3 +41,6 @@ void embed_main_menu(void); void serv_read(char *buf, int bytes); int haschar(char *st, char ch); void readloop(char *oper); +void text_to_server(char *ptr); +void display_enter(void); +void post_message(void); diff --git a/webcit/messages.c b/webcit/messages.c index 31b778e18..2f6ee125e 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -256,3 +256,125 @@ DONE: wprintf("\n"); } + + +/* + * post message (or don't post message) + */ +void post_message(void) { + char buf[256]; + + printf("HTTP/1.0 200 OK\n"); + output_headers(); + wprintf(""); + wprintf("\n"); + + strcpy(buf, bstr("sc")); + if (strcasecmp(buf, "Save message")) { + wprintf("Cancelled. Message was not posted.
\n"); + dump_vars(); + } + + else { + sprintf(buf,"ENT0 1|%s|0|0",bstr("recp")); + serv_puts(buf); + serv_gets(buf); + if (buf[0]=='4') { + text_to_server(bstr("msgtext")); + serv_puts("000"); + wprintf("Message has been posted.
\n"); + } + else { + wprintf("%s
\n",&buf[4]); + } + } + + wprintf("\n"); + wDumpContent(); + } + + + + + + + + +/* + * prompt for a recipient (to be called from display_enter() only) + */ +void prompt_for_recipient() { + + wprintf("
"); + wprintf("Send private e-mail\n"); + wprintf("
\n"); + + wprintf("
"); + wprintf("
\n"); + wprintf("Enter recipient: "); + wprintf("
\n"); + wprintf(""); + wprintf(""); + wprintf("
\n"); + } + + + +/* + * display the message entry screen + */ +void display_enter(void) { + char buf[256]; + long now; + struct tm *tm; + + printf("HTTP/1.0 200 OK\n"); + output_headers(); + wprintf(""); + wprintf("\n"); + + sprintf(buf,"ENT0 0|%s|0|0",bstr("recp")); + serv_puts(buf); + serv_gets(buf); + + if (!strncmp(buf,"570",3)) { + if (strlen(bstr("recp"))>0) { + wprintf("%s
\n",&buf[4]); + } + prompt_for_recipient(); + goto DONE; + } + + if (buf[0]!='2') { + wprintf("%s
\n",&buf[4]); + goto DONE; + } + + wprintf("
Enter message below. Messages are formatted to\n"); + wprintf("the reader's screen width. To defeat the\n"); + wprintf("formatting, indent a line at least one space. \n"); + wprintf("
"); + + time(&now); + tm=(struct tm *)localtime(&now); + strcpy(buf,(char *)asctime(tm)); buf[strlen(buf)-1]=0; + strcpy(&buf[16],&buf[19]); + wprintf("
%s ",&buf[4]); + wprintf("from %s ",wc_username); + if (strlen(bstr("recp"))>0) wprintf("to %s ",bstr("recp")); + wprintf("in %s> ",wc_roomname); + wprintf("
\n"); + + wprintf("
\n"); + wprintf("\n", + bstr("recp")); + wprintf(""); + wprintf("
\n"); + + wprintf("

\n"); + + wprintf("

\n"); +DONE: wprintf("\n"); + wDumpContent(); + } diff --git a/webcit/roomops.c b/webcit/roomops.c index bd26fe7a1..72126a580 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -237,7 +237,20 @@ void gotoroom(char *gname, int display_name) extract_int(&buf[4],1), extract_int(&buf[4],2)); - /* FIX add room image here */ + /* Display room graphic. The server doesn't actually need the + * room name, but we supply it in order to keep the browser + * from using a cached graphic from another room. + */ + serv_puts("OIMG _roompic_"); + serv_gets(buf); + if (buf[0]=='2') { + wprintf(""); + wprintf(""); + serv_puts("CLOS"); + serv_gets(buf); + } wprintf(""); readinfo(0); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 9c894e03b..087a7bc78 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -111,3 +111,44 @@ void fmout(FILE *fp) } } + + + + + +/* + * transmit message text (in memory) to the server + */ +void text_to_server(char *ptr) { + char buf[256]; + int ch,a,pos; + + pos = 0; + + strcpy(buf,""); + while (ptr[pos]!=0) { + ch = ptr[pos++]; + if (ch==10) { + while (isspace(buf[strlen(buf)-1])) + buf[strlen(buf)-1]=0; + serv_puts(buf); + strcpy(buf,""); + } + else { + a = strlen(buf); + buf[a+1] = 0; + buf[a] = ch; + if ((ch==32)&&(strlen(buf)>200)) { + buf[a]=0; + serv_puts(buf); + strcpy(buf,""); + } + if (strlen(buf)>250) { + serv_puts(buf); + strcpy(buf,""); + } + } + } + serv_puts(buf); + } + diff --git a/webcit/webcit.c b/webcit/webcit.c index e0c731829..f828791ad 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -102,10 +102,10 @@ void addurls(char *url) { for (a=0; aurl_data = malloc(strlen(up)); + u->url_data = malloc(strlen(up)+1); strcpy(u->url_data, up); + u->url_data[b] = 0; unescape_input(u->url_data); - up = ptr; ++up; } @@ -571,6 +571,14 @@ fclose(fp); readloop("readfwd"); } + else if (!strcasecmp(action, "display_enter")) { + display_enter(); + } + + else if (!strcasecmp(action, "post")) { + post_message(); + } + /* When all else fails... */ else { printf("HTTP/1.0 200 OK\n");