5 * \defgroup InetCfg Functions which handle Internet domain configuration etc.
6 * \ingroup CitadelConfig
13 * \brief display the inet config dialog
15 void display_inetconf(void)
32 char *ic_spec[ic_max];
34 char *ic_keyword[ic_max];
35 char *ic_boxtitle[ic_max];
36 char *ic_desc[ic_max];
38 /* DON'T NEVER EVER AGAIN TRANSLATE CITADEL COMMANDS! */
39 ic_keyword[0] = "localhost";
40 ic_keyword[1] = "directory";
41 ic_keyword[2] = "gatewaydomain";
42 ic_keyword[3] = "smarthost";
43 ic_keyword[4] = "rbl";
44 ic_keyword[5] = "spamassassin";
46 ic_boxtitle[0] = _("Local host aliases");
47 ic_boxtitle[1] = _("Directory domains");
48 ic_boxtitle[2] = _("Gateway domains");
49 ic_boxtitle[3] = _("Smart hosts");
50 ic_boxtitle[4] = _("RBL hosts");
51 ic_boxtitle[5] = _("SpamAssassin hosts");
53 ic_desc[0] = _("(domains for which this host receives mail)");
54 ic_desc[1] = _("(domains mapped with the Global Address Book)");
55 ic_desc[2] = _("(domains whose subdomains match Citadel hosts)");
56 ic_desc[3] = _("(if present, forward all outbound mail to one of these hosts)");
57 ic_desc[4] = _("(hosts running a Realtime Blackhole List)");
58 ic_desc[5] = _("(hosts running the SpamAssassin service)");
60 for (i=0; i<ic_max; ++i) {
61 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 (strlen(ic_spec[which]) > 0) 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 (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
91 output_headers(1, 1, 2, 0, 0, 0);
92 wprintf("<div id=\"banner\">\n");
93 wprintf("<TABLE class=\"inetconf_banner\"><TR><TD>");
94 wprintf("<SPAN CLASS=\"titlebar\">");
95 wprintf(_("Internet configuration"));
97 wprintf("</TD></TR></TABLE>\n");
98 wprintf("</div>\n<div id=\"content\">\n");
100 wprintf("<div class=\"fix_scrollbar_bug\">"
101 "<table border=0 width=100%%><tr><td valign=top>\n");
102 for (which=0; which<ic_max; ++which) {
103 if (which == (ic_max / 2)) {
104 wprintf("</TD><TD VALIGN=TOP>");
106 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
107 do_template("beginbox");
108 wprintf("<span class=\"menudesc\">");
109 escputs(ic_desc[which]);
110 wprintf("</span><br />");
111 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
112 if (strlen(ic_spec[which]) > 0) {
113 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
114 wprintf("<TR><TD ALIGN=LEFT>");
115 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
117 wprintf("</TD><TD ALIGN=RIGHT>"
118 "<a href=\"save_inetconf?oper=delete&ename=");
120 wprintf("&etype=%s\" ", ic_keyword[which]);
121 wprintf("onClick=\"return confirm('%s');\">",
122 _("Delete this entry?"));
123 wprintf("<font size=-1>");
124 wprintf(_("(Delete)"));
125 wprintf("</font></a></TD></TR>\n");
128 wprintf("<FORM METHOD=\"POST\" action=\"save_inetconf\">\n"
130 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
131 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
132 wprintf("</TD><TD ALIGN=RIGHT>"
133 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
134 "</TD></TR></TABLE></FORM>\n");
135 do_template("endbox");
137 wprintf("</td></tr></table></div>\n");
140 for (i=0; i<ic_max; ++i) {
148 * \brief save changes to the inet config
150 void save_inetconf(void) {
159 newconfig = malloc(65536);
161 strcpy(newconfig, "");
162 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
163 serv_getln(buf, SIZ);
164 if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
165 extract_token(ename, buf, 0, '|', SIZ);
166 extract_token(etype, buf, 1, '|', SIZ);
167 if (strlen(buf) == 0) {
168 /** skip blank lines */
170 else if ((!strcasecmp(ename, bstr("ename")))
171 && (!strcasecmp(etype, bstr("etype")))
172 && (!strcasecmp(bstr("oper"), "delete"))
174 sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
177 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
178 strcat(newconfig, buf);
182 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
183 serv_getln(buf, SIZ);
185 serv_puts(newconfig);
186 if (!strcasecmp(bstr("oper"), "add")) {
187 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
188 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));