inetconf.c

00001 /* 
00002  * $Id: inetconf.c 5147 2007-05-08 15:36:22Z ajc $
00003  */
00009 #include "webcit.h"
00010 
00011 
00015 void display_inetconf(void)
00016 {
00017         char buf[SIZ];
00018         char ename[SIZ];
00019         char etype[SIZ];
00020         int i;
00021         int which;
00022 
00023         enum {
00024                 ic_localhost,
00025                 ic_directory,
00026                 ic_gwdom,
00027                 ic_smarthost,
00028                 ic_rbl,
00029                 ic_spamass,
00030                 ic_masq,
00031                 ic_max
00032         };
00033         char *ic_spec[ic_max];
00034         char *ic_misc;
00035         char *ic_keyword[ic_max];
00036         char *ic_boxtitle[ic_max];
00037         char *ic_desc[ic_max];
00038 
00039         /* DON'T NEVER EVER AGAIN TRANSLATE CITADEL COMMANDS! */
00040         ic_keyword[0] = "localhost";
00041         ic_keyword[1] = "directory";
00042         ic_keyword[2] = "gatewaydomain";
00043         ic_keyword[3] = "smarthost";
00044         ic_keyword[4] = "rbl";
00045         ic_keyword[5] = "spamassassin";
00046         ic_keyword[6] = "masqdomain";
00047        
00048 
00049         ic_boxtitle[0] = _("Local host aliases");
00050         ic_boxtitle[1] = _("Directory domains");
00051         ic_boxtitle[2] = _("Gateway domains");
00052         ic_boxtitle[3] = _("Smart hosts");
00053         ic_boxtitle[4] = _("RBL hosts");
00054         ic_boxtitle[5] = _("SpamAssassin hosts");
00055         ic_boxtitle[6] = _("Masqueradable domains");
00056 
00057         ic_desc[0] = _("(domains for which this host receives mail)");
00058         ic_desc[1] = _("(domains mapped with the Global Address Book)");
00059         ic_desc[2] = _("(domains whose subdomains match Citadel hosts)");
00060         ic_desc[3] = _("(if present, forward all outbound mail to one of these hosts)");
00061         ic_desc[4] = _("(hosts running a Realtime Blackhole List)");
00062         ic_desc[5] = _("(hosts running the SpamAssassin service)");
00063         ic_desc[6] = _("(Domains as which users are allowed to masquerade)");
00064 
00065         for (i=0; i<ic_max; ++i) {
00066                 ic_spec[i] = strdup("");
00067         }
00068         ic_misc = strdup("");
00069 
00070         serv_printf("CONF GETSYS|application/x-citadel-internet-config");
00071         serv_getln(buf, sizeof buf);
00072         if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00073 
00074                 extract_token(ename, buf, 0, '|', sizeof ename);
00075                 extract_token(etype, buf, 1, '|', sizeof etype);
00076                 which = (-1);
00077                 for (i=0; i<ic_max; ++i) {
00078                         if (!strcasecmp(etype, ic_keyword[i])) {
00079                                 which = i;
00080                         }
00081                 }
00082 
00083                 if (which >= 0) {
00084                         ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
00085                         if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
00086                         strcat(ic_spec[which], ename);
00087                 }
00088                 else {
00089                         ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
00090                         if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
00091                         strcat(ic_misc, buf);
00092                 }
00093 
00094         }
00095 
00096         output_headers(1, 1, 2, 0, 0, 0);
00097         wprintf("<div id=\"banner\">\n");
00098         wprintf("<TABLE class=\"inetconf_banner\"><TR><TD>");
00099         wprintf("<SPAN CLASS=\"titlebar\">");
00100         wprintf(_("Internet configuration"));
00101         wprintf("</SPAN>\n");
00102         wprintf("</TD></TR></TABLE>\n");
00103         wprintf("</div>\n<div id=\"content\">\n");
00104 
00105         wprintf("<div class=\"fix_scrollbar_bug\">"
00106                 "<table border=0 width=100%%><tr><td valign=top>\n");
00107         for (which=0; which<ic_max; ++which) {
00108                 if (which == (ic_max / 2)) {
00109                         wprintf("</TD><TD VALIGN=TOP>");
00110                 }
00111                 svprintf("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
00112                 do_template("beginbox");
00113                 wprintf("<span class=\"menudesc\">");
00114                 escputs(ic_desc[which]);
00115                 wprintf("</span><br />");
00116                 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
00117                 if (strlen(ic_spec[which]) > 0) {
00118                         for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
00119                                 wprintf("<TR><TD ALIGN=LEFT>");
00120                                 extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
00121                                 escputs(buf);
00122                                 wprintf("</TD><TD ALIGN=RIGHT>"
00123                                         "<a href=\"save_inetconf?oper=delete&ename=");
00124                                 escputs(buf);
00125                                 wprintf("&etype=%s\" ", ic_keyword[which]);
00126                                 wprintf("onClick=\"return confirm('%s');\">",
00127                                         _("Delete this entry?"));
00128                                 wprintf("<font size=-1>");
00129                                 wprintf(_("(Delete)"));
00130                                 wprintf("</font></a></TD></TR>\n");
00131                         }
00132                 }
00133                 wprintf("<FORM METHOD=\"POST\" action=\"save_inetconf\">\n"
00134                         "<TR><TD>"
00135                         "<INPUT TYPE=\"text\" NAME=\"ename\" MAXLENGTH=\"64\">"
00136                         "<INPUT TYPE=\"hidden\" NAME=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
00137                 wprintf("</TD><TD ALIGN=RIGHT>"
00138                         "<INPUT TYPE=\"submit\" NAME=\"oper\" VALUE=\"Add\">"
00139                         "</TD></TR></TABLE></FORM>\n");
00140                 do_template("endbox");
00141         }
00142         wprintf("</td></tr></table></div>\n");
00143         wDumpContent(1);
00144 
00145         for (i=0; i<ic_max; ++i) {
00146                 free(ic_spec[i]);
00147         }
00148         free(ic_misc);
00149 }
00150 
00151 
00155 void save_inetconf(void) {
00156         char *buf;
00157         char *ename;
00158         char *etype;
00159         char *newconfig;
00160 
00161         buf = malloc(SIZ);
00162         ename = malloc(SIZ);
00163         etype = malloc(SIZ);
00164         newconfig = malloc(65536);
00165 
00166         strcpy(newconfig, "");
00167         serv_printf("CONF GETSYS|application/x-citadel-internet-config");
00168         serv_getln(buf, SIZ);
00169         if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
00170                 extract_token(ename, buf, 0, '|', SIZ);
00171                 extract_token(etype, buf, 1, '|', SIZ);
00172                 if (strlen(buf) == 0) {
00174                 }
00175                 else if ((!strcasecmp(ename, bstr("ename")))
00176                    &&   (!strcasecmp(etype, bstr("etype")))
00177                    &&   (!strcasecmp(bstr("oper"), "delete"))
00178                 ) {
00179                         sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
00180                 }
00181                 else {
00182                         if (strlen(newconfig) > 0) strcat(newconfig, "\n");
00183                         strcat(newconfig, buf);
00184                 }
00185         }
00186 
00187         serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
00188         serv_getln(buf, SIZ);
00189         if (buf[0] == '4') {
00190                 serv_puts(newconfig);
00191                 if (!strcasecmp(bstr("oper"), "add")) {
00192                         serv_printf("%s|%s", bstr("ename"), bstr("etype") );
00193                         sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));
00194                 }
00195                 serv_puts("000");
00196         }
00197         
00198         display_inetconf();
00199 
00200         free(buf);
00201         free(ename);
00202         free(etype);
00203         free(newconfig);
00204 }
00205 
00206 
00207 

Generated on Wed Jun 20 23:13:08 2007 for webcit by  doxygen 1.5.2