* Made the frames stuff less dependent on the HTML TARGET= directive
[citadel.git] / webcit / sysmsgs.c
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <signal.h>
5 #include <sys/types.h>
6 #include <ctype.h>
7 #include <string.h>
8 #include "webcit.h"
9 #include "child.h"
10
11 /*
12  * display the form for editing something (room info, bio, etc)
13  */
14 void display_edit(char *description, char *check_cmd,
15                 char *read_cmd, char *save_cmd) {
16         char buf[256];
17
18         serv_puts(check_cmd);
19         serv_gets(buf);
20
21         if (buf[0]!='2') {
22                 display_error(&buf[4]);
23                 return;
24                 }
25
26         printf("HTTP/1.0 200 OK\n");
27         output_headers(1, "bottom");
28
29         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
30         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
31         wprintf("<B>Edit ");
32         escputs(description);
33         wprintf("</B></FONT></TD></TR></TABLE>\n");
34
35         wprintf("<CENTER>Enter %s below.  Text is formatted to\n", description);
36         wprintf("the <EM>reader's</EM> screen width.  To defeat the\n");
37         wprintf("formatting, indent a line at least one space.  \n");
38         wprintf("<BR>");
39
40         wprintf("<FORM METHOD=\"POST\" ACTION=\"%s\">\n", save_cmd);
41         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">");
42         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
43         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 WIDTH=80>");
44         serv_puts(read_cmd);
45         serv_gets(buf);
46         if (buf[0] == '1') server_to_text();
47         wprintf("</TEXTAREA><P>\n");
48
49         wprintf("</FORM></CENTER></BODY></HTML>\n");
50         wDumpContent();
51         }
52
53
54 /*
55  * save a screen which was displayed with display_edit()
56  */
57 void save_edit(char *description, char *enter_cmd, int regoto) {
58         char buf[256];
59
60         if (strcmp(bstr("sc"),"Save")) {
61                 printf("HTTP/1.0 200 OK\n");
62                 output_headers(1, "bottom");
63                 wprintf("Cancelled.  %s was not saved.<BR>\n", description);
64                 wDumpContent();
65                 return;
66                 }
67
68         serv_puts(enter_cmd);
69         serv_gets(buf);
70         if (buf[0]!='4') {
71                 display_error(&buf[4]);
72                 return;
73                 }
74
75         text_to_server(bstr("msgtext"));
76         serv_puts("000");
77
78         if (regoto) {
79                 gotoroom(wc_roomname, 1);
80                 }
81         else {
82                 printf("HTTP/1.0 200 OK\n");
83                 output_headers(1, "bottom");
84                 wprintf("%s has been saved.</BODY></HTML>\n", description);
85                 wDumpContent();
86                 }
87         }