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 CtdlShutdownServiceHooks(void);
103 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
104 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
105 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
106 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
107 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
108 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
109 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
110 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
111 void CtdlRegisterServiceHook(int tcp_port,
113 void (*h_greeting_function) (void),
114 void (*h_command_function) (void),
115 void (*h_async_function) (void),
116 const char *ServiceName
118 void CtdlRegisterFixedOutputHook(char *content_type, void (*output_function) (char *supplied_data, int len));
119 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
122 * if you say a) (which may take a while)
123 * don't forget to say b)
125 void CtdlDisableHouseKeeping(void);
126 void CtdlEnableHouseKeeping(void);
128 /* TODODRW: This needs to be changed into a hook type interface
129 * for now we have this horrible hack
131 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
133 /* return the current context list as an array and do it in a safe manner
134 * The returned data is a copy so only reading is useful
135 * The number of contexts is returned in count.
136 * Beware, this does not copy any of the data pointed to by the context.
137 * This means that you can not rely on things like the redirect buffer being valid.
138 * You must free the returned pointer when done.
140 struct CitContext *CtdlGetContextArray (int *count);
141 void CtdlFillSystemContext(struct CitContext *context, char *name);
142 int CtdlTrySingleUser(void);
143 void CtdlEndSingleUser(void);
144 int CtdlWantSingleUser(void);
145 int CtdlIsSingleUser(void);
148 int CtdlIsUserLoggedIn (char *user_name);
149 int CtdlIsUserLoggedInByNum (long usernum);
150 void CtdlBumpNewMailCounter(long which_user);
154 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
155 * This provides a quick way to initialize a variable that might be used to indicate
156 * messages that should not be processed. For example, a new inbox script will use this
157 * to record determine that messages older than this should not be processed.
158 * This function is defined in control.c
160 long CtdlGetCurrentMessageNumber(void);
165 * Expose various room operation functions from room_ops.c to the modules API
168 unsigned CtdlCreateRoom(char *new_room_name,
175 int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name);
176 int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name);
177 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
178 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view);
179 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
180 typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data);
181 void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data);
182 char *LoadRoomNetConfigFile(long roomnum);
183 void SaveRoomNetConfigFile(long roomnum, const char *raw_netconfig);
184 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
185 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
186 void CtdlUserGoto (char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest);
187 struct floor *CtdlGetCachedFloor(int floor_num);
188 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
189 void CtdlGetFloor (struct floor *flbuf, int floor_num);
190 void CtdlPutFloor (struct floor *flbuf, int floor_num);
191 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
192 int CtdlGetFloorByName(const char *floor_name);
193 int CtdlGetFloorByNameLock(const char *floor_name);
194 int CtdlGetAvailableFloor(void);
195 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
196 void CtdlPutRoom(struct ctdlroom *);
199 * Possible return values for CtdlRenameRoom()
202 crr_ok, /* success */
203 crr_room_not_found, /* room not found */
204 crr_already_exists, /* new name already exists */
205 crr_noneditable, /* cannot edit this room */
206 crr_invalid_floor, /* target floor does not exist */
207 crr_access_denied /* not allowed to edit this room */
213 * API declarations from citserver.h
215 int CtdlAccessCheck(int);
216 /* 'required access level' values which may be passed to CtdlAccessCheck()
220 ac_logged_in_or_guest,
227 #define NODENAME CtdlGetConfigStr("c_nodename")
228 #define FQDN CtdlGetConfigStr("c_fqdn")
229 #define CREATAIDE CtdlGetConfigInt("c_creataide")
230 #define REGISCALL CtdlGetConfigInt("c_regiscall")
231 #define TWITDETECT CtdlGetConfigInt("c_twitdetect")
232 #define TWITROOM CtdlGetConfigStr("c_twitroom")
233 #define RESTRICT_INTERNET CtdlGetConfigInt("c_restrict")
235 #define CtdlREGISTERRoomCfgType(a, p, uniq, nSegs, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, nSegs, s, d);
240 * Expose API calls from user_ops.c
242 int CtdlGetUser(struct ctdluser *usbuf, char *name);
243 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
244 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
245 void CtdlPutUser(struct ctdluser *usbuf);
246 void CtdlPutUserLock(struct ctdluser *usbuf);
247 int CtdlLockGetCurrentUser(void);
248 void CtdlPutCurrentUserLock(void);
249 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
250 void CtdlGetRelationship(struct visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room);
251 void CtdlSetRelationship(struct visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room);
252 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
253 int CtdlLoginExistingUser(const char *username);
256 * Values which may be returned by CtdlLoginExistingUser()
260 pass_already_logged_in,
266 int CtdlTryPassword(const char *password, long len);
268 * Values which may be returned by CtdlTryPassword()
272 login_already_logged_in,
273 login_too_many_users,
277 void CtdlUserLogout(void);
280 * Expose API calls from msgbase.c
285 * Expose API calls from euidindex.c
287 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
291 * Expose API calls from external authentication driver
293 int attach_extauth(struct ctdluser *who, StrBuf *claimed_id);
295 #endif /* CTDL_MODULE_H */