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"
49 // define macros for module init stuff
51 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
53 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
55 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
57 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
59 #define CtdlAideMessage(TEXT, SUBJECT) \
69 // Hook functions available to modules.
71 // Priority levels for event hooks
72 #define PRIO_QUEUE 500
73 #define PRIO_AGGR 1000
74 #define PRIO_SEND 1500
75 #define PRIO_CLEANUP 2000
76 #define PRIO_HOUSE 3000
77 #define PRIO_CREATE 10000
78 #define PRIO_LOGOUT 15000
79 #define PRIO_LOGIN 20000
80 #define PRIO_START 25000
81 #define PRIO_STOP 30000
82 #define PRIO_ASYNC 35000
83 #define PRIO_SHUTDOWN 40000
84 #define PRIO_UNSTEALTH 45000
85 #define PRIO_STEALTH 50000
87 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
88 void CtdlShutdownServiceHooks(void);
89 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
90 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
91 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
92 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
93 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
94 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
95 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
96 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
97 void CtdlRegisterServiceHook(int tcp_port,
99 void (*h_greeting_function) (void),
100 void (*h_command_function) (void),
101 void (*h_async_function) (void),
102 const char *ServiceName
104 void CtdlRegisterFixedOutputHook(char *content_type, void (*output_function) (char *supplied_data, int len));
105 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
107 void CtdlDisableHouseKeeping(void); // If you call this, it may take a while...
108 void CtdlEnableHouseKeeping(void); // ...so don't forget to call this later.
110 // TODODRW: This needs to be changed into a hook type interface
111 // for now we have this horrible hack
112 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
114 // return the current context list as an array and do it in a safe manner
115 // The returned data is a copy so only reading is useful
116 // The number of contexts is returned in count.
117 // Beware, this does not copy any of the data pointed to by the context.
118 // This means that you can not rely on things like the redirect buffer being valid.
119 // You must free the returned pointer when done.
120 struct CitContext *CtdlGetContextArray (int *count);
121 void CtdlFillSystemContext(struct CitContext *context, char *name);
122 int CtdlTrySingleUser(void);
123 void CtdlEndSingleUser(void);
124 int CtdlWantSingleUser(void);
125 int CtdlIsSingleUser(void);
128 int CtdlIsUserLoggedIn (char *user_name);
129 int CtdlIsUserLoggedInByNum (long usernum);
130 void CtdlBumpNewMailCounter(long which_user);
133 // CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
134 // This provides a quick way to initialize a variable that might be used to indicate
135 // messages that should not be processed. For example, a new inbox script will use this
136 // to record determine that messages older than this should not be processed.
137 // This function is defined in control.c
138 long CtdlGetCurrentMessageNumber(void);
142 // Expose various room operation functions from room_ops.c to the modules API
144 unsigned CtdlCreateRoom(char *new_room_name,
151 int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name);
152 int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name);
153 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
154 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view);
155 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
156 typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data);
157 void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data);
158 char *LoadRoomNetConfigFile(long roomnum);
159 void SaveRoomNetConfigFile(long roomnum, const char *raw_netconfig);
160 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
161 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
162 void CtdlUserGoto (char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest);
163 struct floor *CtdlGetCachedFloor(int floor_num);
164 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
165 void CtdlGetFloor (struct floor *flbuf, int floor_num);
166 void CtdlPutFloor (struct floor *flbuf, int floor_num);
167 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
168 int CtdlGetFloorByName(const char *floor_name);
169 int CtdlGetFloorByNameLock(const char *floor_name);
170 int CtdlGetAvailableFloor(void);
171 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
172 void CtdlPutRoom(struct ctdlroom *);
174 // Possible return values for CtdlRenameRoom()
177 crr_room_not_found, // room not found
178 crr_already_exists, // new name already exists
179 crr_noneditable, // cannot edit this room
180 crr_invalid_floor, // target floor does not exist
181 crr_access_denied // not allowed to edit this room
186 // API declarations from citserver.h
187 int CtdlAccessCheck(int);
189 // 'required access level' values which may be passed to CtdlAccessCheck()
192 ac_logged_in_or_guest,
199 #define NODENAME CtdlGetConfigStr("c_nodename")
200 #define FQDN CtdlGetConfigStr("c_fqdn")
201 #define CREATAIDE CtdlGetConfigInt("c_creataide")
202 #define REGISCALL CtdlGetConfigInt("c_regiscall")
203 #define TWITDETECT CtdlGetConfigInt("c_twitdetect")
204 #define TWITROOM CtdlGetConfigStr("c_twitroom")
205 #define RESTRICT_INTERNET CtdlGetConfigInt("c_restrict")
207 #define CtdlREGISTERRoomCfgType(a, p, uniq, nSegs, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, nSegs, s, d);
210 // Expose API calls from user_ops.c
211 int CtdlGetUser(struct ctdluser *usbuf, char *name);
212 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
213 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
214 void CtdlPutUser(struct ctdluser *usbuf);
215 void CtdlPutUserLock(struct ctdluser *usbuf);
216 int CtdlLockGetCurrentUser(void);
217 void CtdlPutCurrentUserLock(void);
218 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
219 void CtdlGetRelationship(struct visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room);
220 void CtdlSetRelationship(struct visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room);
221 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
222 int CtdlLoginExistingUser(const char *username);
224 // Values which may be returned by CtdlLoginExistingUser()
227 pass_already_logged_in,
233 int CtdlTryPassword(const char *password, long len);
235 // Values which may be returned by CtdlTryPassword()
238 login_already_logged_in,
239 login_too_many_users,
243 void CtdlUserLogout(void);
246 // Expose API calls from euidindex.c
247 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
250 // Expose API calls from external authentication driver
251 int attach_extauth(struct ctdluser *who, StrBuf *claimed_id);