Back to index

webcit  8.12-dfsg
Classes | Defines | Typedefs | Functions | Variables
siteconfig.c File Reference
#include "webcit.h"
#include "webserver.h"

Go to the source code of this file.

Classes

struct  _CfgMapping
struct  __LogStatusStruct

Defines

#define CFG_STR   1
#define CFG_YES   2
#define CFG_NO   3

Typedefs

typedef struct _CfgMapping CfgMapping
typedef struct __LogStatusStruct LogStatusStruct

Functions

void LoadExpirePolicy (GPEXWhichPolicy which)
void SaveExpirePolicyFromHTTP (GPEXWhichPolicy which)
int ConditionalExpire (StrBuf *Target, WCTemplputParams *TP)
void tmplput_ExpireValue (StrBuf *Target, WCTemplputParams *TP)
void tmplput_ExpireMode (StrBuf *Target, WCTemplputParams *TP)
void LoadZoneFiles (void)
void load_siteconfig (void)
void siteconfig (void)
void tmplput_servcfg (StrBuf *Target, WCTemplputParams *TP)
int ConditionalServCfg (StrBuf *Target, WCTemplputParams *TP)
int ConditionalServCfgCTXStrBuf (StrBuf *Target, WCTemplputParams *TP)
void DeleteLogStatusStruct (void *v)
void tmplput_servcfg_LogName (StrBuf *Target, WCTemplputParams *TP)
int ConditionalServCfgThisLogEnabled (StrBuf *Target, WCTemplputParams *TP)
HashList * iterate_GetSrvLogEnable (StrBuf *Target, WCTemplputParams *TP)
void InitModule_SITECONFIG (void)
void ServerStartModule_SITECONFIG (void)
void ServerShutdownModule_SITECONFIG (void)
void SessionDestroyModule_SITECONFIG (wcsession *sess)

Variables

HashList * ZoneHash = NULL
ConstStr ExpirePolicyString = {CStrOf(roompolicy) }
ConstStr ExpirePolicyStrings [][2]
CfgMapping ServerConfig []

Class Documentation

struct _CfgMapping

Definition at line 129 of file siteconfig.c.

Class Members
const char * Key
long len
int type
struct __LogStatusStruct

Definition at line 394 of file siteconfig.c.

Class Members
int Enable
StrBuf * Name

Define Documentation

#define CFG_NO   3

Definition at line 137 of file siteconfig.c.

#define CFG_STR   1

Definition at line 135 of file siteconfig.c.

#define CFG_YES   2

Definition at line 136 of file siteconfig.c.


Typedef Documentation

typedef struct _CfgMapping CfgMapping

Function Documentation

int ConditionalExpire ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 67 of file siteconfig.c.

{
       wcsession *WCC = WC;
       GPEXWhichPolicy which;
       int CompareWith;

       which = GetTemplateTokenNumber(Target, TP, 2, 0);
       CompareWith = GetTemplateTokenNumber(Target, TP, 3, 0);

       LoadExpirePolicy(which);
       
       return WCC->Policy[which].expire_mode == CompareWith;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ConditionalServCfg ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 340 of file siteconfig.c.

{
       wcsession *WCC = WC;
       void *vBuf;
       StrBuf *Buf;

       if (WCC->is_aide) {
              if (WCC->ServCfg == NULL)
                     load_siteconfig();
              GetHash(WCC->ServCfg, TKEY(2), &vBuf);
              if (vBuf == NULL) return 0;
              Buf = (StrBuf*) vBuf;
              if (TP->Tokens->nParameters == 3) {
                     return 1;
              }
              else if (IS_NUMBER(TP->Tokens->Params[3]->Type))
                     return (StrTol(Buf) == GetTemplateTokenNumber (Target, TP, 3, 0));
              else
              {
                     const char *pch;
                     long len;
                     
                     GetTemplateTokenString(Target, TP, 3, &pch, &len);
              
                     return ((len == StrLength(Buf)) &&
                            (strcmp(pch, ChrPtr(Buf)) == 0));
              }

       }
       else return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ConditionalServCfgCTXStrBuf ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 372 of file siteconfig.c.

{
       wcsession *WCC = WC;
       void *vBuf;
       StrBuf *Buf;
       StrBuf *ZoneToCheck = (StrBuf*) CTX;

       if ((WCC->is_aide) || (ZoneToCheck == NULL)) {
              if (WCC->ServCfg == NULL)
                     load_siteconfig();
              GetHash(WCC->ServCfg, TKEY(2), &vBuf);
              if (vBuf == NULL) return 0;
              Buf = (StrBuf*) vBuf;

              return strcmp(ChrPtr(Buf), ChrPtr(ZoneToCheck)) == 0;
       }
       else return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ConditionalServCfgThisLogEnabled ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 413 of file siteconfig.c.

{
        LogStatusStruct *Stat = (LogStatusStruct*) CTX;
       return Stat->Enable;
}

Here is the caller graph for this function:

void DeleteLogStatusStruct ( void *  v)

Definition at line 399 of file siteconfig.c.

{
       LogStatusStruct *Stat = (LogStatusStruct*)v;

       FreeStrBuf(&Stat->Name);
       free(Stat);
}

Here is the caller graph for this function:

void InitModule_SITECONFIG ( void  )

Definition at line 460 of file siteconfig.c.

Here is the call graph for this function:

Here is the caller graph for this function:

HashList* iterate_GetSrvLogEnable ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 419 of file siteconfig.c.

{
        HashList *Hash = NULL;
       StrBuf *Buf;
       LogStatusStruct *Stat;
       const char *Pos;
       int Done = 0;
       long len;
       int num_logs = 0;

        serv_puts("LOGP");
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
                Hash = NewHash(1, Flathash);
                while (!Done) {
                        len = StrBuf_ServGetln(Buf);
                        if ((len <0) || 
                            ((len == 3) &&
                             !strcmp(ChrPtr(Buf), "000")))
                        {
                                Done = 1;
                                break;
                        }
                     Stat = (LogStatusStruct*) malloc (sizeof(LogStatusStruct));
                     Pos = NULL;
                     Stat->Name = NewStrBufPlain(NULL, len);
                        StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|');
                        Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|');

                        Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct); 
                     num_logs++;
                }
       }
       FreeStrBuf(&Buf);
       return Hash;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void load_siteconfig ( void  )

Definition at line 215 of file siteconfig.c.

{
       wcsession *WCC = WC;
       StrBuf *Buf;
       HashList *Cfg;
       long len;
       int i, j;
       
       if (WCC->ServCfg == NULL)
              WCC->ServCfg = NewHash(1, NULL);
       Cfg = WCC->ServCfg;

       Buf = NewStrBuf();

       serv_printf("CONF get");
       StrBuf_ServGetln(Buf);
       if (GetServerStatus(Buf, NULL) != 1) {
              StrBufCutLeft(Buf, 4);
              AppendImportantMessage(SKEY(Buf));
              FreeStrBuf(&Buf);
              return;
              
       }
       j = i = 0;
       while (len = StrBuf_ServGetln(Buf),
              (len >= 0) && 
              ((len != 3) || strcmp(ChrPtr(Buf), "000")))
       {
              if (i < (sizeof(ServerConfig) / sizeof(CfgMapping)))
              {
                     Put(Cfg,
                         ServerConfig[i].Key, 
                         ServerConfig[i].len, 
                         Buf, 
                         HFreeStrBuf);
                     i++;
                     Buf = NewStrBuf();
              }
              else {
                     if (j == 0)
                            AppendImportantMessage(_("WARNING: Failed to parse Server Config; do you run a to new citserver?"), -1);
                     j++;
              }
       }
       FreeStrBuf(&Buf);

       LoadExpirePolicy(roompolicy);
       LoadExpirePolicy(floorpolicy);
       LoadExpirePolicy(mailboxespolicy);
       LoadExpirePolicy(sitepolicy);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void LoadExpirePolicy ( GPEXWhichPolicy  which)

Definition at line 29 of file siteconfig.c.

{
       StrBuf *Buf;
       wcsession *WCC = WC;
       long State;
       const char *Pos = NULL;

       serv_printf("GPEX %s", ExpirePolicyStrings[which][0].Key);
       Buf = NewStrBuf();
       StrBuf_ServGetln(Buf);
       if (GetServerStatus(Buf, &State) == 2) {
              Pos = ChrPtr(Buf) + 4;
              WCC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
              WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
       }
       else if (State == 550)
              AppendImportantMessage(_("Higher access is required to access this function."), -1);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void LoadZoneFiles ( void  )

Definition at line 103 of file siteconfig.c.

{
       icalarray *zones;
       int z;
       long len;
       const char *this_zone;
       StrBuf *ZName;
       
       ZoneHash = NewHash(1, NULL);
       ZName = NewStrBufPlain(HKEY("UTC"));
       Put(ZoneHash, HKEY("UTC"), ZName, HFreeStrBuf);
       zones = icaltimezone_get_builtin_timezones();
       for (z = 0; z < zones->num_elements; ++z) {
              /* syslog(9, "Location: %-40s tzid: %s\n",
                     icaltimezone_get_location(icalarray_element_at(zones, z)),
                     icaltimezone_get_tzid(icalarray_element_at(zones, z))
              ); */
              this_zone = icaltimezone_get_location(icalarray_element_at(zones, z));
              len = strlen(this_zone);
              ZName = NewStrBufPlain(this_zone, len);
              Put(ZoneHash, this_zone, len, ZName, HFreeStrBuf);
       }
       SortByHashKey(ZoneHash, 0);
}

Here is the caller graph for this function:

void SaveExpirePolicyFromHTTP ( GPEXWhichPolicy  which)

Definition at line 49 of file siteconfig.c.

{
       StrBuf *Buf;
       long State;

       serv_printf("SPEX %s|%d|%d", 
                          ExpirePolicyStrings[which][0].Key,
                  ibcstr( ExpirePolicyStrings[which][1] ),
                  ibcstr( ExpirePolicyStrings[which][1] )  );

       Buf = NewStrBuf();
       StrBuf_ServGetln(Buf);
       GetServerStatus(Buf, &State);
       if (State == 550)
              AppendImportantMessage(_("Higher access is required to access this function."), -1);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 497 of file siteconfig.c.

{
       DeleteHash(&ZoneHash);
}

Here is the caller graph for this function:

Definition at line 490 of file siteconfig.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 505 of file siteconfig.c.

{
       DeleteHash(&sess->ServCfg);
}

Here is the caller graph for this function:

void siteconfig ( void  )

Definition at line 272 of file siteconfig.c.

{
       wcsession *WCC = WC;
       int i;
       StrBuf *Line;

       if (strlen(bstr("ok_button")) == 0) {
              display_aide_menu();
              return;
       }
       Line = NewStrBuf();
       serv_printf("CONF set");
       StrBuf_ServGetln(Line);
       if (GetServerStatusMsg(Line, NULL, 1, 4) != 4) {
              display_aide_menu();
              FreeStrBuf(&Line);
              return;
       }

       FreeStrBuf(&Line);

       for (i=0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i ++)
       {
              switch (ServerConfig[i].type) {
              default:
              case CFG_STR:
                     serv_putbuf(SBstr(ServerConfig[i].Key, ServerConfig[i].len));
                     break;
              case CFG_YES:
                     serv_puts(YesBstr(ServerConfig[i].Key, 
                                     ServerConfig[i].len) ?
                              "1" : "0");
                     break;
              case CFG_NO:
                     serv_puts(YesBstr(ServerConfig[i].Key, 
                                     ServerConfig[i].len) ?
                              "0" : "1");
                     break;
              }
       }
        serv_puts("000");

       SaveExpirePolicyFromHTTP(sitepolicy);
       SaveExpirePolicyFromHTTP(mailboxespolicy);

       FreeStrBuf(&WCC->serv_info->serv_default_cal_zone);
       WCC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));

       AppendImportantMessage(_("Your system configuration has been updated."), -1);
       DeleteHash(&WCC->ServCfg);
       display_aide_menu();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_ExpireMode ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 92 of file siteconfig.c.

{
       GPEXWhichPolicy which;
       wcsession *WCC = WC;
              
       which = GetTemplateTokenNumber(Target, TP, 2, 0);
       LoadExpirePolicy(which);
       StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_mode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_ExpireValue ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 81 of file siteconfig.c.

{
       GPEXWhichPolicy which;
       wcsession *WCC = WC;
              
       which = GetTemplateTokenNumber(Target, TP, 0, 0);
       LoadExpirePolicy(which);
       StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_value);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_servcfg ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 325 of file siteconfig.c.

{
       wcsession *WCC = WC;
       void *vBuf;
       StrBuf *Buf;

       if (WCC->is_aide) {
              if (WCC->ServCfg == NULL)
                     load_siteconfig();
              GetHash(WCC->ServCfg, TKEY(0), &vBuf);
              Buf = (StrBuf*) vBuf;
              StrBufAppendTemplate(Target, TP, Buf, 1);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_servcfg_LogName ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 407 of file siteconfig.c.

{
        LogStatusStruct *Stat = (LogStatusStruct*) CTX;
       StrBufAppendTemplate(Target, TP, Stat->Name, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

ConstStr ExpirePolicyString = {CStrOf(roompolicy) }

Definition at line 20 of file siteconfig.c.

ConstStr ExpirePolicyStrings[][2]
Initial value:
 {
       { { CStrOf(roompolicy)     } , { strof(roompolicy)     "_value", sizeof(strof(roompolicy)     "_value") - 1 } },
       { { CStrOf(floorpolicy)    } , { strof(floorpolicy)    "_value", sizeof(strof(floorpolicy)    "_value") - 1 } },
       { { CStrOf(sitepolicy)     } , { strof(sitepolicy)     "_value", sizeof(strof(sitepolicy)     "_value") - 1 } },
       { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } }
}

Definition at line 22 of file siteconfig.c.

Definition at line 139 of file siteconfig.c.

HashList* ZoneHash = NULL

Definition at line 18 of file siteconfig.c.