+void tmplput_who_session(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+ StrBufAppendPrintf(Target, "%d", User->Session);
+}
+
+int conditional_who_idle(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+ return User->Idle;
+}
+
+int conditional_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+ return User->SessionCount;
+}
+
+void tmplput_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+ StrBufAppendPrintf(Target, "%d", User->SessionCount);
+}
+
+int conditional_who_isme(StrBuf *Target, WCTemplputParams *TP)
+{
+ UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+ return (User->Session == WC->ctdl_pid);
+}
+
+void
+InitModule_WHO
+(void)
+{
+ RegisterCTX(CTX_WHO);
+
+ WebcitAddUrlHandler(HKEY("terminate_session"), "", 0, _terminate_session, 0);
+
+ RegisterIterator("WHOLIST", 1, NULL, GetWholistHash, NULL, DeleteWholistHash, CTX_WHO, CTX_NONE, IT_NOFLAG);
+
+ RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO);
+ RegisterNamespace("WHO:USERAGENT", 0, 1, tmplput_who_UserAgent, 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("WHO:IDLE", 1, conditional_who_idle, CTX_WHO);
+ RegisterConditional("WHO:NSESSIONS", 1, conditional_who_nsessions, CTX_WHO);
+ RegisterConditional("WHO:ISME", 1, conditional_who_isme, CTX_WHO);
+ RegisterConditional("WHO:REALROOM", 1, conditional_who_realroom, CTX_WHO);
+ RegisterConditional("WHO:REALHOST", 1, conditional_who_realhost, CTX_WHO);