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)
33 char *ic_spec[ic_max];
35 char *ic_keyword[ic_max];
36 char *ic_boxtitle[ic_max];
37 char *ic_desc[ic_max];
39 /* DON'T NEVER EVER AGAIN TRANSLATE CITADEL COMMANDS! */
40 ic_keyword[0] = "localhost";
41 ic_keyword[1] = "directory";
42 ic_keyword[2] = "gatewaydomain";
43 ic_keyword[3] = "smarthost";
44 ic_keyword[4] = "rbl";
45 ic_keyword[5] = "spamassassin";
46 ic_keyword[6] = "masqdomain";
49 ic_boxtitle[0] = _("Local host aliases");
50 ic_boxtitle[1] = _("Directory domains");
51 ic_boxtitle[2] = _("Gateway domains");
52 ic_boxtitle[3] = _("Smart hosts");
53 ic_boxtitle[4] = _("RBL hosts");
54 ic_boxtitle[5] = _("SpamAssassin hosts");
55 ic_boxtitle[6] = _("Masqueradable domains");
57 ic_desc[0] = _("(domains for which this host receives mail)");
58 ic_desc[1] = _("(domains mapped with the Global Address Book)");
59 ic_desc[2] = _("(domains whose subdomains match Citadel hosts)");
60 ic_desc[3] = _("(if present, forward all outbound mail to one of these hosts)");
61 ic_desc[4] = _("(hosts running a Realtime Blackhole List)");
62 ic_desc[5] = _("(hosts running the SpamAssassin service)");
63 ic_desc[6] = _("(Domains as which users are allowed to masquerade)");
65 for (i=0; i<ic_max; ++i) {
66 ic_spec[i] = strdup("");
70 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
71 serv_getln(buf, sizeof buf);
72 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
74 extract_token(ename, buf, 0, '|', sizeof ename);
75 extract_token(etype, buf, 1, '|', sizeof etype);
77 for (i=0; i<ic_max; ++i) {
78 if (!strcasecmp(etype, ic_keyword[i])) {
84 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
85 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
86 strcat(ic_spec[which], ename);
89 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
90 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
96 output_headers(1, 1, 2, 0, 0, 0);
97 wprintf("<div id=\"banner\">\n");
98 wprintf("<TABLE class=\"inetconf_banner\"><TR><TD>");
99 wprintf("<SPAN CLASS=\"titlebar\">");
100 wprintf(_("Internet configuration"));
101 wprintf("</SPAN>\n");
102 wprintf("</TD></TR></TABLE>\n");
103 wprintf("</div>\n<div id=\"content\">\n");
105 wprintf("<div class=\"fix_scrollbar_bug\">"
106 "<table border=0 width=100%%><tr><td valign=top>\n");
107 for (which=0; which<ic_max; ++which) {
108 if (which == (ic_max / 2)) {
109 wprintf("</TD><TD VALIGN=TOP>");
111 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
112 do_template("beginbox");
113 wprintf("<span class=\"menudesc\">");
114 escputs(ic_desc[which]);
115 wprintf("</span><br />");
116 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
117 if (strlen(ic_spec[which]) > 0) {
118 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
119 wprintf("<TR><TD ALIGN=LEFT>");
120 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
122 wprintf("</TD><TD ALIGN=RIGHT>"
123 "<a href=\"save_inetconf?oper=delete&ename=");
125 wprintf("&etype=%s\" ", ic_keyword[which]);
126 wprintf("onClick=\"return confirm('%s');\">",
127 _("Delete this entry?"));
128 wprintf("<font size=-1>");
129 wprintf(_("(Delete)"));
130 wprintf("</font></a></TD></TR>\n");
133 wprintf("<FORM METHOD=\"POST\" action=\"save_inetconf\">\n"
135 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
136 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
137 wprintf("</TD><TD ALIGN=RIGHT>"
138 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
139 "</TD></TR></TABLE></FORM>\n");
140 do_template("endbox");
142 wprintf("</td></tr></table></div>\n");
145 for (i=0; i<ic_max; ++i) {
153 * \brief save changes to the inet config
155 void save_inetconf(void) {
164 newconfig = malloc(65536);
166 strcpy(newconfig, "");
167 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
168 serv_getln(buf, SIZ);
169 if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
170 extract_token(ename, buf, 0, '|', SIZ);
171 extract_token(etype, buf, 1, '|', SIZ);
172 if (strlen(buf) == 0) {
173 /** skip blank lines */
175 else if ((!strcasecmp(ename, bstr("ename")))
176 && (!strcasecmp(etype, bstr("etype")))
177 && (!strcasecmp(bstr("oper"), "delete"))
179 sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
182 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
183 strcat(newconfig, buf);
187 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
188 serv_getln(buf, SIZ);
190 serv_puts(newconfig);
191 if (!strcasecmp(bstr("oper"), "add")) {
192 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
193 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));