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 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
84 serv_getln(buf, sizeof buf);
85 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
87 extract_token(ename, buf, 0, '|', sizeof ename);
88 extract_token(etype, buf, 1, '|', sizeof etype);
90 for (i=0; i<ic_max; ++i) {
91 if (!strcasecmp(etype, ic_keyword[i])) {
97 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
98 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
99 strcat(ic_spec[which], ename);
102 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
103 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
104 strcat(ic_misc, buf);
109 output_headers(1, 1, 2, 0, 0, 0, 0);
110 wprintf("<div id=\"banner\">\n");
111 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
112 wprintf("<SPAN CLASS=\"titlebar\">Internet configuration</SPAN>\n");
113 wprintf("</TD></TR></TABLE>\n");
114 wprintf("</div>\n<div id=\"content\">\n");
116 wprintf("<div id=\"fix_scrollbar_bug\">"
117 "<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', sizeof buf);
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></div>\n");
155 for (i=0; i<ic_max; ++i) {
162 void save_inetconf(void) {
171 newconfig = malloc(65536);
173 strcpy(newconfig, "");
174 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
175 serv_getln(buf, sizeof buf);
176 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
177 extract_token(ename, buf, 0, '|', sizeof ename);
178 extract_token(etype, buf, 1, '|', sizeof etype);
179 if (strlen(buf) == 0) {
180 /* skip blank lines */
182 else if ((!strcasecmp(ename, bstr("ename")))
183 && (!strcasecmp(etype, bstr("etype")))
184 && (!strcasecmp(bstr("oper"), "delete"))
186 sprintf(WC->ImportantMessage, "%s deleted.", ename);
189 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
190 strcat(newconfig, buf);
194 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
195 serv_getln(buf, sizeof buf);
197 serv_puts(newconfig);
198 if (!strcasecmp(bstr("oper"), "add")) {
199 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
200 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));