Reverts commit c6aec42f213ec284e34648f3d69bcf927dccddb1 because putting the opening...
[citadel.git] / webcit / roomlist.c
index 695a7a01a06e4e9a1e2f189f50798c00a7f2ec9c..b9f967ce6cd6fd988e9897130c2d931c9b1fdd81 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * room listings and filters.
  */
@@ -10,9 +9,10 @@ typedef enum __eRoomParamType {
        eNotSet,
        eDomain,
        eAlias
-} eRoomParamType;
+}eRoomParamType;
 
-HashList *GetWhoKnowsHash(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
+{
        StrBuf *Line;
        StrBuf *Token;
        long State;
@@ -23,19 +23,26 @@ HashList *GetWhoKnowsHash(StrBuf * Target, WCTemplputParams * TP) {
        serv_puts("WHOK");
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) {
+       if (GetServerStatus(Line, &State) == 1) 
+       {
                Whok = NewHash(1, Flathash);
-               while (!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
+               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000")) 
+                       {
                                Done = 1;
                        }
-                       else {
-
+                       else
+                       {
+                       
                                const char *Pos = NULL;
-                               Token = NewStrBufPlain(NULL, StrLength(Line));
+                               Token = NewStrBufPlain (NULL, StrLength(Line));
                                StrBufExtract_NextToken(Token, Line, &Pos, '|');
 
-                               Put(Whok, IKEY(n), Token, HFreeStrBuf);
+                               Put(Whok, 
+                                   IKEY(n),
+                                   Token, 
+                                   HFreeStrBuf);
                                n++;
                        }
        }
@@ -48,17 +55,19 @@ HashList *GetWhoKnowsHash(StrBuf * Target, WCTemplputParams * TP) {
 }
 
 
-void DeleteFloor(void *vFloor) {
+void DeleteFloor(void *vFloor)
+{
        Floor *pFloor;
-       pFloor = (Floor *) vFloor;
+       pFloor = (Floor*) vFloor;
        FreeStrBuf(&pFloor->Name);
        free(pFloor);
 }
 
-int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) {
-       Floor *f1 = (Floor *) GetSearchPayload(vfloor1);
-       Floor *f2 = (Floor *) GetSearchPayload(vfloor2);
-
+int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) 
+{
+       Floor *f1 = (Floor*) GetSearchPayload(vfloor1);
+       Floor *f2 = (Floor*) GetSearchPayload(vfloor2);
+       
        /* prefer My floor over alpabetical sort */
        if (f1->ID == VIRTUAL_MY_FLOOR)
                return 1;
@@ -68,7 +77,8 @@ int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) {
        return strcmp(ChrPtr(f1->Name), ChrPtr(f2->Name));
 }
 
-HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) 
+{
        int Done = 0;
        const char *Err;
        StrBuf *Buf;
@@ -90,26 +100,30 @@ HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP) {
        WCC->FloorsByName = floorsbyname = NewHash(1, NULL);
        Buf = NewStrBuf();
 
-       pFloor = (Floor *) malloc(sizeof(Floor));
+       pFloor = (Floor*) malloc(sizeof(Floor));
        pFloor->ID = VIRTUAL_MY_FLOOR;
        pFloor->Name = NewStrBufPlain(_("My Folders"), -1);
        pFloor->NRooms = 0;
-
+       
        Put(floors, IKEY(pFloor->ID), pFloor, DeleteFloor);
        Put(floorsbyname, SKEY(pFloor->Name), pFloor, reference_free_handler);
 
-       serv_puts("LFLR");      /* get floors */
-       StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);      /* '100', we hope */
-       if (GetServerStatus(Buf, NULL) == 1) {
-               while (!Done && StrBuf_ServGetln(Buf) >= 0)
-                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
+       serv_puts("LFLR"); /* get floors */
+       StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
+       if (GetServerStatus(Buf, NULL) == 1) 
+       {
+               while(!Done && StrBuf_ServGetln(Buf) >= 0)
+                       if ( (StrLength(Buf)==3) && 
+                            !strcmp(ChrPtr(Buf), "000")) 
+                       {
                                Done = 1;
                        }
-                       else {
-
+                       else
+                       {
+                       
                                Pos = NULL;
 
-                               pFloor = (Floor *) malloc(sizeof(Floor));
+                               pFloor = (Floor*) malloc(sizeof(Floor));
                                pFloor->ID = StrBufExtractNext_int(Buf, &Pos, '|');
                                pFloor->Name = NewStrBufPlain(NULL, StrLength(Buf));
                                StrBufExtract_NextToken(pFloor->Name, Buf, &Pos, '|');
@@ -120,20 +134,21 @@ HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP) {
                        }
        }
        FreeStrBuf(&Buf);
-
+       
        /* now lets pre-sort them alphabeticaly. */
        i = 1;
        SortByPayload(floors, SortFloorsByNameOrder);
        it = GetNewHashPos(floors, 0);
-       while (GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor))
-               ((Floor *) vFloor)->AlphaN = i++;
+       while ( GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor)) 
+               ((Floor*) vFloor)->AlphaN = i++;
        DeleteHashPos(&it);
        SortByHashKeyStr(floors);
 
        return floors;
 }
 
-HashList *GetZappedRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetZappedRoomListHash(StrBuf *Target, WCTemplputParams *TP) 
+{
        wcsession *WCC = WC;
 
        if (WCC->Floors == NULL)
@@ -141,27 +156,32 @@ HashList *GetZappedRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
        serv_puts("LZRM -1");
        return GetRoomListHash(Target, TP);
 }
-HashList *GetRoomListHashLKRA(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP) 
+{
        wcsession *WCC = WC;
 
        if (WCC->Floors == NULL)
                GetFloorListHash(Target, TP);
-       if (WCC->Rooms == NULL) {
+       if (WCC->Rooms == NULL) 
+       {
                serv_puts("LKRA");
-               WCC->Rooms = GetRoomListHash(Target, TP);
+               WCC->Rooms =  GetRoomListHash(Target, TP);
        }
        return WCC->Rooms;
 }
 
-HashList *GetRoomListHashLPRM(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetRoomListHashLPRM(StrBuf *Target, WCTemplputParams *TP) 
+{
        serv_puts("LPRM");
        return GetRoomListHash(Target, TP);
 }
 
 
-void FlushIgnetCfgs(folder * room) {
+void FlushIgnetCfgs(folder *room)
+{
        int i;
-       if (room->IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL) {
+       if (room->IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
+       {
                for (i = ignet_push_share; i < maxRoomNetCfg; i++)
                        DeleteHash(&room->IgnetCfgs[i]);
        }
@@ -170,7 +190,8 @@ void FlushIgnetCfgs(folder * room) {
 
 }
 
-void FlushFolder(folder * room) {
+void FlushFolder(folder *room)
+{
        int i;
 
        FreeStrBuf(&room->XAPass);
@@ -183,25 +204,28 @@ void FlushFolder(folder * room) {
 
        FlushIgnetCfgs(room);
 
-       if (room->RoomNameParts != NULL) {
-               for (i = 0; i < room->nRoomNameParts; i++)
+       if (room->RoomNameParts != NULL)
+       {
+               for (i=0; i < room->nRoomNameParts; i++)
                        FreeStrBuf(&room->RoomNameParts[i]);
                free(room->RoomNameParts);
        }
        memset(room, 0, sizeof(folder));
 }
 
-void vDeleteFolder(void *vFolder) {
+void vDeleteFolder(void *vFolder)
+{
        folder *room;
 
-       room = (folder *) vFolder;
+       room = (folder*) vFolder;
        FlushFolder(room);
 
        free(room);
 }
 
 
-HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP) 
+{
        int Done = 0;
        HashList *rooms;
        folder *room;
@@ -215,14 +239,18 @@ HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
        Buf = NewStrBuf();
        rooms = NewHash(1, NULL);
        StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) == 1) {
-               while (!Done && (StrBuf_ServGetln(Buf) >= 0))
-                       if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
+       if (GetServerStatus(Buf, NULL) == 1) 
+       {
+               while(!Done && (StrBuf_ServGetln(Buf) >= 0))
+                       if ( (StrLength(Buf)==3) && 
+                            !strcmp(ChrPtr(Buf), "000")) 
+                       {
                                Done = 1;
                        }
-                       else {
+                       else
+                       {                               
                                Pos = NULL;
-                               room = (folder *) malloc(sizeof(folder));
+                               room = (folder*) malloc (sizeof(folder));
                                memset(room, 0, sizeof(folder));
 
                                /* Load the base data from the server reply */
@@ -249,30 +277,37 @@ HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
                                /* Evaluate the Server sent data for later use */
                                /* find out, whether we are in a sub-room */
                                room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
-                               if (room->nRoomNameParts > 1) {
+                               if (room->nRoomNameParts > 1)
+                               {
                                        int i;
 
                                        Pos = NULL;
-                                       room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
-                                       memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
-                                       for (i = 0; i < room->nRoomNameParts; i++) {
+                                       room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
+                                       memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
+                                       for (i=0; i < room->nRoomNameParts; i++)
+                                       {
                                                room->RoomNameParts[i] = NewStrBuf();
-                                               StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
+                                               StrBufExtract_NextToken(room->RoomNameParts[i],
+                                                                       room->name, &Pos, '\\');
                                        }
                                }
 
                                /* Private mailboxes on the main floor get remapped to the personal folder */
-                               if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
+                               if ((room->QRFlags & QR_MAILBOX) && 
+                                   (room->floorid == 0))
+                               {
                                        room->floorid = VIRTUAL_MY_FLOOR;
-                                       if ((room->nRoomNameParts == 1) &&
-                                           (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
+                                       if ((room->nRoomNameParts == 1) && 
+                                           (StrLength(room->name) == 4) && 
+                                           (strcmp(ChrPtr(room->name), "Mail") == 0))
+                                       {
                                                room->is_inbox = 1;
                                        }
 
                                }
                                /* get a pointer to the floor we're on: */
                                GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
-                               room->Floor = (const Floor *) vFloor;
+                               room->Floor = (const Floor*) vFloor;
 
 
 
@@ -285,13 +320,14 @@ HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
        SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("fileunsorted"), 0);
        if (SortIt != NULL)
                SortByPayload(rooms, SortIt);
-       else
+       else 
                SortByPayload(rooms, SortRoomsByListOrder);
        FreeStrBuf(&Buf);
        return rooms;
 }
 
-HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP) 
+{
        wcsession *WCC = WC;
        StrBuf *Line;
        StrBuf *Token;
@@ -300,20 +336,24 @@ HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
        long aliaslen;
        long locallen;
        long State;
-
-       serv_puts("GNET " FILE_MAILALIAS);
+       
+       serv_puts("GNET "FILE_MAILALIAS);
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) {
+       if (GetServerStatus(Line, &State) == 1) 
+       {
                int Done = 0;
                int n = 0;
 
                Aliases = NewHash(1, NULL);
-               while (!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
+               while(!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000"))
+                       {
                                Done = 1;
                        }
-                       else {
+                       else
+                       {
                                pComma = strchr(ChrPtr(Line), ',');
                                if (pComma == NULL)
                                        continue;
@@ -327,7 +367,10 @@ HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
                                if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
                                        continue;
                                Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
-                               Put(Aliases, IKEY(n), Token, HFreeStrBuf);
+                               Put(Aliases, 
+                                   IKEY(n),
+                                   Token, 
+                                   HFreeStrBuf);
                                n++;
                        }
        }
@@ -340,9 +383,15 @@ HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
 }
 
 
-void AppendPossibleAliasWithDomain(HashList * PossibleAliases,
-                                  long *nPossibleAliases,
-                                  const HashList * Domains, const char *prefix, long len, const char *Alias, long AliasLen) {
+void AppendPossibleAliasWithDomain(
+       HashList *PossibleAliases,
+       long *nPossibleAliases,
+       const HashList *Domains, 
+       const char *prefix,
+       long len,
+       const char* Alias,
+       long AliasLen)
+{
        const StrBuf *OneDomain;
        StrBuf *Line;
        HashPos *It = NULL;
@@ -353,29 +402,34 @@ void AppendPossibleAliasWithDomain(HashList * PossibleAliases,
 
        It = GetNewHashPos(Domains, 1);
        n = *nPossibleAliases;
-       while (GetNextHashPos(Domains, It, &KLen, &Key, &pV)) {
-               OneDomain = (const StrBuf *) pV;
+       while (GetNextHashPos(Domains, It, &KLen, &Key, &pV))
+       {
+               OneDomain = (const StrBuf*) pV;
                Line = NewStrBuf();
                StrBufAppendBufPlain(Line, prefix, len, 0);
                StrBufAppendBufPlain(Line, Alias, AliasLen, 0);
                StrBufAppendBufPlain(Line, HKEY("@"), 0);
                StrBufAppendBuf(Line, OneDomain, 0);
 
-               Put(PossibleAliases, IKEY(n), Line, HFreeStrBuf);
+               Put(PossibleAliases, 
+                   IKEY(n),
+                   Line, 
+                   HFreeStrBuf);
                n++;
        }
        DeleteHashPos(&It);
        *nPossibleAliases = n;
 }
 
-HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP) 
+{
        wcsession *WCC = WC;
        HashList *Domains;
        StrBuf *Line;
        StrBuf *Token;
        StrBuf *RoomName;
        HashList *PossibleAliases = NULL;
-
+       
        const char *pComma;
        const char *pAt;
        long aliaslen;
@@ -396,19 +450,27 @@ HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
        StrBufAsciify(RoomName, '_');
        StrBufReplaceChars(RoomName, ' ', '_');
 
-       AppendPossibleAliasWithDomain(PossibleAliases, &n, Domains, HKEY("room_"), SKEY(RoomName));
+       AppendPossibleAliasWithDomain(PossibleAliases,
+                                     &n,
+                                     Domains,
+                                     HKEY("room_"),
+                                     SKEY(RoomName));
 
 
-       serv_puts("GNET " FILE_MAILALIAS);
+       serv_puts("GNET "FILE_MAILALIAS);
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) {
+       if (GetServerStatus(Line, &State) == 1) 
+       {
                int Done = 0;
 
-               while (!Done && (StrBuf_ServGetln(Line) >= 0))
-                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
+               while(!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000"))
+                       {
                                Done = 1;
                        }
-                       else {
+                       else
+                       {
                                pComma = strchr(ChrPtr(Line), ',');
                                if (pComma == NULL)
                                        continue;
@@ -422,15 +484,24 @@ HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
                                if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
                                        continue;
                                pAt = strchr(ChrPtr(Line), '@');
-                               if ((pAt == NULL) || (pAt > pComma)) {
+                               if ((pAt == NULL) || (pAt > pComma))
+                               {
                                        AppendPossibleAliasWithDomain(PossibleAliases,
-                                                                     &n, Domains, HKEY(""), ChrPtr(Line), aliaslen);
+                                                                     &n,
+                                                                     Domains,
+                                                                     HKEY(""),
+                                                                     ChrPtr(Line),
+                                                                     aliaslen);
                                        n++;
                                }
-                               else {
-
+                               else
+                               {
+                                       
                                        Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
-                                       Put(PossibleAliases, IKEY(n), Token, HFreeStrBuf);
+                                       Put(PossibleAliases,
+                                           IKEY(n),
+                                           Token,
+                                           HFreeStrBuf);
                                        n++;
                                }
                        }
@@ -444,7 +515,8 @@ HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
 }
 
 
-HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
+HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP) 
+{
        wcsession *WCC = WC;
        StrBuf *Line;
        StrBuf *Token;
@@ -452,51 +524,65 @@ HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
        long WantThisOne;
        long PutTo;
        long State;
-
+       
        WantThisOne = GetTemplateTokenNumber(Target, TP, 5, -1);
        if ((WantThisOne < 0) || (WantThisOne > maxRoomNetCfg))
                return NULL;
-       if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL)
+       if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
                return WCC->CurRoom.IgnetCfgs[WantThisOne];
 
-       WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList *) StrBufNOTNULL;
+       WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList*) StrBufNOTNULL;
        serv_puts("GNET");
        Line = NewStrBuf();
        Token = NewStrBuf();
        StrBuf_ServGetln(Line);
-       if (GetServerStatus(Line, &State) == 1) {
+       if (GetServerStatus(Line, &State) == 1) 
+       {
                const char *Pos = NULL;
                int Done = 0;
                int HaveRoomMailAlias = 0;
 
-               while (!Done && (StrBuf_ServGetln(Line) >= 0)) {
+               while(!Done && (StrBuf_ServGetln(Line) >= 0))
+               {
                        if (StrLength(Line) == 0)
                                continue;
-                       if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000"))
+                       {
                                Done = 1;
                        }
-                       else {
+                       else
+                       {
                                StrBufExtract_NextToken(Token, Line, &Pos, '|');
                                PutTo = GetTokenDefine(SKEY(Token), -1);
-                               if (PutTo == roommailalias) {
+                               if (PutTo == roommailalias)
+                               {
                                        if (HaveRoomMailAlias > 0)
-                                               continue;       /* Only ONE alias possible! */
+                                               continue; /* Only ONE alias possible! */
                                        HaveRoomMailAlias++;
                                }
-                               if ((PutTo >= 0) && (PutTo < maxRoomNetCfg) && (Pos != StrBufNOTNULL)) {
+                               if ((PutTo >= 0) && 
+                                   (PutTo < maxRoomNetCfg) &&
+                                   (Pos != StrBufNOTNULL))
+                               {
                                        int n;
                                        HashList *SubH;
-
-                                       if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL) {
+                                       
+                                       if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL)
+                                       {
                                                n = 0;
                                                WCC->CurRoom.IgnetCfgs[PutTo] = NewHash(1, NULL);
                                        }
-                                       else {
+                                       else 
+                                       {
                                                n = GetCount(WCC->CurRoom.IgnetCfgs[PutTo]);
                                        }
                                        SubH = NewHash(1, NULL);
-                                       Put(WCC->CurRoom.IgnetCfgs[PutTo], IKEY(n), SubH, HDeleteHash);
-                                       n = 1;  /* #0 is the type... */
+                                       Put(WCC->CurRoom.IgnetCfgs[PutTo], 
+                                           IKEY(n),
+                                           SubH, 
+                                           HDeleteHash);
+                                       n = 1; /* #0 is the type... */
                                        while (Pos != StrBufNOTNULL) {
                                                Content = NewStrBuf();
                                                StrBufExtract_NextToken(Content, Line, &Pos, '|');
@@ -504,7 +590,10 @@ HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
                                                if ((PutTo == roommailalias) && n == 1)
                                                        WCC->CurRoom.RoomAlias = Content;
 
-                                               Put(SubH, IKEY(n), Content, HFreeStrBuf);
+                                               Put(SubH, 
+                                                   IKEY(n),
+                                                   Content, 
+                                                   HFreeStrBuf);
                                                n++;
                                        }
                                }
@@ -522,29 +611,30 @@ HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
 }
 
 /** Unused function that orders rooms by the listorder flag */
-int SortRoomsByListOrder(const void *room1, const void *room2) {
-       folder *r1 = (folder *) GetSearchPayload(room1);
-       folder *r2 = (folder *) GetSearchPayload(room2);
-
-       if (r1->Order == r2->Order)
-               return 0;
-       if (r1->Order > r2->Order)
-               return 1;
+int SortRoomsByListOrder(const void *room1, const void *room2) 
+{
+       folder *r1 = (folder*) GetSearchPayload(room1);
+       folder *r2 = (folder*) GetSearchPayload(room2);
+  
+       if (r1->Order == r2->Order) return 0;
+       if (r1->Order > r2->Order) return 1;
        return -1;
 }
 
-int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
-       folder *r1 = (folder *) GetSearchPayload(room1);
-       folder *r2 = (folder *) GetSearchPayload(room2);
-
-       if ((r1->Floor == NULL) || (r2->Floor == NULL))
+int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) 
+{
+       folder *r1 = (folder*) GetSearchPayload(room1);
+       folder *r2 = (folder*) GetSearchPayload(room2);
+  
+       if ((r1->Floor == NULL)  ||
+           (r2->Floor == NULL))
                return 0;
-
+               
        /**
         * are we on the same floor? else sort by floor.
         */
-       if (r1->Floor != r2->Floor) {
-
+       if (r1->Floor != r2->Floor)
+       {
                /**
                 * the private rooms are first in any case.
                 */
@@ -552,11 +642,10 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
                        return -1;
                if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
                        return 1;
-
                /**
                 * else decide alpaheticaly by floorname
                 */
-               return (r1->Floor->AlphaN > r2->Floor->AlphaN) ? 1 : -1;
+               return (r1->Floor->AlphaN > r2->Floor->AlphaN)? 1 : -1;
        }
 
        /**
@@ -564,17 +653,22 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
         * we want the toplevel to be first, regardless of sort
         * sequence.
         */
-       if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
+       if (((r1->nRoomNameParts > 1) || 
+           (r2->nRoomNameParts > 1)    )&&
+           (r1->nRoomNameParts != r2->nRoomNameParts))
+       {
                int i, ret;
-               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
-
-               for (i = 0; i < nparts; i++) {
-                       ret = strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
+               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
+                       r2->nRoomNameParts : r1->nRoomNameParts;
 
+               for (i=0; i < nparts; i++)
+               {
+                       ret = strcmp (ChrPtr(r1->name), 
+                                     ChrPtr(r2->name));
                        /**
                         * Deltas in common parts? exit here.
                         */
-                       if (ret != 0)
+                       if (ret != 0) 
                                return ret;
                }
 
@@ -591,21 +685,24 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
        /**
         * else just sort alphabeticaly.
         */
-       return strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
+       return strcmp (ChrPtr(r1->name), 
+                      ChrPtr(r2->name));
 }
 
-int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2) {
-       folder *r1 = (folder *) GetSearchPayload(room1);
-       folder *r2 = (folder *) GetSearchPayload(room2);
+int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2) 
+{
+       folder *r1 = (folder*) GetSearchPayload(room1);
+       folder *r2 = (folder*) GetSearchPayload(room2);
 
-       if ((r1->Floor == NULL) || (r2->Floor == NULL))
+       if ((r1->Floor == NULL)  ||
+           (r2->Floor == NULL))
                return 0;
 
        /**
         * are we on the same floor? else sort by floor.
         */
-       if (r2->Floor != r1->Floor) {
-
+       if (r2->Floor != r1->Floor)
+       {
                /**
                 * the private rooms are first in any case.
                 */
@@ -613,12 +710,11 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
                        return -1;
                if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
                        return 1;
-
                /**
                 * else decide alpaheticaly by floorname
                 */
 
-               return (r1->Floor->AlphaN < r2->Floor->AlphaN) ? 1 : -1;
+               return (r1->Floor->AlphaN < r2->Floor->AlphaN)? 1 : -1;
        }
 
        /**
@@ -626,26 +722,32 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
         * we want the toplevel to be first, regardless of sort
         * sequence.
         */
-       if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
+       if (((r1->nRoomNameParts > 1) || 
+           (r2->nRoomNameParts > 1)    )&&
+           (r1->nRoomNameParts != r2->nRoomNameParts))
+       {
                int i, ret;
-               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
-
-               for (i = 0; i < nparts; i++) {
+               int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
+                       r2->nRoomNameParts : r1->nRoomNameParts;
 
+               for (i=0; i < nparts; i++)
+               {
                        /**
                         * special cases if one room is top-level...
                         */
                        if (r2->nRoomNameParts == 1)
-                               ret = strcmp(ChrPtr(r2->name), ChrPtr(r1->RoomNameParts[i]));
+                               ret = strcmp (ChrPtr(r2->name), 
+                                             ChrPtr(r1->RoomNameParts[i]));
                        else if (r1->nRoomNameParts == 1)
-                               ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->name));
-                       else
-                               ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->RoomNameParts[i]));
-
+                               ret = strcmp (ChrPtr(r2->RoomNameParts[i]),
+                                             ChrPtr(r1->name));
+                       else 
+                               ret = strcmp (ChrPtr(r2->RoomNameParts[i]), 
+                                             ChrPtr(r1->RoomNameParts[i]));
                        /**
                         * Deltas in common parts? exit here.
                         */
-                       if (ret != 0)
+                       if (ret != 0) 
                                return ret;
                }
 
@@ -658,64 +760,71 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
                        return -1;
        }
 
-       return strcmp(ChrPtr(r2->name), ChrPtr(r1->name));
+       return strcmp (ChrPtr(r2->name), 
+                      ChrPtr(r1->name));
 }
 
-int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
-       folder *r1 = (folder *) room1;
-       folder *r2 = (folder *) room2;
+int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) 
+{
+       folder *r1 = (folder*) room1;
+       folder *r2 = (folder*) room2;
+  
 
-
-       if ((r1->Floor == NULL) || (r2->Floor == NULL))
+       if ((r1->Floor == NULL)  ||
+           (r2->Floor == NULL))
                return 0;
-
+               
        if (r1->Floor == r2->Floor)
                return 0;
-       else {
+       else 
+       {
                wcsession *WCC = WC;
                static int columns = 3;
                int boxes_per_column = 0;
                int nf;
 
                nf = GetCount(WCC->Floors);
-               while (nf % columns != 0)
-                       ++nf;
+               while (nf % columns != 0) ++nf;
                boxes_per_column = (nf / columns);
                if (boxes_per_column < 1)
                        boxes_per_column = 1;
                if (r1->Floor->AlphaN % boxes_per_column == 0)
                        return 2;
-               else
+               else 
                        return 1;
        }
 }
 
 
-int CompareRooms(const folder * room1, const folder * room2) {
+int CompareRooms(const folder *room1, const folder *room2) 
+{
        if ((room1 == NULL) || (room2 == NULL))
                return -1;
        return CompareRoomListByFloorRoomPrivFirst(room1, room2);
 }
 
-int ConditionalThisRoomIsStrBufContextAlias(StrBuf * Target, WCTemplputParams * TP) {
-       wcsession *WCC = WC;
-       const char *pVal;
-       long len;
-       eRoomParamType ParamType;
+int ConditionalThisRoomIsStrBufContextAlias(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession       *WCC = WC;
+       const char      *pVal;
+       long             len;
+       eRoomParamType   ParamType;
 
        ParamType = GetTemplateTokenNumber(Target, TP, 2, eNotSet);
        GetTemplateTokenString(Target, TP, 3, &pVal, &len);
 
-       if (ParamType == eNotSet) {
+       if (ParamType == eNotSet)
+       {
                return StrLength(WCC->CurRoom.RoomAlias) == 0;
        }
-       else if (ParamType == eDomain) {
-               const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
+       else if (ParamType == eDomain)
+       {
+               const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
                const char *pAt;
 
-               if (CtxStr == NULL)
+               if (CtxStr == NULL) 
                        return 0;
-
+               
                if (StrLength(WCC->CurRoom.RoomAlias) == 0)
                        return 0;
 
@@ -727,32 +836,36 @@ int ConditionalThisRoomIsStrBufContextAlias(StrBuf * Target, WCTemplputParams *
                        return 0;
                return strcmp(pAt + 1, ChrPtr(CtxStr)) == 0;
        }
-       else if (ParamType == eAlias) {
-               const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
+       else if (ParamType == eAlias)
+       {
+               const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
 
-               if (CtxStr == NULL)
+               if (CtxStr == NULL) 
                        return 0;
-
+               
                if (StrLength(WCC->CurRoom.RoomAlias) == 0)
                        return 0;
 
                return strcmp(ChrPtr(WCC->CurRoom.RoomAlias), ChrPtr(CtxStr)) == 0;
        }
-       else {
-               LogTemplateError(Target, "TokenParameter", 2, TP, "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
+       else
+       {
+               LogTemplateError(Target, "TokenParameter", 2, TP, 
+                                "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
                return 0;
        }
 
 }
 
-int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
-       wcsession *WCC = WC;
-       folder *Folder = (folder *) CTX(CTX_ROOMS);
-       HashPos *it;
-       StrBuf *Dir;
-       void *vDir;
-       long len;
-       const char *Key;
+int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession  *WCC = WC;
+       folder     *Folder = (folder *)CTX(CTX_ROOMS);
+       HashPos    *it;
+       StrBuf     * Dir;
+       void       *vDir;
+       long        len;
+        const char *Key;
        int i, j, urlp;
        int delta;
 
@@ -764,7 +877,10 @@ int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
        urlp = GetCount(WCC->Directory);
        delta = Folder->nRoomNameParts - urlp + 1;
 
-       syslog(LOG_DEBUG, "\n->%s: %d - %ld ", ChrPtr(Folder->name), urlp, Folder->nRoomNameParts);
+       syslog(LOG_DEBUG, "\n->%s: %d - %ld ", 
+              ChrPtr(Folder->name), 
+              urlp, 
+              Folder->nRoomNameParts);
        /* list only the floors which are in relation to the dav_depth header */
        if (WCC->Hdr->HR.dav_depth != delta) {
                syslog(LOG_DEBUG, "1\n");
@@ -776,16 +892,24 @@ int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
        /* Fast forward the floorname we checked above... */
        GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir);
 
-       if (Folder->nRoomNameParts > 1) {
-               for (i = 0, j = 1; (i > Folder->nRoomNameParts) && (j > urlp); i++, j++) {
-                       if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
+       if (Folder->nRoomNameParts > 1) {               
+               for (i = 0, j = 1; 
+                    (i > Folder->nRoomNameParts) && (j > urlp); 
+                    i++, j++)
+               {
+                       if (!GetNextHashPos(WCC->Directory, 
+                                           it, &len, &Key, &vDir) ||
+                           (vDir == NULL))
+                       {
                                DeleteHashPos(&it);
 
                                syslog(LOG_DEBUG, "3\n");
                                return 0;
                        }
-                       Dir = (StrBuf *) vDir;
-                       if (strcmp(ChrPtr(Folder->RoomNameParts[i]), ChrPtr(Dir)) != 0) {
+                       Dir = (StrBuf*) vDir;
+                       if (strcmp(ChrPtr(Folder->RoomNameParts[i]), 
+                                  ChrPtr(Dir)) != 0)
+                       {
                                DeleteHashPos(&it);
                                syslog(LOG_DEBUG, "4\n");
                                return 0;
@@ -795,16 +919,20 @@ int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
                return 1;
        }
        else {
-               if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
+               if (!GetNextHashPos(WCC->Directory, 
+                                   it, &len, &Key, &vDir) ||
+                   (vDir == NULL))
+               {
                        DeleteHashPos(&it);
-
+                       
                        syslog(LOG_DEBUG, "5\n");
                        return WCC->Hdr->HR.dav_depth == 1;
                }
                DeleteHashPos(&it);
-               Dir = (StrBuf *) vDir;
+               Dir = (StrBuf*) vDir;
                if (WCC->Hdr->HR.dav_depth == 0) {
-                       return (strcmp(ChrPtr(Folder->name), ChrPtr(Dir))
+                       return (strcmp(ChrPtr(Folder->name), 
+                                      ChrPtr(Dir))
                                == 0);
 
                }
@@ -813,7 +941,10 @@ int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
 }
 
 
-void InitModule_ROOMLIST(void) {
+void 
+InitModule_ROOMLIST
+(void)
+{
        /* we duplicate this, just to be shure its already done. */
        RegisterCTX(CTX_ROOMS);
        RegisterCTX(CTX_FLOORS);
@@ -821,8 +952,7 @@ void InitModule_ROOMLIST(void) {
        RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
        RegisterIterator("ITERATE:THISROOM:GNET", 1, NULL, GetNetConfigHash, NULL, NULL, CTX_STRBUFARR, CTX_NONE, IT_NOFLAG);
        RegisterIterator("ITERATE:THISROOM:MALIAS", 1, NULL, GetThisRoomMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
-       RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF,
-                        CTX_NONE, IT_NOFLAG);
+       RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
 
        RegisterIterator("LFLR", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
        RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, NULL, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
@@ -842,6 +972,8 @@ void InitModule_ROOMLIST(void) {
        RegisterSortFunc(HKEY("byfloorroom"),
                         NULL, 0,
                         CompareRoomListByFloorRoomPrivFirst,
-                        CompareRoomListByFloorRoomPrivFirstRev, GroupchangeRoomListByFloorRoomPrivFirst, CTX_ROOMS);
+                        CompareRoomListByFloorRoomPrivFirstRev,
+                        GroupchangeRoomListByFloorRoomPrivFirst,
+                        CTX_ROOMS);
 
 }