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