4 * Functions which handle Internet domain configuration etc.
15 #include <sys/types.h>
17 #include <sys/socket.h>
20 #include <netinet/in.h>
32 void display_inetconf(void)
49 char *ic_spec[ic_max];
52 char *ic_keyword[] = {
61 char *ic_boxtitle[] = {
71 "(domains for which this host receives mail)",
72 "(domains mapped with the Global Address Book)",
73 "(domains whose subdomains match Citadel hosts)",
74 "(if present, forward all outbound mail to one of these hosts)",
75 "(hosts running a Realtime Blackhole List)",
76 "(hosts running the SpamAssassin service)",
79 for (i=0; i<ic_max; ++i) {
80 ic_spec[i] = strdup("");
85 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
86 wprintf("<SPAN CLASS=\"titlebar\">Internet configuration</SPAN>\n");
87 wprintf("</TD></TR></TABLE>\n");
89 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
91 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
93 extract(ename, buf, 0);
94 extract(etype, buf, 1);
96 for (i=0; i<ic_max; ++i) {
97 if (!strcasecmp(etype, ic_keyword[i])) {
103 ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
104 if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
105 strcat(ic_spec[which], ename);
108 ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
109 if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
110 strcat(ic_misc, buf);
115 wprintf("<TABLE border=0 width=100%%><TR><TD VALIGN=TOP>\n");
116 for (which=0; which<ic_max; ++which) {
117 if (which == (ic_max / 2)) {
118 wprintf("</TD><TD VALIGN=TOP>");
120 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
121 do_template("beginbox");
122 wprintf("<span class=\"menudesc\">");
123 escputs(ic_desc[which]);
124 wprintf("</span><br>");
125 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
126 if (strlen(ic_spec[which]) > 0) {
127 for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
128 wprintf("<TR><TD ALIGN=LEFT>");
129 extract_token(buf, ic_spec[which], i, '\n');
131 wprintf("</TD><TD ALIGN=RIGHT>"
132 "<A HREF=\"/save_inetconf?oper=delete&ename=");
134 wprintf("&etype=%s\" ", ic_keyword[which]);
135 wprintf("onClick=\"return confirm('Delete ");
138 wprintf("<font size=-1>(Delete)</font></a></TD></TR>\n");
141 wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_inetconf\">\n"
143 "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
144 "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
145 wprintf("</TD><TD ALIGN=RIGHT>"
146 "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
147 "</TD></TR></TABLE></FORM>\n");
148 do_template("endbox");
150 wprintf("</TD></TR></TABLE>\n");
154 for (i=0; i<ic_max; ++i) {
161 void save_inetconf(void) {
165 char newconfig[65536];
167 strcpy(newconfig, "");
168 serv_printf("CONF GETSYS|application/x-citadel-internet-config");
170 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
171 extract(ename, buf, 0);
172 extract(etype, buf, 1);
173 if (strlen(buf) == 0) {
174 /* skip blank lines */
176 else if ((!strcasecmp(ename, bstr("ename")))
177 && (!strcasecmp(etype, bstr("etype")))
178 && (!strcasecmp(bstr("oper"), "delete"))
180 sprintf(WC->ImportantMessage, "%s deleted.", ename);
183 if (strlen(newconfig) > 0) strcat(newconfig, "\n");
184 strcat(newconfig, buf);
188 serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
191 serv_puts(newconfig);
192 if (!strcasecmp(bstr("oper"), "add")) {
193 serv_printf("%s|%s", bstr("ename"), bstr("etype") );
194 sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));