+
+void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
+}
+
+void tmplput_serv_admin(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_sysadm, 0);
+}
+
+void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_nodename, 0);
+}
+
+void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_humannode, 0);
+}
+
+void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_fqdn, 0);
+}
+
+void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_software, 0);
+}
+
+void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP)
+{
+ if (WC->serv_info == NULL) return;
+ StrBufAppendPrintf(Target, "%d", WC->serv_info->serv_rev_level);
+}
+int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return 0;
+ return WCC->serv_info->serv_newuser_disabled != 0;
+}
+
+int conditional_serv_supports_guest(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return 0;
+ return WCC->serv_info->serv_supports_guest != 0;
+}
+
+int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return 0;
+ return WCC->serv_info->serv_supports_openid != 0;
+}
+
+int conditional_serv_fulltext_enabled(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return 0;
+ return WCC->serv_info->serv_fulltext_enabled != 0;
+}
+
+int conditional_serv_ldap_enabled(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return 0;
+ return WCC->serv_info->serv_supports_ldap != 0;
+}
+
+void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ if (WCC->serv_info == NULL)
+ return;
+ StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0);
+}
+
+void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP)
+{
+ int n = 0;
+ int Done = 0;
+ StrBuf *Line;
+ StrBuf *Buf;
+
+ Buf = NewStrBuf();
+ Line = NewStrBuf();
+ serv_printf("MESG %s", TP->Tokens->Params[0]->Start);
+
+ StrBuf_ServGetln(Line);
+ if (GetServerStatus(Line, NULL) == 1) {
+ while (!Done && (StrBuf_ServGetln(Line)>=0)) {
+ if ( (StrLength(Line)==3) &&
+ !strcmp(ChrPtr(Line), "000"))
+ Done = 1;
+ else
+ {
+ if (n > 0)
+ StrBufAppendBufPlain(Buf, "\n", 1, 0);
+ StrBufAppendBuf(Buf, Line, 0);
+ }
+ n++;
+ }
+
+ FlushStrBuf(Line);
+ FmOut(Line, "center", Buf);
+ StrBufAppendTemplate(Target, TP, Line, 1);
+ }
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&Line);
+}
+
+void tmplput_site_prefix(StrBuf *Target, WCTemplputParams *TP) {
+ wcsession *WCC = WC;
+ if ((WCC != NULL) && (WCC->Hdr->HostHeader != NULL)) {
+ StrBufAppendTemplate(Target, TP, WCC->Hdr->HostHeader, 0);
+ }
+}
+
+void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority)
+{
+ StrBuf *MT;
+ MT = NewStrBufPlain(MimeType, MTLen);
+ Put(EmbeddableMimes, IKEY(Priority), MT, HFreeStrBuf);
+}
+
+void CreateMimeStr(void)
+{
+ HashPos *it;
+ void *vMime;
+ long len = 0;
+ const char *Key;
+
+ it = GetNewHashPos(EmbeddableMimes, 0);
+ while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) &&
+ (vMime != NULL)) {
+ if (StrLength(EmbeddableMimeStrs) > 0)
+ StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("|"), 0);
+ else
+ StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("MSGP "), 0);
+ StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf*) vMime, 0);
+ }
+ DeleteHashPos(&it);
+}
+
+void
+ServerStartModule_SERV_FUNC
+(void)
+{
+ EmbeddableMimes = NewHash(1, Flathash);
+ EmbeddableMimeStrs = NewStrBuf();
+}
+
+
+void
+ServerShutdownModule_SERV_FUNC
+(void)
+{
+ FreeStrBuf(&EmbeddableMimeStrs);
+ DeleteHash(&EmbeddableMimes);
+}
+
+void
+InitModule_SERVFUNC
+(void)
+{
+ is_uds = strcasecmp(ctdlhost, "uds") == 0;
+ if (is_uds)
+ snprintf(serv_sock_name, PATH_MAX, "%s/citadel.socket", ctdlport);
+
+ RegisterConditional("COND:SERV:OPENID", 2, conditional_serv_supports_openid, CTX_NONE);
+ RegisterConditional("COND:SERV:NEWU", 2, conditional_serv_newuser_disabled, CTX_NONE);
+ RegisterConditional("COND:SERV:FULLTEXT_ENABLED", 2, conditional_serv_fulltext_enabled, CTX_NONE);
+ RegisterConditional("COND:SERV:LDAP_ENABLED", 2, conditional_serv_ldap_enabled, CTX_NONE);
+ RegisterConditional("COND:SERV:SUPPORTS_GUEST", 2, conditional_serv_supports_guest, CTX_NONE);
+ RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, NULL, CTX_NONE);
+ RegisterNamespace("SERV:NODENAME", 0, 1, tmplput_serv_nodename, NULL, CTX_NONE);
+ RegisterNamespace("SERV:HUMANNODE", 0, 1, tmplput_serv_humannode, NULL, CTX_NONE);
+ RegisterNamespace("SERV:FQDN", 0, 1, tmplput_serv_fqdn, NULL, CTX_NONE);
+
+ RegisterNamespace("SERV:SOFTWARE", 0, 1, tmplput_serv_software, NULL, CTX_NONE);
+ RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, NULL, CTX_NONE);
+ RegisterNamespace("SERV:BBS_CITY", 0, 1, tmplput_serv_bbs_city, NULL, CTX_NONE);
+ RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, NULL, CTX_NONE);
+ RegisterNamespace("SERV:ADMIN", 0, 1, tmplput_serv_admin, NULL, CTX_NONE);
+
+ RegisterNamespace("SERV:SITE:PREFIX", 0, 1, tmplput_site_prefix, NULL, CTX_NONE);
+
+
+}
+
+
+
+void
+SessionDestroyModule_SERVFUNC
+(wcsession *sess)
+{
+ DeleteServInfo(&sess->serv_info);
+}