* Removed some temporary diagnostics that had been left in serv_sieve.c
[citadel.git] / citadel / include / ctdl_module.h
blob754b2e146eab08670361a379e4a3767b33ac53d3
1 /* $Id$ */
3 #ifndef CTDL_MODULE_H
4 #define CTDL_MODULE_H
6 #include <libcitadel.h>
7 #include "server.h"
8 #include "sysdep_decls.h"
9 #include "msgbase.h"
10 #include "threads.h"
12 * define macros for module init stuff
15 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
17 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
19 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
21 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
25 * Prototype for making log entries in Citadel.
28 void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
31 * Fix the interface to aide_message so that it complies with the Coding style
34 #define CtdlAideMessage(TEXT, SUBJECT) aide_message(TEXT, SUBJECT)
37 * Hook functions available to modules.
40 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
41 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
43 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
44 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
46 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
47 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
49 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
50 int EventType);
51 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
52 int EventType);
54 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
55 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
57 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
58 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
60 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
61 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
63 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
64 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
66 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
67 void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd);
69 void CtdlRegisterServiceHook(int tcp_port,
70 char *sockpath,
71 void (*h_greeting_function) (void),
72 void (*h_command_function) (void),
73 void (*h_async_function) (void),
74 const char *ServiceName
76 void CtdlUnregisterServiceHook(int tcp_port,
77 char *sockpath,
78 void (*h_greeting_function) (void),
79 void (*h_command_function) (void),
80 void (*h_async_function) (void)
83 void CtdlRegisterFixedOutputHook(char *content_type,
84 void (*output_function) (char *supplied_data, int len)
86 void CtdlUnRegisterFixedOutputHook(char *content_type);
88 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
90 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
94 * Directory services hooks for LDAP etc
97 #define DIRECTORY_USER_DEL 1 // Delete a user entry
98 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
99 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
100 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
101 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
102 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
104 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
105 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
107 /* TODODRW: This needs to be changed into a hook type interface
108 * for now we have this horrible hack
110 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
114 * Citadel Threads API
116 struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
117 struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
118 void CtdlThreadSleep(int secs);
119 void CtdlThreadStop(struct CtdlThreadNode *thread);
120 int CtdlThreadCheckStop(void);
121 /* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */
122 const char *CtdlThreadName(const char *name);
123 struct CtdlThreadNode *CtdlThreadSelf(void);
124 int CtdlThreadGetCount(void);
125 int CtdlThreadGetWorkers(void);
126 double CtdlThreadGetWorkerAvg(void);
127 double CtdlThreadGetLoadAvg(void);
128 void CtdlThreadGC(void);
129 void CtdlThreadStopAll(void);
130 int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
131 void CtdlThreadAllocTSD(void);
133 #define CTDLTHREAD_BIGSTACK 0x0001
134 #define CTDLTHREAD_WORKER 0x0002
136 /* Macros to speed up getting outr thread */
138 #define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
139 #define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
140 #define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
142 /** return the current context list as an array and do it in a safe manner
143 * The returned data is a copy so only reading is useful
144 * The number of contexts is returned in count.
145 * Beware, this does not copy any of the data pointed to by the context.
146 * This means that you can not rely on things like the redirect buffer being valid.
147 * You must free the returned pointer when done.
149 struct CitContext *CtdlGetContextArray (int *count);
150 void CtdlFillSystemContext(struct CitContext *context, char *name);
152 int CtdlTrySingleUser(void);
153 void CtdlEndSingleUser(void);
154 int CtdlWantSingleUser(void);
155 int CtdlIsSingleUser(void);
159 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
160 * This provides a quick way to initialise a variable that might be used to indicate
161 * messages that should not be processed. EG. a new Sieve script will use this
162 * to record determine that messages older than this should not be processed.
163 * This function is defined in control.c
165 long CtdlGetCurrentMessageNumber(void);
167 #endif /* CTDL_MODULE_H */