15 #include <sys/types.h>
17 #if TIME_WITH_SYS_TIME
18 # include <sys/time.h>
22 # include <sys/time.h>
38 #include <libcitadel.h>
41 #include "sysdep_decls.h"
45 * define macros for module init stuff
48 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
50 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
52 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
54 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
58 * Prototype for making log entries in Citadel.
61 void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
63 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
66 * Hook functions available to modules.
69 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
70 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
72 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
73 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
75 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
76 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
78 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
80 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
83 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
84 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
86 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
87 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
89 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
90 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
92 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
93 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
95 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
97 void CtdlRegisterServiceHook(int tcp_port,
99 void (*h_greeting_function) (void),
100 void (*h_command_function) (void),
101 void (*h_async_function) (void),
102 const char *ServiceName
104 void CtdlUnregisterServiceHook(int tcp_port,
106 void (*h_greeting_function) (void),
107 void (*h_command_function) (void),
108 void (*h_async_function) (void)
111 void CtdlRegisterFixedOutputHook(char *content_type,
112 void (*output_function) (char *supplied_data, int len)
114 void CtdlUnRegisterFixedOutputHook(char *content_type);
116 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
118 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
122 * Directory services hooks for LDAP etc
125 #define DIRECTORY_USER_DEL 1 // Delete a user entry
126 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
127 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
128 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
129 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
130 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
132 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
133 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
135 /* TODODRW: This needs to be changed into a hook type interface
136 * for now we have this horrible hack
138 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
142 * Citadel Threads API
144 struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
145 struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
146 void CtdlThreadSleep(int secs);
147 void CtdlThreadStop(struct CtdlThreadNode *thread);
148 int CtdlThreadCheckStop(void);
149 /* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */
150 const char *CtdlThreadName(const char *name);
151 struct CtdlThreadNode *CtdlThreadSelf(void);
152 int CtdlThreadGetCount(void);
153 int CtdlThreadGetWorkers(void);
154 double CtdlThreadGetWorkerAvg(void);
155 double CtdlThreadGetLoadAvg(void);
156 void CtdlThreadGC(void);
157 void CtdlThreadStopAll(void);
158 int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
159 void CtdlThreadAllocTSD(void);
161 #define CTDLTHREAD_BIGSTACK 0x0001
162 #define CTDLTHREAD_WORKER 0x0002
164 /* Macros to speed up getting outr thread */
166 #define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
167 #define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
168 #define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
170 /** return the current context list as an array and do it in a safe manner
171 * The returned data is a copy so only reading is useful
172 * The number of contexts is returned in count.
173 * Beware, this does not copy any of the data pointed to by the context.
174 * This means that you can not rely on things like the redirect buffer being valid.
175 * You must free the returned pointer when done.
177 struct CitContext *CtdlGetContextArray (int *count);
178 void CtdlFillSystemContext(struct CitContext *context, char *name);
180 int CtdlTrySingleUser(void);
181 void CtdlEndSingleUser(void);
182 int CtdlWantSingleUser(void);
183 int CtdlIsSingleUser(void);
187 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
188 * This provides a quick way to initialise a variable that might be used to indicate
189 * messages that should not be processed. EG. a new Sieve script will use this
190 * to record determine that messages older than this should not be processed.
191 * This function is defined in control.c
193 long CtdlGetCurrentMessageNumber(void);
198 * Expose various room operation functions from room_ops.c to the modules API
201 unsigned CtdlCreateRoom(char *new_room_name,
208 int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
209 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
210 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
211 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
212 int *result, int *view);
213 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
214 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
216 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
217 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
218 void CtdlUserGoto (char *where, int display_result, int transiently,
219 int *msgs, int *new);
220 struct floor *CtdlGetCachedFloor(int floor_num);
221 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
222 void CtdlGetFloor (struct floor *flbuf, int floor_num);
223 void CtdlPutFloor (struct floor *flbuf, int floor_num);
224 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
225 void CtdlPutRoom(struct ctdlroom *);
228 * Possible return values for CtdlRenameRoom()
231 crr_ok, /* success */
232 crr_room_not_found, /* room not found */
233 crr_already_exists, /* new name already exists */
234 crr_noneditable, /* cannot edit this room */
235 crr_invalid_floor, /* target floor does not exist */
236 crr_access_denied /* not allowed to edit this room */
242 * API declarations from citserver.h
244 int CtdlAccessCheck(int);
245 /* 'required access level' values which may be passed to CtdlAccessCheck()
258 * API declarations from serv_extensions.h
260 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, char *search_string, char *func_name);
262 * Global system configuration. Don't change anything here. It's all in dtds/config-defs.h now.
265 #include "datadefinitions.h"
266 #include "dtds/config-defs.h"
267 #include "undef_data.h"
270 extern struct config config;
272 #endif /* CTDL_MODULE_H */