9 #define GC_REDIRECT_TO_LOCAL
10 #include <gc/gc_local_alloc.h>
12 #define GC_MALLOC malloc
13 #define GC_MALLOC_ATOMIC malloc
15 #define GC_REALLOC realloc
28 #include <sys/types.h>
30 #if TIME_WITH_SYS_TIME
31 # include <sys/time.h>
35 # include <sys/time.h>
54 #include <libcitadel.h>
57 #include "sysdep_decls.h"
60 #include "citadel_dirs.h"
64 * define macros for module init stuff
67 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
69 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
71 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
73 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
75 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
77 * Hook functions available to modules.
80 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
81 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
82 void CtdlShutdownServiceHooks(void);
84 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
85 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
87 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
88 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
90 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
92 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
95 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
96 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
98 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
99 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
101 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
102 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
104 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
105 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
107 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
109 void CtdlRegisterServiceHook(int tcp_port,
111 void (*h_greeting_function) (void),
112 void (*h_command_function) (void),
113 void (*h_async_function) (void),
114 const char *ServiceName
116 void CtdlUnregisterServiceHook(int tcp_port,
118 void (*h_greeting_function) (void),
119 void (*h_command_function) (void),
120 void (*h_async_function) (void)
123 void CtdlRegisterFixedOutputHook(char *content_type,
124 void (*output_function) (char *supplied_data, int len)
126 void CtdlUnRegisterFixedOutputHook(char *content_type);
128 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
130 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
134 * Directory services hooks for LDAP etc
137 #define DIRECTORY_USER_DEL 1 // Delete a user entry
138 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
139 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
140 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
141 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
142 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
144 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
145 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
147 /* TODODRW: This needs to be changed into a hook type interface
148 * for now we have this horrible hack
150 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
152 /* return the current context list as an array and do it in a safe manner
153 * The returned data is a copy so only reading is useful
154 * The number of contexts is returned in count.
155 * Beware, this does not copy any of the data pointed to by the context.
156 * This means that you can not rely on things like the redirect buffer being valid.
157 * You must free the returned pointer when done.
159 struct CitContext *CtdlGetContextArray (int *count);
160 void CtdlFillSystemContext(struct CitContext *context, char *name);
161 void CtdlClearSystemContext(void);
162 int CtdlTrySingleUser(void);
163 void CtdlEndSingleUser(void);
164 int CtdlWantSingleUser(void);
165 int CtdlIsSingleUser(void);
168 int CtdlIsUserLoggedIn (char *user_name);
169 int CtdlIsUserLoggedInByNum (long usernum);
170 void CtdlBumpNewMailCounter(long which_user);
174 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
175 * This provides a quick way to initialise a variable that might be used to indicate
176 * messages that should not be processed. EG. a new Sieve script will use this
177 * to record determine that messages older than this should not be processed.
178 * This function is defined in control.c
180 long CtdlGetCurrentMessageNumber(void);
185 * Expose various room operation functions from room_ops.c to the modules API
188 unsigned CtdlCreateRoom(char *new_room_name,
195 int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
196 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
197 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
198 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
199 int *result, int *view);
200 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
201 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
203 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
204 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
205 void CtdlUserGoto (char *where, int display_result, int transiently,
206 int *msgs, int *new);
207 struct floor *CtdlGetCachedFloor(int floor_num);
208 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
209 void CtdlGetFloor (struct floor *flbuf, int floor_num);
210 void CtdlPutFloor (struct floor *flbuf, int floor_num);
211 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
212 int CtdlGetFloorByName(const char *floor_name);
213 int CtdlGetFloorByNameLock(const char *floor_name);
214 int CtdlGetAvailableFloor(void);
215 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
216 void CtdlPutRoom(struct ctdlroom *);
219 * Possible return values for CtdlRenameRoom()
222 crr_ok, /* success */
223 crr_room_not_found, /* room not found */
224 crr_already_exists, /* new name already exists */
225 crr_noneditable, /* cannot edit this room */
226 crr_invalid_floor, /* target floor does not exist */
227 crr_access_denied /* not allowed to edit this room */
233 * API declarations from citserver.h
235 int CtdlAccessCheck(int);
236 /* 'required access level' values which may be passed to CtdlAccessCheck()
240 ac_logged_in_or_guest,
250 * API declarations from serv_extensions.h
252 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
254 * Global system configuration. Don't change anything here. It's all in dtds/config-defs.h now.
257 #include "datadefinitions.h"
258 #include "dtds/config-defs.h"
259 #include "undef_data.h"
262 extern struct config config;
267 * Expose API calls from user_ops.c
269 int CtdlGetUser(struct ctdluser *usbuf, char *name);
270 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
271 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
272 void CtdlPutUser(struct ctdluser *usbuf);
273 void CtdlPutUserLock(struct ctdluser *usbuf);
274 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
275 void CtdlGetRelationship(visit *vbuf,
276 struct ctdluser *rel_user,
277 struct ctdlroom *rel_room);
278 void CtdlSetRelationship(visit *newvisit,
279 struct ctdluser *rel_user,
280 struct ctdlroom *rel_room);
281 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
283 int CtdlLoginExistingUser(char *authname, const char *username);
286 * Values which may be returned by CtdlLoginExistingUser()
290 pass_already_logged_in,
296 int CtdlTryPassword(const char *password, long len);
298 * Values which may be returned by CtdlTryPassword()
302 login_already_logged_in,
303 login_too_many_users,
307 void CtdlUserLogout(void);
313 * Expose API calls from msgbase.c
315 char *CtdlGetSysConfig(char *sysconfname);
316 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
322 * Expose API calls from euidindex.c
324 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
327 #endif /* CTDL_MODULE_H */