* Commands to add, change, delete floors
authorArt Cancro <ajc@citadel.org>
Mon, 5 Aug 2002 15:53:00 +0000 (15:53 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 5 Aug 2002 15:53:00 +0000 (15:53 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/floors.c [new file with mode: 0644]
webcit/mainmenu.c
webcit/webcit.c
webcit/webcit.h

index 5095b0d64557a4c0c9a0ca98337646cfc6f7e2a6..12e1ae655d28c263ce26cc61c155196b3dff456d 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 323.54  2002/08/05 15:53:00  ajc
+* Commands to add, change, delete floors
+
 Revision 323.53  2002/07/26 03:20:04  ajc
 * Beautified the folder tabs in "edit room"
 
@@ -884,4 +887,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index f9b04c1c2070ed4c7f14700425d82929a2ded1c5..8d73ab61ac727df5d6b76207a12560155fc8668c 100644 (file)
@@ -23,7 +23,7 @@ distclean: clean
 
 
 webserver: webserver.o context_loop.o tools.o \
-       cookie_conversion.o locate_host.o \
+       cookie_conversion.o locate_host.o floors.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
        roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \
        vcard.o vcard_edit.o preferences.o html2html.o \
@@ -31,7 +31,7 @@ webserver: webserver.o context_loop.o tools.o \
        $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
        roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \
-       locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o \
+       locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o floors.o \
        mime_parser.o graphics.o netconf.o preferences.o html2html.o \
        $(LIBOBJS) $(LIBS) -o webserver
 
diff --git a/webcit/floors.c b/webcit/floors.c
new file mode 100644 (file)
index 0000000..ebcafca
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Administrative screens for floor maintenance
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#include "webcit.h"
+
+
+
+
+/*
+ * Display floor configuration.  If prepend_html is not NULL, its contents
+ * will be displayed at the top of the screen.
+ */
+void display_floorconfig(char *prepend_html)
+{
+       char buf[SIZ];
+
+       int floornum;
+       char floorname[SIZ];
+       int refcount;
+
+       output_headers(3);
+
+       if (prepend_html != NULL) {
+               write(WC->http_sock, prepend_html, strlen(prepend_html));
+       }
+
+       serv_printf("LFLR");    /* FIXME put a real test here */
+       serv_gets(buf);
+       if (buf[0] != '1') {
+               wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
+               wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+               wprintf("<B>Error</B>\n");
+               wprintf("</FONT></TD></TR></TABLE><BR>\n");
+               wprintf("%s<BR>\n", &buf[4]);
+               wDumpContent(1);
+               return;
+       }
+
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
+               "<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Floor configuration"
+               "</B></FONT></TD></TR></TABLE>\n"
+       );
+
+       wprintf("<TABLE BORDER=1 WIDTH=100%>\n"
+               "<TR><TH>Floor number</TH>"
+               "<TH>Floor name</TH>"
+               "<TH>Number of rooms</TH></TR>\n"
+       );
+
+       while (serv_gets(buf), strcmp(buf, "000")) {
+               floornum = extract_int(buf, 0);
+               extract(floorname, buf, 1);
+               refcount = extract_int(buf, 2);
+
+               wprintf("<TR><TD>%d", floornum);
+               if (refcount == 0) {
+                       wprintf(" <A HREF=\"/delete_floor?floornum=%d\">"
+                               "(delete floor)</A>");
+               }
+               wprintf("</TD>");
+
+               wprintf("<TD>"
+                       "<FORM METHOD=\"POST\" ACTION=\"/rename_floor\">"
+                       "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
+                       "VALUE=\"%d\">"
+                       "<INPUT TYPE=\"text\" NAME=\"floorname\" "
+                       "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
+                       floornum, floorname);
+               wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
+                       "VALUE=\"Change name\">"
+                       "</FORM></TD>");
+
+               wprintf("<TD>%d</TD></TR>\n", refcount);
+       }
+
+       wprintf("<TR><TD>&nbsp;</TD>"
+               "<TD><FORM METHOD=\"POST\" ACTION=\"/create_floor\">"
+               "<INPUT TYPE=\"text\" NAME=\"floorname\" "
+               "MAXLENGTH=\"250\">\n"
+               "<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
+               "VALUE=\"Create new floor\">"
+               "</FORM></TD>"
+               "<TD>&nbsp;</TD></TR>\n");
+
+       wprintf("</TABLE>\n");
+
+       wDumpContent(1);
+}
+
+
+
+void delete_floor(void) {
+       int floornum;
+       char buf[SIZ];
+       char message[SIZ];
+
+       floornum = atoi(bstr("floornum"));
+
+       serv_printf("KFLR %d|1", floornum);
+       serv_gets(buf);
+
+       if (buf[0] == '2') {
+               sprintf(message, "<B><I>Floor has been deleted."
+                               "</I></B><BR><BR>\n");
+       }
+       else {
+               sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+       }
+
+       display_floorconfig(message);
+}
+
+
+void create_floor(void) {
+       char buf[SIZ];
+       char message[SIZ];
+       char floorname[SIZ];
+
+       strcpy(floorname, bstr("floorname"));
+
+       serv_printf("CFLR %s|1", floorname);
+       serv_gets(buf);
+
+       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+
+       display_floorconfig(message);
+}
+
+
+void rename_floor(void) {
+       int floornum;
+       char buf[SIZ];
+       char message[SIZ];
+       char floorname[SIZ];
+
+       floornum = atoi(bstr("floornum"));
+       strcpy(floorname, bstr("floorname"));
+
+       serv_printf("EFLR %d|%s", floornum, floorname);
+       serv_gets(buf);
+
+       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+
+       display_floorconfig(message);
+}
+
+
index c9855d6132b4e5b926da77f51ee8ddd7b4453eba..805506d068bd6edb2061eee2d291b4559cceaf38 100644 (file)
@@ -177,6 +177,9 @@ void display_main_menu(void)
                        wprintf("<LI><A HREF=\"/validate\">\n");
                        wprintf("Validate new users</A>\n");
 
+                       wprintf("<LI><A HREF=\"/display_floorconfig\">\n");
+                       wprintf("Add, change, or delete floors</A>\n");
+
                        wprintf("<LI><A HREF=\"/select_floor_to_edit_pic\">\n");
                        wprintf("Set or change a floor label graphic</A>\n");
 
index 71df42ecae109c486b7043049b0e165ba3926e4b..5bf13354ef4ff34c50d206a9fe98071e3a6a06b1 100644 (file)
@@ -1055,6 +1055,12 @@ void session_loop(struct httprequest *req)
                do_graphics_upload("UIMG 1|_roompic_");
        } else if (!strcasecmp(action, "select_floor_to_edit_pic")) {
                select_floor_to_edit_pic();
+       } else if (!strcasecmp(action, "delete_floor")) {
+               delete_floor();
+       } else if (!strcasecmp(action, "rename_floor")) {
+               rename_floor();
+       } else if (!strcasecmp(action, "create_floor")) {
+               create_floor();
        } else if (!strcasecmp(action, "display_editfloorpic")) {
                sprintf(buf, "UIMG 0|_floorpic_|%s",
                        bstr("which_floor"));
@@ -1126,6 +1132,8 @@ void session_loop(struct httprequest *req)
                do_stuff_to_msgs();
        } else if (!strcasecmp(action, "change_start_page")) {
                change_start_page();
+       } else if (!strcasecmp(action, "display_floorconfig")) {
+               display_floorconfig(NULL);
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1);
 
index 500fa6f1bf94a49c55bb7c28e3494b2aa48b5733..9797ed593bf413224ca591a86de0ffd2f2c10e4b 100644 (file)
@@ -315,3 +315,7 @@ void display_addressbook(long msgnum, char alpha);
 void offer_start_page(void);
 void change_start_page(void);
 void output_html(void);
+void display_floorconfig(char *);
+void delete_floor(void);
+void create_floor(void);
+void rename_floor(void);