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 ic_keyword[0] = _("localhost");
39 ic_keyword[1] = _("directory");
40 ic_keyword[2] = _("gatewaydomain");
41 ic_keyword[3] = _("smarthost");
42 ic_keyword[4] = _("rbl");
43 ic_keyword[5] = _("spamassassin");
45 ic_boxtitle[0] = _("Local host aliases");
46 ic_boxtitle[1] = _("Directory domains");
47 ic_boxtitle[2] = _("Gateway domains");
48 ic_boxtitle[3] = _("Smart hosts");
49 ic_boxtitle[4] = _("RBL hosts");
50 ic_boxtitle[5] = _("SpamAssassin hosts");
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] = _("(domains whose subdomains match Citadel hosts)");
55 ic_desc[3] = _("(if present, forward all outbound mail to one of these hosts)");
56 ic_desc[4] = _("(hosts running a Realtime Blackhole List)");
57 ic_desc[5] = _("(hosts running the SpamAssassin service)");
59 for (i=0; i<ic_max; ++i) {
60 ic_spec[i] = strdup("");
64 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
65 serv_getln(buf, sizeof buf);
66 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(ename, buf, 0, '|', sizeof ename);
69 extract_token(etype, buf, 1, '|', sizeof etype);
71 for (i=0; i<ic_max; ++i) {
72 if (!strcasecmp(etype, ic_keyword[i])) {
78 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
79 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
80 strcat(ic_spec[which], ename);
83 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
84 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
90 output_headers(1, 1, 2, 0, 0, 0);
91 wprintf("<div id=\"banner\">\n");
92 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
93 wprintf("<SPAN CLASS=\"titlebar\">");
94 wprintf(_("Internet configuration"));
96 wprintf("</TD></TR></TABLE>\n");
97 wprintf("</div>\n<div id=\"content\">\n");
99 wprintf("<div class=\"fix_scrollbar_bug\">"
100 "<table border=0 width=100%%><tr><td valign=top>\n");
101 for (which=0; which<ic_max; ++which) {
102 if (which == (ic_max / 2)) {
103 wprintf("</TD><TD VALIGN=TOP>");
105 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
106 do_template("beginbox");
107 wprintf("<span class=\"menudesc\">");
108 escputs(ic_desc[which]);
109 wprintf("</span><br />");
110 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
111 if (strlen(ic_spec[which]) > 0) {
112 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
113 wprintf("<TR><TD ALIGN=LEFT>");
114 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
116 wprintf("</TD><TD ALIGN=RIGHT>"
117 "<a href=\"save_inetconf?oper=delete&ename=");
119 wprintf("&etype=%s\" ", ic_keyword[which]);
120 wprintf("onClick=\"return confirm('%s');\">",
121 _("Delete this entry?"));
122 wprintf("<font size=-1>");
123 wprintf(_("(Delete)"));
124 wprintf("</font></a></TD></TR>\n");
127 wprintf("<FORM METHOD=\"POST\" action=\"save_inetconf\">\n"
129 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
130 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
131 wprintf("</TD><TD ALIGN=RIGHT>"
132 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
133 "</TD></TR></TABLE></FORM>\n");
134 do_template("endbox");
136 wprintf("</td></tr></table></div>\n");
139 for (i=0; i<ic_max; ++i) {
147 * \brief save changes to the inet config
149 void save_inetconf(void) {
158 newconfig = malloc(65536);
160 strcpy(newconfig, "");
161 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
162 serv_getln(buf, SIZ);
163 if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
164 extract_token(ename, buf, 0, '|', SIZ);
165 extract_token(etype, buf, 1, '|', SIZ);
166 if (strlen(buf) == 0) {
167 /** skip blank lines */
169 else if ((!strcasecmp(ename, bstr("ename")))
170 && (!strcasecmp(etype, bstr("etype")))
171 && (!strcasecmp(bstr("oper"), "delete"))
173 sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
176 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
177 strcat(newconfig, buf);
181 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
182 serv_getln(buf, SIZ);
184 serv_puts(newconfig);
185 if (!strcasecmp(bstr("oper"), "add")) {
186 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
187 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));