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