+HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ StrBuf *Line;
+ StrBuf *Token;
+ HashList *Aliases = NULL;
+ const char *pComma;
+ long aliaslen;
+ long locallen;
+ long State;
+
+ serv_puts("GNET "FILE_MAILALIAS);
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ 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"))
+ {
+ Done = 1;
+ }
+ else
+ {
+ pComma = strchr(ChrPtr(Line), ',');
+ if (pComma == NULL)
+ continue;
+ aliaslen = pComma - ChrPtr(Line);
+ locallen = StrLength(Line) - 1 - aliaslen;
+ if (locallen - 5 != StrLength(WCC->CurRoom.name))
+ continue;
+ if (strncmp(pComma + 1, "room_", 5) != 0)
+ continue;
+
+ if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
+ continue;
+ Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
+ Put(Aliases,
+ IKEY(n),
+ Token,
+ HFreeStrBuf);
+ n++;
+ }
+ }
+ else if (State == 550)
+ AppendImportantMessage(_("Higher access is required to access this function."), -1);
+
+ FreeStrBuf(&Line);
+
+ return Aliases;
+}
+
+
+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;
+ const char *Key;
+ long KLen;
+ void *pV;
+ int n;
+
+ It = GetNewHashPos(Domains, 1);
+ n = *nPossibleAliases;
+ 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);
+ n++;
+ }
+ DeleteHashPos(&It);
+ *nPossibleAliases = n;
+}
+
+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;
+ long locallen;
+ long State;
+ long n = 0;
+
+ Domains = GetValidDomainNames(Target, TP);
+ if (Domains == NULL)
+ return NULL;
+ if (GetCount(Domains) == 0) {
+ DeleteHash(Domains);
+ return NULL;
+ }
+ PossibleAliases = NewHash(1, NULL);
+ Line = NewStrBuf();
+ RoomName = NewStrBufDup(WCC->CurRoom.name);
+ StrBufAsciify(RoomName, '_');
+ StrBufReplaceChars(RoomName, ' ', '_');
+
+ AppendPossibleAliasWithDomain(PossibleAliases,
+ &n,
+ Domains,
+ HKEY("room_"),
+ SKEY(RoomName));
+
+
+ serv_puts("GNET "FILE_MAILALIAS);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatus(Line, &State) == 1)
+ {
+ int Done = 0;
+
+ while(!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ( (StrLength(Line)==3) &&
+ !strcmp(ChrPtr(Line), "000"))
+ {
+ Done = 1;
+ }
+ else
+ {
+ pComma = strchr(ChrPtr(Line), ',');
+ if (pComma == NULL)
+ continue;
+ aliaslen = pComma - ChrPtr(Line);
+ locallen = StrLength(Line) - 1 - aliaslen;
+ if (locallen - 5 != StrLength(WCC->CurRoom.name))
+ continue;
+ if (strncmp(pComma + 1, "room_", 5) != 0)
+ continue;
+
+ if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
+ continue;
+ pAt = strchr(ChrPtr(Line), '@');
+ if ((pAt == NULL) || (pAt > pComma))
+ {
+ AppendPossibleAliasWithDomain(PossibleAliases,
+ &n,
+ Domains,
+ HKEY(""),
+ ChrPtr(Line),
+ aliaslen);
+ n++;
+ }
+ else
+ {
+
+ Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
+ Put(PossibleAliases,
+ IKEY(n),
+ Token,
+ HFreeStrBuf);
+ n++;
+ }
+ }
+ }
+ else if (State == 550)
+ AppendImportantMessage(_("Higher access is required to access this function."), -1);
+ DeleteHash(&Domains);
+ FreeStrBuf(&Line);
+ FreeStrBuf(&RoomName);
+ return PossibleAliases;
+}
+
+
+HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ StrBuf *Line;
+ StrBuf *Token;
+ StrBuf *Content;
+ 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)
+ return WCC->CurRoom.IgnetCfgs[WantThisOne];
+
+ WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList*) StrBufNOTNULL;
+ serv_puts("GNET");
+ Line = NewStrBuf();
+ Token = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ if (GetServerStatus(Line, &State) == 1)
+ {
+ const char *Pos = NULL;
+ int Done = 0;
+ int HaveRoomMailAlias = 0;
+
+ while(!Done && (StrBuf_ServGetln(Line) >= 0))
+ {
+ if (StrLength(Line) == 0)
+ continue;
+ if ( (StrLength(Line)==3) &&
+ !strcmp(ChrPtr(Line), "000"))
+ {
+ Done = 1;
+ }
+ else
+ {
+ StrBufExtract_NextToken(Token, Line, &Pos, '|');
+ PutTo = GetTokenDefine(SKEY(Token), -1);
+ if (PutTo == roommailalias)
+ {
+ if (HaveRoomMailAlias > 0)
+ continue; /* Only ONE alias possible! */
+ HaveRoomMailAlias++;
+ }
+ if ((PutTo >= 0) &&
+ (PutTo < maxRoomNetCfg) &&
+ (Pos != StrBufNOTNULL))
+ {
+ int n;
+ HashList *SubH;
+
+ if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL)
+ {
+ n = 0;
+ WCC->CurRoom.IgnetCfgs[PutTo] = NewHash(1, NULL);
+ }
+ 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... */
+ while (Pos != StrBufNOTNULL) {
+ Content = NewStrBuf();
+ StrBufExtract_NextToken(Content, Line, &Pos, '|');
+
+ if ((PutTo == roommailalias) && n == 1)
+ WCC->CurRoom.RoomAlias = Content;
+
+ Put(SubH,
+ IKEY(n),
+ Content,
+ HFreeStrBuf);
+ n++;
+ }
+ }
+ Pos = NULL;
+ }
+ }
+ }
+ else if (State == 550)
+ AppendImportantMessage(_("Higher access is required to access this function."), -1);
+
+ FreeStrBuf(&Line);
+ FreeStrBuf(&Token);
+
+ return WCC->CurRoom.IgnetCfgs[WantThisOne];
+}
+