4 * Functions which handle Internet domain configuration etc.
15 #include <sys/types.h>
17 #include <sys/socket.h>
20 #include <netinet/in.h>
32 void display_inetconf(void)
49 char *ic_spec[ic_max];
52 char *ic_keyword[] = {
61 char *ic_boxtitle[] = {
71 "(domains for which this host receives mail)",
72 "(domains mapped with the Global Address Book)",
73 "(domains whose subdomains match Citadel hosts)",
74 "(if present, forward all outbound mail to one of these hosts)",
75 "(hosts running a Realtime Blackhole List)",
76 "(hosts running the SpamAssassin service)",
79 for (i=0; i<ic_max; ++i) {
80 ic_spec[i] = strdup("");
84 output_headers(1, 1, 2, 0, 0, 0, 0);
85 wprintf("<div id=\"banner\">\n");
86 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
87 wprintf("<SPAN CLASS=\"titlebar\">Internet configuration</SPAN>\n");
88 wprintf("</TD></TR></TABLE>\n");
89 wprintf("</div><div id=\"text\">\n");
91 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
93 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
95 extract(ename, buf, 0);
96 extract(etype, buf, 1);
98 for (i=0; i<ic_max; ++i) {
99 if (!strcasecmp(etype, ic_keyword[i])) {
105 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
106 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
107 strcat(ic_spec[which], ename);
110 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
111 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
112 strcat(ic_misc, buf);
117 wprintf("<TABLE border=0 width=100%%><TR><TD VALIGN=TOP>\n");
118 for (which=0; which<ic_max; ++which) {
119 if (which == (ic_max / 2)) {
120 wprintf("</TD><TD VALIGN=TOP>");
122 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
123 do_template("beginbox");
124 wprintf("<span class=\"menudesc\">");
125 escputs(ic_desc[which]);
126 wprintf("</span><br />");
127 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
128 if (strlen(ic_spec[which]) > 0) {
129 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
130 wprintf("<TR><TD ALIGN=LEFT>");
131 extract_token(buf, ic_spec[which], i, '\n');
133 wprintf("</TD><TD ALIGN=RIGHT>"
134 "<A HREF=\"/save_inetconf?oper=delete&ename=");
136 wprintf("&etype=%s\" ", ic_keyword[which]);
137 wprintf("onClick=\"return confirm('Delete ");
140 wprintf("<font size=-1>(Delete)</font></a></TD></TR>\n");
143 wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_inetconf\">\n"
145 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
146 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
147 wprintf("</TD><TD ALIGN=RIGHT>"
148 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
149 "</TD></TR></TABLE></FORM>\n");
150 do_template("endbox");
152 wprintf("</TD></TR></TABLE>\n");
156 for (i=0; i<ic_max; ++i) {
163 void save_inetconf(void) {
167 char newconfig[65536];
169 strcpy(newconfig, "");
170 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
172 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
173 extract(ename, buf, 0);
174 extract(etype, buf, 1);
175 if (strlen(buf) == 0) {
176 /* skip blank lines */
178 else if ((!strcasecmp(ename, bstr("ename")))
179 && (!strcasecmp(etype, bstr("etype")))
180 && (!strcasecmp(bstr("oper"), "delete"))
182 sprintf(WC->ImportantMessage, "%s deleted.", ename);
185 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
186 strcat(newconfig, buf);
190 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
193 serv_puts(newconfig);
194 if (!strcasecmp(bstr("oper"), "add")) {
195 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
196 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));