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 \
$(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
--- /dev/null
+/*
+ * 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> </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> </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);
+}
+
+
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"));
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);