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]);
253 void initialize_server_extensions(void)
259 /*lprintf(CTDL_INFO, "%s\n", serv_bio_init());
260 lprintf(CTDL_INFO, "%s\n", serv_calendar_init());
261 lprintf(CTDL_INFO, "%s\n", serv_notes_init());
262 lprintf(CTDL_INFO, "%s\n", serv_ldap_init());
263 lprintf(CTDL_INFO, "%s\n", serv_chat_init());
264 lprintf(CTDL_INFO, "%s\n", serv_expire_init());
265 lprintf(CTDL_INFO, "%s\n", serv_imap_init());
266 lprintf(CTDL_INFO, "%s\n", serv_upgrade_init());
267 lprintf(CTDL_INFO, "%s\n", serv_inetcfg_init());
268 lprintf(CTDL_INFO, "%s\n", serv_listsub_init());
269 lprintf(CTDL_INFO, "%s\n", serv_mrtg_init());
270 lprintf(CTDL_INFO, "%s\n", serv_netfilter_init());
271 lprintf(CTDL_INFO, "%s\n", serv_network_init());
272 lprintf(CTDL_INFO, "%s\n", serv_newuser_init());
273 lprintf(CTDL_INFO, "%s\n", serv_pas2_init());
274 lprintf(CTDL_INFO, "%s\n", serv_smtp_init());
275 lprintf(CTDL_INFO, "%s\n", serv_pop3_init());
276 lprintf(CTDL_INFO, "%s\n", serv_rwho_init());
277 lprintf(CTDL_INFO, "%s\n", serv_spam_init());*/
278 /* lprintf(CTDL_INFO, "%s\n", serv_test_init()); */
279 /*lprintf(CTDL_INFO, "%s\n", serv_vandelay_init());
280 lprintf(CTDL_INFO, "%s\n", serv_vcard_init());
281 lprintf(CTDL_INFO, "%s\n", serv_fulltext_init());
282 lprintf(CTDL_INFO, "%s\n", serv_autocompletion_init());
283 lprintf(CTDL_INFO, "%s\n", serv_postfix_tcpdict());
284 lprintf(CTDL_INFO, "%s\n", serv_sieve_init());
285 lprintf(CTDL_INFO, "%s\n", serv_managesieve_init());
286 lprintf(CTDL_INFO, "%s\n", serv_funambol_init());*/
287 for (filter = 1; filter != 0; filter = filter << 1)
288 if ((filter & DetailErrorFlags) != 0)
289 LogPrintMessages(filter);
294 void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
297 struct CleanupFunctionHook *newfcn;
299 newfcn = (struct CleanupFunctionHook *)
300 malloc(sizeof(struct CleanupFunctionHook));
301 newfcn->next = CleanupHookTable;
302 newfcn->h_function_pointer = fcn_ptr;
303 CleanupHookTable = newfcn;
305 lprintf(CTDL_INFO, "Registered a new cleanup function\n");
309 void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
311 struct CleanupFunctionHook *cur, *p;
313 for (cur = CleanupHookTable; cur != NULL; cur = cur->next) {
314 /* This will also remove duplicates if any */
315 while (cur != NULL &&
316 fcn_ptr == cur->h_function_pointer) {
317 lprintf(CTDL_INFO, "Unregistered cleanup function\n");
319 if (cur == CleanupHookTable) {
320 CleanupHookTable = p;
328 void CtdlDestroyCleanupHooks(void)
330 struct CleanupFunctionHook *cur, *p;
332 cur = CleanupHookTable;
335 lprintf(CTDL_INFO, "Destroyed cleanup function\n");
340 CleanupHookTable = NULL;
344 void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
347 struct SessionFunctionHook *newfcn;
349 newfcn = (struct SessionFunctionHook *)
350 malloc(sizeof(struct SessionFunctionHook));
351 newfcn->next = SessionHookTable;
352 newfcn->h_function_pointer = fcn_ptr;
353 newfcn->eventtype = EventType;
354 SessionHookTable = newfcn;
356 lprintf(CTDL_INFO, "Registered a new session function (type %d)\n",
361 void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
363 struct SessionFunctionHook *cur, *p;
365 for (cur = SessionHookTable; cur != NULL; cur = cur->next) {
366 /* This will also remove duplicates if any */
367 while (cur != NULL &&
368 fcn_ptr == cur->h_function_pointer &&
369 EventType == cur->eventtype) {
370 lprintf(CTDL_INFO, "Unregistered session function (type %d)\n",
373 if (cur == SessionHookTable) {
374 SessionHookTable = p;
382 void CtdlDestroySessionHooks(void)
384 struct SessionFunctionHook *cur, *p;
386 cur = SessionHookTable;
389 lprintf(CTDL_INFO, "Destroyed session function\n");
394 SessionHookTable = NULL;
398 void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
401 struct UserFunctionHook *newfcn;
403 newfcn = (struct UserFunctionHook *)
404 malloc(sizeof(struct UserFunctionHook));
405 newfcn->next = UserHookTable;
406 newfcn->h_function_pointer = fcn_ptr;
407 newfcn->eventtype = EventType;
408 UserHookTable = newfcn;
410 lprintf(CTDL_INFO, "Registered a new user function (type %d)\n",
415 void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
417 struct UserFunctionHook *cur, *p;
419 for (cur = UserHookTable; cur != NULL; cur = cur->next) {
420 /* This will also remove duplicates if any */
421 while (cur != NULL &&
422 fcn_ptr == cur->h_function_pointer &&
423 EventType == cur->eventtype) {
424 lprintf(CTDL_INFO, "Unregistered user function (type %d)\n",
427 if (cur == UserHookTable) {
436 void CtdlDestroyUserHooks(void)
438 struct UserFunctionHook *cur, *p;
443 lprintf(CTDL_INFO, "Destroyed user function \n");
448 UserHookTable = NULL;
452 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
456 struct MessageFunctionHook *newfcn;
458 newfcn = (struct MessageFunctionHook *)
459 malloc(sizeof(struct MessageFunctionHook));
460 newfcn->next = MessageHookTable;
461 newfcn->h_function_pointer = handler;
462 newfcn->eventtype = EventType;
463 MessageHookTable = newfcn;
465 lprintf(CTDL_INFO, "Registered a new message function (type %d)\n",
470 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
473 struct MessageFunctionHook *cur, *p;
475 for (cur = MessageHookTable; cur != NULL; cur = cur->next) {
476 /* This will also remove duplicates if any */
477 while (cur != NULL &&
478 handler == cur->h_function_pointer &&
479 EventType == cur->eventtype) {
480 lprintf(CTDL_INFO, "Unregistered message function (type %d)\n",
483 if (cur == MessageHookTable) {
484 MessageHookTable = p;
492 void CtdlDestroyMessageHook(void)
494 struct MessageFunctionHook *cur, *p;
496 cur = MessageHookTable;
499 lprintf(CTDL_INFO, "Destroyed message function \n");
504 MessageHookTable = NULL;
508 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
510 struct RoomFunctionHook *newfcn;
512 newfcn = (struct RoomFunctionHook *)
513 malloc(sizeof(struct RoomFunctionHook));
514 newfcn->next = RoomHookTable;
515 newfcn->fcn_ptr = fcn_ptr;
516 RoomHookTable = newfcn;
518 lprintf(CTDL_INFO, "Registered a new room function\n");
522 void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
524 struct RoomFunctionHook *cur, *p;
526 for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
527 while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
528 lprintf(CTDL_INFO, "Unregistered room function\n");
530 if (cur == RoomHookTable) {
540 void CtdlDestroyRoomHooks(void)
542 struct RoomFunctionHook *cur, *p;
547 lprintf(CTDL_INFO, "Unregistered room function\n");
552 RoomHookTable = NULL;
555 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
557 struct NetprocFunctionHook *newfcn;
559 newfcn = (struct NetprocFunctionHook *)
560 malloc(sizeof(struct NetprocFunctionHook));
561 newfcn->next = NetprocHookTable;
562 newfcn->h_function_pointer = handler;
563 NetprocHookTable = newfcn;
565 lprintf(CTDL_INFO, "Registered a new netproc function\n");
569 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
571 struct NetprocFunctionHook *cur, *p;
573 for (cur = NetprocHookTable; cur != NULL; cur = cur->next) {
574 /* This will also remove duplicates if any */
575 while (cur != NULL &&
576 handler == cur->h_function_pointer ) {
577 lprintf(CTDL_INFO, "Unregistered netproc function\n");
579 if (cur == NetprocHookTable) {
580 NetprocHookTable = p;
588 void CtdlDestroyNetprocHooks(void)
590 struct NetprocFunctionHook *cur, *p;
592 cur = NetprocHookTable;
595 lprintf(CTDL_INFO, "Unregistered netproc function\n");
600 NetprocHookTable = NULL;
604 void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
606 struct DeleteFunctionHook *newfcn;
608 newfcn = (struct DeleteFunctionHook *)
609 malloc(sizeof(struct DeleteFunctionHook));
610 newfcn->next = DeleteHookTable;
611 newfcn->h_function_pointer = handler;
612 DeleteHookTable = newfcn;
614 lprintf(CTDL_INFO, "Registered a new netproc function\n");
618 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
620 struct DeleteFunctionHook *cur, *p;
622 for (cur = DeleteHookTable; cur != NULL; cur = cur->next) {
623 /* This will also remove duplicates if any */
624 while (cur != NULL &&
625 handler == cur->h_function_pointer ) {
626 lprintf(CTDL_INFO, "Unregistered netproc function\n");
628 if (cur == DeleteHookTable) {
636 void CtdlDestroyDeleteHooks(void)
638 struct DeleteFunctionHook *cur, *p;
640 cur = DeleteHookTable;
643 lprintf(CTDL_INFO, "Destroyed netproc function\n");
648 DeleteHookTable = NULL;
654 void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int) )
656 struct FixedOutputHook *newfcn;
658 newfcn = (struct FixedOutputHook *)
659 malloc(sizeof(struct FixedOutputHook));
660 newfcn->next = FixedOutputTable;
661 newfcn->h_function_pointer = handler;
662 safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
663 FixedOutputTable = newfcn;
665 lprintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
669 void CtdlUnregisterFixedOutputHook(char *content_type)
671 struct FixedOutputHook *cur, *p;
673 for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
674 /* This will also remove duplicates if any */
675 while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
676 lprintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
678 if (cur == FixedOutputTable) {
679 FixedOutputTable = p;
687 void CtdlDestroyFixedOutputHooks(void)
689 struct FixedOutputHook *cur, *p;
691 cur = FixedOutputTable;
694 lprintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
700 FixedOutputTable = NULL;
703 /* returns nonzero if we found a hook and used it */
704 int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
706 struct FixedOutputHook *fcn;
708 for (fcn = FixedOutputTable; fcn != NULL; fcn = fcn->next) {
709 if (!strcasecmp(content_type, fcn->content_type)) {
710 (*fcn->h_function_pointer) (content, content_length);
721 void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
724 struct XmsgFunctionHook *newfcn;
726 newfcn = (struct XmsgFunctionHook *)
727 malloc(sizeof(struct XmsgFunctionHook));
728 newfcn->next = XmsgHookTable;
729 newfcn->order = order;
730 newfcn->h_function_pointer = fcn_ptr;
731 XmsgHookTable = newfcn;
732 lprintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
736 void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
738 struct XmsgFunctionHook *cur, *p;
740 for (cur = XmsgHookTable; cur != NULL; cur = cur->next) {
741 /* This will also remove duplicates if any */
742 while (cur != NULL &&
743 fcn_ptr == cur->h_function_pointer &&
744 order == cur->order) {
745 lprintf(CTDL_INFO, "Unregistered x-msg function "
746 "(priority %d)\n", order);
748 if (cur == XmsgHookTable) {
757 void CtdlDestroyXmsgHooks(void)
759 struct XmsgFunctionHook *cur, *p;
764 lprintf(CTDL_INFO, "Destroyed x-msg function "
765 "(priority %d)\n", cur->order);
771 XmsgHookTable = NULL;
775 void CtdlRegisterServiceHook(int tcp_port,
777 void (*h_greeting_function) (void),
778 void (*h_command_function) (void),
779 void (*h_async_function) (void)
782 struct ServiceFunctionHook *newfcn;
787 newfcn = (struct ServiceFunctionHook *)
788 malloc(sizeof(struct ServiceFunctionHook));
789 message = (char*) malloc (SIZ);
791 newfcn->next = ServiceHookTable;
792 newfcn->tcp_port = tcp_port;
793 newfcn->sockpath = sockpath;
794 newfcn->h_greeting_function = h_greeting_function;
795 newfcn->h_command_function = h_command_function;
796 newfcn->h_async_function = h_async_function;
798 if (sockpath != NULL) {
799 newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions, &error);
800 snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
802 else if (tcp_port <= 0) { /* port -1 to disable */
803 lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n");
809 newfcn->msock = ig_tcp_server(config.c_ip_addr,
811 config.c_maxsessions,
813 snprintf(message, SIZ, "TCP port %s:%d: ",
814 config.c_ip_addr, tcp_port);
817 if (newfcn->msock > 0) {
818 ServiceHookTable = newfcn;
819 strcat(message, "registered.");
820 lprintf(CTDL_INFO, "%s\n", message);
823 AddPortError(message, error);
824 strcat(message, "FAILED.");
825 lprintf(CTDL_CRIT, "%s\n", message);
833 void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
834 void (*h_greeting_function) (void),
835 void (*h_command_function) (void),
836 void (*h_async_function) (void)
839 struct ServiceFunctionHook *cur, *p;
841 for (cur = ServiceHookTable; cur != NULL; cur = cur->next) {
842 /* This will also remove duplicates if any */
843 while (cur != NULL &&
844 !(sockpath && cur->sockpath &&
845 strcmp(sockpath, cur->sockpath)) &&
846 h_greeting_function == cur->h_greeting_function &&
847 h_command_function == cur->h_command_function &&
848 h_async_function == cur->h_async_function &&
849 tcp_port == cur->tcp_port) {
852 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
854 } else if (tcp_port) {
855 lprintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
857 lprintf(CTDL_INFO, "Unregistered unknown service\n");
860 if (cur == ServiceHookTable) {
861 ServiceHookTable = p;
869 void CtdlDestroyServiceHook(void)
871 struct ServiceFunctionHook *cur, *p;
873 cur = ServiceHookTable;
878 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
880 } else if (cur->tcp_port) {
881 lprintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
883 lprintf(CTDL_INFO, "Unregistered unknown service\n");
889 ServiceHookTable = NULL;
893 void PerformSessionHooks(int EventType)
895 struct SessionFunctionHook *fcn = NULL;
897 for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
898 if (fcn->eventtype == EventType) {
899 (*fcn->h_function_pointer) ();
904 void PerformUserHooks(struct ctdluser *usbuf, int EventType)
906 struct UserFunctionHook *fcn = NULL;
908 for (fcn = UserHookTable; fcn != NULL; fcn = fcn->next) {
909 if (fcn->eventtype == EventType) {
910 (*fcn->h_function_pointer) (usbuf);
915 int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
917 struct MessageFunctionHook *fcn = NULL;
918 int total_retval = 0;
920 /* Other code may elect to protect this message from server-side
921 * handlers; if this is the case, don't do anything.
922 lprintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
923 EventType, msg->cm_flags);
925 if (msg->cm_flags & CM_SKIP_HOOKS) {
926 lprintf(CTDL_DEBUG, "Skipping hooks\n");
930 /* Otherwise, run all the hooks appropriate to this event type.
932 for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
933 if (fcn->eventtype == EventType) {
934 total_retval = total_retval +
935 (*fcn->h_function_pointer) (msg);
939 /* Return the sum of the return codes from the hook functions. If
940 * this is an EVT_BEFORESAVE event, a nonzero return code will cause
941 * the save operation to abort.
947 int PerformRoomHooks(struct ctdlroom *target_room)
949 struct RoomFunctionHook *fcn;
950 int total_retval = 0;
952 lprintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
954 for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
955 total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
958 /* Return the sum of the return codes from the hook functions.
964 int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
966 struct NetprocFunctionHook *fcn;
967 int total_retval = 0;
969 for (fcn = NetprocHookTable; fcn != NULL; fcn = fcn->next) {
970 total_retval = total_retval +
971 (*fcn->h_function_pointer) (msg, target_room);
974 /* Return the sum of the return codes from the hook functions.
975 * A nonzero return code will cause the message to *not* be imported.
981 void PerformDeleteHooks(char *room, long msgnum)
983 struct DeleteFunctionHook *fcn;
985 for (fcn = DeleteHookTable; fcn != NULL; fcn = fcn->next) {
986 (*fcn->h_function_pointer) (room, msgnum);
994 int PerformXmsgHooks(char *sender, char *recp, char *msg)
996 struct XmsgFunctionHook *fcn;
1000 for (p=0; p<MAX_XMSG_PRI; ++p) {
1001 for (fcn = XmsgHookTable; fcn != NULL; fcn = fcn->next) {
1002 if (fcn->order == p) {
1004 (*fcn->h_function_pointer)
1005 (sender, recp, msg);
1008 /* Break out of the loop if a higher-priority function
1009 * successfully delivered the message. This prevents duplicate
1010 * deliveries to local users simultaneously signed onto
1013 if (total_sent) break;