4 * Citadel Dynamic Loading Module
5 * Written by Brian Costello <btx@calyx.net>
13 #include <sys/types.h>
20 #include "serv_extensions.h"
21 #include "sysdep_decls.h"
31 struct CleanupFunctionHook *CleanupHookTable = NULL;
32 struct SessionFunctionHook *SessionHookTable = NULL;
33 struct UserFunctionHook *UserHookTable = NULL;
34 struct XmsgFunctionHook *XmsgHookTable = NULL;
35 struct MessageFunctionHook *MessageHookTable = NULL;
36 struct NetprocFunctionHook *NetprocHookTable = NULL;
37 struct DeleteFunctionHook *DeleteHookTable = NULL;
38 struct ServiceFunctionHook *ServiceHookTable = NULL;
39 struct FixedOutputHook *FixedOutputTable = NULL;
40 struct RoomFunctionHook *RoomHookTable = NULL;
43 struct ProtoFunctionHook {
44 void (*handler) (char *cmdbuf);
47 struct ProtoFunctionHook *next;
48 } *ProtoHookList = NULL;
51 #define ERR_PORT (1 << 1)
54 static char *portlist = NULL;
55 static size_t nSizPort = 0;
57 static char *errormessages = NULL;
58 static size_t nSizErrmsg = 0;
61 static long DetailErrorFlags;
63 char *ErrSubject = "Startup Problems";
64 char *ErrGeneral = "Citadel had trouble on starting up. %s This means, citadel won't be the service provider for a specific service you configured it to.\n\n"
65 "If you don't want citadel to provide these services, turn them off in WebCit via %s%s\n\n%s\n\n"
66 "To make both ways actualy take place restart the citserver with \"sendcommand down\"\n\n"
67 "The errors returned by the system were:\n%s\n"
68 "You can recheck the above if you follow this faq item:\n"
69 "http://www.citadel.org/doku.php/faq:mastering_your_os:net#netstat";
72 char *ErrPortShort = "We couldn't bind all ports you configured to be provided by citadel server.";
73 char *ErrPortWhere = "Admin->System Preferences->Network.\n\nThe failed ports and sockets are: ";
74 char *ErrPortHint = "If you want citadel to provide you with that functionality, "
75 "check the output of \"netstat -lnp\" on linux Servers or \"netstat -na\" on *BSD"
76 " and stop the programm, that binds these ports. You should eventually remove "
77 " their initscripts in /etc/init.d so that you won't get this trouble once more.\n";
80 void LogPrintMessages(long err)
82 char *List, *DetailList, *Short, *Where, *Hint, *Message;
83 int n = nSizPort + nSizErrmsg + 5;
85 Message = (char*) malloc(n * SIZ);
94 DetailList = errormessages;
105 snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
107 quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
108 if (errormessages!=NULL) free (errormessages);
109 errormessages = NULL;
110 if (portlist!=NULL) free (portlist);
117 void AppendString(char **target, char *append, size_t *len, size_t rate)
123 AddLen = strlen(append);
129 *target = (char*)malloc (*len * SIZ);
133 oLen = strlen(*target);
134 RelPtr = strlen(*target);
135 if (oLen + AddLen + 2 > *len * SIZ)
137 char *Buff = *target;
138 size_t NewSiz = *len + 10;
139 *target = malloc (NewSiz * SIZ);
140 memcpy (*target, Buff, NewSiz * SIZ);
144 memcpy (*target + oLen, append, AddLen);
145 (*target)[oLen + AddLen + 1] = '\n';
146 (*target)[oLen + AddLen + 2] = '\0';
149 void AddPortError(char *Port, char *ErrorMessage)
154 DetailErrorFlags |= ERR_PORT;
156 AppendString(&errormessages, ErrorMessage, &nSizErrmsg, 10);
157 AppendString(&portlist, Port, &nSizPort, 2);
159 pos = strchr (portlist, ':');
160 if (pos != NULL) *pos = ';';
162 len = strlen (errormessages);
163 if (nSizErrmsg * SIZ > len + 3)
165 errormessages[len] = ';';
166 errormessages[len+1] = ' ';
167 errormessages[len+2] = '\0';
172 void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
174 struct ProtoFunctionHook *p;
176 p = (struct ProtoFunctionHook *)
177 malloc(sizeof(struct ProtoFunctionHook));
180 fprintf(stderr, "can't malloc new ProtoFunctionHook\n");
183 p->handler = handler;
186 p->next = ProtoHookList;
188 lprintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
192 void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd)
194 struct ProtoFunctionHook *cur = NULL;
195 struct ProtoFunctionHook *p = NULL;
196 struct ProtoFunctionHook *lastcur = NULL;
198 for (cur = ProtoHookList;
200 cur = (cur != NULL)? cur->next: NULL) {
201 /* This will also remove duplicates if any */
202 while (cur != NULL &&
203 handler == cur->handler &&
204 !strcmp(cmd, cur->cmd)) {
205 lprintf(CTDL_INFO, "Unregistered server command %s (%s)\n",
208 if (cur == ProtoHookList) {
211 else if (lastcur != NULL)
222 void CtdlDestroyProtoHooks(void)
224 struct ProtoFunctionHook *cur, *p;
229 lprintf(CTDL_INFO, "Destroyed server command %s (%s)\n",
230 cur->cmd, cur->desc);
235 ProtoHookList = NULL;
239 int DLoader_Exec_Cmd(char *cmdbuf)
241 struct ProtoFunctionHook *p;
243 for (p = ProtoHookList; p; p = p->next) {
244 if (!strncasecmp(cmdbuf, p->cmd, 4)) {
245 p->handler(&cmdbuf[5]);
252 void initialize_server_extensions(void)
258 lprintf(CTDL_INFO, "%s\n", serv_bio_init());
259 lprintf(CTDL_INFO, "%s\n", serv_calendar_init());
260 lprintf(CTDL_INFO, "%s\n", serv_notes_init());
261 lprintf(CTDL_INFO, "%s\n", serv_ldap_init());
262 lprintf(CTDL_INFO, "%s\n", serv_chat_init());
263 lprintf(CTDL_INFO, "%s\n", serv_expire_init());
264 lprintf(CTDL_INFO, "%s\n", serv_imap_init());
265 lprintf(CTDL_INFO, "%s\n", serv_upgrade_init());
266 lprintf(CTDL_INFO, "%s\n", serv_inetcfg_init());
267 lprintf(CTDL_INFO, "%s\n", serv_listsub_init());
268 lprintf(CTDL_INFO, "%s\n", serv_mrtg_init());
269 lprintf(CTDL_INFO, "%s\n", serv_netfilter_init());
270 lprintf(CTDL_INFO, "%s\n", serv_network_init());
271 lprintf(CTDL_INFO, "%s\n", serv_newuser_init());
272 lprintf(CTDL_INFO, "%s\n", serv_pas2_init());
273 lprintf(CTDL_INFO, "%s\n", serv_smtp_init());
274 lprintf(CTDL_INFO, "%s\n", serv_pop3_init());
275 lprintf(CTDL_INFO, "%s\n", serv_rwho_init());
276 lprintf(CTDL_INFO, "%s\n", serv_spam_init());
277 /* lprintf(CTDL_INFO, "%s\n", serv_test_init()); */
278 lprintf(CTDL_INFO, "%s\n", serv_vandelay_init());
279 lprintf(CTDL_INFO, "%s\n", serv_vcard_init());
280 lprintf(CTDL_INFO, "%s\n", serv_fulltext_init());
281 lprintf(CTDL_INFO, "%s\n", serv_autocompletion_init());
282 lprintf(CTDL_INFO, "%s\n", serv_postfix_tcpdict());
283 lprintf(CTDL_INFO, "%s\n", serv_sieve_init());
284 lprintf(CTDL_INFO, "%s\n", serv_managesieve_init());
285 lprintf(CTDL_INFO, "%s\n", serv_funambol_init());
286 for (filter = 1; filter != 0; filter = filter << 1)
287 if ((filter & DetailErrorFlags) != 0)
288 LogPrintMessages(filter);
293 void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
296 struct CleanupFunctionHook *newfcn;
298 newfcn = (struct CleanupFunctionHook *)
299 malloc(sizeof(struct CleanupFunctionHook));
300 newfcn->next = CleanupHookTable;
301 newfcn->h_function_pointer = fcn_ptr;
302 CleanupHookTable = newfcn;
304 lprintf(CTDL_INFO, "Registered a new cleanup function\n");
308 void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
310 struct CleanupFunctionHook *cur, *p;
312 for (cur = CleanupHookTable; cur != NULL; cur = cur->next) {
313 /* This will also remove duplicates if any */
314 while (cur != NULL &&
315 fcn_ptr == cur->h_function_pointer) {
316 lprintf(CTDL_INFO, "Unregistered cleanup function\n");
318 if (cur == CleanupHookTable) {
319 CleanupHookTable = p;
327 void CtdlDestroyCleanupHooks(void)
329 struct CleanupFunctionHook *cur, *p;
331 cur = CleanupHookTable;
334 lprintf(CTDL_INFO, "Destroyed cleanup function\n");
339 CleanupHookTable = NULL;
343 void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
346 struct SessionFunctionHook *newfcn;
348 newfcn = (struct SessionFunctionHook *)
349 malloc(sizeof(struct SessionFunctionHook));
350 newfcn->next = SessionHookTable;
351 newfcn->h_function_pointer = fcn_ptr;
352 newfcn->eventtype = EventType;
353 SessionHookTable = newfcn;
355 lprintf(CTDL_INFO, "Registered a new session function (type %d)\n",
360 void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
362 struct SessionFunctionHook *cur, *p;
364 for (cur = SessionHookTable; cur != NULL; cur = cur->next) {
365 /* This will also remove duplicates if any */
366 while (cur != NULL &&
367 fcn_ptr == cur->h_function_pointer &&
368 EventType == cur->eventtype) {
369 lprintf(CTDL_INFO, "Unregistered session function (type %d)\n",
372 if (cur == SessionHookTable) {
373 SessionHookTable = p;
381 void CtdlDestroySessionHooks(void)
383 struct SessionFunctionHook *cur, *p;
385 cur = SessionHookTable;
388 lprintf(CTDL_INFO, "Destroyed session function\n");
393 SessionHookTable = NULL;
397 void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
400 struct UserFunctionHook *newfcn;
402 newfcn = (struct UserFunctionHook *)
403 malloc(sizeof(struct UserFunctionHook));
404 newfcn->next = UserHookTable;
405 newfcn->h_function_pointer = fcn_ptr;
406 newfcn->eventtype = EventType;
407 UserHookTable = newfcn;
409 lprintf(CTDL_INFO, "Registered a new user function (type %d)\n",
414 void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
416 struct UserFunctionHook *cur, *p;
418 for (cur = UserHookTable; cur != NULL; cur = cur->next) {
419 /* This will also remove duplicates if any */
420 while (cur != NULL &&
421 fcn_ptr == cur->h_function_pointer &&
422 EventType == cur->eventtype) {
423 lprintf(CTDL_INFO, "Unregistered user function (type %d)\n",
426 if (cur == UserHookTable) {
435 void CtdlDestroyUserHooks(void)
437 struct UserFunctionHook *cur, *p;
442 lprintf(CTDL_INFO, "Destroyed user function \n");
447 UserHookTable = NULL;
451 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
455 struct MessageFunctionHook *newfcn;
457 newfcn = (struct MessageFunctionHook *)
458 malloc(sizeof(struct MessageFunctionHook));
459 newfcn->next = MessageHookTable;
460 newfcn->h_function_pointer = handler;
461 newfcn->eventtype = EventType;
462 MessageHookTable = newfcn;
464 lprintf(CTDL_INFO, "Registered a new message function (type %d)\n",
469 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
472 struct MessageFunctionHook *cur, *p;
474 for (cur = MessageHookTable; cur != NULL; cur = cur->next) {
475 /* This will also remove duplicates if any */
476 while (cur != NULL &&
477 handler == cur->h_function_pointer &&
478 EventType == cur->eventtype) {
479 lprintf(CTDL_INFO, "Unregistered message function (type %d)\n",
482 if (cur == MessageHookTable) {
483 MessageHookTable = p;
491 void CtdlDestroyMessageHook(void)
493 struct MessageFunctionHook *cur, *p;
495 cur = MessageHookTable;
498 lprintf(CTDL_INFO, "Destroyed message function \n");
503 MessageHookTable = NULL;
507 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
509 struct RoomFunctionHook *newfcn;
511 newfcn = (struct RoomFunctionHook *)
512 malloc(sizeof(struct RoomFunctionHook));
513 newfcn->next = RoomHookTable;
514 newfcn->fcn_ptr = fcn_ptr;
515 RoomHookTable = newfcn;
517 lprintf(CTDL_INFO, "Registered a new room function\n");
521 void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
523 struct RoomFunctionHook *cur, *p;
525 for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
526 while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
527 lprintf(CTDL_INFO, "Unregistered room function\n");
529 if (cur == RoomHookTable) {
539 void CtdlDestroyRoomHooks(void)
541 struct RoomFunctionHook *cur, *p;
546 lprintf(CTDL_INFO, "Unregistered room function\n");
551 RoomHookTable = NULL;
554 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
556 struct NetprocFunctionHook *newfcn;
558 newfcn = (struct NetprocFunctionHook *)
559 malloc(sizeof(struct NetprocFunctionHook));
560 newfcn->next = NetprocHookTable;
561 newfcn->h_function_pointer = handler;
562 NetprocHookTable = newfcn;
564 lprintf(CTDL_INFO, "Registered a new netproc function\n");
568 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
570 struct NetprocFunctionHook *cur, *p;
572 for (cur = NetprocHookTable; cur != NULL; cur = cur->next) {
573 /* This will also remove duplicates if any */
574 while (cur != NULL &&
575 handler == cur->h_function_pointer ) {
576 lprintf(CTDL_INFO, "Unregistered netproc function\n");
578 if (cur == NetprocHookTable) {
579 NetprocHookTable = p;
587 void CtdlDestroyNetprocHooks(void)
589 struct NetprocFunctionHook *cur, *p;
591 cur = NetprocHookTable;
594 lprintf(CTDL_INFO, "Unregistered netproc function\n");
599 NetprocHookTable = NULL;
603 void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
605 struct DeleteFunctionHook *newfcn;
607 newfcn = (struct DeleteFunctionHook *)
608 malloc(sizeof(struct DeleteFunctionHook));
609 newfcn->next = DeleteHookTable;
610 newfcn->h_function_pointer = handler;
611 DeleteHookTable = newfcn;
613 lprintf(CTDL_INFO, "Registered a new netproc function\n");
617 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
619 struct DeleteFunctionHook *cur, *p;
621 for (cur = DeleteHookTable; cur != NULL; cur = cur->next) {
622 /* This will also remove duplicates if any */
623 while (cur != NULL &&
624 handler == cur->h_function_pointer ) {
625 lprintf(CTDL_INFO, "Unregistered netproc function\n");
627 if (cur == DeleteHookTable) {
635 void CtdlDestroyDeleteHooks(void)
637 struct DeleteFunctionHook *cur, *p;
639 cur = DeleteHookTable;
642 lprintf(CTDL_INFO, "Destroyed netproc function\n");
647 DeleteHookTable = NULL;
653 void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int) )
655 struct FixedOutputHook *newfcn;
657 newfcn = (struct FixedOutputHook *)
658 malloc(sizeof(struct FixedOutputHook));
659 newfcn->next = FixedOutputTable;
660 newfcn->h_function_pointer = handler;
661 safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
662 FixedOutputTable = newfcn;
664 lprintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
668 void CtdlUnregisterFixedOutputHook(char *content_type)
670 struct FixedOutputHook *cur, *p;
672 for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
673 /* This will also remove duplicates if any */
674 while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
675 lprintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
677 if (cur == FixedOutputTable) {
678 FixedOutputTable = p;
686 void CtdlDestroyFixedOutputHooks(void)
688 struct FixedOutputHook *cur, *p;
690 cur = FixedOutputTable;
693 lprintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
699 FixedOutputTable = NULL;
702 /* returns nonzero if we found a hook and used it */
703 int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
705 struct FixedOutputHook *fcn;
707 for (fcn = FixedOutputTable; fcn != NULL; fcn = fcn->next) {
708 if (!strcasecmp(content_type, fcn->content_type)) {
709 (*fcn->h_function_pointer) (content, content_length);
720 void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
723 struct XmsgFunctionHook *newfcn;
725 newfcn = (struct XmsgFunctionHook *)
726 malloc(sizeof(struct XmsgFunctionHook));
727 newfcn->next = XmsgHookTable;
728 newfcn->order = order;
729 newfcn->h_function_pointer = fcn_ptr;
730 XmsgHookTable = newfcn;
731 lprintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
735 void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
737 struct XmsgFunctionHook *cur, *p;
739 for (cur = XmsgHookTable; cur != NULL; cur = cur->next) {
740 /* This will also remove duplicates if any */
741 while (cur != NULL &&
742 fcn_ptr == cur->h_function_pointer &&
743 order == cur->order) {
744 lprintf(CTDL_INFO, "Unregistered x-msg function "
745 "(priority %d)\n", order);
747 if (cur == XmsgHookTable) {
756 void CtdlDestroyXmsgHooks(void)
758 struct XmsgFunctionHook *cur, *p;
763 lprintf(CTDL_INFO, "Destroyed x-msg function "
764 "(priority %d)\n", cur->order);
770 XmsgHookTable = NULL;
774 void CtdlRegisterServiceHook(int tcp_port,
776 void (*h_greeting_function) (void),
777 void (*h_command_function) (void),
778 void (*h_async_function) (void)
781 struct ServiceFunctionHook *newfcn;
786 newfcn = (struct ServiceFunctionHook *)
787 malloc(sizeof(struct ServiceFunctionHook));
788 message = (char*) malloc (SIZ);
790 newfcn->next = ServiceHookTable;
791 newfcn->tcp_port = tcp_port;
792 newfcn->sockpath = sockpath;
793 newfcn->h_greeting_function = h_greeting_function;
794 newfcn->h_command_function = h_command_function;
795 newfcn->h_async_function = h_async_function;
797 if (sockpath != NULL) {
798 newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions, &error);
799 snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
801 else if (tcp_port <= 0) { /* port -1 to disable */
802 lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n");
808 newfcn->msock = ig_tcp_server(config.c_ip_addr,
810 config.c_maxsessions,
812 snprintf(message, SIZ, "TCP port %s:%d: ",
813 config.c_ip_addr, tcp_port);
816 if (newfcn->msock > 0) {
817 ServiceHookTable = newfcn;
818 strcat(message, "registered.");
819 lprintf(CTDL_INFO, "%s\n", message);
822 AddPortError(message, error);
823 strcat(message, "FAILED.");
824 lprintf(CTDL_CRIT, "%s\n", message);
832 void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
833 void (*h_greeting_function) (void),
834 void (*h_command_function) (void),
835 void (*h_async_function) (void)
838 struct ServiceFunctionHook *cur, *p;
840 for (cur = ServiceHookTable; cur != NULL; cur = cur->next) {
841 /* This will also remove duplicates if any */
842 while (cur != NULL &&
843 !(sockpath && cur->sockpath &&
844 strcmp(sockpath, cur->sockpath)) &&
845 h_greeting_function == cur->h_greeting_function &&
846 h_command_function == cur->h_command_function &&
847 h_async_function == cur->h_async_function &&
848 tcp_port == cur->tcp_port) {
851 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
853 } else if (tcp_port) {
854 lprintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
856 lprintf(CTDL_INFO, "Unregistered unknown service\n");
859 if (cur == ServiceHookTable) {
860 ServiceHookTable = p;
868 void CtdlDestroyServiceHook(void)
870 struct ServiceFunctionHook *cur, *p;
872 cur = ServiceHookTable;
877 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
879 } else if (cur->tcp_port) {
880 lprintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
882 lprintf(CTDL_INFO, "Unregistered unknown service\n");
888 ServiceHookTable = NULL;
892 void PerformSessionHooks(int EventType)
894 struct SessionFunctionHook *fcn = NULL;
896 for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
897 if (fcn->eventtype == EventType) {
898 (*fcn->h_function_pointer) ();
903 void PerformUserHooks(struct ctdluser *usbuf, int EventType)
905 struct UserFunctionHook *fcn = NULL;
907 for (fcn = UserHookTable; fcn != NULL; fcn = fcn->next) {
908 if (fcn->eventtype == EventType) {
909 (*fcn->h_function_pointer) (usbuf);
914 int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
916 struct MessageFunctionHook *fcn = NULL;
917 int total_retval = 0;
919 /* Other code may elect to protect this message from server-side
920 * handlers; if this is the case, don't do anything.
921 lprintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
922 EventType, msg->cm_flags);
924 if (msg->cm_flags & CM_SKIP_HOOKS) {
925 lprintf(CTDL_DEBUG, "Skipping hooks\n");
929 /* Otherwise, run all the hooks appropriate to this event type.
931 for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
932 if (fcn->eventtype == EventType) {
933 total_retval = total_retval +
934 (*fcn->h_function_pointer) (msg);
938 /* Return the sum of the return codes from the hook functions. If
939 * this is an EVT_BEFORESAVE event, a nonzero return code will cause
940 * the save operation to abort.
946 int PerformRoomHooks(struct ctdlroom *target_room)
948 struct RoomFunctionHook *fcn;
949 int total_retval = 0;
951 lprintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
953 for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
954 total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
957 /* Return the sum of the return codes from the hook functions.
963 int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
965 struct NetprocFunctionHook *fcn;
966 int total_retval = 0;
968 for (fcn = NetprocHookTable; fcn != NULL; fcn = fcn->next) {
969 total_retval = total_retval +
970 (*fcn->h_function_pointer) (msg, target_room);
973 /* Return the sum of the return codes from the hook functions.
974 * A nonzero return code will cause the message to *not* be imported.
980 void PerformDeleteHooks(char *room, long msgnum)
982 struct DeleteFunctionHook *fcn;
984 for (fcn = DeleteHookTable; fcn != NULL; fcn = fcn->next) {
985 (*fcn->h_function_pointer) (room, msgnum);
993 int PerformXmsgHooks(char *sender, char *recp, char *msg)
995 struct XmsgFunctionHook *fcn;
999 for (p=0; p<MAX_XMSG_PRI; ++p) {
1000 for (fcn = XmsgHookTable; fcn != NULL; fcn = fcn->next) {
1001 if (fcn->order == p) {
1003 (*fcn->h_function_pointer)
1004 (sender, recp, msg);
1007 /* Break out of the loop if a higher-priority function
1008 * successfully delivered the message. This prevents duplicate
1009 * deliveries to local users simultaneously signed onto
1012 if (total_sent) break;