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>
37 #include <libcitadel.h>
40 #include "sysdep_decls.h"
43 #include "citadel_dirs.h"
47 * define macros for module init stuff
50 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
52 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
54 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
56 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
58 #define CtdlAideMessage(TEXT, SUBJECT) \
69 * Hook functions available to modules.
72 #define PRIO_QUEUE 500
73 #define PRIO_AGGR 1000
74 #define PRIO_SEND 1500
75 #define PRIO_CLEANUP 2000
76 /* Priorities for EVT_HOUSE */
77 #define PRIO_HOUSE 3000
78 /* Priorities for EVT_LOGIN */
79 #define PRIO_CREATE 10000
80 /* Priorities for EVT_LOGOUT */
81 #define PRIO_LOGOUT 15000
82 /* Priorities for EVT_LOGIN */
83 #define PRIO_LOGIN 20000
84 /* Priorities for EVT_START */
85 #define PRIO_START 25000
86 /* Priorities for EVT_STOP */
87 #define PRIO_STOP 30000
88 /* Priorities for EVT_ASYNC */
89 #define PRIO_ASYNC 35000
90 /* Priorities for EVT_SHUTDOWN */
91 #define PRIO_SHUTDOWN 40000
92 /* Priorities for EVT_UNSTEALTH */
93 #define PRIO_UNSTEALTH 45000
94 /* Priorities for EVT_STEALTH */
95 #define PRIO_STEALTH 50000
98 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
99 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
100 void CtdlShutdownServiceHooks(void);
102 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
103 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
105 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
106 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
108 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
109 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
111 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
112 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
114 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
115 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
117 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
118 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
120 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
121 void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void));
123 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
125 void CtdlRegisterServiceHook(int tcp_port,
127 void (*h_greeting_function) (void),
128 void (*h_command_function) (void),
129 void (*h_async_function) (void),
130 const char *ServiceName
132 void CtdlUnregisterServiceHook(int tcp_port,
134 void (*h_greeting_function) (void),
135 void (*h_command_function) (void),
136 void (*h_async_function) (void)
139 void CtdlRegisterFixedOutputHook(char *content_type,
140 void (*output_function) (char *supplied_data, int len)
142 void CtdlUnRegisterFixedOutputHook(char *content_type);
144 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
146 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
149 * if you say a) (which may take a while)
150 * don't forget to say b)
152 void CtdlDisableHouseKeeping(void);
153 void CtdlEnableHouseKeeping(void);
156 * Directory services hooks for LDAP etc
159 #define DIRECTORY_USER_DEL 1 // Delete a user entry
160 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
161 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
162 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
163 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
164 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
166 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
167 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
169 /* TODODRW: This needs to be changed into a hook type interface
170 * for now we have this horrible hack
172 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
174 /* return the current context list as an array and do it in a safe manner
175 * The returned data is a copy so only reading is useful
176 * The number of contexts is returned in count.
177 * Beware, this does not copy any of the data pointed to by the context.
178 * This means that you can not rely on things like the redirect buffer being valid.
179 * You must free the returned pointer when done.
181 struct CitContext *CtdlGetContextArray (int *count);
182 void CtdlFillSystemContext(struct CitContext *context, char *name);
183 int CtdlTrySingleUser(void);
184 void CtdlEndSingleUser(void);
185 int CtdlWantSingleUser(void);
186 int CtdlIsSingleUser(void);
189 int CtdlIsUserLoggedIn (char *user_name);
190 int CtdlIsUserLoggedInByNum (long usernum);
191 void CtdlBumpNewMailCounter(long which_user);
195 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
196 * This provides a quick way to initialise a variable that might be used to indicate
197 * messages that should not be processed. For example, a new inbox script will use this
198 * to record determine that messages older than this should not be processed.
199 * This function is defined in control.c
201 long CtdlGetCurrentMessageNumber(void);
206 * Expose various room operation functions from room_ops.c to the modules API
209 unsigned CtdlCreateRoom(char *new_room_name,
216 int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name);
217 int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name);
218 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
219 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view);
220 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
221 typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data);
222 void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data);
223 typedef void (*ForEachRoomNetCfgCallBack)(struct ctdlroom *EachRoom, void *out_data, char *cfg);
224 char *LoadRoomNetConfigFile(long roomnum);
225 void SaveChangedConfigs(void);
226 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
227 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
228 void CtdlUserGoto (char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest);
229 struct floor *CtdlGetCachedFloor(int floor_num);
230 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
231 void CtdlGetFloor (struct floor *flbuf, int floor_num);
232 void CtdlPutFloor (struct floor *flbuf, int floor_num);
233 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
234 int CtdlGetFloorByName(const char *floor_name);
235 int CtdlGetFloorByNameLock(const char *floor_name);
236 int CtdlGetAvailableFloor(void);
237 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
238 void CtdlPutRoom(struct ctdlroom *);
241 * Possible return values for CtdlRenameRoom()
244 crr_ok, /* success */
245 crr_room_not_found, /* room not found */
246 crr_already_exists, /* new name already exists */
247 crr_noneditable, /* cannot edit this room */
248 crr_invalid_floor, /* target floor does not exist */
249 crr_access_denied /* not allowed to edit this room */
255 * API declarations from citserver.h
257 int CtdlAccessCheck(int);
258 /* 'required access level' values which may be passed to CtdlAccessCheck()
262 ac_logged_in_or_guest,
272 * API declarations from serv_extensions.h
274 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
276 #define NODENAME CtdlGetConfigStr("c_nodename")
277 #define FQDN CtdlGetConfigStr("c_fqdn")
278 #define CTDLUID ctdluid
279 #define CREATAIDE CtdlGetConfigInt("c_creataide")
280 #define REGISCALL CtdlGetConfigInt("c_regiscall")
281 #define TWITDETECT CtdlGetConfigInt("c_twitdetect")
282 #define TWITROOM CtdlGetConfigStr("c_twitroom")
283 #define RESTRICT_INTERNET CtdlGetConfigInt("c_restrict")
285 #define CtdlREGISTERRoomCfgType(a, p, uniq, nSegs, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, nSegs, s, d);
290 * Expose API calls from user_ops.c
292 int CtdlGetUser(struct ctdluser *usbuf, char *name);
293 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
294 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
295 void CtdlPutUser(struct ctdluser *usbuf);
296 void CtdlPutUserLock(struct ctdluser *usbuf);
297 int CtdlLockGetCurrentUser(void);
298 void CtdlPutCurrentUserLock(void);
299 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
300 void CtdlGetRelationship(visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room);
301 void CtdlSetRelationship(visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room);
302 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
303 int CtdlLoginExistingUser(const char *username);
306 * Values which may be returned by CtdlLoginExistingUser()
310 pass_already_logged_in,
316 int CtdlTryPassword(const char *password, long len);
318 * Values which may be returned by CtdlTryPassword()
322 login_already_logged_in,
323 login_too_many_users,
327 void CtdlUserLogout(void);
330 * Expose API calls from msgbase.c
335 * Expose API calls from euidindex.c
337 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
341 * Expose API calls from modules/openid/serv_openid_rp.c in order to turn it into a generic external authentication driver
343 int attach_extauth(struct ctdluser *who, StrBuf *claimed_id);
345 #endif /* CTDL_MODULE_H */