upsi, that const was missing.
[citadel.git] / webcit / serv_func.c
1
2 #include "webcit.h"
3 #include "webserver.h"
4
5 int is_uds = 0;
6 char serv_sock_name[PATH_MAX] = "";
7
8 HashList *EmbeddableMimes = NULL;
9 StrBuf *EmbeddableMimeStrs = NULL;
10
11
12 void SetInlinMimeRenderers(void)
13 {
14         StrBuf *Buf;
15
16         Buf = NewStrBuf();
17
18         /* Tell the server what kind of richtext we prefer */
19         serv_putbuf(EmbeddableMimeStrs);
20         StrBuf_ServGetln(Buf);
21
22         FreeStrBuf(&Buf);
23 }
24
25
26 void DeleteServInfo(ServInfo **FreeMe)
27 {
28         if (*FreeMe == NULL)
29                 return;
30         FreeStrBuf(&(*FreeMe)->serv_nodename);
31         FreeStrBuf(&(*FreeMe)->serv_humannode);
32         FreeStrBuf(&(*FreeMe)->serv_fqdn);
33         FreeStrBuf(&(*FreeMe)->serv_software);
34         FreeStrBuf(&(*FreeMe)->serv_bbs_city);
35         FreeStrBuf(&(*FreeMe)->serv_sysadm);
36         FreeStrBuf(&(*FreeMe)->serv_default_cal_zone);
37         FreeStrBuf(&(*FreeMe)->serv_svn_revision);
38         free(*FreeMe);
39         *FreeMe = NULL;
40 }
41
42 /*
43  * get info about the server we've connected to
44  *
45  * browser_host         the citadel we want to connect to
46  * user_agent           which browser uses our client?
47  */
48 ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent)
49 {
50         ServInfo *info;
51         StrBuf *Buf;
52         int a;
53         int rc;
54
55         Buf = NewStrBuf();
56
57         /* Tell the server what kind of client is connecting */
58         serv_printf("IDEN %d|%d|%d|%s|%s",
59                     DEVELOPER_ID,
60                     CLIENT_ID,
61                     CLIENT_VERSION,
62                     ChrPtr(user_agent),
63                     ChrPtr(browser_host)
64         );
65         StrBuf_ServGetln(Buf);
66         if (GetServerStatus(Buf, NULL) != 2) {
67                 syslog(0, "get_serv_info(IDEN): unexpected answer [%s]\n",
68                         ChrPtr(Buf));
69                 FreeStrBuf(&Buf);
70                 return NULL;
71         }
72
73         /*
74          * Tell the server that when we save a calendar event, we
75          * want invitations to be generated by the Citadel server
76          * instead of by the client.
77          */
78         serv_puts("ICAL sgi|1");
79         StrBuf_ServGetln(Buf);
80         if (GetServerStatus(Buf, NULL) != 2) {
81                 syslog(0, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n",
82                         ChrPtr(Buf));
83                 FreeStrBuf(&Buf);
84                 return NULL;
85         }
86
87         /* Now ask the server to tell us a little bit about itself... */
88         serv_puts("INFO");
89         StrBuf_ServGetln(Buf);
90         if (GetServerStatus(Buf, NULL) != 1) {
91                 syslog(0, "get_serv_info(INFO sgi|1): unexpected answer [%s]\n",
92                         ChrPtr(Buf));
93                 FreeStrBuf(&Buf);
94                 return NULL;
95         }
96
97         info = (ServInfo*)malloc(sizeof(ServInfo));
98         memset(info, 0, sizeof(ServInfo));
99         a = 0;
100         while (rc = StrBuf_ServGetln(Buf),
101                (rc >= 0) &&
102                ((rc != 3) || 
103                 strcmp(ChrPtr(Buf), "000")))
104         {
105                 switch (a) {
106                 case 0:
107                         info->serv_pid = StrToi(Buf);
108                         WC->ctdl_pid = info->serv_pid;
109                         break;
110                 case 1:
111                         info->serv_nodename = NewStrBufDup(Buf);
112                         break;
113                 case 2:
114                         info->serv_humannode = NewStrBufDup(Buf);
115                         break;
116                 case 3:
117                         info->serv_fqdn = NewStrBufDup(Buf);
118                         break;
119                 case 4:
120                         info->serv_software = NewStrBufDup(Buf);
121                         break;
122                 case 5:
123                         info->serv_rev_level = StrToi(Buf);
124                         break;
125                 case 6:
126                         info->serv_bbs_city = NewStrBufDup(Buf);
127                         break;
128                 case 7:
129                         info->serv_sysadm = NewStrBufDup(Buf);
130                         break;
131                 case 14:
132                         info->serv_supports_ldap = StrToi(Buf);
133                         break;
134                 case 15:
135                         info->serv_newuser_disabled = StrToi(Buf);
136                         break;
137                 case 16:
138                         info->serv_default_cal_zone = NewStrBufDup(Buf);
139                         break;
140                 case 20:
141                         info->serv_supports_sieve = StrToi(Buf);
142                         break;
143                 case 21:
144                         info->serv_fulltext_enabled = StrToi(Buf);
145                         break;
146                 case 22:
147                         info->serv_svn_revision = NewStrBufDup(Buf);
148                         break;
149                 case 23:
150                         info->serv_supports_openid = StrToi(Buf);
151                         break;
152                 case 24:
153                         info->serv_supports_guest = StrToi(Buf);
154                         break;
155                 }
156                 ++a;
157         }
158         FreeStrBuf(&Buf);
159         return info;
160 }
161
162 int GetConnected (void)
163 {
164         StrBuf *Buf;
165         wcsession *WCC = WC;
166
167         if (WCC->ReadBuf == NULL)
168                 WCC->ReadBuf = NewStrBufPlain(NULL, SIZ * 4);
169         if (is_uds) /* unix domain socket */
170                 WCC->serv_sock = uds_connectsock(serv_sock_name);
171         else        /* tcp socket */
172                 WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
173         
174         if (WCC->serv_sock < 0) {
175                 FreeStrBuf(&WCC->ReadBuf);
176                 return 1;
177         }
178         else {
179                 long Status;
180                 int short_status;
181                 Buf = NewStrBuf();
182                 WCC->connected = 1;
183                 StrBuf_ServGetln(Buf);  /* get the server greeting */
184                 short_status = GetServerStatus(Buf, &Status);
185                 FreeStrBuf(&Buf);
186
187                 /* Server isn't ready for us? */
188                 if (short_status != 2) {
189                         if (Status == 571) {
190                                 hprintf("HTTP/1.1 503 Service Unavailable\r\n");
191                                 hprintf("Content-type: text/plain; charset=utf-8\r\n");
192                                 wc_printf(_("This server is already serving its maximum number of users and cannot accept any additional logins at this time.  Please try again later or contact your system administrator."));
193                         }
194                         else {
195                                 wc_printf("%ld %s\n",
196                                         Status,
197                                         _("Received unexpected answer from Citadel server; bailing out.")
198                                 );
199                                 hprintf("HTTP/1.1 502 Bad Gateway\r\n");
200                                 hprintf("Content-type: text/plain; charset=utf-8\r\n");
201                         }
202                         end_burst();
203                         end_webcit_session();
204                         return 1;
205                 }
206
207                 /*
208                  * From what host is our user connecting?  Go with
209                  * the host at the other end of the HTTP socket,
210                  * unless we are following X-Forwarded-For: headers
211                  * and such a header has already turned up something.
212                  */
213                 if ( (!follow_xff) || (StrLength(WCC->Hdr->HR.browser_host) == 0) ) {
214                         if (WCC->Hdr->HR.browser_host == NULL) {
215                                 WCC->Hdr->HR.browser_host = NewStrBuf();
216                                 Put(WCC->Hdr->HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"), 
217                                     WCC->Hdr->HR.browser_host, HFreeStrBuf);
218                         }
219                         locate_host(WCC->Hdr->HR.browser_host, WCC->Hdr->http_sock);
220                 }
221                 if (WCC->serv_info == NULL) {
222                         WCC->serv_info = get_serv_info(WCC->Hdr->HR.browser_host, WCC->Hdr->HR.user_agent);
223                 }
224                 if (WCC->serv_info == NULL){
225                         begin_burst();
226                         wc_printf(_("Received unexpected answer from Citadel server; bailing out."));
227                         hprintf("HTTP/1.1 502 Bad Gateway\r\n");
228                         hprintf("Content-type: text/plain; charset=utf-8\r\n");
229                         end_burst();
230                         end_webcit_session();
231                         return 1;
232                 }
233                 if (WCC->serv_info->serv_rev_level < MINIMUM_CIT_VERSION) {
234                         begin_burst();
235                         wc_printf(_("You are connected to a Citadel "
236                                   "server running Citadel %d.%02d. \n"
237                                   "In order to run this version of WebCit "
238                                   "you must also have Citadel %d.%02d or"
239                                   " newer.\n\n\n"),
240                                 WCC->serv_info->serv_rev_level / 100,
241                                 WCC->serv_info->serv_rev_level % 100,
242                                 MINIMUM_CIT_VERSION / 100,
243                                 MINIMUM_CIT_VERSION % 100
244                                 );
245                         hprintf("HTTP/1.1 200 OK\r\n");
246                         hprintf("Content-type: text/plain; charset=utf-8\r\n");
247                         end_burst();
248                         end_webcit_session();
249                         return 1;
250                 }
251                 SetInlinMimeRenderers();
252         }
253         return 0;
254 }
255
256 /*
257  *  Read Citadel variformat text and spit it out as HTML.
258  *  align html align string
259  */
260 inline void fmout(const char *align)
261 {
262         _fmout(WC->WBuf, align);
263 }
264
265 void _fmout(StrBuf *Target, const char *align)
266 {
267         int intext = 0;
268         int bq = 0;
269         char buf[SIZ];
270
271         StrBufAppendPrintf(Target, "<div align=%s>\n", align);
272         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
273
274                 if ((intext == 1) && (isspace(buf[0]))) {
275                         wc_printf("<br>");
276                 }
277                 intext = 1;
278
279                 /*
280                  * Quoted text should be displayed in italics and in a
281                  * different colour.  This code understands Citadel-style
282                  * " >" quotes and will convert to <BLOCKQUOTE> tags.
283                  */
284                 if ((bq == 0) && (!strncmp(buf, " >", 2))) {
285                         StrBufAppendBufPlain(Target, HKEY("<BLOCKQUOTE>"), 0);
286                         bq = 1;
287                 } else if ((bq == 1) && (strncmp(buf, " >", 2))) {
288                         StrBufAppendBufPlain(Target, HKEY("</BLOCKQUOTE>"), 0);
289                         bq = 0;
290                 }
291                 if ((bq == 1) && (!strncmp(buf, " >", 2))) {
292                         strcpy(buf, &buf[2]);
293                 }
294                 /* Activate embedded URL's */
295                 url(buf, sizeof(buf));
296
297                 escputs(buf);
298                 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
299         }
300         if (bq == 1) {
301                 wc_printf("</I>");
302         }
303         wc_printf("</div><br>\n");
304 }
305
306 void FmOut(StrBuf *Target, const char *align, const StrBuf *Source)
307 {
308         const char *ptr, *pte;
309         const char *BufPtr = NULL;
310         StrBuf *Line = NewStrBufPlain(NULL, SIZ);
311         StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
312         StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
313         int bn = 0;
314         int bq = 0;
315         int i;
316         long len;
317         int intext = 0;
318
319         StrBufAppendPrintf(Target, "<div class=\"fmout-%s\">\n", align);
320
321         if (StrLength(Source) > 0) 
322                 do 
323                 {
324                         StrBufSipLine(Line, Source, &BufPtr);
325                         bq = 0;
326                         i = 0;
327                         ptr = ChrPtr(Line);
328                         len = StrLength(Line);
329                         pte = ptr + len;
330
331                         if ((intext == 1) && (isspace(*ptr))) {
332                                 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
333                         }
334                         intext = 1;
335                         if (isspace(*ptr)) while ((ptr < pte) &&
336                                                   ((*ptr == '>') ||
337                                                    isspace(*ptr)))
338                                            {
339                                                    if (*ptr == '>')
340                                                            bq++;
341                                                    ptr ++;
342                                                    i++;
343                                            }
344
345                         /*
346                          * Quoted text should be displayed in italics and in a
347                          * different colour.  This code understands Citadel-style
348                          * " >" quotes and will convert to <BLOCKQUOTE> tags.
349                          */
350                         if (i > 0) StrBufCutLeft(Line, i);
351                 
352
353                         for (i = bn; i < bq; i++)                               
354                                 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
355                         for (i = bq; i < bn; i++)                               
356                                 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
357                         bn = bq;
358
359                         if (StrLength(Line) == 0)
360                                 continue;
361
362                         /* Activate embedded URL's */
363                         UrlizeText(Line1, Line, Line2);
364
365                         StrEscAppend(Target, Line1, NULL, 0, 0);
366
367                         StrBufAppendBufPlain(Target, HKEY("\n"), 0);
368                 }
369                 while ((BufPtr != StrBufNOTNULL) &&
370                        (BufPtr != NULL));
371
372         for (i = 0; i < bn; i++) {
373                 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
374         }
375         StrBufAppendBufPlain(Target, HKEY("</div><br>\n"), 0);
376         FreeStrBuf(&Line);
377         FreeStrBuf(&Line1);
378         FreeStrBuf(&Line2);
379 }
380
381
382
383 /*
384  *  Transmit message text (in memory) to the server.
385  */
386 void text_to_server(char *ptr)
387 {
388         char buf[256];
389         int ch, a, pos, len;
390
391         pos = 0;
392         buf[0] = 0;
393
394         while (ptr[pos] != 0) {
395                 ch = ptr[pos++];
396                 if (ch == 10) {
397                         len = strlen(buf);
398                         while ( (isspace(buf[len - 1]))
399                                 && (buf[0] !=  '\0') 
400                                 && (buf[1] !=  '\0') )
401                                 buf[--len] = 0;
402                         serv_puts(buf);
403                         buf[0] = 0;
404                         if (ptr[pos] != 0) strcat(buf, " ");
405                 } else {
406                         a = strlen(buf);
407                         buf[a + 1] = 0;
408                         buf[a] = ch;
409                         if ((ch == 32) && (strlen(buf) > 200)) {
410                                 buf[a] = 0;
411                                 serv_puts(buf);
412                                 buf[0] = 0;
413                         }
414                         if (strlen(buf) > 250) {
415                                 serv_puts(buf);
416                                 buf[0] = 0;
417                         }
418                 }
419         }
420         serv_puts(buf);
421 }
422
423
424 /*
425  * Transmit message text (in memory) to the server, converting to Quoted-Printable encoding as we go.
426  */
427 void text_to_server_qp(char *ptr)
428 {
429         unsigned char ch, buf[256];
430         int pos;
431         int output_len = 0;
432
433         pos = 0;
434         buf[0] = 0;
435         output_len = 0;
436
437         while (ptr[pos] != 0) {
438                 ch = (unsigned char)(ptr[pos++]);
439
440                 if (ch == 13) {
441                         /* ignore carriage returns */
442                 }
443                 else if (ch == 10) {
444                         /* hard line break */
445                         if (output_len > 0) {
446                                 if (isspace(buf[output_len-1])) {
447                                         sprintf((char *)&buf[output_len-1], "=%02X", buf[output_len-1]);
448                                         output_len += 2;
449                                 }
450                         }
451                         buf[output_len++] = 0;
452                         serv_puts((char *)buf);
453                         output_len = 0;
454                 }
455                 else if (ch == 9) {
456                         buf[output_len++] = ch;
457                 }
458                 else if ( (ch >= 32) && (ch <= 60) ) {
459                         buf[output_len++] = ch;
460                 }
461                 else if ( (ch >= 62) && (ch <= 126) ) {
462                         buf[output_len++] = ch;
463                 }
464                 else {
465                         sprintf((char *)&buf[output_len], "=%02X", ch);
466                         output_len += 3;
467                 }
468                 
469                 if (output_len > 72) {
470                         /* soft line break */
471                         if (isspace(buf[output_len-1])) {
472                                 sprintf((char *)&buf[output_len-1], "=%02X", buf[output_len-1]);
473                                 output_len += 2;
474                         }
475                         buf[output_len++] = '=';
476                         buf[output_len++] = 0;
477                         serv_puts((char *)buf);
478                         output_len = 0;
479                 }
480         }
481
482         /* end of data - transmit anything that's left */
483         if (output_len > 0) {
484                 if (isspace(buf[output_len-1])) {
485                         sprintf((char *)&buf[output_len-1], "=%02X", buf[output_len-1]);
486                         output_len += 2;
487                 }
488                 buf[output_len++] = 0;
489                 serv_puts((char *)buf);
490                 output_len = 0;
491         }
492 }
493
494
495
496
497 /*
498  * translate server message output to text (used for editing room info files and such)
499  */
500 void server_to_text()
501 {
502         char buf[SIZ];
503
504         int count = 0;
505
506         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
507                 if ((buf[0] == 32) && (count > 0)) {
508                         wc_printf("\n");
509                 }
510                 wc_printf("%s", buf);
511                 ++count;
512         }
513 }
514
515
516
517
518 /*
519  * Read text from server, appending to a string buffer until the
520  * usual 000 terminator is found.  Caller is responsible for freeing
521  * the returned pointer.
522  */
523 int read_server_text(StrBuf *Buf, long *nLines)
524 {
525         wcsession *WCC = WC;
526         long nRead;
527         long nTotal = 0;
528         long nlines;
529         
530         nlines = 0;
531         while ((WCC->serv_sock!=-1) &&
532                (nRead = StrBuf_ServGetln(Buf), (nRead >= 0) ))
533         {
534                 if (strcmp(ChrPtr(Buf) + nTotal, "000") != 0) {
535                         StrBufCutRight(Buf, nRead);
536                         break;
537                 }
538                 nTotal += nRead;
539                 nlines ++;
540         }
541
542         *nLines = nlines;
543         return nTotal;
544 }
545
546
547 int GetServerStatus(StrBuf *Line, long* FullState)
548 {
549         if (FullState != NULL)
550                 *FullState = StrTol(Line);
551         return ChrPtr(Line)[0] - 48;
552 }
553
554
555 void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP)
556 {
557         StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
558 }
559
560 void tmplput_serv_admin(StrBuf *Target, WCTemplputParams *TP)
561 {
562         wcsession *WCC = WC;
563         if (WCC->serv_info == NULL)
564                 return;
565         StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_sysadm, 0);
566 }
567
568 void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP)
569 {
570         wcsession *WCC = WC;
571         if (WCC->serv_info == NULL)
572                 return;
573         StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_nodename, 0);
574 }
575
576 void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP)
577 {
578         wcsession *WCC = WC;
579         if (WCC->serv_info == NULL)
580                 return;
581         StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_humannode, 0);
582 }
583
584 void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP)
585 {
586         wcsession *WCC = WC;
587         if (WCC->serv_info == NULL)
588                 return;
589         StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_fqdn, 0);
590 }
591
592 void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP)
593 {
594         wcsession *WCC = WC;
595         if (WCC->serv_info == NULL)
596                 return;
597         StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_software, 0);
598 }
599
600 void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP)
601 {
602         wcsession *WCC = WC;
603         if (WCC->serv_info == NULL)
604                 return;
605         StrBufAppendPrintf(Target, "%d.%02d",
606                             WCC->serv_info->serv_rev_level / 100,
607                             WCC->serv_info->serv_rev_level % 100);
608 }
609 int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP)
610 {
611         wcsession *WCC = WC;
612         if (WCC->serv_info == NULL)
613                 return 0;
614         return WCC->serv_info->serv_newuser_disabled != 0;
615 }
616
617 int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP)
618 {
619         wcsession *WCC = WC;
620         if (WCC->serv_info == NULL)
621                 return 0;
622         return WCC->serv_info->serv_supports_openid != 0;
623 }
624
625 int conditional_serv_fulltext_enabled(StrBuf *Target, WCTemplputParams *TP)
626 {
627         wcsession *WCC = WC;
628         if (WCC->serv_info == NULL)
629                 return 0;
630         return WCC->serv_info->serv_fulltext_enabled != 0;
631 }
632
633 int conditional_serv_ldap_enabled(StrBuf *Target, WCTemplputParams *TP)
634 {
635         wcsession *WCC = WC;
636         if (WCC->serv_info == NULL)
637                 return 0;
638         return WCC->serv_info->serv_supports_ldap != 0;
639 }
640
641 void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP)
642 {
643         wcsession *WCC = WC;
644         if (WCC->serv_info == NULL)
645                 return;
646         StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0);
647 }
648
649 void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP)
650 {
651         int n = 0;
652         int Done = 0;
653         StrBuf *Line;
654         StrBuf *Buf;
655
656         Buf = NewStrBuf();
657         Line = NewStrBuf();
658         serv_printf("MESG %s", TP->Tokens->Params[0]->Start);
659
660         StrBuf_ServGetln(Line);
661         if (GetServerStatus(Line, NULL) == 1) {
662                 while (!Done &&  (StrBuf_ServGetln(Line)>=0)) {
663                         if ( (StrLength(Line)==3) && 
664                              !strcmp(ChrPtr(Line), "000")) 
665                                 Done = 1;
666                         else
667                         {
668                                 if (n > 0)
669                                         StrBufAppendBufPlain(Buf, "\n", 1, 0);
670                                 StrBufAppendBuf(Buf, Line, 0);
671                         }
672                         n++;
673                 }
674         
675                 FlushStrBuf(Line);
676                 FmOut(Line, "center", Buf);
677                 StrBufAppendTemplate(Target, TP, Line, 1);
678         }
679         FreeStrBuf(&Buf);
680         FreeStrBuf(&Line);
681 }
682
683
684 void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority)
685 {
686         StrBuf *MT;
687         MT = NewStrBufPlain(MimeType, MTLen);
688         Put(EmbeddableMimes, IKEY(Priority), MT, HFreeStrBuf);
689 }
690
691 void CreateMimeStr(void)
692 {
693         HashPos  *it;
694         void *vMime;
695         long len = 0;
696         const char *Key;
697
698         it = GetNewHashPos(EmbeddableMimes, 0);
699         while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) &&
700                (vMime != NULL)) {
701                 if (StrLength(EmbeddableMimeStrs) > 0)
702                         StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("|"), 0);
703                 else 
704                         StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("MSGP "), 0);
705                 StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf*) vMime, 0);
706         }
707         DeleteHashPos(&it);
708 }
709
710 void
711 ServerStartModule_SERV_FUNC
712 (void)
713 {
714         EmbeddableMimes = NewHash(1, Flathash);
715         EmbeddableMimeStrs = NewStrBuf();
716 }
717
718
719 void
720 ServerShutdownModule_SERV_FUNC
721 (void)
722 {
723         FreeStrBuf(&EmbeddableMimeStrs);
724         DeleteHash(&EmbeddableMimes);
725 }
726
727 void 
728 InitModule_SERVFUNC
729 (void)
730 {
731         is_uds = strcasecmp(ctdlhost, "uds") == 0;
732         if (is_uds)
733                 snprintf(serv_sock_name, PATH_MAX, "%s/citadel.socket", ctdlport);
734
735         RegisterConditional(HKEY("COND:SERV:OPENID"), 2, conditional_serv_supports_openid, CTX_NONE);
736         RegisterConditional(HKEY("COND:SERV:NEWU"), 2, conditional_serv_newuser_disabled, CTX_NONE);
737         RegisterConditional(HKEY("COND:SERV:FULLTEXT_ENABLED"), 2, conditional_serv_fulltext_enabled, CTX_NONE);
738         RegisterConditional(HKEY("COND:SERV:LDAP_ENABLED"), 2, conditional_serv_ldap_enabled, CTX_NONE);
739         RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, NULL, CTX_NONE);
740         RegisterNamespace("SERV:NODENAME", 0, 1, tmplput_serv_nodename, NULL, CTX_NONE);
741         RegisterNamespace("SERV:HUMANNODE", 0, 1, tmplput_serv_humannode, NULL, CTX_NONE);
742         RegisterNamespace("SERV:FQDN", 0, 1, tmplput_serv_fqdn, NULL, CTX_NONE);
743         RegisterNamespace("SERV:SOFTWARE", 0, 1, tmplput_serv_software, NULL, CTX_NONE);
744         RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, NULL, CTX_NONE);
745         RegisterNamespace("SERV:BBS_CITY", 0, 1, tmplput_serv_bbs_city, NULL, CTX_NONE);
746         RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, NULL, CTX_NONE);
747         RegisterNamespace("SERV:ADMIN", 0, 1, tmplput_serv_admin, NULL, CTX_NONE);
748 }
749
750
751
752 void 
753 SessionDestroyModule_SERVFUNC
754 (wcsession *sess)
755 {
756         DeleteServInfo(&sess->serv_info);
757 }