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"
26 #include "modules/crypto/serv_crypto.h" /* Needed until a universal crypto startup hook is implimented for CtdlStartTLS */
33 struct CleanupFunctionHook *CleanupHookTable = NULL;
34 struct SessionFunctionHook *SessionHookTable = NULL;
35 struct UserFunctionHook *UserHookTable = NULL;
36 struct XmsgFunctionHook *XmsgHookTable = NULL;
37 struct MessageFunctionHook *MessageHookTable = NULL;
38 struct NetprocFunctionHook *NetprocHookTable = NULL;
39 struct DeleteFunctionHook *DeleteHookTable = NULL;
40 struct ServiceFunctionHook *ServiceHookTable = NULL;
41 struct FixedOutputHook *FixedOutputTable = NULL;
42 struct RoomFunctionHook *RoomHookTable = NULL;
43 struct MaintenanceThreadHook *MaintenanceThreadHookTable = NULL;
44 struct SearchFunctionHook *SearchFunctionHookTable = NULL;
46 struct ProtoFunctionHook {
47 void (*handler) (char *cmdbuf);
50 struct ProtoFunctionHook *next;
51 } *ProtoHookList = NULL;
54 #define ERR_PORT (1 << 1)
57 static char *portlist = NULL;
58 static size_t nSizPort = 0;
60 static char *errormessages = NULL;
61 size_t nSizErrmsg = 0;
64 long DetailErrorFlags;
66 char *ErrSubject = "Startup Problems";
67 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"
68 "If you don't want citadel to provide these services, turn them off in WebCit via %s%s\n\n%s\n\n"
69 "To make both ways actualy take place restart the citserver with \"sendcommand down\"\n\n"
70 "The errors returned by the system were:\n%s\n"
71 "You can recheck the above if you follow this faq item:\n"
72 "http://www.citadel.org/doku.php/faq:mastering_your_os:net#netstat";
75 char *ErrPortShort = "We couldn't bind all ports you configured to be provided by citadel server.";
76 char *ErrPortWhere = "Admin->System Preferences->Network.\n\nThe failed ports and sockets are: ";
77 char *ErrPortHint = "If you want citadel to provide you with that functionality, "
78 "check the output of \"netstat -lnp\" on linux Servers or \"netstat -na\" on *BSD"
79 " and stop the programm, that binds these ports. You should eventually remove "
80 " their initscripts in /etc/init.d so that you won't get this trouble once more.\n";
83 void LogPrintMessages(long err)
85 char *List, *DetailList, *Short, *Where, *Hint, *Message;
86 int n = nSizPort + nSizErrmsg + 5;
88 Message = (char*) malloc(n * SIZ);
97 DetailList = errormessages;
108 snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
111 lprintf(0,ErrSubject);
112 quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
113 if (errormessages!=NULL) free (errormessages);
114 errormessages = NULL;
115 if (portlist!=NULL) free (portlist);
122 void AppendString(char **target, char *append, size_t *len, size_t rate)
128 AddLen = strlen(append);
134 *target = (char*)malloc (*len * SIZ);
138 oLen = strlen(*target);
139 RelPtr = strlen(*target);
140 if (oLen + AddLen + 2 > *len * SIZ)
142 char *Buff = *target;
143 size_t NewSiz = *len + 10;
144 *target = malloc (NewSiz * SIZ);
145 memcpy (*target, Buff, NewSiz * SIZ);
149 memcpy (*target + oLen, append, AddLen);
150 (*target)[oLen + AddLen + 1] = '\n';
151 (*target)[oLen + AddLen + 2] = '\0';
154 void AddPortError(char *Port, char *ErrorMessage)
159 DetailErrorFlags |= ERR_PORT;
161 AppendString(&errormessages, ErrorMessage, &nSizErrmsg, 10);
162 AppendString(&portlist, Port, &nSizPort, 2);
164 pos = strchr (portlist, ':');
165 if (pos != NULL) *pos = ';';
167 len = strlen (errormessages);
168 if (nSizErrmsg * SIZ > len + 3)
170 errormessages[len] = ';';
171 errormessages[len+1] = ' ';
172 errormessages[len+2] = '\0';
177 void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
179 struct ProtoFunctionHook *p;
181 p = (struct ProtoFunctionHook *)
182 malloc(sizeof(struct ProtoFunctionHook));
185 fprintf(stderr, "can't malloc new ProtoFunctionHook\n");
188 p->handler = handler;
191 p->next = ProtoHookList;
193 lprintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
197 void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd)
199 struct ProtoFunctionHook *cur = NULL;
200 struct ProtoFunctionHook *p = NULL;
201 struct ProtoFunctionHook *lastcur = NULL;
203 for (cur = ProtoHookList;
205 cur = (cur != NULL)? cur->next: NULL) {
206 /* This will also remove duplicates if any */
207 while (cur != NULL &&
208 handler == cur->handler &&
209 !strcmp(cmd, cur->cmd)) {
210 lprintf(CTDL_INFO, "Unregistered server command %s (%s)\n",
213 if (cur == ProtoHookList) {
216 else if (lastcur != NULL)
227 void CtdlDestroyProtoHooks(void)
229 struct ProtoFunctionHook *cur, *p;
234 lprintf(CTDL_INFO, "Destroyed server command %s (%s)\n",
235 cur->cmd, cur->desc);
240 ProtoHookList = NULL;
244 int DLoader_Exec_Cmd(char *cmdbuf)
246 struct ProtoFunctionHook *p;
248 for (p = ProtoHookList; p; p = p->next) {
249 if (!strncasecmp(cmdbuf, p->cmd, 4)) {
250 p->handler(&cmdbuf[5]);
258 void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
261 struct CleanupFunctionHook *newfcn;
263 newfcn = (struct CleanupFunctionHook *)
264 malloc(sizeof(struct CleanupFunctionHook));
265 newfcn->next = CleanupHookTable;
266 newfcn->h_function_pointer = fcn_ptr;
267 CleanupHookTable = newfcn;
269 lprintf(CTDL_INFO, "Registered a new cleanup function\n");
273 void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
275 struct CleanupFunctionHook *cur, *p;
277 for (cur = CleanupHookTable; cur != NULL; cur = cur->next) {
278 /* This will also remove duplicates if any */
279 while (cur != NULL &&
280 fcn_ptr == cur->h_function_pointer) {
281 lprintf(CTDL_INFO, "Unregistered cleanup function\n");
283 if (cur == CleanupHookTable) {
284 CleanupHookTable = p;
292 void CtdlDestroyCleanupHooks(void)
294 struct CleanupFunctionHook *cur, *p;
296 cur = CleanupHookTable;
299 lprintf(CTDL_INFO, "Destroyed cleanup function\n");
304 CleanupHookTable = NULL;
308 void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
311 struct SessionFunctionHook *newfcn;
313 newfcn = (struct SessionFunctionHook *)
314 malloc(sizeof(struct SessionFunctionHook));
315 newfcn->next = SessionHookTable;
316 newfcn->h_function_pointer = fcn_ptr;
317 newfcn->eventtype = EventType;
318 SessionHookTable = newfcn;
320 lprintf(CTDL_INFO, "Registered a new session function (type %d)\n",
325 void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
327 struct SessionFunctionHook *cur, *p;
329 for (cur = SessionHookTable; cur != NULL; cur = cur->next) {
330 /* This will also remove duplicates if any */
331 while (cur != NULL &&
332 fcn_ptr == cur->h_function_pointer &&
333 EventType == cur->eventtype) {
334 lprintf(CTDL_INFO, "Unregistered session function (type %d)\n",
337 if (cur == SessionHookTable) {
338 SessionHookTable = p;
346 void CtdlDestroySessionHooks(void)
348 struct SessionFunctionHook *cur, *p;
350 cur = SessionHookTable;
353 lprintf(CTDL_INFO, "Destroyed session function\n");
358 SessionHookTable = NULL;
362 void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
365 struct UserFunctionHook *newfcn;
367 newfcn = (struct UserFunctionHook *)
368 malloc(sizeof(struct UserFunctionHook));
369 newfcn->next = UserHookTable;
370 newfcn->h_function_pointer = fcn_ptr;
371 newfcn->eventtype = EventType;
372 UserHookTable = newfcn;
374 lprintf(CTDL_INFO, "Registered a new user function (type %d)\n",
379 void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
381 struct UserFunctionHook *cur, *p;
383 for (cur = UserHookTable; cur != NULL; cur = cur->next) {
384 /* This will also remove duplicates if any */
385 while (cur != NULL &&
386 fcn_ptr == cur->h_function_pointer &&
387 EventType == cur->eventtype) {
388 lprintf(CTDL_INFO, "Unregistered user function (type %d)\n",
391 if (cur == UserHookTable) {
400 void CtdlDestroyUserHooks(void)
402 struct UserFunctionHook *cur, *p;
407 lprintf(CTDL_INFO, "Destroyed user function \n");
412 UserHookTable = NULL;
416 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
420 struct MessageFunctionHook *newfcn;
422 newfcn = (struct MessageFunctionHook *)
423 malloc(sizeof(struct MessageFunctionHook));
424 newfcn->next = MessageHookTable;
425 newfcn->h_function_pointer = handler;
426 newfcn->eventtype = EventType;
427 MessageHookTable = newfcn;
429 lprintf(CTDL_INFO, "Registered a new message function (type %d)\n",
434 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
437 struct MessageFunctionHook *cur, *p;
439 for (cur = MessageHookTable; cur != NULL; cur = cur->next) {
440 /* This will also remove duplicates if any */
441 while (cur != NULL &&
442 handler == cur->h_function_pointer &&
443 EventType == cur->eventtype) {
444 lprintf(CTDL_INFO, "Unregistered message function (type %d)\n",
447 if (cur == MessageHookTable) {
448 MessageHookTable = p;
456 void CtdlDestroyMessageHook(void)
458 struct MessageFunctionHook *cur, *p;
460 cur = MessageHookTable;
463 lprintf(CTDL_INFO, "Destroyed message function \n");
468 MessageHookTable = NULL;
472 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
474 struct RoomFunctionHook *newfcn;
476 newfcn = (struct RoomFunctionHook *)
477 malloc(sizeof(struct RoomFunctionHook));
478 newfcn->next = RoomHookTable;
479 newfcn->fcn_ptr = fcn_ptr;
480 RoomHookTable = newfcn;
482 lprintf(CTDL_INFO, "Registered a new room function\n");
486 void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
488 struct RoomFunctionHook *cur, *p;
490 for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
491 while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
492 lprintf(CTDL_INFO, "Unregistered room function\n");
494 if (cur == RoomHookTable) {
504 void CtdlDestroyRoomHooks(void)
506 struct RoomFunctionHook *cur, *p;
511 lprintf(CTDL_INFO, "Unregistered room function\n");
516 RoomHookTable = NULL;
519 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
521 struct NetprocFunctionHook *newfcn;
523 newfcn = (struct NetprocFunctionHook *)
524 malloc(sizeof(struct NetprocFunctionHook));
525 newfcn->next = NetprocHookTable;
526 newfcn->h_function_pointer = handler;
527 NetprocHookTable = newfcn;
529 lprintf(CTDL_INFO, "Registered a new netproc function\n");
533 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
535 struct NetprocFunctionHook *cur, *p;
537 for (cur = NetprocHookTable; cur != NULL; cur = cur->next) {
538 /* This will also remove duplicates if any */
539 while (cur != NULL &&
540 handler == cur->h_function_pointer ) {
541 lprintf(CTDL_INFO, "Unregistered netproc function\n");
543 if (cur == NetprocHookTable) {
544 NetprocHookTable = p;
552 void CtdlDestroyNetprocHooks(void)
554 struct NetprocFunctionHook *cur, *p;
556 cur = NetprocHookTable;
559 lprintf(CTDL_INFO, "Unregistered netproc function\n");
564 NetprocHookTable = NULL;
568 void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
570 struct DeleteFunctionHook *newfcn;
572 newfcn = (struct DeleteFunctionHook *)
573 malloc(sizeof(struct DeleteFunctionHook));
574 newfcn->next = DeleteHookTable;
575 newfcn->h_function_pointer = handler;
576 DeleteHookTable = newfcn;
578 lprintf(CTDL_INFO, "Registered a new netproc function\n");
582 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
584 struct DeleteFunctionHook *cur, *p;
586 for (cur = DeleteHookTable; cur != NULL; cur = cur->next) {
587 /* This will also remove duplicates if any */
588 while (cur != NULL &&
589 handler == cur->h_function_pointer ) {
590 lprintf(CTDL_INFO, "Unregistered netproc function\n");
592 if (cur == DeleteHookTable) {
600 void CtdlDestroyDeleteHooks(void)
602 struct DeleteFunctionHook *cur, *p;
604 cur = DeleteHookTable;
607 lprintf(CTDL_INFO, "Destroyed netproc function\n");
612 DeleteHookTable = NULL;
618 void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int) )
620 struct FixedOutputHook *newfcn;
622 newfcn = (struct FixedOutputHook *)
623 malloc(sizeof(struct FixedOutputHook));
624 newfcn->next = FixedOutputTable;
625 newfcn->h_function_pointer = handler;
626 safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
627 FixedOutputTable = newfcn;
629 lprintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
633 void CtdlUnregisterFixedOutputHook(char *content_type)
635 struct FixedOutputHook *cur, *p;
637 for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
638 /* This will also remove duplicates if any */
639 while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
640 lprintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
642 if (cur == FixedOutputTable) {
643 FixedOutputTable = p;
651 void CtdlDestroyFixedOutputHooks(void)
653 struct FixedOutputHook *cur, *p;
655 cur = FixedOutputTable;
658 lprintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
664 FixedOutputTable = NULL;
667 /* returns nonzero if we found a hook and used it */
668 int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
670 struct FixedOutputHook *fcn;
672 for (fcn = FixedOutputTable; fcn != NULL; fcn = fcn->next) {
673 if (!strcasecmp(content_type, fcn->content_type)) {
674 (*fcn->h_function_pointer) (content, content_length);
685 void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
688 struct XmsgFunctionHook *newfcn;
690 newfcn = (struct XmsgFunctionHook *)
691 malloc(sizeof(struct XmsgFunctionHook));
692 newfcn->next = XmsgHookTable;
693 newfcn->order = order;
694 newfcn->h_function_pointer = fcn_ptr;
695 XmsgHookTable = newfcn;
696 lprintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
700 void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order)
702 struct XmsgFunctionHook *cur, *p;
704 for (cur = XmsgHookTable; cur != NULL; cur = cur->next) {
705 /* This will also remove duplicates if any */
706 while (cur != NULL &&
707 fcn_ptr == cur->h_function_pointer &&
708 order == cur->order) {
709 lprintf(CTDL_INFO, "Unregistered x-msg function "
710 "(priority %d)\n", order);
712 if (cur == XmsgHookTable) {
721 void CtdlDestroyXmsgHooks(void)
723 struct XmsgFunctionHook *cur, *p;
728 lprintf(CTDL_INFO, "Destroyed x-msg function "
729 "(priority %d)\n", cur->order);
735 XmsgHookTable = NULL;
739 void CtdlRegisterServiceHook(int tcp_port,
741 void (*h_greeting_function) (void),
742 void (*h_command_function) (void),
743 void (*h_async_function) (void),
744 const char *ServiceName)
746 struct ServiceFunctionHook *newfcn;
751 newfcn = (struct ServiceFunctionHook *)
752 malloc(sizeof(struct ServiceFunctionHook));
753 message = (char*) malloc (SIZ);
755 newfcn->next = ServiceHookTable;
756 newfcn->tcp_port = tcp_port;
757 newfcn->sockpath = sockpath;
758 newfcn->h_greeting_function = h_greeting_function;
759 newfcn->h_command_function = h_command_function;
760 newfcn->h_async_function = h_async_function;
761 newfcn->ServiceName = ServiceName;
763 if (sockpath != NULL) {
764 newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions, &error);
765 snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
767 else if (tcp_port <= 0) { /* port -1 to disable */
768 lprintf(CTDL_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
774 newfcn->msock = ig_tcp_server(config.c_ip_addr,
776 config.c_maxsessions,
778 snprintf(message, SIZ, "TCP port %s:%d: (%s) ",
779 config.c_ip_addr, tcp_port, ServiceName);
782 if (newfcn->msock > 0) {
783 ServiceHookTable = newfcn;
784 strcat(message, "registered.");
785 lprintf(CTDL_INFO, "%s\n", message);
788 AddPortError(message, error);
789 strcat(message, "FAILED.");
790 lprintf(CTDL_CRIT, "%s\n", message);
798 void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
799 void (*h_greeting_function) (void),
800 void (*h_command_function) (void),
801 void (*h_async_function) (void)
804 struct ServiceFunctionHook *cur, *p;
806 for (cur = ServiceHookTable; cur != NULL; cur = cur->next) {
807 /* This will also remove duplicates if any */
808 while (cur != NULL &&
809 !(sockpath && cur->sockpath &&
810 strcmp(sockpath, cur->sockpath)) &&
811 h_greeting_function == cur->h_greeting_function &&
812 h_command_function == cur->h_command_function &&
813 h_async_function == cur->h_async_function &&
814 tcp_port == cur->tcp_port) {
817 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
819 } else if (tcp_port) {
820 lprintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
822 lprintf(CTDL_INFO, "Unregistered unknown service\n");
825 if (cur == ServiceHookTable) {
826 ServiceHookTable = p;
834 void CtdlDestroyServiceHook(void)
836 struct ServiceFunctionHook *cur, *p;
838 cur = ServiceHookTable;
843 lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
845 } else if (cur->tcp_port) {
846 lprintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
848 lprintf(CTDL_INFO, "Unregistered unknown service\n");
854 ServiceHookTable = NULL;
857 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name)
859 struct SearchFunctionHook *newfcn;
861 if (!name || !fcn_ptr) {
865 newfcn = (struct SearchFunctionHook *)
866 malloc(sizeof(struct SearchFunctionHook));
867 newfcn->next = SearchFunctionHookTable;
869 newfcn->fcn_ptr = fcn_ptr;
870 SearchFunctionHookTable = newfcn;
872 lprintf(CTDL_INFO, "Registered a new search function (%s)\n", name);
875 void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name)
877 struct SearchFunctionHook *cur, *p;
879 for (cur = SearchFunctionHookTable; cur != NULL; cur = cur->next) {
880 while (fcn_ptr && (cur->fcn_ptr == fcn_ptr) && name && !strcmp(name, cur->name)) {
881 lprintf(CTDL_INFO, "Unregistered search function(%s)\n", name);
883 if (cur == SearchFunctionHookTable) {
884 SearchFunctionHookTable = p;
892 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, char *search_string, char *func_name)
894 struct SearchFunctionHook *fcn = NULL;
896 for (fcn = SearchFunctionHookTable; fcn != NULL; fcn = fcn->next) {
897 if (!func_name || !strcmp(func_name, fcn->name)) {
898 (*fcn->fcn_ptr) (num_msgs, search_msgs, search_string);
906 void PerformSessionHooks(int EventType)
908 struct SessionFunctionHook *fcn = NULL;
910 for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
911 if (fcn->eventtype == EventType) {
912 (*fcn->h_function_pointer) ();
917 void PerformUserHooks(struct ctdluser *usbuf, int EventType)
919 struct UserFunctionHook *fcn = NULL;
921 for (fcn = UserHookTable; fcn != NULL; fcn = fcn->next) {
922 if (fcn->eventtype == EventType) {
923 (*fcn->h_function_pointer) (usbuf);
928 int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
930 struct MessageFunctionHook *fcn = NULL;
931 int total_retval = 0;
933 /* Other code may elect to protect this message from server-side
934 * handlers; if this is the case, don't do anything.
935 lprintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
936 EventType, msg->cm_flags);
938 if (msg->cm_flags & CM_SKIP_HOOKS) {
939 lprintf(CTDL_DEBUG, "Skipping hooks\n");
943 /* Otherwise, run all the hooks appropriate to this event type.
945 for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
946 if (fcn->eventtype == EventType) {
947 total_retval = total_retval +
948 (*fcn->h_function_pointer) (msg);
952 /* Return the sum of the return codes from the hook functions. If
953 * this is an EVT_BEFORESAVE event, a nonzero return code will cause
954 * the save operation to abort.
960 int PerformRoomHooks(struct ctdlroom *target_room)
962 struct RoomFunctionHook *fcn;
963 int total_retval = 0;
965 lprintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
967 for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
968 total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
971 /* Return the sum of the return codes from the hook functions.
977 int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
979 struct NetprocFunctionHook *fcn;
980 int total_retval = 0;
982 for (fcn = NetprocHookTable; fcn != NULL; fcn = fcn->next) {
983 total_retval = total_retval +
984 (*fcn->h_function_pointer) (msg, target_room);
987 /* Return the sum of the return codes from the hook functions.
988 * A nonzero return code will cause the message to *not* be imported.
994 void PerformDeleteHooks(char *room, long msgnum)
996 struct DeleteFunctionHook *fcn;
998 for (fcn = DeleteHookTable; fcn != NULL; fcn = fcn->next) {
999 (*fcn->h_function_pointer) (room, msgnum);
1007 int PerformXmsgHooks(char *sender, char *recp, char *msg)
1009 struct XmsgFunctionHook *fcn;
1013 for (p=0; p<MAX_XMSG_PRI; ++p) {
1014 for (fcn = XmsgHookTable; fcn != NULL; fcn = fcn->next) {
1015 if (fcn->order == p) {
1017 (*fcn->h_function_pointer)
1018 (sender, recp, msg);
1021 /* Break out of the loop if a higher-priority function
1022 * successfully delivered the message. This prevents duplicate
1023 * deliveries to local users simultaneously signed onto
1026 if (total_sent) break;
1031 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc)(void *arg))
1033 struct MaintenanceThreadHook *newfcn;
1035 newfcn = (struct MaintenanceThreadHook *)
1036 malloc(sizeof(struct MaintenanceThreadHook));
1037 newfcn->name = name;
1038 newfcn->next = MaintenanceThreadHookTable;
1039 newfcn->fcn_ptr = thread_proc;
1040 MaintenanceThreadHookTable = newfcn;
1042 lprintf(CTDL_INFO, "Registered a new maintenance thread function\n");
1047 * Dirty hack until we impliment a hook mechanism for this
1049 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response)
1052 CtdlStartTLS (ok_response, nosup_response, error_response);