]> code.citadel.org Git - citadel.git/blobdiff - webcit/inetconf.c
* use the const str type libcitadel gives us, instead of roling our own.
[citadel.git] / webcit / inetconf.c
index 5882bb5bb5f088bbcd3580e82fae586099edbb6c..51fcc946f7eabd4b23c3eda992919d1470b9f07c 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- *
  * Functions which handle Internet domain configuration etc.
  */
 
@@ -12,28 +10,27 @@ typedef enum _e_cfg {
        ic_localhost,
        ic_directory,
        ic_smarthost,
+       ic_fallback,
        ic_rbl,
        ic_spamass,
        ic_masq,
        ic_clamav,
+       ic_notify,
        ic_max
 } ECfg;
 
-typedef struct _ConstStrBuf {
-       const char *name;
-       size_t len;
-} ConstStrBuf;
-
 
   /* These are server config keywords; do not localize! */
-ConstStrBuf CfgNames[] = {
+ConstStr CfgNames[] = {
        { HKEY("localhost") },
        { HKEY("directory") },
        { HKEY("smarthost") },
+       { HKEY("fallbackhost") },
        { HKEY("rbl") },
        { HKEY("spamassassin") },
        { HKEY("masqdomain") },
-       { HKEY("clamav") }
+       { HKEY("clamav") },
+       { HKEY("notify") }
 };
 
        
@@ -53,9 +50,9 @@ void load_inetconf(void)
        
        WCC->InetCfg = NewHash(1, NULL);
 
-       for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStrBuf)); i++) {
+       for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStr)); i++) {
                Hash = NewHash(1, NULL);
-               Put(WCC->InetCfg, CfgNames[i].name, CfgNames[i].len, Hash, HDeleteHash);
+               Put(WCC->InetCfg, CKEY(CfgNames[i]), Hash, HDeleteHash);
        }
 
        serv_printf("CONF GETSYS|application/x-citadel-internet-config");
@@ -126,6 +123,7 @@ void new_save_inetconf(void) {
                FlushStrBuf(Str);       
        }
        else if (!strcasecmp(bstr("oper"), "add")) {
+               StrBuf *name;
                eName = sbstr("ename");
                if (eName == NULL) {
                        StrBufPrintf(WCC->ImportantMsg, _("Invalid Parameter"));
@@ -135,8 +133,9 @@ void new_save_inetconf(void) {
 
                nUsed = GetCount(Hash);
                nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
-       
-               Put(Hash, nnn, nUsed, NewStrBufDup(eName), HFreeStrBuf); 
+               name = NewStrBufDup(eName);
+               StrBufTrim(name);
+               Put(Hash, nnn, nUsed, name, HFreeStrBuf); 
                StrBufPrintf(WCC->ImportantMsg, "%s %s", 
                             /*<domain> added status message*/ _("added."), 
                             ChrPtr(eName));
@@ -146,12 +145,12 @@ void new_save_inetconf(void) {
        serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 4) {
-               for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStrBuf)); i++) {
+               for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStr)); i++) {
                        HashPos *where;
                        const char *Key;
                        long KeyLen;
 
-                       GetHash(WCC->InetCfg, CfgNames[i].name, CfgNames[i].len, &vHash);
+                       GetHash(WCC->InetCfg, CKEY(CfgNames[i]), &vHash);
                        Hash = (HashList*) vHash;
                        if (Hash == NULL) {
                                sprintf(WC->ImportantMessage, _("Invalid Parameter"));
@@ -165,7 +164,7 @@ void new_save_inetconf(void) {
                                        if ((Str!= NULL) && (StrLength(Str) > 0))
                                                serv_printf("%s|%s", 
                                                            ChrPtr(Str),
-                                                           CfgNames[i].name); 
+                                                           CfgNames[i].Key); 
                                }
                                DeleteHashPos(&where);
                        }                       
@@ -177,11 +176,6 @@ void new_save_inetconf(void) {
        url_do_template();
 }
 
-void InetCfgSubst(StrBuf *TemplBuffer, WCTemplputParams *TP)
-{
-       SVPutBuf("SERVCFG:INET:HOSTNAME", CTX, 1);
-}
-
 void DeleteInetConfHash(StrBuf *Target, WCTemplputParams *TP)
 {
        wcsession *WCC = WC;
@@ -200,7 +194,7 @@ HashList *GetInetConfHash(StrBuf *Target, WCTemplputParams *TP)
        if (WCC->InetCfg == NULL)
                load_inetconf();
        GetHash(WCC->InetCfg, TKEY(5), &vHash);
-       svprintf(HKEY("SERVCFG:INET:TYPE"), WCS_STRING, TP->Tokens->Params[5]->Start);
+       PutBstr(HKEY("__SERVCFG:INET:TYPE"), NewStrBufPlain(TKEY(5)));
        return vHash;
 }
 
@@ -208,7 +202,7 @@ void
 InitModule_INETCONF
 (void)
 {
-       WebcitAddUrlHandler(HKEY("save_inetconf"), new_save_inetconf, 0);
-       RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, InetCfgSubst, NULL, CTX_INETCFG, CTX_NONE, IT_NOFLAG);
-       RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInetConfHash, CTX_NONE);
+       WebcitAddUrlHandler(HKEY("save_inetconf"), "", 0, new_save_inetconf, 0);
+       RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInetConfHash, NULL, CTX_NONE);
 }