From f072b76e977498d750a69b156340b6d2cf3e5bd1 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 28 Dec 1998 05:26:32 +0000 Subject: [PATCH] * Added "edit room info file" * Added "edit bio" --- webcit/ChangeLog | 4 +++ webcit/Makefile.in | 7 ++-- webcit/child.h | 5 +++ webcit/serv_func.c | 26 ++++++++++++++ webcit/sysmsgs.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ webcit/webcit.c | 17 +++++++++ 6 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 webcit/sysmsgs.c diff --git a/webcit/ChangeLog b/webcit/ChangeLog index a8f697fac..8e6ad9385 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,7 @@ +Mon Dec 28 00:26:01 EST 1998 Art Cancro + * Added "edit room info file" + * Added "edit bio" + Sat Dec 26 23:12:47 EST 1998 Art Cancro * Changed the "auto read new" functionality from a meta refresh tag to an "onload" directive (the former was causing graphics problems) diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 83d59bc63..a9ecdd2fa 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -35,9 +35,9 @@ snprintf.o: snprintf.c webcit: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ - roomops.o tools.o messages.o userlist.o paging.o + roomops.o tools.o messages.o userlist.o paging.o sysmsgs.o $(CC) webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ - tools.o roomops.o messages.o userlist.o paging.o -o webcit + tools.o roomops.o messages.o userlist.o paging.o sysmsgs.o -o webcit webcit.o: webcit.c webcit.h child.h $(CC) $(CFLAGS) $(DEFS) -c webcit.c @@ -72,6 +72,9 @@ messages.o: messages.c webcit.h child.h paging.o: paging.c webcit.h child.h $(CC) $(CFLAGS) $(DEFS) -c paging.c +sysmsgs.o: sysmsgs.c webcit.h child.h + $(CC) $(CFLAGS) $(DEFS) -c sysmsgs.c + Makefile: $(srcdir)/Makefile.in config.status CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/webcit/child.h b/webcit/child.h index 8a27b7508..62d893253 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -63,3 +63,8 @@ void display_entroom(void); void entroom(void); void display_editroom(void); void editroom(void); +void server_to_text(void); +void save_edit(char *description, char *enter_cmd, int regoto); +void display_edit(char *description, char *check_cmd, + char *read_cmd, char *save_cmd); +void gotoroom(char *gname, int display_name); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 087a7bc78..fd23284f4 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -152,3 +152,29 @@ void text_to_server(char *ptr) { serv_puts(buf); } + + + + + +/* + * translate server message output to text + * (used for editing room info files and such) + */ +void server_to_text() { + char buf[256]; + + int count = 0; + + while (serv_gets(buf), strcmp(buf, "000") ) { + if ( (buf[0] == 32) && (count > 0) ) { + wprintf("\n"); + } + wprintf("%s", buf); + ++count; + } + } + + + + diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c new file mode 100644 index 000000000..739b53fdb --- /dev/null +++ b/webcit/sysmsgs.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "child.h" + +/* + * display the form for editing something (room info, bio, etc) + */ +void display_edit(char *description, char *check_cmd, + char *read_cmd, char *save_cmd) { + char buf[256]; + + serv_puts(check_cmd); + serv_gets(buf); + + if (buf[0]!='2') { + display_error(&buf[4]); + return; + } + + printf("HTTP/1.0 200 OK\n"); + output_headers(1); + + wprintf("
"); + wprintf("Edit "); + escputs(description); + wprintf("
\n"); + + wprintf("
Enter %s below. Text is formatted to\n", description); + wprintf("the reader's screen width. To defeat the\n"); + wprintf("formatting, indent a line at least one space. \n"); + wprintf("
"); + + wprintf("
\n", save_cmd); + wprintf(""); + wprintf("
\n"); + wprintf("

\n"); + + wprintf("

\n"); + wDumpContent(); + } + + +/* + * save a screen which was displayed with display_edit() + */ +void save_edit(char *description, char *enter_cmd, int regoto) { + char buf[256]; + + if (strcmp(bstr("sc"),"Save")) { + printf("HTTP/1.0 200 OK\n"); + output_headers(1); + wprintf("Cancelled. %s was not saved.
\n", description); + wDumpContent(); + return; + } + + serv_puts(enter_cmd); + serv_gets(buf); + if (buf[0]!='4') { + display_error(&buf[4]); + return; + } + + text_to_server(bstr("msgtext")); + serv_puts("000"); + + if (regoto) { + gotoroom(wc_roomname, 1); + } + else { + printf("HTTP/1.0 200 OK\n"); + output_headers(1); + wprintf("%s has been saved.\n", description); + wDumpContent(); + } + } diff --git a/webcit/webcit.c b/webcit/webcit.c index 2fa13e76c..043094451 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -724,6 +724,23 @@ fclose(fp); editroom(); } + else if (!strcasecmp(action, "display_editinfo")) { + display_edit("Room info", "EINF 0", "RINF", "/editinfo"); + } + + else if (!strcasecmp(action, "editinfo")) { + save_edit("Room info", "EINF 1", 1); + } + + else if (!strcasecmp(action, "display_editbio")) { + sprintf(buf, "RBIO %s", wc_username); + display_edit("Your bio", "NOOP", buf, "editbio"); + } + + else if (!strcasecmp(action, "editbio")) { + save_edit("Your bio", "EBIO", 0); + } + /* When all else fails... */ else { printf("HTTP/1.0 200 OK\n"); -- 2.39.2