]> 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 269967e4a7f9c243d7184c66fcd6885633f76a3c..51fcc946f7eabd4b23c3eda992919d1470b9f07c 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- *
  * Functions which handle Internet domain configuration etc.
  */
 
@@ -21,14 +19,9 @@ typedef enum _e_cfg {
        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") },
@@ -57,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");
@@ -152,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"));
@@ -171,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);
                        }                       
@@ -183,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;
@@ -206,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;
 }
 
@@ -215,6 +203,6 @@ InitModule_INETCONF
 (void)
 {
        WebcitAddUrlHandler(HKEY("save_inetconf"), "", 0, new_save_inetconf, 0);
-       RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, InetCfgSubst, NULL, CTX_INETCFG, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
        RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInetConfHash, NULL, CTX_NONE);
 }