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) \
86 #define CtdlAideFPMessage(TEXT, SUBJECT, N, STR, STRLEN) \
87 flood_protect_quickie_message( \
99 * Hook functions available to modules.
102 #define PRIO_QUEUE 500
103 #define PRIO_AGGR 1000
104 #define PRIO_SEND 1500
105 #define PRIO_CLEANUP 2000
106 /* Priorities for EVT_HOUSE */
107 #define PRIO_HOUSE 3000
108 /* Priorities for EVT_LOGIN */
109 #define PRIO_CREATE 10000
110 /* Priorities for EVT_LOGOUT */
111 #define PRIO_LOGOUT 15000
112 /* Priorities for EVT_LOGIN */
113 #define PRIO_LOGIN 20000
114 /* Priorities for EVT_START */
115 #define PRIO_START 25000
116 /* Priorities for EVT_STOP */
117 #define PRIO_STOP 30000
118 /* Priorities for EVT_ASYNC */
119 #define PRIO_ASYNC 35000
120 /* Priorities for EVT_SHUTDOWN */
121 #define PRIO_SHUTDOWN 40000
122 /* Priorities for EVT_UNSTEALTH */
123 #define PRIO_UNSTEALTH 45000
124 /* Priorities for EVT_STEALTH */
125 #define PRIO_STEALTH 50000
126 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
127 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
128 void CtdlShutdownServiceHooks(void);
130 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
131 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
133 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
134 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
136 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
138 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
141 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
142 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
144 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
145 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
147 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
148 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
150 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
151 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
153 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
154 void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void));
156 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
158 void CtdlRegisterServiceHook(int tcp_port,
160 void (*h_greeting_function) (void),
161 void (*h_command_function) (void),
162 void (*h_async_function) (void),
163 const char *ServiceName
165 void CtdlUnregisterServiceHook(int tcp_port,
167 void (*h_greeting_function) (void),
168 void (*h_command_function) (void),
169 void (*h_async_function) (void)
172 void CtdlRegisterFixedOutputHook(char *content_type,
173 void (*output_function) (char *supplied_data, int len)
175 void CtdlUnRegisterFixedOutputHook(char *content_type);
177 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
179 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
183 * Directory services hooks for LDAP etc
186 #define DIRECTORY_USER_DEL 1 // Delete a user entry
187 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
188 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
189 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
190 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
191 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
193 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
194 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
196 /* TODODRW: This needs to be changed into a hook type interface
197 * for now we have this horrible hack
199 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
201 /* return the current context list as an array and do it in a safe manner
202 * The returned data is a copy so only reading is useful
203 * The number of contexts is returned in count.
204 * Beware, this does not copy any of the data pointed to by the context.
205 * This means that you can not rely on things like the redirect buffer being valid.
206 * You must free the returned pointer when done.
208 struct CitContext *CtdlGetContextArray (int *count);
209 void CtdlFillSystemContext(struct CitContext *context, char *name);
210 int CtdlTrySingleUser(void);
211 void CtdlEndSingleUser(void);
212 int CtdlWantSingleUser(void);
213 int CtdlIsSingleUser(void);
216 int CtdlIsUserLoggedIn (char *user_name);
217 int CtdlIsUserLoggedInByNum (long usernum);
218 void CtdlBumpNewMailCounter(long which_user);
222 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
223 * This provides a quick way to initialise a variable that might be used to indicate
224 * messages that should not be processed. EG. a new Sieve script will use this
225 * to record determine that messages older than this should not be processed.
226 * This function is defined in control.c
228 long CtdlGetCurrentMessageNumber(void);
233 * Expose various room operation functions from room_ops.c to the modules API
236 unsigned CtdlCreateRoom(char *new_room_name,
243 int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
244 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
245 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
246 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
247 int *result, int *view);
248 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
249 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
251 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
252 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
253 void CtdlUserGoto (char *where, int display_result, int transiently,
254 int *msgs, int *new);
255 struct floor *CtdlGetCachedFloor(int floor_num);
256 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
257 void CtdlGetFloor (struct floor *flbuf, int floor_num);
258 void CtdlPutFloor (struct floor *flbuf, int floor_num);
259 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
260 int CtdlGetFloorByName(const char *floor_name);
261 int CtdlGetFloorByNameLock(const char *floor_name);
262 int CtdlGetAvailableFloor(void);
263 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
264 void CtdlPutRoom(struct ctdlroom *);
267 * Possible return values for CtdlRenameRoom()
270 crr_ok, /* success */
271 crr_room_not_found, /* room not found */
272 crr_already_exists, /* new name already exists */
273 crr_noneditable, /* cannot edit this room */
274 crr_invalid_floor, /* target floor does not exist */
275 crr_access_denied /* not allowed to edit this room */
281 * API declarations from citserver.h
283 int CtdlAccessCheck(int);
284 /* 'required access level' values which may be passed to CtdlAccessCheck()
288 ac_logged_in_or_guest,
298 * API declarations from serv_extensions.h
300 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
303 * Global system configuration
306 char c_nodename[16]; /* short name of this node on a Citadel network */
307 char c_fqdn[64]; /* this site's fully qualified domain name */
308 char c_humannode[21]; /* human-readable site name */
309 char c_phonenum[16]; /* telephone number */
310 uid_t c_ctdluid; /* uid of posix account under which Citadel will run */
311 char c_creataide; /* 1 = creating a room auto-grants room aide privileges */
312 int c_sleeping; /* watchdog timer (seconds) */
313 char c_initax; /* initial access level for new users */
314 char c_regiscall; /* after c_regiscall logins user will be asked to register */
315 char c_twitdetect; /* automatically move messages from problem users to trashcan */
316 char c_twitroom[ROOMNAMELEN]; /* name of trashcan */
317 char c_moreprompt[80]; /* paginator prompt */
318 char c_restrict; /* require per-user permission to send Internet mail */
320 char c_site_location[32]; /* geographic location of this Citadel site */
321 char c_sysadm[26]; /* name of system administrator */
324 int c_maxsessions; /* maximum number of concurrent sessions allowed */
325 char c_ip_addr[20]; /* bind address for listening sockets */
326 int c_port_number; /* port number for Citadel protocol (usually 504) */
328 struct ExpirePolicy c_ep; /* default expire policy for the entire site */
329 int c_userpurge; /* user purge time (in days) */
330 int c_roompurge; /* room purge time (in days) */
331 char c_logpages[ROOMNAMELEN];
338 int c_rfc822_strict_from;
343 char c_enable_fulltext;
344 char c_baseroom[ROOMNAMELEN];
345 char c_aideroom[ROOMNAMELEN];
347 struct ExpirePolicy c_mbxep;
348 char c_ldap_host[128];
350 char c_ldap_base_dn[256];
351 char c_ldap_bind_dn[256];
352 char c_ldap_bind_pw[256];
358 char c_instant_expunge;
359 char c_allow_spoofing;
360 char c_journal_email;
361 char c_journal_pubmsgs;
362 char c_journal_dest[128];
363 char c_default_cal_zone[128];
364 int c_pftcpdict_port;
365 int c_managesieve_port;
367 char c_funambol_host[256];
369 char c_funambol_source[256];
370 char c_funambol_auth[256];
371 char c_rbl_at_greeting;
372 char c_master_user[32];
373 char c_master_pass[32];
374 char c_pager_program[256];
375 char c_imap_keep_from;
379 time_t c_pop3_fastest;
380 int c_spam_flag_only;
384 extern struct config config;
389 * Expose API calls from user_ops.c
391 int CtdlGetUser(struct ctdluser *usbuf, char *name);
392 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
393 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
394 void CtdlPutUser(struct ctdluser *usbuf);
395 void CtdlPutUserLock(struct ctdluser *usbuf);
396 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
397 void CtdlGetRelationship(visit *vbuf,
398 struct ctdluser *rel_user,
399 struct ctdlroom *rel_room);
400 void CtdlSetRelationship(visit *newvisit,
401 struct ctdluser *rel_user,
402 struct ctdlroom *rel_room);
403 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
405 int CtdlLoginExistingUser(char *authname, const char *username);
408 * Values which may be returned by CtdlLoginExistingUser()
412 pass_already_logged_in,
418 int CtdlTryPassword(const char *password, long len);
420 * Values which may be returned by CtdlTryPassword()
424 login_already_logged_in,
425 login_too_many_users,
429 void CtdlUserLogout(void);
435 * Expose API calls from msgbase.c
437 char *CtdlGetSysConfig(char *sysconfname);
438 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
444 * Expose API calls from euidindex.c
446 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
449 #endif /* CTDL_MODULE_H */