4 * Functions which handle Internet domain configuration etc.
10 * display the inet config dialog
12 void display_inetconf(void)
31 char *ic_spec[ic_max];
33 char *ic_keyword[ic_max];
34 char *ic_boxtitle[ic_max];
35 char *ic_desc[ic_max];
37 /* These are server config keywords; do not localize! */
38 ic_keyword[0] = "localhost";
39 ic_keyword[1] = "directory";
40 ic_keyword[2] = "smarthost";
41 ic_keyword[3] = "rbl";
42 ic_keyword[4] = "spamassassin";
43 ic_keyword[5] = "masqdomain";
45 ic_boxtitle[0] = _("Local host aliases");
46 ic_boxtitle[1] = _("Directory domains");
47 ic_boxtitle[2] = _("Smart hosts");
48 ic_boxtitle[3] = _("RBL hosts");
49 ic_boxtitle[4] = _("SpamAssassin hosts");
50 ic_boxtitle[5] = _("Masqueradable domains");
52 ic_desc[0] = _("(domains for which this host receives mail)");
53 ic_desc[1] = _("(domains mapped with the Global Address Book)");
54 ic_desc[2] = _("(if present, forward all outbound mail to one of these hosts)");
55 ic_desc[3] = _("(hosts running a Realtime Blackhole List)");
56 ic_desc[4] = _("(hosts running the SpamAssassin service)");
57 ic_desc[5] = _("(Domains as which users are allowed to masquerade)");
59 for (i=0; i<ic_max; ++i) {
60 ic_spec[i] = strdup("");
65 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
66 serv_getln(buf, sizeof buf);
67 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
69 extract_token(ename, buf, 0, '|', sizeof ename);
70 extract_token(etype, buf, 1, '|', sizeof etype);
72 for (i=0; i<ic_max; ++i) {
73 if (!strcasecmp(etype, ic_keyword[i])) {
79 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
80 if (!IsEmptyStr(ic_spec[which])) strcat(ic_spec[which], "\n");
81 strcat(ic_spec[which], ename);
84 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
85 if (!IsEmptyStr(ic_misc)) strcat(ic_misc, "\n");
91 output_headers(1, 1, 2, 0, 0, 0);
92 wprintf("<div id=\"banner\">\n");
94 wprintf(_("Internet configuration"));
98 wprintf("<div id=\"content\" class=\"service\">\n");
100 wprintf("<div class=\"fix_scrollbar_bug\">"
101 "<table border=0 width=100%% cellspacing=\"10px\" cellpadding=\"10px\"> "
102 "<tr><td valign=top width=50%%>\n");
103 for (which=0; which<ic_max; ++which) {
104 if (which == (ic_max / 2)) {
105 wprintf("</td><td valign=top>");
107 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
108 do_template("beginbox");
109 wprintf("<span class=\"menudesc\">");
110 escputs(ic_desc[which]);
111 wprintf("</span><br />");
112 wprintf("<table border=0 cellspacing=\"2px\" cellpadding=\"2px\" width=94%% "
113 "class=\"altern\" >\n");
115 if (!IsEmptyStr(ic_spec[which])) {
116 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
118 wprintf("<tr class=\"%s\">",
119 (bg ? "even" : "odd")
121 wprintf("<td align=left>");
122 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
124 wprintf("</td><td align=left>"
125 "<span class=\"button_link\">"
126 "<a href=\"save_inetconf?oper=delete&ename=");
128 wprintf("&etype=%s\" ", ic_keyword[which]);
129 wprintf("onClick=\"return confirm('%s');\">",
130 _("Delete this entry?"));
131 wprintf(_("Delete"));
132 wprintf("</a></span></td></tr>\n");
136 wprintf("<form method=\"post\" action=\"save_inetconf\">\n");
137 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
139 "<input type=\"text\" name=\"ename\" maxlength=\"64\">"
140 "<input type=\"hidden\" name=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
141 wprintf("</td><td align=left>"
142 "<input type=\"submit\" name=\"oper\" value=\"Add\">"
143 "</td></tr></table></form>\n");
144 do_template("endbox");
147 wprintf("</td></tr></table></div>\n");
150 for (i=0; i<ic_max; ++i) {
158 * save changes to the inet config
160 void save_inetconf(void) {
169 newconfig = malloc(65536);
171 strcpy(newconfig, "");
172 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
173 serv_getln(buf, SIZ);
174 if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
175 extract_token(ename, buf, 0, '|', SIZ);
176 extract_token(etype, buf, 1, '|', SIZ);
177 if (IsEmptyStr(buf)) {
178 /* skip blank lines */
180 else if ((!strcasecmp(ename, bstr("ename")))
181 && (!strcasecmp(etype, bstr("etype")))
182 && (!strcasecmp(bstr("oper"), "delete"))
184 sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
187 if (!IsEmptyStr(newconfig)) strcat(newconfig, "\n");
188 strcat(newconfig, buf);
192 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
193 serv_getln(buf, SIZ);
195 serv_puts(newconfig);
196 if (!strcasecmp(bstr("oper"), "add")) {
197 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
198 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));