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