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"
50 * define macros for module init stuff
53 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
55 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
57 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
59 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
61 #define CtdlAideMessage(TEXT, SUBJECT) \
72 * Hook functions available to modules.
75 #define PRIO_QUEUE 500
76 #define PRIO_AGGR 1000
77 #define PRIO_SEND 1500
78 #define PRIO_CLEANUP 2000
79 /* Priorities for EVT_HOUSE */
80 #define PRIO_HOUSE 3000
81 /* Priorities for EVT_LOGIN */
82 #define PRIO_CREATE 10000
83 /* Priorities for EVT_LOGOUT */
84 #define PRIO_LOGOUT 15000
85 /* Priorities for EVT_LOGIN */
86 #define PRIO_LOGIN 20000
87 /* Priorities for EVT_START */
88 #define PRIO_START 25000
89 /* Priorities for EVT_STOP */
90 #define PRIO_STOP 30000
91 /* Priorities for EVT_ASYNC */
92 #define PRIO_ASYNC 35000
93 /* Priorities for EVT_SHUTDOWN */
94 #define PRIO_SHUTDOWN 40000
95 /* Priorities for EVT_UNSTEALTH */
96 #define PRIO_UNSTEALTH 45000
97 /* Priorities for EVT_STEALTH */
98 #define PRIO_STEALTH 50000
101 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
102 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
103 void CtdlShutdownServiceHooks(void);
105 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
106 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
108 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
109 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
111 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
112 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
114 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
115 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
117 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
118 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
120 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
121 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
123 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
124 void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void));
126 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
128 void CtdlRegisterServiceHook(int tcp_port,
130 void (*h_greeting_function) (void),
131 void (*h_command_function) (void),
132 void (*h_async_function) (void),
133 const char *ServiceName
135 void CtdlUnregisterServiceHook(int tcp_port,
137 void (*h_greeting_function) (void),
138 void (*h_command_function) (void),
139 void (*h_async_function) (void)
142 void CtdlRegisterFixedOutputHook(char *content_type, void (*output_function) (char *supplied_data, int len));
143 void CtdlUnRegisterFixedOutputHook(char *content_type);
144 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
145 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
148 * if you say a) (which may take a while)
149 * don't forget to say b)
151 void CtdlDisableHouseKeeping(void);
152 void CtdlEnableHouseKeeping(void);
154 /* TODODRW: This needs to be changed into a hook type interface
155 * for now we have this horrible hack
157 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
159 /* return the current context list as an array and do it in a safe manner
160 * The returned data is a copy so only reading is useful
161 * The number of contexts is returned in count.
162 * Beware, this does not copy any of the data pointed to by the context.
163 * This means that you can not rely on things like the redirect buffer being valid.
164 * You must free the returned pointer when done.
166 struct CitContext *CtdlGetContextArray (int *count);
167 void CtdlFillSystemContext(struct CitContext *context, char *name);
168 int CtdlTrySingleUser(void);
169 void CtdlEndSingleUser(void);
170 int CtdlWantSingleUser(void);
171 int CtdlIsSingleUser(void);
174 int CtdlIsUserLoggedIn (char *user_name);
175 int CtdlIsUserLoggedInByNum (long usernum);
176 void CtdlBumpNewMailCounter(long which_user);
180 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
181 * This provides a quick way to initialize a variable that might be used to indicate
182 * messages that should not be processed. For example, a new inbox script will use this
183 * to record determine that messages older than this should not be processed.
184 * This function is defined in control.c
186 long CtdlGetCurrentMessageNumber(void);
191 * Expose various room operation functions from room_ops.c to the modules API
194 unsigned CtdlCreateRoom(char *new_room_name,
201 int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name);
202 int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name);
203 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
204 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view);
205 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
206 typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data);
207 void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data);
208 char *LoadRoomNetConfigFile(long roomnum);
209 void SaveRoomNetConfigFile(long roomnum, const char *raw_netconfig);
210 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
211 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
212 void CtdlUserGoto (char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest);
213 struct floor *CtdlGetCachedFloor(int floor_num);
214 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
215 void CtdlGetFloor (struct floor *flbuf, int floor_num);
216 void CtdlPutFloor (struct floor *flbuf, int floor_num);
217 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
218 int CtdlGetFloorByName(const char *floor_name);
219 int CtdlGetFloorByNameLock(const char *floor_name);
220 int CtdlGetAvailableFloor(void);
221 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
222 void CtdlPutRoom(struct ctdlroom *);
225 * Possible return values for CtdlRenameRoom()
228 crr_ok, /* success */
229 crr_room_not_found, /* room not found */
230 crr_already_exists, /* new name already exists */
231 crr_noneditable, /* cannot edit this room */
232 crr_invalid_floor, /* target floor does not exist */
233 crr_access_denied /* not allowed to edit this room */
239 * API declarations from citserver.h
241 int CtdlAccessCheck(int);
242 /* 'required access level' values which may be passed to CtdlAccessCheck()
246 ac_logged_in_or_guest,
256 * API declarations from serv_extensions.h
258 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
260 #define NODENAME CtdlGetConfigStr("c_nodename")
261 #define FQDN CtdlGetConfigStr("c_fqdn")
262 #define CTDLUID ctdluid
263 #define CREATAIDE CtdlGetConfigInt("c_creataide")
264 #define REGISCALL CtdlGetConfigInt("c_regiscall")
265 #define TWITDETECT CtdlGetConfigInt("c_twitdetect")
266 #define TWITROOM CtdlGetConfigStr("c_twitroom")
267 #define RESTRICT_INTERNET CtdlGetConfigInt("c_restrict")
269 #define CtdlREGISTERRoomCfgType(a, p, uniq, nSegs, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, nSegs, s, d);
274 * Expose API calls from user_ops.c
276 int CtdlGetUser(struct ctdluser *usbuf, char *name);
277 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
278 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
279 void CtdlPutUser(struct ctdluser *usbuf);
280 void CtdlPutUserLock(struct ctdluser *usbuf);
281 int CtdlLockGetCurrentUser(void);
282 void CtdlPutCurrentUserLock(void);
283 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
284 void CtdlGetRelationship(visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room);
285 void CtdlSetRelationship(visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room);
286 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
287 int CtdlLoginExistingUser(const char *username);
290 * Values which may be returned by CtdlLoginExistingUser()
294 pass_already_logged_in,
300 int CtdlTryPassword(const char *password, long len);
302 * Values which may be returned by CtdlTryPassword()
306 login_already_logged_in,
307 login_too_many_users,
311 void CtdlUserLogout(void);
314 * Expose API calls from msgbase.c
319 * Expose API calls from euidindex.c
321 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
325 * Expose API calls from modules/openid/serv_openid_rp.c in order to turn it into a generic external authentication driver
327 int attach_extauth(struct ctdluser *who, StrBuf *claimed_id);
329 #endif /* CTDL_MODULE_H */