]> code.citadel.org Git - citadel.git/blobdiff - citadel/include/ctdl_module.h
Added the functions to allow scheduling of a thread to start at some
[citadel.git] / citadel / include / ctdl_module.h
index a839ffbabc7cdeafdab05a6db17f64f9e8f4c5ae..932e0fe387428c71341190cc6745174ca928014c 100644 (file)
@@ -1,19 +1,40 @@
-/* $Id:$ */
+/* $Id$ */
 
 #ifndef CTDL_MODULE_H
 #define CTDL_MODULE_H
 
-
 #include "server.h"
 #include "sysdep_decls.h"
+#include "msgbase.h"
+
 /*
  * define macros for module init stuff
  */
  
+#define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
+
+#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
+
+#define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
+
+#define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
+
+
+/*
+ * Prototype for making log entries in Citadel.
+ */
+
+void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
+
+/*
+ * Fix the interface to aide_message so that it complies with the Coding style
+ */
  
-#define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (void)
+#define CtdlAideMessage(TEXT, SUBJECT) aide_message(TEXT, SUBJECT)
 
-#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init ()
+/*
+ * Hook functions available to modules.
+ */
 
 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
@@ -21,8 +42,8 @@ void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
 
-void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
-void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
+void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
+void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
 
 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
                                                        int EventType);
@@ -45,10 +66,11 @@ void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
 void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd);
 
 void CtdlRegisterServiceHook(int tcp_port,
-                       char *sockpath,
-                        void (*h_greeting_function) (void),
-                        void (*h_command_function) (void),
-                        void (*h_async_function) (void)
+                            char *sockpath,
+                            void (*h_greeting_function) (void),
+                            void (*h_command_function) (void),
+                            void (*h_async_function) (void),
+                            const char *ServiceName
 );
 void CtdlUnregisterServiceHook(int tcp_port,
                        char *sockpath,
@@ -64,9 +86,54 @@ void CtdlUnRegisterFixedOutputHook(char *content_type);
 
 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
 
+void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
+
+
+/*
+ * Directory services hooks for LDAP etc
+ */
+
+#define DIRECTORY_USER_DEL 1   // Delete a user entry
+#define DIRECTORY_CREATE_HOST 2        // Create a host entry if not already there.
+#define DIRECTORY_CREATE_OBJECT 3      // Create a new object for directory entry
+#define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
+#define DIRECTORY_SAVE_OBJECT 5        // Save the object to the directory service
+#define DIRECTORY_FREE_OBJECT 6        // Free the object and its attributes
+
+int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
+int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
+
 /* TODODRW: This needs to be changed into a hook type interface
  * for now we have this horrible hack
  */
 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
 
+
+/*
+ * Citadel Threads API
+ */
+struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
+struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
+void CtdlThreadSleep(int secs);
+void CtdlThreadStop(struct CtdlThreadNode *thread);
+int CtdlThreadCheckStop(void);
+void CtdlThreadCancel(struct CtdlThreadNode *thread);
+const char *CtdlThreadName(const char *name);
+struct CtdlThreadNode *CtdlThreadSelf(void);
+int CtdlThreadGetCount(void);
+int CtdlThreadGetWorkers(void);
+double CtdlThreadGetWorkerAvg(void);
+double CtdlThreadGetLoadAvg(void);
+void CtdlThreadGC(void);
+void CtdlThreadStopAll(void);
+int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout, struct CtdlThreadNode *self);
+void CtdlThreadAllocTSD(void);
+
+/* Macros to speed up getting outr thread */
+
+#define MYCURSORS      (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
+#define MYTID          (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
+#define CT             (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
+
+
 #endif /* CTDL_MODULE_H */