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"
44 #include "citadel_dirs.h"
46 * define macros for module init stuff
49 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
51 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
53 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
55 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
59 * Prototype for making log entries in Citadel.
62 void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
64 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
67 * Hook functions available to modules.
70 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
71 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
73 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
74 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
76 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
77 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
79 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
81 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
84 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
85 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
87 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
88 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
90 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
91 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
93 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
94 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
96 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
98 void CtdlRegisterServiceHook(int tcp_port,
100 void (*h_greeting_function) (void),
101 void (*h_command_function) (void),
102 void (*h_async_function) (void),
103 const char *ServiceName
105 void CtdlUnregisterServiceHook(int tcp_port,
107 void (*h_greeting_function) (void),
108 void (*h_command_function) (void),
109 void (*h_async_function) (void)
112 void CtdlRegisterFixedOutputHook(char *content_type,
113 void (*output_function) (char *supplied_data, int len)
115 void CtdlUnRegisterFixedOutputHook(char *content_type);
117 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
119 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
123 * Directory services hooks for LDAP etc
126 #define DIRECTORY_USER_DEL 1 // Delete a user entry
127 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
128 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
129 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
130 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
131 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
133 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
134 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
136 /* TODODRW: This needs to be changed into a hook type interface
137 * for now we have this horrible hack
139 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
143 * Citadel Threads API
145 struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
146 struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
147 void CtdlThreadSleep(int secs);
148 void CtdlThreadStop(struct CtdlThreadNode *thread);
149 int CtdlThreadCheckStop(void);
150 /* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */
151 const char *CtdlThreadName(const char *name);
152 struct CtdlThreadNode *CtdlThreadSelf(void);
153 int CtdlThreadGetCount(void);
154 int CtdlThreadGetWorkers(void);
155 double CtdlThreadGetWorkerAvg(void);
156 double CtdlThreadGetLoadAvg(void);
157 void CtdlThreadGC(void);
158 void CtdlThreadStopAll(void);
159 int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
160 void CtdlThreadAllocTSD(void);
162 #define CTDLTHREAD_BIGSTACK 0x0001
163 #define CTDLTHREAD_WORKER 0x0002
165 /* Macros to speed up getting outr thread */
167 #define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
168 #define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
169 #define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
171 /** return the current context list as an array and do it in a safe manner
172 * The returned data is a copy so only reading is useful
173 * The number of contexts is returned in count.
174 * Beware, this does not copy any of the data pointed to by the context.
175 * This means that you can not rely on things like the redirect buffer being valid.
176 * You must free the returned pointer when done.
178 struct CitContext *CtdlGetContextArray (int *count);
179 void CtdlFillSystemContext(struct CitContext *context, char *name);
181 int CtdlTrySingleUser(void);
182 void CtdlEndSingleUser(void);
183 int CtdlWantSingleUser(void);
184 int CtdlIsSingleUser(void);
188 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
189 * This provides a quick way to initialise a variable that might be used to indicate
190 * messages that should not be processed. EG. a new Sieve script will use this
191 * to record determine that messages older than this should not be processed.
192 * This function is defined in control.c
194 long CtdlGetCurrentMessageNumber(void);
199 * Expose various room operation functions from room_ops.c to the modules API
202 unsigned CtdlCreateRoom(char *new_room_name,
209 int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
210 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
211 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
212 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
213 int *result, int *view);
214 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
215 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
217 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
218 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
219 void CtdlUserGoto (char *where, int display_result, int transiently,
220 int *msgs, int *new);
221 struct floor *CtdlGetCachedFloor(int floor_num);
222 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
223 void CtdlGetFloor (struct floor *flbuf, int floor_num);
224 void CtdlPutFloor (struct floor *flbuf, int floor_num);
225 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
226 void CtdlPutRoom(struct ctdlroom *);
229 * Possible return values for CtdlRenameRoom()
232 crr_ok, /* success */
233 crr_room_not_found, /* room not found */
234 crr_already_exists, /* new name already exists */
235 crr_noneditable, /* cannot edit this room */
236 crr_invalid_floor, /* target floor does not exist */
237 crr_access_denied /* not allowed to edit this room */
243 * API declarations from citserver.h
245 int CtdlAccessCheck(int);
246 /* 'required access level' values which may be passed to CtdlAccessCheck()
259 * API declarations from serv_extensions.h
261 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, char *search_string, char *func_name);
263 * Global system configuration. Don't change anything here. It's all in dtds/config-defs.h now.
266 #include "datadefinitions.h"
267 #include "dtds/config-defs.h"
268 #include "undef_data.h"
271 extern struct config config;
276 * Expose API calls from user_ops.c
278 int CtdlGetUser(struct ctdluser *usbuf, char name[]);
279 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
280 void CtdlPutUser(struct ctdluser *usbuf);
281 void CtdlPutUserLock(struct ctdluser *usbuf);
282 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
285 #endif /* CTDL_MODULE_H */