4 * Functions which handle Internet domain configuration etc.
14 #include <sys/types.h>
16 #include <sys/socket.h>
19 #include <netinet/in.h>
31 void display_inetconf(void)
48 char *ic_spec[ic_max];
51 char *ic_keyword[] = {
60 char *ic_boxtitle[] = {
70 "(domains for which this host receives mail)",
71 "(domains mapped with the Global Address Book)",
72 "(domains whose subdomains match Citadel hosts)",
73 "(if present, forward all outbound mail to one of these hosts)",
74 "(hosts running a Realtime Blackhole List)",
75 "(hosts running the SpamAssassin service)",
78 for (i=0; i<ic_max; ++i) {
79 ic_spec[i] = strdup("");
83 output_headers(1, 1, 2, 0, 0, 0, 0);
84 wprintf("<div id=\"banner\">\n");
85 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
86 wprintf("<SPAN CLASS=\"titlebar\">Internet configuration</SPAN>\n");
87 wprintf("</TD></TR></TABLE>\n");
88 wprintf("</div>\n<div id=\"content\">\n");
90 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
92 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
94 extract(ename, buf, 0);
95 extract(etype, buf, 1);
97 for (i=0; i<ic_max; ++i) {
98 if (!strcasecmp(etype, ic_keyword[i])) {
104 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
105 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
106 strcat(ic_spec[which], ename);
109 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
110 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
111 strcat(ic_misc, buf);
116 wprintf("<TABLE border=0 width=100%%><TR><TD VALIGN=TOP>\n");
117 for (which=0; which<ic_max; ++which) {
118 if (which == (ic_max / 2)) {
119 wprintf("</TD><TD VALIGN=TOP>");
121 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
122 do_template("beginbox");
123 wprintf("<span class=\"menudesc\">");
124 escputs(ic_desc[which]);
125 wprintf("</span><br />");
126 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
127 if (strlen(ic_spec[which]) > 0) {
128 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
129 wprintf("<TR><TD ALIGN=LEFT>");
130 extract_token(buf, ic_spec[which], i, '\n');
132 wprintf("</TD><TD ALIGN=RIGHT>"
133 "<A HREF=\"/save_inetconf?oper=delete&ename=");
135 wprintf("&etype=%s\" ", ic_keyword[which]);
136 wprintf("onClick=\"return confirm('Delete ");
139 wprintf("<font size=-1>(Delete)</font></a></TD></TR>\n");
142 wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_inetconf\">\n"
144 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
145 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
146 wprintf("</TD><TD ALIGN=RIGHT>"
147 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
148 "</TD></TR></TABLE></FORM>\n");
149 do_template("endbox");
151 wprintf("</TD></TR></TABLE>\n");
155 for (i=0; i<ic_max; ++i) {
162 void save_inetconf(void) {
166 char newconfig[65536];
168 strcpy(newconfig, "");
169 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
171 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
172 extract(ename, buf, 0);
173 extract(etype, buf, 1);
174 if (strlen(buf) == 0) {
175 /* skip blank lines */
177 else if ((!strcasecmp(ename, bstr("ename")))
178 && (!strcasecmp(etype, bstr("etype")))
179 && (!strcasecmp(bstr("oper"), "delete"))
181 sprintf(WC->ImportantMessage, "%s deleted.", ename);
184 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
185 strcat(newconfig, buf);
189 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
192 serv_puts(newconfig);
193 if (!strcasecmp(bstr("oper"), "add")) {
194 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
195 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));