d1b4db02a79545a1881b29ea748c40a4fbff45d7
[citadel.git] / citadel / serv_chat.c
1 /*
2  * serv_chat.c
3  * 
4  * This module handles all "real time" communication between users.  The
5  * modes of communication currently supported are Chat and Paging.
6  *
7  * $Id$
8  */
9 #include "sysdep.h"
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <signal.h>
15 #include <pwd.h>
16 #include <errno.h>
17 #include <sys/types.h>
18 #include <sys/time.h>
19 #include <sys/wait.h>
20 #include <string.h>
21 #include <limits.h>
22 #include "citadel.h"
23 #include "server.h"
24 #include <syslog.h>
25 #include "serv_chat.h"
26 #include "sysdep_decls.h"
27 #include "citserver.h"
28 #include "support.h"
29 #include "config.h"
30 #include "dynloader.h"
31 #include "tools.h"
32 #include "msgbase.h"
33 #include "user_ops.h"
34 #include "room_ops.h"
35
36 struct ChatLine *ChatQueue = NULL;
37 int ChatLastMsg = 0;
38
39 extern struct CitContext *ContextList;
40
41
42
43 void allwrite(char *cmdbuf, int flag, char *username)
44 {
45         FILE *fp;
46         char bcast[256];
47         char *un;
48         struct ChatLine *clptr, *clnew;
49         time_t now;
50
51         if (CC->fake_username[0])
52                 un = CC->fake_username;
53         else
54                 un = CC->usersupp.fullname;
55         if (flag == 1) {
56                 snprintf(bcast, sizeof bcast, ":|<%s %s>", un, cmdbuf);
57         } else if (flag == 0) {
58                 snprintf(bcast, sizeof bcast, "%s|%s", un, cmdbuf);
59         } else if (flag == 2) {
60                 snprintf(bcast, sizeof bcast, ":|<%s whispers %s>", un, cmdbuf);
61         }
62         if ((strcasecmp(cmdbuf, "NOOP")) && (flag != 2)) {
63                 fp = fopen(CHATLOG, "a");
64                 fprintf(fp, "%s\n", bcast);
65                 fclose(fp);
66         }
67         clnew = (struct ChatLine *) mallok(sizeof(struct ChatLine));
68         memset(clnew, 0, sizeof(struct ChatLine));
69         if (clnew == NULL) {
70                 fprintf(stderr, "citserver: cannot alloc chat line: %s\n",
71                         strerror(errno));
72                 return;
73         }
74         time(&now);
75         clnew->next = NULL;
76         clnew->chat_time = now;
77         safestrncpy(clnew->chat_room, CC->quickroom.QRname,
78                         sizeof clnew->chat_room);
79         clnew->chat_room[sizeof clnew->chat_room - 1] = 0;
80         if (username) {
81                 safestrncpy(clnew->chat_username, username,
82                         sizeof clnew->chat_username);
83                 clnew->chat_username[sizeof clnew->chat_username - 1] = 0;
84         } else
85                 clnew->chat_username[0] = '\0';
86         safestrncpy(clnew->chat_text, bcast, sizeof clnew->chat_text);
87
88         /* Here's the critical section.
89          * First, add the new message to the queue...
90          */
91         begin_critical_section(S_CHATQUEUE);
92         ++ChatLastMsg;
93         clnew->chat_seq = ChatLastMsg;
94         if (ChatQueue == NULL) {
95                 ChatQueue = clnew;
96         } else {
97                 for (clptr = ChatQueue; clptr->next != NULL; clptr = clptr->next);;
98                 clptr->next = clnew;
99         }
100
101         /* Then, before releasing the lock, free the expired messages */
102         while (1) {
103                 if (ChatQueue == NULL)
104                         goto DONE_FREEING;
105                 if ((now - ChatQueue->chat_time) < 120L)
106                         goto DONE_FREEING;
107                 clptr = ChatQueue;
108                 ChatQueue = ChatQueue->next;
109                 phree(clptr);
110         }
111 DONE_FREEING:
112         end_critical_section(S_CHATQUEUE);
113 }
114
115
116 t_context *find_context(char **unstr)
117 {
118         t_context *t_cc, *found_cc = NULL;
119         char *name, *tptr;
120
121         if ((!*unstr) || (!unstr))
122                 return (NULL);
123
124         begin_critical_section(S_SESSION_TABLE);
125         for (t_cc = ContextList; ((t_cc) && (!found_cc)); t_cc = t_cc->next) {
126                 if (t_cc->fake_username[0])
127                         name = t_cc->fake_username;
128                 else
129                         name = t_cc->curr_user;
130                 tptr = *unstr;
131                 if ((!strncasecmp(name, tptr, strlen(name))) && (tptr[strlen(name)] == ' ')) {
132                         found_cc = t_cc;
133                         *unstr = &(tptr[strlen(name) + 1]);
134                 }
135         }
136         end_critical_section(S_SESSION_TABLE);
137
138         return (found_cc);
139 }
140
141 /*
142  * List users in chat.
143  * allflag ==   0 = list users in chat
144  *              1 = list users in chat, followed by users not in chat
145  *              2 = display count only
146  */
147
148 void do_chat_listing(int allflag)
149 {
150         struct CitContext *ccptr;
151         int count = 0;
152         int count_elsewhere = 0;
153         char roomname[ROOMNAMELEN];
154
155         if ((allflag == 0) || (allflag == 1))
156                 cprintf(":|\n:| Users currently in chat:\n");
157         begin_critical_section(S_SESSION_TABLE);
158         for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
159                 if (ccptr->cs_flags & CS_CHAT) {
160                         if (!strcasecmp(ccptr->quickroom.QRname,
161                            CC->quickroom.QRname)) {
162                                 ++count;
163                         }
164                         else {
165                                 ++count_elsewhere;
166                         }
167                 }
168
169                 GenerateRoomDisplay(roomname, ccptr, CC);
170                 if ((CC->usersupp.axlevel < 6)
171                    && (strlen(ccptr->fake_roomname)>0)) {
172                         strcpy(roomname, ccptr->fake_roomname);
173                 }
174
175                 if ((ccptr->cs_flags & CS_CHAT)
176                     && ((ccptr->cs_flags & CS_STEALTH) == 0)) {
177                         if ((allflag == 0) || (allflag == 1)) {
178                                 cprintf(":| %-25s <%s>:\n",
179                                         (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user,
180                                         roomname);
181                         }
182                 }
183         }
184
185         if (allflag == 1) {
186                 cprintf(":|\n:| Users not in chat:\n");
187                 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
188
189                         if (((ccptr->cs_flags & CS_CHAT) == 0)
190                             && ((ccptr->cs_flags & CS_STEALTH) == 0)) {
191                                 cprintf(":| %-25s <%s>:\n",
192                                         (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user,
193                                         roomname);
194                         }
195                 }
196         }
197         end_critical_section(S_SESSION_TABLE);
198
199         if (allflag == 2) {
200                 if (count > 1) {
201                         cprintf(":|There are %d users here.\n", count);
202                 }
203                 else {
204                         cprintf(":|Note: you are the only one here.\n");
205                 }
206                 if (count_elsewhere > 0) {
207                         cprintf(":|There are %d users chatting in other rooms.\n", count_elsewhere);
208                 }
209         }
210
211         cprintf(":|\n");
212 }
213
214
215 void cmd_chat(char *argbuf)
216 {
217         char cmdbuf[256];
218         char *un;
219         char *strptr1;
220         int MyLastMsg, ThisLastMsg;
221         struct ChatLine *clptr;
222         struct CitContext *t_context;
223         int retval;
224
225         if (!(CC->logged_in)) {
226                 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
227                 return;
228         }
229
230         CC->cs_flags = CC->cs_flags | CS_CHAT;
231         cprintf("%d Entering chat mode (type '/help' for available commands)\n",
232                 START_CHAT_MODE);
233
234         MyLastMsg = ChatLastMsg;
235
236         if ((CC->cs_flags & CS_STEALTH) == 0) {
237                 allwrite("<entering chat>", 0, NULL);
238         }
239         strcpy(cmdbuf, "");
240
241         do_chat_listing(2);
242
243         while (1) {
244                 int ok_cmd;
245                 int linelen;
246
247                 ok_cmd = 0;
248                 linelen = strlen(cmdbuf);
249                 if (linelen > 100) --linelen;   /* truncate too-long lines */
250                 cmdbuf[linelen + 1] = 0;
251
252                 retval = client_read_to(&cmdbuf[linelen], 1, 2);
253
254                 if (retval < 0) {       /* socket broken? */
255                         if ((CC->cs_flags & CS_STEALTH) == 0) {
256                                 allwrite("<disconnected>", 0, NULL);
257                         }
258                         return;
259                 }
260
261                 /* if we have a complete line, do send processing */
262                 if (strlen(cmdbuf) > 0)
263                         if (cmdbuf[strlen(cmdbuf) - 1] == 10) {
264                                 cmdbuf[strlen(cmdbuf) - 1] = 0;
265                                 time(&CC->lastcmd);
266                                 time(&CC->lastidle);
267
268                                 if ((!strcasecmp(cmdbuf, "exit"))
269                                     || (!strcasecmp(cmdbuf, "/exit"))
270                                     || (!strcasecmp(cmdbuf, "quit"))
271                                     || (!strcasecmp(cmdbuf, "logout"))
272                                     || (!strcasecmp(cmdbuf, "logoff"))
273                                     || (!strcasecmp(cmdbuf, "/q"))
274                                     || (!strcasecmp(cmdbuf, ".q"))
275                                     || (!strcasecmp(cmdbuf, "/quit"))
276                                     )
277                                         strcpy(cmdbuf, "000");
278
279                                 if (!strcmp(cmdbuf, "000")) {
280                                         if ((CC->cs_flags & CS_STEALTH) == 0) {
281                                                 allwrite("<exiting chat>", 0, NULL);
282                                         }
283                                         sleep(1);
284                                         cprintf("000\n");
285                                         CC->cs_flags = CC->cs_flags - CS_CHAT;
286                                         return;
287                                 }
288                                 if ((!strcasecmp(cmdbuf, "/help"))
289                                     || (!strcasecmp(cmdbuf, "help"))
290                                     || (!strcasecmp(cmdbuf, "/?"))
291                                     || (!strcasecmp(cmdbuf, "?"))) {
292                                         cprintf(":|\n");
293                                         cprintf(":|Available commands: \n");
294                                         cprintf(":|/help   (prints this message) \n");
295                                         cprintf(":|/who    (list users currently in chat) \n");
296                                         cprintf(":|/whobbs (list users in chat -and- elsewhere) \n");
297                                         cprintf(":|/me     ('action' line, ala irc) \n");
298                                         cprintf(":|/msg    (send private message, ala irc) \n");
299                                         cprintf(":|/quit   (return to the BBS) \n");
300                                         cprintf(":|\n");
301                                         ok_cmd = 1;
302                                 }
303                                 if (!strcasecmp(cmdbuf, "/who")) {
304                                         do_chat_listing(0);
305                                         ok_cmd = 1;
306                                 }
307                                 if (!strcasecmp(cmdbuf, "/whobbs")) {
308                                         do_chat_listing(1);
309                                         ok_cmd = 1;
310                                 }
311                                 if (!strncasecmp(cmdbuf, "/me ", 4)) {
312                                         allwrite(&cmdbuf[4], 1, NULL);
313                                         ok_cmd = 1;
314                                 }
315                                 if (!strncasecmp(cmdbuf, "/msg ", 5)) {
316                                         ok_cmd = 1;
317                                         strptr1 = &cmdbuf[5];
318                                         if ((t_context = find_context(&strptr1))) {
319                                                 allwrite(strptr1, 2, CC->curr_user);
320                                                 if (strcasecmp(CC->curr_user, t_context->curr_user))
321                                                         allwrite(strptr1, 2, t_context->curr_user);
322                                         } else
323                                                 cprintf(":|User not found.\n", cmdbuf);
324                                         cprintf("\n");
325                                 }
326                                 if ((cmdbuf[0] != '/') && (strlen(cmdbuf) > 0)) {
327                                         ok_cmd = 1;
328                                         allwrite(cmdbuf, 0, NULL);
329                                 }
330                                 if ((!ok_cmd) && (cmdbuf[0]) && (cmdbuf[0] != '\n'))
331                                         cprintf(":|Command %s is not understood.\n", cmdbuf);
332
333                                 strcpy(cmdbuf, "");
334
335                         }
336                 /* now check the queue for new incoming stuff */
337
338                 if (CC->fake_username[0])
339                         un = CC->fake_username;
340                 else
341                         un = CC->curr_user;
342                 if (ChatLastMsg > MyLastMsg) {
343                         ThisLastMsg = ChatLastMsg;
344                         for (clptr = ChatQueue; clptr != NULL; clptr = clptr->next) {
345                                 if ((clptr->chat_seq > MyLastMsg) && ((!clptr->chat_username[0]) || (!strncasecmp(un, clptr->chat_username, 32)))) {
346                                         if ((!clptr->chat_room[0]) || (!strncasecmp(CC->quickroom.QRname, clptr->chat_room, ROOMNAMELEN))) {
347                                                 cprintf("%s\n", clptr->chat_text);
348                                         }
349                                 }
350                         }
351                         MyLastMsg = ThisLastMsg;
352                 }
353         }
354 }
355
356
357
358 /*
359  * Delete any remaining express messages
360  */
361 void delete_express_messages(void) {
362         struct ExpressMessage *ptr;
363
364         begin_critical_section(S_SESSION_TABLE);
365         while (CC->FirstExpressMessage != NULL) {
366                 ptr = CC->FirstExpressMessage->next;
367                 if (CC->FirstExpressMessage->text != NULL)
368                         phree(CC->FirstExpressMessage->text);
369                 phree(CC->FirstExpressMessage);
370                 CC->FirstExpressMessage = ptr;
371                 }
372         end_critical_section(S_SESSION_TABLE);
373         }
374
375
376
377
378 /*
379  * Poll for express messages (OLD METHOD -- ***DEPRECATED ***)
380  */
381 void cmd_pexp(char *argbuf)
382 {
383         struct ExpressMessage *ptr, *holdptr;
384
385         if (CC->FirstExpressMessage == NULL) {
386                 cprintf("%d No express messages waiting.\n", ERROR);
387                 return;
388         }
389         begin_critical_section(S_SESSION_TABLE);
390         ptr = CC->FirstExpressMessage;
391         CC->FirstExpressMessage = NULL;
392         end_critical_section(S_SESSION_TABLE);
393
394         cprintf("%d Express msgs:\n", LISTING_FOLLOWS);
395         while (ptr != NULL) {
396                 if (ptr->flags && EM_BROADCAST)
397                         cprintf("Broadcast message ");
398                 else if (ptr->flags && EM_CHAT)
399                         cprintf("Chat request ");
400                 else if (ptr->flags && EM_GO_AWAY)
401                         cprintf("Please logoff now, as requested ");
402                 else
403                         cprintf("Message ");
404                 cprintf("from %s:\n", ptr->sender);
405                 if (ptr->text != NULL)
406                         memfmout(80, ptr->text, 0, "\n");
407
408                 holdptr = ptr->next;
409                 if (ptr->text != NULL) phree(ptr->text);
410                 phree(ptr);
411                 ptr = holdptr;
412         }
413         cprintf("000\n");
414 }
415
416
417 /*
418  * Get express messages (new method)
419  */
420 void cmd_gexp(char *argbuf) {
421         struct ExpressMessage *ptr;
422
423         if (CC->FirstExpressMessage == NULL) {
424                 cprintf("%d No express messages waiting.\n", ERROR);
425                 return;
426         }
427
428         begin_critical_section(S_SESSION_TABLE);
429         ptr = CC->FirstExpressMessage;
430         CC->FirstExpressMessage = CC->FirstExpressMessage->next;
431         end_critical_section(S_SESSION_TABLE);
432
433         cprintf("%d %d|%ld|%d|%s|%s\n",
434                 LISTING_FOLLOWS,
435                 ((ptr->next != NULL) ? 1 : 0),          /* more msgs? */
436                 ptr->timestamp,                         /* time sent */
437                 ptr->flags,                             /* flags */
438                 ptr->sender,                            /* sender of msg */
439                 config.c_nodename);                     /* static for now */
440         if (ptr->text != NULL) {
441                 memfmout(80, ptr->text, 0, "\n");
442                 if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n");
443                 phree(ptr->text);
444                 }
445         cprintf("000\n");
446         phree(ptr);
447 }
448
449
450
451 /* 
452  * This is the back end to the express message sending function.  
453  * Returns the number of users to which the message was sent.
454  * Sending a zero-length message tests for recipients without sending messages.
455  */
456 int send_express_message(char *lun, char *x_user, char *x_msg)
457 {
458         int message_sent = 0;           /* number of successful sends */
459
460         struct CitContext *ccptr;
461         struct ExpressMessage *newmsg, *findend;
462         char *un;
463         size_t msglen = 0;
464         int do_send = 0;                /* set to 1 to actually page, not
465                                          * just check to see if we can.
466                                          */
467         struct savelist *sl = NULL;     /* list of rooms to save this page */
468         struct savelist *sptr;
469         struct CtdlMessage *logmsg;
470         char roomname[ROOMNAMELEN];
471         long msgnum;
472
473         if (strlen(x_msg) > 0) {
474                 msglen = strlen(x_msg) + 4;
475                 do_send = 1;
476                 }
477
478         /* find the target user's context and append the message */
479         begin_critical_section(S_SESSION_TABLE);
480         for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
481
482                 if (ccptr->fake_username[0])    /* <bc> */
483                         un = ccptr->fake_username;
484                 else
485                         un = ccptr->usersupp.fullname;
486
487                 if ( ((!strcasecmp(un, x_user))
488                     || (!strcasecmp(x_user, "broadcast")))
489                     && ((ccptr->disable_exp == 0)
490                     || (CC->usersupp.axlevel >= 6)) ) {
491                         if (do_send) {
492                                 newmsg = (struct ExpressMessage *)
493                                         mallok(sizeof (struct ExpressMessage));
494                                 memset(newmsg, 0,
495                                         sizeof (struct ExpressMessage));
496                                 safestrncpy(newmsg->sender, lun,
497                                             sizeof newmsg->sender);
498                                 if (!strcasecmp(x_user, "broadcast"))
499                                         newmsg->flags |= EM_BROADCAST;
500                                 newmsg->text = mallok(msglen);
501                                 safestrncpy(newmsg->text, x_msg, msglen);
502
503                                 if (ccptr->FirstExpressMessage == NULL)
504                                         ccptr->FirstExpressMessage = newmsg;
505                                 else {
506                                         findend = ccptr->FirstExpressMessage;
507                                         while (findend->next != NULL)
508                                                 findend = findend->next;
509                                         findend->next = newmsg;
510                                 }
511
512                                 /* and log it ... */
513                                 if (ccptr != CC) {
514                                         sptr = (struct savelist *)
515                                                 malloc(sizeof(struct savelist));
516                                         sptr->next = sl;
517                                         MailboxName(sptr->roomname,
518                                                 &ccptr->usersupp, PAGELOGROOM);
519                                         sl = sptr;
520                                 }
521                         }
522                         ++message_sent;
523                 }
524         }
525         end_critical_section(S_SESSION_TABLE);
526
527         /* Log the page to disk if configured to do so  */
528         if ( (do_send) && (message_sent) ) {
529
530                 logmsg = mallok(sizeof(struct CtdlMessage));
531                 memset(logmsg, 0, sizeof(struct CtdlMessage));
532                 logmsg->cm_magic = CTDLMESSAGE_MAGIC;
533                 logmsg->cm_anon_type = MES_NORMAL;
534                 logmsg->cm_format_type = 0;
535                 logmsg->cm_fields['A'] = strdoop(lun);
536                 logmsg->cm_fields['N'] = strdoop(NODENAME);
537                 logmsg->cm_fields['O'] = strdoop(PAGELOGROOM);
538                 logmsg->cm_fields['R'] = strdoop(x_user);
539                 logmsg->cm_fields['M'] = strdoop(x_msg);
540
541                 MailboxName(roomname, &CC->usersupp, PAGELOGROOM);
542                 create_room(roomname, 4, "", 0);
543                 msgnum = CtdlSaveMsg(logmsg, "", roomname, MES_LOCAL);
544                 if (strlen(config.c_logpages) > 0) {
545                         create_room(config.c_logpages, 3, "", 0);
546                         CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0);
547                 }
548                 while (sl != NULL) {
549                         create_room(sl->roomname, 4, "", 0);
550                         CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0);
551                         sptr = sl->next;
552                         phree(sl);
553                         sl = sptr;
554                 }
555
556                 CtdlFreeMessage(logmsg);
557         }
558
559         return (message_sent);
560 }
561
562 /*
563  * send express messages  <bc>
564  */
565 void cmd_sexp(char *argbuf)
566 {
567         int message_sent = 0;
568         char x_user[256];
569         char x_msg[256];
570         char *lun;              /* <bc> */
571         char *x_big_msgbuf = NULL;
572
573         if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
574                 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
575                 return;
576         }
577         if (CC->fake_username[0])
578                 lun = CC->fake_username;
579         else
580                 lun = CC->usersupp.fullname;
581
582         extract(x_user, argbuf, 0);
583
584         extract(x_msg, argbuf, 1);
585
586         if (!x_user[0]) {
587                 cprintf("%d You were not previously paged.\n", ERROR);
588                 return;
589         }
590         if ((!strcasecmp(x_user, "broadcast")) && (CC->usersupp.axlevel < 6)) {
591                 cprintf("%d Higher access required to send a broadcast.\n",
592                         ERROR + HIGHER_ACCESS_REQUIRED);
593                 return;
594         }
595         /* This loop handles text-transfer pages */
596         if (!strcmp(x_msg, "-")) {
597                 message_sent = PerformXmsgHooks(lun, x_user, "");
598                 if (message_sent == 0) {
599                         cprintf("%d '%s' is not logged in "
600                                 "or is not accepting pages.\n",
601                                 ERROR, x_user);
602                         return;
603                 }
604                 cprintf("%d Transmit message (will deliver to %d users)\n",
605                         SEND_LISTING, message_sent);
606                 x_big_msgbuf = mallok(256);
607                 memset(x_big_msgbuf, 0, 256);
608                 while (client_gets(x_msg), strcmp(x_msg, "000")) {
609                         x_big_msgbuf = reallok(x_big_msgbuf,
610                                strlen(x_big_msgbuf) + strlen(x_msg) + 4);
611                         if (strlen(x_big_msgbuf) > 0)
612                            if (x_big_msgbuf[strlen(x_big_msgbuf)] != '\n')
613                                 strcat(x_big_msgbuf, "\n");
614                         strcat(x_big_msgbuf, x_msg);
615                 }
616                 PerformXmsgHooks(lun, x_user, x_big_msgbuf);
617                 phree(x_big_msgbuf);
618
619                 /* This loop handles inline pages */
620         } else {
621                 message_sent = PerformXmsgHooks(lun, x_user, x_msg);
622
623                 if (message_sent > 0) {
624                         if (strlen(x_msg) > 0)
625                                 cprintf("%d Message sent", OK);
626                         else
627                                 cprintf("%d Ok to send message", OK);
628                         if (message_sent > 1)
629                                 cprintf(" to %d users", message_sent);
630                         cprintf(".\n");
631                 } else {
632                         cprintf("%d '%s' is not logged in "
633                                 "or is not accepting pages.\n",
634                                 ERROR, x_user);
635                 }
636
637
638         }
639 }
640
641
642
643 /*
644  * Enter or exit paging-disabled mode
645  */
646 void cmd_dexp(char *argbuf)
647 {
648         int new_state;
649
650         if (!CC->logged_in) {
651                 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
652                 return;
653                 }
654
655         new_state = extract_int(argbuf, 0);
656         if ((new_state == 0) || (new_state == 1)) {
657                 CC->disable_exp = new_state;
658                 }
659         cprintf("%d %d\n", OK, CC->disable_exp);
660         }
661
662
663
664
665
666 char *Dynamic_Module_Init(void)
667 {
668         CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat");
669         CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for express messages");
670         CtdlRegisterProtoHook(cmd_gexp, "GEXP", "Get express messages");
671         CtdlRegisterProtoHook(cmd_sexp, "SEXP", "Send an express message");
672         CtdlRegisterProtoHook(cmd_dexp, "DEXP", "Disable express messages");
673         CtdlRegisterSessionHook(delete_express_messages, EVT_STOP);
674         CtdlRegisterXmsgHook(send_express_message, XMSG_PRI_LOCAL);
675         return "$Id$";
676 }
677