4 * Citadel Dynamic Loading Module
5 * Written by Brian Costello <btx@calyx.net>
13 #include <sys/types.h>
18 #include <libcitadel.h>
21 #include "serv_extensions.h"
22 #include "sysdep_decls.h"
26 #include "modules/crypto/serv_crypto.h" /* Needed until a universal crypto startup hook is implimented for CtdlStartTLS */
28 #include "ctdl_module.h"
35 struct CleanupFunctionHook *CleanupHookTable = NULL;
36 struct SessionFunctionHook *SessionHookTable = NULL;
37 struct UserFunctionHook *UserHookTable = NULL;
38 struct XmsgFunctionHook *XmsgHookTable = NULL;
39 struct MessageFunctionHook *MessageHookTable = NULL;
40 struct NetprocFunctionHook *NetprocHookTable = NULL;
41 struct DeleteFunctionHook *DeleteHookTable = NULL;
42 struct ServiceFunctionHook *ServiceHookTable = NULL;
43 struct FixedOutputHook *FixedOutputTable = NULL;
44 struct RoomFunctionHook *RoomHookTable = NULL;
45 struct SearchFunctionHook *SearchFunctionHookTable = NULL;
47 struct ProtoFunctionHook {
48 void (*handler) (char *cmdbuf);
53 HashList *ProtoHookList = NULL;
56 #define ERR_PORT (1 << 1)
59 static char *portlist = NULL;
60 static size_t nSizPort = 0;
62 static char *errormessages = NULL;
63 size_t nSizErrmsg = 0;
66 long DetailErrorFlags;
68 char *ErrSubject = "Startup Problems";
69 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"
70 "If you don't want citadel to provide these services, turn them off in WebCit via %s%s\n\n%s\n\n"
71 "To make both ways actualy take place restart the citserver with \"sendcommand down\"\n\n"
72 "The errors returned by the system were:\n%s\n"
73 "You can recheck the above if you follow this faq item:\n"
74 "http://www.citadel.org/doku.php/faq:mastering_your_os:net#netstat";
77 char *ErrPortShort = "We couldn't bind all ports you configured to be provided by citadel server.";
78 char *ErrPortWhere = "Admin->System Preferences->Network.\n\nThe failed ports and sockets are: ";
79 char *ErrPortHint = "If you want citadel to provide you with that functionality, "
80 "check the output of \"netstat -lnp\" on linux Servers or \"netstat -na\" on *BSD"
81 " and stop the programm, that binds these ports.\n You should eventually remove "
82 " their initscripts in /etc/init.d so that you won't get this trouble once more.\n"
83 " After that goto Administration -> Shutdown Citadel to make Citadel retry to bind this port.\n";
86 void LogPrintMessages(long err)
88 char *List, *DetailList, *Short, *Where, *Hint, *Message;
89 int n = nSizPort + nSizErrmsg + 5;
91 Message = (char*) malloc(n * SIZ);
93 DetailErrorFlags = DetailErrorFlags & ~err;
102 DetailList = errormessages;
113 snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
115 CtdlLogPrintf(0,Message);
116 CtdlLogPrintf(0,ErrSubject);
117 quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
118 if (errormessages!=NULL) free (errormessages);
119 errormessages = NULL;
120 if (portlist!=NULL) free (portlist);
127 void AppendString(char **target, char *append, size_t *len, size_t rate)
133 AddLen = strlen(append);
139 *target = (char*)malloc (*len * SIZ);
143 oLen = strlen(*target);
144 RelPtr = strlen(*target);
145 if (oLen + AddLen + 2 > *len * SIZ)
147 char *Buff = *target;
148 size_t NewSiz = *len + 10;
149 *target = malloc (NewSiz * SIZ);
150 memcpy (*target, Buff, NewSiz * SIZ);
154 memcpy (*target + oLen, append, AddLen);
155 (*target)[oLen + AddLen + 1] = '\n';
156 (*target)[oLen + AddLen + 2] = '\0';
159 void AddPortError(char *Port, char *ErrorMessage)
164 DetailErrorFlags |= ERR_PORT;
166 AppendString(&errormessages, ErrorMessage, &nSizErrmsg, 10);
167 AppendString(&portlist, Port, &nSizPort, 2);
169 pos = strchr (portlist, ':');
170 if (pos != NULL) *pos = ';';
172 len = strlen (errormessages);
173 if (nSizErrmsg * SIZ > len + 3)
175 errormessages[len] = ';';
176 errormessages[len+1] = ' ';
177 errormessages[len+2] = '\0';
182 int DLoader_Exec_Cmd(char *cmdbuf)
185 struct ProtoFunctionHook *p;
187 if (GetHash(ProtoHookList, cmdbuf, 4, &vP) && (vP != NULL)) {
188 p = (struct ProtoFunctionHook*) vP;
189 p->handler(&cmdbuf[5]);
195 int FourHash(const char *key, long length)
199 const unsigned char *ptr = (const unsigned char*)key;
201 for (i = 0; i < 4; i++, ptr ++)
211 void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
213 struct ProtoFunctionHook *p;
215 if (ProtoHookList == NULL)
216 ProtoHookList = NewHash (1, FourHash);
219 p = (struct ProtoFunctionHook *)
220 malloc(sizeof(struct ProtoFunctionHook));
223 fprintf(stderr, "can't malloc new ProtoFunctionHook\n");
226 p->handler = handler;
230 Put(ProtoHookList, cmd, 4, p, NULL);
231 CtdlLogPrintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
234 void CtdlDestroyProtoHooks(void)
237 DeleteHash(&ProtoHookList);
241 void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
244 struct CleanupFunctionHook *newfcn;
246 newfcn = (struct CleanupFunctionHook *)
247 malloc(sizeof(struct CleanupFunctionHook));
248 newfcn->next = CleanupHookTable;
249 newfcn->h_function_pointer = fcn_ptr;
250 CleanupHookTable = newfcn;
252 CtdlLogPrintf(CTDL_INFO, "Registered a new cleanup function\n");
256 void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
258 struct CleanupFunctionHook *cur, *p;
260 for (cur = CleanupHookTable; cur != NULL; cur = cur->next) {
261 /* This will also remove duplicates if any */
262 while (cur != NULL &&
263 fcn_ptr == cur->h_function_pointer) {
264 CtdlLogPrintf(CTDL_INFO, "Unregistered cleanup function\n");
266 if (cur == CleanupHookTable) {
267 CleanupHookTable = p;
275 void CtdlDestroyCleanupHooks(void)
277 struct CleanupFunctionHook *cur, *p;
279 cur = CleanupHookTable;
282 CtdlLogPrintf(CTDL_INFO, "Destroyed cleanup function\n");
287 CleanupHookTable = NULL;
291 void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
294 struct SessionFunctionHook *newfcn;
296 newfcn = (struct SessionFunctionHook *)
297 malloc(sizeof(struct SessionFunctionHook));
298 newfcn->next = SessionHookTable;
299 newfcn->h_function_pointer = fcn_ptr;
300 newfcn->eventtype = EventType;
301 SessionHookTable = newfcn;
303 CtdlLogPrintf(CTDL_INFO, "Registered a new session function (type %d)\n",
308 void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
310 struct SessionFunctionHook *cur, *p;
312 for (cur = SessionHookTable; 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 EventType == cur->eventtype) {
317 CtdlLogPrintf(CTDL_INFO, "Unregistered session function (type %d)\n",
320 if (cur == SessionHookTable) {
321 SessionHookTable = p;
329 void CtdlDestroySessionHooks(void)
331 struct SessionFunctionHook *cur, *p;
333 cur = SessionHookTable;
336 CtdlLogPrintf(CTDL_INFO, "Destroyed session function\n");
341 SessionHookTable = NULL;
345 void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
348 struct UserFunctionHook *newfcn;
350 newfcn = (struct UserFunctionHook *)
351 malloc(sizeof(struct UserFunctionHook));
352 newfcn->next = UserHookTable;
353 newfcn->h_function_pointer = fcn_ptr;
354 newfcn->eventtype = EventType;
355 UserHookTable = newfcn;
357 CtdlLogPrintf(CTDL_INFO, "Registered a new user function (type %d)\n",
362 void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
364 struct UserFunctionHook *cur, *p;
366 for (cur = UserHookTable; cur != NULL; cur = cur->next) {
367 /* This will also remove duplicates if any */
368 while (cur != NULL &&
369 fcn_ptr == cur->h_function_pointer &&
370 EventType == cur->eventtype) {
371 CtdlLogPrintf(CTDL_INFO, "Unregistered user function (type %d)\n",
374 if (cur == UserHookTable) {
383 void CtdlDestroyUserHooks(void)
385 struct UserFunctionHook *cur, *p;
390 CtdlLogPrintf(CTDL_INFO, "Destroyed user function \n");
395 UserHookTable = NULL;
399 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
403 struct MessageFunctionHook *newfcn;
405 newfcn = (struct MessageFunctionHook *)
406 malloc(sizeof(struct MessageFunctionHook));
407 newfcn->next = MessageHookTable;
408 newfcn->h_function_pointer = handler;
409 newfcn->eventtype = EventType;
410 MessageHookTable = newfcn;
412 CtdlLogPrintf(CTDL_INFO, "Registered a new message function (type %d)\n",
417 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
420 struct MessageFunctionHook *cur, *p;
422 for (cur = MessageHookTable; cur != NULL; cur = cur->next) {
423 /* This will also remove duplicates if any */
424 while (cur != NULL &&
425 handler == cur->h_function_pointer &&
426 EventType == cur->eventtype) {
427 CtdlLogPrintf(CTDL_INFO, "Unregistered message function (type %d)\n",
430 if (cur == MessageHookTable) {
431 MessageHookTable = p;
439 void CtdlDestroyMessageHook(void)
441 struct MessageFunctionHook *cur, *p;
443 cur = MessageHookTable;
446 CtdlLogPrintf(CTDL_INFO, "Destroyed message function (type %d)\n", cur->eventtype);
451 MessageHookTable = NULL;
455 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
457 struct RoomFunctionHook *newfcn;
459 newfcn = (struct RoomFunctionHook *)
460 malloc(sizeof(struct RoomFunctionHook));
461 newfcn->next = RoomHookTable;
462 newfcn->fcn_ptr = fcn_ptr;
463 RoomHookTable = newfcn;
465 CtdlLogPrintf(CTDL_INFO, "Registered a new room function\n");
469 void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
471 struct RoomFunctionHook *cur, *p;
473 for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
474 while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
475 CtdlLogPrintf(CTDL_INFO, "Unregistered room function\n");
477 if (cur == RoomHookTable) {
487 void CtdlDestroyRoomHooks(void)
489 struct RoomFunctionHook *cur, *p;
494 CtdlLogPrintf(CTDL_INFO, "Destroyed room function\n");
499 RoomHookTable = NULL;
502 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
504 struct NetprocFunctionHook *newfcn;
506 newfcn = (struct NetprocFunctionHook *)
507 malloc(sizeof(struct NetprocFunctionHook));
508 newfcn->next = NetprocHookTable;
509 newfcn->h_function_pointer = handler;
510 NetprocHookTable = newfcn;
512 CtdlLogPrintf(CTDL_INFO, "Registered a new netproc function\n");
516 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
518 struct NetprocFunctionHook *cur, *p;
520 for (cur = NetprocHookTable; cur != NULL; cur = cur->next) {
521 /* This will also remove duplicates if any */
522 while (cur != NULL &&
523 handler == cur->h_function_pointer ) {
524 CtdlLogPrintf(CTDL_INFO, "Unregistered netproc function\n");
526 if (cur == NetprocHookTable) {
527 NetprocHookTable = p;
535 void CtdlDestroyNetprocHooks(void)
537 struct NetprocFunctionHook *cur, *p;
539 cur = NetprocHookTable;
542 CtdlLogPrintf(CTDL_INFO, "Destroyed netproc function\n");
547 NetprocHookTable = NULL;
551 void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
553 struct DeleteFunctionHook *newfcn;
555 newfcn = (struct DeleteFunctionHook *)
556 malloc(sizeof(struct DeleteFunctionHook));
557 newfcn->next = DeleteHookTable;
558 newfcn->h_function_pointer = handler;
559 DeleteHookTable = newfcn;
561 CtdlLogPrintf(CTDL_INFO, "Registered a new delete function\n");
565 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
567 struct DeleteFunctionHook *cur, *p;
569 for (cur = DeleteHookTable; cur != NULL; cur = cur->next) {
570 /* This will also remove duplicates if any */
571 while (cur != NULL &&
572 handler == cur->h_function_pointer ) {
573 CtdlLogPrintf(CTDL_INFO, "Unregistered delete function\n");
575 if (cur == DeleteHookTable) {
583 void CtdlDestroyDeleteHooks(void)
585 struct DeleteFunctionHook *cur, *p;
587 cur = DeleteHookTable;
590 CtdlLogPrintf(CTDL_INFO, "Destroyed delete function\n");
595 DeleteHookTable = NULL;
601 void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int) )
603 struct FixedOutputHook *newfcn;
605 newfcn = (struct FixedOutputHook *)
606 malloc(sizeof(struct FixedOutputHook));
607 newfcn->next = FixedOutputTable;
608 newfcn->h_function_pointer = handler;
609 safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
610 FixedOutputTable = newfcn;
612 CtdlLogPrintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
616 void CtdlUnregisterFixedOutputHook(char *content_type)
618 struct FixedOutputHook *cur, *p;
620 for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
621 /* This will also remove duplicates if any */
622 while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
623 CtdlLogPrintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
625 if (cur == FixedOutputTable) {
626 FixedOutputTable = p;
634 void CtdlDestroyFixedOutputHooks(void)
636 struct FixedOutputHook *cur, *p;
638 cur = FixedOutputTable;
641 CtdlLogPrintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
647 FixedOutputTable = NULL;
650 /* returns nonzero if we found a hook and used it */
651 int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
653 struct FixedOutputHook *fcn;
655 for (fcn = FixedOutputTable; fcn != NULL; fcn = fcn->next) {
656 if (!strcasecmp(content_type, fcn->content_type)) {
657 (*fcn->h_function_pointer) (content, content_length);
668 void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int order)
671 struct XmsgFunctionHook *newfcn;
673 newfcn = (struct XmsgFunctionHook *) malloc(sizeof(struct XmsgFunctionHook));
674 newfcn->next = XmsgHookTable;
675 newfcn->order = order;
676 newfcn->h_function_pointer = fcn_ptr;
677 XmsgHookTable = newfcn;
678 CtdlLogPrintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
682 void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int order)
684 struct XmsgFunctionHook *cur, *p;
686 for (cur = XmsgHookTable; cur != NULL; cur = cur->next) {
687 /* This will also remove duplicates if any */
688 while (cur != NULL &&
689 fcn_ptr == cur->h_function_pointer &&
690 order == cur->order) {
691 CtdlLogPrintf(CTDL_INFO, "Unregistered x-msg function "
692 "(priority %d)\n", order);
694 if (cur == XmsgHookTable) {
703 void CtdlDestroyXmsgHooks(void)
705 struct XmsgFunctionHook *cur, *p;
710 CtdlLogPrintf(CTDL_INFO, "Destroyed x-msg function "
711 "(priority %d)\n", cur->order);
717 XmsgHookTable = NULL;
721 void CtdlRegisterServiceHook(int tcp_port,
723 void (*h_greeting_function) (void),
724 void (*h_command_function) (void),
725 void (*h_async_function) (void),
726 const char *ServiceName)
728 struct ServiceFunctionHook *newfcn;
733 newfcn = (struct ServiceFunctionHook *)
734 malloc(sizeof(struct ServiceFunctionHook));
735 message = (char*) malloc (SIZ);
737 newfcn->next = ServiceHookTable;
738 newfcn->tcp_port = tcp_port;
739 newfcn->sockpath = sockpath;
740 newfcn->h_greeting_function = h_greeting_function;
741 newfcn->h_command_function = h_command_function;
742 newfcn->h_async_function = h_async_function;
743 newfcn->ServiceName = ServiceName;
745 if (sockpath != NULL) {
746 newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions, &error);
747 snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
749 else if (tcp_port <= 0) { /* port -1 to disable */
750 CtdlLogPrintf(CTDL_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
756 newfcn->msock = ig_tcp_server(config.c_ip_addr,
758 config.c_maxsessions,
760 snprintf(message, SIZ, "TCP port %s:%d: (%s) ",
761 config.c_ip_addr, tcp_port, ServiceName);
764 if (newfcn->msock > 0) {
765 ServiceHookTable = newfcn;
766 strcat(message, "registered.");
767 CtdlLogPrintf(CTDL_INFO, "%s\n", message);
770 AddPortError(message, error);
771 strcat(message, "FAILED.");
772 CtdlLogPrintf(CTDL_CRIT, "%s\n", message);
780 void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
781 void (*h_greeting_function) (void),
782 void (*h_command_function) (void),
783 void (*h_async_function) (void)
786 struct ServiceFunctionHook *cur, *p;
788 for (cur = ServiceHookTable; cur != NULL; cur = cur->next) {
789 /* This will also remove duplicates if any */
790 while (cur != NULL &&
791 !(sockpath && cur->sockpath &&
792 strcmp(sockpath, cur->sockpath)) &&
793 h_greeting_function == cur->h_greeting_function &&
794 h_command_function == cur->h_command_function &&
795 h_async_function == cur->h_async_function &&
796 tcp_port == cur->tcp_port) {
799 CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
801 } else if (tcp_port) {
802 CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
804 CtdlLogPrintf(CTDL_INFO, "Unregistered service \"%s\"\n", cur->ServiceName);
807 if (cur == ServiceHookTable) {
808 ServiceHookTable = p;
816 void CtdlDestroyServiceHook(void)
818 struct ServiceFunctionHook *cur, *p;
820 cur = ServiceHookTable;
825 CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
827 } else if (cur->tcp_port) {
828 CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
830 CtdlLogPrintf(CTDL_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
836 ServiceHookTable = NULL;
839 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name)
841 struct SearchFunctionHook *newfcn;
843 if (!name || !fcn_ptr) {
847 newfcn = (struct SearchFunctionHook *)
848 malloc(sizeof(struct SearchFunctionHook));
849 newfcn->next = SearchFunctionHookTable;
851 newfcn->fcn_ptr = fcn_ptr;
852 SearchFunctionHookTable = newfcn;
854 CtdlLogPrintf(CTDL_INFO, "Registered a new search function (%s)\n", name);
857 void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name)
859 struct SearchFunctionHook *cur, *p;
861 for (cur = SearchFunctionHookTable; cur != NULL; cur = cur->next) {
862 while (fcn_ptr && (cur->fcn_ptr == fcn_ptr) && name && !strcmp(name, cur->name)) {
863 CtdlLogPrintf(CTDL_INFO, "Unregistered search function(%s)\n", name);
865 if (cur == SearchFunctionHookTable) {
866 SearchFunctionHookTable = p;
874 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name)
876 struct SearchFunctionHook *fcn = NULL;
878 for (fcn = SearchFunctionHookTable; fcn != NULL; fcn = fcn->next) {
879 if (!func_name || !strcmp(func_name, fcn->name)) {
880 (*fcn->fcn_ptr) (num_msgs, search_msgs, search_string);
888 void PerformSessionHooks(int EventType)
890 struct SessionFunctionHook *fcn = NULL;
892 for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
893 if (fcn->eventtype == EventType) {
894 if (EventType == EVT_TIMER) {
895 citthread_setspecific(MyConKey, NULL); /* for every hook */
897 (*fcn->h_function_pointer) ();
902 void PerformUserHooks(struct ctdluser *usbuf, int EventType)
904 struct UserFunctionHook *fcn = NULL;
906 for (fcn = UserHookTable; fcn != NULL; fcn = fcn->next) {
907 if (fcn->eventtype == EventType) {
908 (*fcn->h_function_pointer) (usbuf);
913 int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
915 struct MessageFunctionHook *fcn = NULL;
916 int total_retval = 0;
918 /* Other code may elect to protect this message from server-side
919 * handlers; if this is the case, don't do anything.
920 CtdlLogPrintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
921 EventType, msg->cm_flags);
923 if (msg->cm_flags & CM_SKIP_HOOKS) {
924 CtdlLogPrintf(CTDL_DEBUG, "Skipping hooks\n");
928 /* Otherwise, run all the hooks appropriate to this event type.
930 for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
931 if (fcn->eventtype == EventType) {
932 total_retval = total_retval +
933 (*fcn->h_function_pointer) (msg);
937 /* Return the sum of the return codes from the hook functions. If
938 * this is an EVT_BEFORESAVE event, a nonzero return code will cause
939 * the save operation to abort.
945 int PerformRoomHooks(struct ctdlroom *target_room)
947 struct RoomFunctionHook *fcn;
948 int total_retval = 0;
950 CtdlLogPrintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
952 for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
953 total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
956 /* Return the sum of the return codes from the hook functions.
962 int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
964 struct NetprocFunctionHook *fcn;
965 int total_retval = 0;
967 for (fcn = NetprocHookTable; fcn != NULL; fcn = fcn->next) {
968 total_retval = total_retval +
969 (*fcn->h_function_pointer) (msg, target_room);
972 /* Return the sum of the return codes from the hook functions.
973 * A nonzero return code will cause the message to *not* be imported.
979 void PerformDeleteHooks(char *room, long msgnum)
981 struct DeleteFunctionHook *fcn;
983 for (fcn = DeleteHookTable; fcn != NULL; fcn = fcn->next) {
984 (*fcn->h_function_pointer) (room, msgnum);
992 int PerformXmsgHooks(char *sender, char *sender_email, char *recp, char *msg)
994 struct XmsgFunctionHook *fcn;
998 for (p=0; p<MAX_XMSG_PRI; ++p) {
999 for (fcn = XmsgHookTable; fcn != NULL; fcn = fcn->next) {
1000 if (fcn->order == p) {
1002 (*fcn->h_function_pointer)
1003 (sender, sender_email, recp, msg);
1006 /* Break out of the loop if a higher-priority function
1007 * successfully delivered the message. This prevents duplicate
1008 * deliveries to local users simultaneously signed onto
1011 if (total_sent) break;
1018 * Dirty hack until we impliment a hook mechanism for this
1020 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response)
1023 CtdlStartTLS (ok_response, nosup_response, error_response);