+
+void _terminate_session(void) {
+ slrp_highest();
+ terminate_session();
+}
+
+HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
+
+{
+ StrBuf *Buf;
+ HashList *List;
+ time_t now;
+
+ Buf = NewStrBuf();
+
+ serv_puts("TIME");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ const char *pos = ChrPtr(Buf) + 4;
+ now = StrBufExtractNext_long(Buf, &pos, '|');
+ }
+ else {
+ now = time(NULL);
+ }
+
+ List = NewHash(1, NULL);
+ GetWholistSection(List, now, Buf);
+ FreeStrBuf(&Buf);
+ return List;
+}
+
+
+void DeleteWholistHash(HashList **KillMe)
+{
+ DeleteHash(KillMe);
+}
+
+void tmplput_who_username(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->UserName, 0);
+}
+
+void tmplput_who_room(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->Room, 0);
+}
+
+void tmplput_who_host(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->Host, 0);
+}
+
+void tmplput_who_realroom(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->RealRoom, 0);
+}
+int conditional_who_realroom(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ return StrLength(User->RealRoom) > 0;
+}
+
+void tmplput_who_realhost(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->RealHost, 0);
+}
+
+void tmplput_who_lastactive(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendPrintf(Target, "%d", User->LastActive);
+}
+
+void tmplput_who_idlesince(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendPrintf(Target, "%d", User->IdleSince);
+}
+
+void tmplput_who_session(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendPrintf(Target, "%d", User->Session);
+}
+
+int conditional_who_idle(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ return User->Idle;
+}
+
+int conditional_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ return User->SessionCount;
+}
+
+void tmplput_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendPrintf(Target, "%d", User->SessionCount);
+}
+
+int conditional_who_isme(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ return (User->Session == WC->ctdl_pid);
+}
+
+void
+InitModule_WHO
+(void)
+{
+
+
+ WebcitAddUrlHandler(HKEY("terminate_session"), "", 0, _terminate_session, 0);
+ WebcitAddUrlHandler(HKEY("edit_me"), "", 0, edit_me, 0);
+
+ RegisterIterator("WHOLIST", 0, NULL, GetWholistHash, NULL, DeleteWholistHash, CTX_WHO, CTX_NONE, IT_NOFLAG);
+
+ RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO);
+ RegisterNamespace("WHO:ROOM", 0, 1, tmplput_who_room, NULL, CTX_WHO);
+ RegisterNamespace("WHO:HOST", 0, 1, tmplput_who_host, NULL, CTX_WHO);
+ RegisterNamespace("WHO:REALROOM", 0, 1, tmplput_who_realroom, NULL, CTX_WHO);
+ RegisterNamespace("WHO:REALHOST", 0, 1, tmplput_who_realhost, NULL, CTX_WHO);
+ RegisterNamespace("WHO:LASTACTIVE", 0, 1, tmplput_who_lastactive, NULL, CTX_WHO);
+ RegisterNamespace("WHO:IDLESINCE", 0, 1, tmplput_who_idlesince, NULL, CTX_WHO);
+ RegisterNamespace("WHO:SESSION", 0, 1, tmplput_who_session, NULL, CTX_WHO);
+ RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+ RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+
+ RegisterConditional(HKEY("WHO:IDLE"), 1, conditional_who_idle, CTX_WHO);
+ RegisterConditional(HKEY("WHO:NSESSIONS"), 1, conditional_who_nsessions, CTX_WHO);
+ RegisterConditional(HKEY("WHO:ISME"), 1, conditional_who_isme, CTX_WHO);
+ RegisterConditional(HKEY("WHO:REALROOM"), 1, conditional_who_realroom, CTX_WHO);
+}