* Replaced serv_gets() with serv_getln() - which now requires the caller
[citadel.git] / webcit / floors.c
index ebcafcaef81e8998a1f65d9e4c59476a929447fc..ceb2e5087521123e20a4f3df7eea518625b6e82d 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * $Id$
+ *
  * Administrative screens for floor maintenance
  *
  */
@@ -24,6 +26,7 @@
 #include <pthread.h>
 #include <signal.h>
 #include "webcit.h"
+#include "webserver.h"
 
 
 
@@ -40,45 +43,56 @@ void display_floorconfig(char *prepend_html)
        char floorname[SIZ];
        int refcount;
 
-       output_headers(3);
-
+        output_headers(1, 1, 2, 0, 0, 0, 0);
+        wprintf("<div id=\"banner\">\n"
+                "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
+                "<SPAN CLASS=\"titlebar\">Add/change/delete floors</SPAN>"
+                "</TD></TR></TABLE>\n"
+                "</div>\n<div id=\"content\">\n"
+        );
+                                                                                                                             
        if (prepend_html != NULL) {
-               write(WC->http_sock, prepend_html, strlen(prepend_html));
+               wprintf("<br /><b><i>");
+               client_write(prepend_html, strlen(prepend_html));
+               wprintf("</i></b><br /><br />\n");
        }
 
-       serv_printf("LFLR");    /* FIXME put a real test here */
-       serv_gets(buf);
+       serv_printf("LFLR");
+       serv_getln(buf, sizeof 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]);
+               wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
+               wprintf("<SPAN CLASS=\"titlebar\">Error</SPAN>\n");
+               wprintf("</TD></TR></TABLE>\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"
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<TABLE BORDER=1 WIDTH=100%% bgcolor=\"#ffffff\">\n"
                "<TR><TH>Floor number</TH>"
                "<TH>Floor name</TH>"
                "<TH>Number of rooms</TH></TR>\n"
        );
 
-       while (serv_gets(buf), strcmp(buf, "000")) {
+       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                floornum = extract_int(buf, 0);
-               extract(floorname, buf, 1);
+               extract_token(floorname, buf, 1, '|', sizeof floorname);
                refcount = extract_int(buf, 2);
 
-               wprintf("<TR><TD>%d", floornum);
+               wprintf("<TR><TD><TABLE border=0><TR><TD>%d", floornum);
                if (refcount == 0) {
-                       wprintf(" <A HREF=\"/delete_floor?floornum=%d\">"
-                               "(delete floor)</A>");
+                       wprintf("</TD><TD>"
+                               "<A HREF=\"/delete_floor?floornum=%d\">"
+                               "<FONT SIZE=-1>(delete floor)</A>"
+                               "</FONT><br />", floornum
+                       );
                }
+               wprintf("<FONT SIZE=-1>"
+                       "<A HREF=\"/display_editfloorpic&"
+                       "which_floor=%d\">(edit graphic)</A>",
+                       floornum);
+               wprintf("</TD></TR></TABLE>");
                wprintf("</TD>");
 
                wprintf("<TD>"
@@ -104,8 +118,7 @@ void display_floorconfig(char *prepend_html)
                "</FORM></TD>"
                "<TD>&nbsp;</TD></TR>\n");
 
-       wprintf("</TABLE>\n");
-
+       wprintf("</table></div>\n");
        wDumpContent(1);
 }
 
@@ -119,14 +132,13 @@ void delete_floor(void) {
        floornum = atoi(bstr("floornum"));
 
        serv_printf("KFLR %d|1", floornum);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
        if (buf[0] == '2') {
-               sprintf(message, "<B><I>Floor has been deleted."
-                               "</I></B><BR><BR>\n");
+               sprintf(message, "Floor has been deleted.");
        }
        else {
-               sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+               sprintf(message, "%s", &buf[4]);
        }
 
        display_floorconfig(message);
@@ -141,9 +153,13 @@ void create_floor(void) {
        strcpy(floorname, bstr("floorname"));
 
        serv_printf("CFLR %s|1", floorname);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
-       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+       if (buf[0] == '2') {
+               sprintf(message, "New floor has been created.");
+       } else {
+               sprintf(message, "%s", &buf[4]);
+       }
 
        display_floorconfig(message);
 }
@@ -159,9 +175,9 @@ void rename_floor(void) {
        strcpy(floorname, bstr("floorname"));
 
        serv_printf("EFLR %d|%s", floornum, floorname);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
-       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+       sprintf(message, "%s", &buf[4]);
 
        display_floorconfig(message);
 }