* Better alignment of system messages
[citadel.git] / webcit / sysmsgs.c
1
2
3 #include <ctype.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <fcntl.h>
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <sys/wait.h>
11 #include <sys/socket.h>
12 #include <sys/time.h>
13 #include <limits.h>
14 #include <netinet/in.h>
15 #include <netdb.h>
16 #include <string.h>
17 #include <pwd.h>
18 #include <errno.h>
19 #include <stdarg.h>
20 #include <pthread.h>
21 #include <signal.h>
22 #include "webcit.h"
23
24
25
26
27
28
29
30
31 /*
32  * display the form for editing something (room info, bio, etc)
33  */
34 void display_edit(char *description, char *check_cmd,
35                   char *read_cmd, char *save_cmd, int headers_type)
36 {
37         char buf[SIZ];
38
39         serv_puts(check_cmd);
40         serv_gets(buf);
41
42         if (buf[0] != '2') {
43                 strcpy(WC->ImportantMessage, &buf[4]);
44                 display_main_menu();
45                 return;
46         }
47         output_headers(headers_type);
48
49         svprintf("BOXTITLE", WCS_STRING, "Edit %s", description);
50         do_template("beginbox");
51
52         wprintf("<CENTER>Enter %s below.  Text is formatted to\n", description);
53         wprintf("the <EM>reader's</EM> screen width.  To defeat the\n");
54         wprintf("formatting, indent a line at least one space.  \n");
55         wprintf("<BR>");
56
57         wprintf("<FORM METHOD=\"POST\" ACTION=\"%s\">\n", save_cmd);
58         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft "
59                 "ROWS=10 COLS=80 WIDTH=80>\n");
60         serv_puts(read_cmd);
61         serv_gets(buf);
62         if (buf[0] == '1')
63                 server_to_text();
64         wprintf("</TEXTAREA><BR><BR>\n");
65         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">");
66         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
67
68         wprintf("</FORM></CENTER>\n");
69         do_template("endbox");
70         wDumpContent(1);
71 }
72
73
74 /*
75  * save a screen which was displayed with display_edit()
76  */
77 void save_edit(char *description, char *enter_cmd, int regoto)
78 {
79         char buf[SIZ];
80
81         if (strcmp(bstr("sc"), "Save")) {
82                 sprintf(WC->ImportantMessage,
83                         "Cancelled.  %s was not saved.\n", description);
84                 display_main_menu();
85                 return;
86         }
87         serv_puts(enter_cmd);
88         serv_gets(buf);
89         if (buf[0] != '4') {
90                 strcpy(WC->ImportantMessage, &buf[4]);
91                 display_main_menu();
92                 return;
93         }
94         text_to_server(bstr("msgtext"), 0);
95         serv_puts("000");
96
97         if (regoto) {
98                 smart_goto(WC->wc_roomname);
99         } else {
100                 sprintf(WC->ImportantMessage,
101                         "%s has been saved.\n", description);
102                 display_main_menu();
103                 return;
104         }
105 }