+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;
+}
+
+