#include "tools.h"
#include "config.h"
+#include "modules/crypto/serv_crypto.h" /* Needed until a universal crypto startup hook is implimented for CtdlStartTLS */
+
#ifndef HAVE_SNPRINTF
#include <stdarg.h>
#include "snprintf.h"
struct DeleteFunctionHook *DeleteHookTable = NULL;
struct ServiceFunctionHook *ServiceHookTable = NULL;
struct FixedOutputHook *FixedOutputTable = NULL;
+struct RoomFunctionHook *RoomHookTable = NULL;
+struct MaintenanceThreadHook *MaintenanceThreadHookTable = NULL;
+struct SearchFunctionHook *SearchFunctionHookTable = NULL;
struct ProtoFunctionHook {
void (*handler) (char *cmdbuf);
snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
+ if (errormessages!=NULL) free (errormessages);
+ errormessages = NULL;
+ if (portlist!=NULL) free (portlist);
+ portlist = NULL;
free(Message);
}
return 0;
}
+#if 0
void initialize_server_extensions(void)
{
long filter;
- lprintf(CTDL_INFO, "%s\n", serv_bio_init());
+ nSizErrmsg = 0;
+
+ /*lprintf(CTDL_INFO, "%s\n", serv_bio_init());
lprintf(CTDL_INFO, "%s\n", serv_calendar_init());
lprintf(CTDL_INFO, "%s\n", serv_notes_init());
lprintf(CTDL_INFO, "%s\n", serv_ldap_init());
lprintf(CTDL_INFO, "%s\n", serv_smtp_init());
lprintf(CTDL_INFO, "%s\n", serv_pop3_init());
lprintf(CTDL_INFO, "%s\n", serv_rwho_init());
- lprintf(CTDL_INFO, "%s\n", serv_spam_init());
+ lprintf(CTDL_INFO, "%s\n", serv_spam_init());*/
/* lprintf(CTDL_INFO, "%s\n", serv_test_init()); */
- lprintf(CTDL_INFO, "%s\n", serv_vandelay_init());
+ /*lprintf(CTDL_INFO, "%s\n", serv_vandelay_init());
lprintf(CTDL_INFO, "%s\n", serv_vcard_init());
lprintf(CTDL_INFO, "%s\n", serv_fulltext_init());
lprintf(CTDL_INFO, "%s\n", serv_autocompletion_init());
lprintf(CTDL_INFO, "%s\n", serv_postfix_tcpdict());
lprintf(CTDL_INFO, "%s\n", serv_sieve_init());
lprintf(CTDL_INFO, "%s\n", serv_managesieve_init());
- lprintf(CTDL_INFO, "%s\n", serv_funambol_init());
+ lprintf(CTDL_INFO, "%s\n", serv_funambol_init());*/
for (filter = 1; filter != 0; filter = filter << 1)
if ((filter & DetailErrorFlags) != 0)
LogPrintMessages(filter);
}
-
+#endif
void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
{
}
+void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
+{
+ struct RoomFunctionHook *newfcn;
+
+ newfcn = (struct RoomFunctionHook *)
+ malloc(sizeof(struct RoomFunctionHook));
+ newfcn->next = RoomHookTable;
+ newfcn->fcn_ptr = fcn_ptr;
+ RoomHookTable = newfcn;
+
+ lprintf(CTDL_INFO, "Registered a new room function\n");
+}
+
+
+void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
+{
+ struct RoomFunctionHook *cur, *p;
+
+ for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
+ while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
+ lprintf(CTDL_INFO, "Unregistered room function\n");
+ p = cur->next;
+ if (cur == RoomHookTable) {
+ RoomHookTable = p;
+ }
+ free(cur);
+ cur = p;
+ }
+ }
+}
+
+
+void CtdlDestroyRoomHooks(void)
+{
+ struct RoomFunctionHook *cur, *p;
+
+ cur = RoomHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Unregistered room function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ RoomHookTable = NULL;
+}
+
void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
{
struct NetprocFunctionHook *newfcn;
ServiceHookTable = NULL;
}
+void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name)
+{
+ struct SearchFunctionHook *newfcn;
+
+ if (!name || !fcn_ptr) {
+ return;
+ }
+
+ newfcn = (struct SearchFunctionHook *)
+ malloc(sizeof(struct SearchFunctionHook));
+ newfcn->next = SearchFunctionHookTable;
+ newfcn->name = name;
+ newfcn->fcn_ptr = fcn_ptr;
+ SearchFunctionHookTable = newfcn;
+
+ lprintf(CTDL_INFO, "Registered a new search function (%s)\n", name);
+}
+
+void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name)
+{
+ struct SearchFunctionHook *cur, *p;
+
+ for (cur = SearchFunctionHookTable; cur != NULL; cur = cur->next) {
+ while (fcn_ptr && (cur->fcn_ptr == fcn_ptr) && name && !strcmp(name, cur->name)) {
+ lprintf(CTDL_INFO, "Unregistered search function(%s)\n", name);
+ p = cur->next;
+ if (cur == SearchFunctionHookTable) {
+ SearchFunctionHookTable = p;
+ }
+ free (cur);
+ cur = p;
+ }
+ }
+}
+
+void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, char *search_string, char *func_name)
+{
+ struct SearchFunctionHook *fcn = NULL;
+
+ for (fcn = SearchFunctionHookTable; fcn != NULL; fcn = fcn->next) {
+ if (!func_name || !strcmp(func_name, fcn->name)) {
+ (*fcn->fcn_ptr) (num_msgs, search_msgs, search_string);
+ return;
+ }
+ }
+ *num_msgs = 0;
+}
+
void PerformSessionHooks(int EventType)
{
}
+int PerformRoomHooks(struct ctdlroom *target_room)
+{
+ struct RoomFunctionHook *fcn;
+ int total_retval = 0;
+
+ lprintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
+
+ for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
+ total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
+ }
+
+ /* Return the sum of the return codes from the hook functions.
+ */
+ return total_retval;
+}
+
int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
{
}
return total_sent;
}
+
+void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc)(void *arg))
+{
+ struct MaintenanceThreadHook *newfcn;
+
+ newfcn = (struct MaintenanceThreadHook *)
+ malloc(sizeof(struct MaintenanceThreadHook));
+ newfcn->name = name;
+ newfcn->next = MaintenanceThreadHookTable;
+ newfcn->fcn_ptr = thread_proc;
+ MaintenanceThreadHookTable = newfcn;
+
+ lprintf(CTDL_INFO, "Registered a new maintenance thread function\n");
+}
+
+
+/*
+ * Dirty hack until we impliment a hook mechanism for this
+ */
+void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response)
+{
+#ifdef HAVE_OPENSSL
+ CtdlStartTLS (ok_response, nosup_response, error_response);
+#endif
+}