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) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
77 * Hook functions available to modules.
80 #define PRIO_QUEUE 500
81 #define PRIO_AGGR 1000
82 #define PRIO_SEND 1500
83 #define PRIO_CLEANUP 2000
84 /* Priorities for EVT_HOUSE */
85 #define PRIO_HOUSE 3000
86 /* Priorities for EVT_LOGIN */
87 #define PRIO_CREATE 10000
88 /* Priorities for EVT_LOGOUT */
89 #define PRIO_LOGOUT 15000
90 /* Priorities for EVT_LOGIN */
91 #define PRIO_LOGIN 20000
92 /* Priorities for EVT_START */
93 #define PRIO_START 25000
94 /* Priorities for EVT_STOP */
95 #define PRIO_STOP 30000
96 /* Priorities for EVT_ASYNC */
97 #define PRIO_ASYNC 35000
98 /* Priorities for EVT_SHUTDOWN */
99 #define PRIO_SHUTDOWN 40000
100 /* Priorities for EVT_UNSTEALTH */
101 #define PRIO_UNSTEALTH 45000
102 /* Priorities for EVT_STEALTH */
103 #define PRIO_STEALTH 50000
104 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
105 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
106 void CtdlShutdownServiceHooks(void);
108 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
109 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
111 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
112 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
114 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
116 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
119 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
120 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
122 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
123 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
125 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
126 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
128 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
129 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
131 void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
132 void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void));
134 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
136 void CtdlRegisterServiceHook(int tcp_port,
138 void (*h_greeting_function) (void),
139 void (*h_command_function) (void),
140 void (*h_async_function) (void),
141 const char *ServiceName
143 void CtdlUnregisterServiceHook(int tcp_port,
145 void (*h_greeting_function) (void),
146 void (*h_command_function) (void),
147 void (*h_async_function) (void)
150 void CtdlRegisterFixedOutputHook(char *content_type,
151 void (*output_function) (char *supplied_data, int len)
153 void CtdlUnRegisterFixedOutputHook(char *content_type);
155 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
157 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
161 * Directory services hooks for LDAP etc
164 #define DIRECTORY_USER_DEL 1 // Delete a user entry
165 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
166 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
167 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
168 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
169 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
171 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
172 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
174 /* TODODRW: This needs to be changed into a hook type interface
175 * for now we have this horrible hack
177 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
179 /* return the current context list as an array and do it in a safe manner
180 * The returned data is a copy so only reading is useful
181 * The number of contexts is returned in count.
182 * Beware, this does not copy any of the data pointed to by the context.
183 * This means that you can not rely on things like the redirect buffer being valid.
184 * You must free the returned pointer when done.
186 struct CitContext *CtdlGetContextArray (int *count);
187 void CtdlFillSystemContext(struct CitContext *context, char *name);
188 int CtdlTrySingleUser(void);
189 void CtdlEndSingleUser(void);
190 int CtdlWantSingleUser(void);
191 int CtdlIsSingleUser(void);
194 int CtdlIsUserLoggedIn (char *user_name);
195 int CtdlIsUserLoggedInByNum (long usernum);
196 void CtdlBumpNewMailCounter(long which_user);
200 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
201 * This provides a quick way to initialise a variable that might be used to indicate
202 * messages that should not be processed. EG. a new Sieve script will use this
203 * to record determine that messages older than this should not be processed.
204 * This function is defined in control.c
206 long CtdlGetCurrentMessageNumber(void);
211 * Expose various room operation functions from room_ops.c to the modules API
214 unsigned CtdlCreateRoom(char *new_room_name,
221 int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
222 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
223 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
224 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
225 int *result, int *view);
226 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
227 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
229 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
230 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
231 void CtdlUserGoto (char *where, int display_result, int transiently,
232 int *msgs, int *new);
233 struct floor *CtdlGetCachedFloor(int floor_num);
234 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
235 void CtdlGetFloor (struct floor *flbuf, int floor_num);
236 void CtdlPutFloor (struct floor *flbuf, int floor_num);
237 void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
238 int CtdlGetFloorByName(const char *floor_name);
239 int CtdlGetFloorByNameLock(const char *floor_name);
240 int CtdlGetAvailableFloor(void);
241 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
242 void CtdlPutRoom(struct ctdlroom *);
245 * Possible return values for CtdlRenameRoom()
248 crr_ok, /* success */
249 crr_room_not_found, /* room not found */
250 crr_already_exists, /* new name already exists */
251 crr_noneditable, /* cannot edit this room */
252 crr_invalid_floor, /* target floor does not exist */
253 crr_access_denied /* not allowed to edit this room */
259 * API declarations from citserver.h
261 int CtdlAccessCheck(int);
262 /* 'required access level' values which may be passed to CtdlAccessCheck()
266 ac_logged_in_or_guest,
276 * API declarations from serv_extensions.h
278 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
281 * Global system configuration
284 char c_nodename[16]; /* short name of this node on a Citadel network */
285 char c_fqdn[64]; /* this site's fully qualified domain name */
286 char c_humannode[21]; /* human-readable site name */
287 char c_phonenum[16]; /* telephone number */
288 uid_t c_ctdluid; /* uid of posix account under which Citadel will run */
289 char c_creataide; /* 1 = creating a room auto-grants room aide privileges */
290 int c_sleeping; /* watchdog timer (seconds) */
291 char c_initax; /* initial access level for new users */
292 char c_regiscall; /* after c_regiscall logins user will be asked to register */
293 char c_twitdetect; /* automatically move messages from problem users to trashcan */
294 char c_twitroom[ROOMNAMELEN]; /* name of trashcan */
295 char c_moreprompt[80]; /* paginator prompt */
296 char c_restrict; /* require per-user permission to send Internet mail */
298 char c_site_location[32]; /* geographic location of this Citadel site */
299 char c_sysadm[26]; /* name of system administrator */
302 int c_maxsessions; /* maximum number of concurrent sessions allowed */
303 char c_ip_addr[20]; /* bind address for listening sockets */
304 int c_port_number; /* port number for Citadel protocol (usually 504) */
306 struct ExpirePolicy c_ep; /* default expire policy for the entire site */
307 int c_userpurge; /* user purge time (in days) */
308 int c_roompurge; /* room purge time (in days) */
309 char c_logpages[ROOMNAMELEN];
316 int c_rfc822_strict_from;
321 char c_enable_fulltext;
322 char c_baseroom[ROOMNAMELEN];
323 char c_aideroom[ROOMNAMELEN];
325 struct ExpirePolicy c_mbxep;
326 char c_ldap_host[128];
328 char c_ldap_base_dn[256];
329 char c_ldap_bind_dn[256];
330 char c_ldap_bind_pw[256];
336 char c_instant_expunge;
337 char c_allow_spoofing;
338 char c_journal_email;
339 char c_journal_pubmsgs;
340 char c_journal_dest[128];
341 char c_default_cal_zone[128];
342 int c_pftcpdict_port;
343 int c_managesieve_port;
345 char c_funambol_host[256];
347 char c_funambol_source[256];
348 char c_funambol_auth[256];
349 char c_rbl_at_greeting;
350 char c_master_user[32];
351 char c_master_pass[32];
352 char c_pager_program[256];
353 char c_imap_keep_from;
357 time_t c_pop3_fastest;
358 int c_spam_flag_only;
362 extern struct config config;
367 * Expose API calls from user_ops.c
369 int CtdlGetUser(struct ctdluser *usbuf, char *name);
370 int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
371 int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
372 void CtdlPutUser(struct ctdluser *usbuf);
373 void CtdlPutUserLock(struct ctdluser *usbuf);
374 int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
375 void CtdlGetRelationship(visit *vbuf,
376 struct ctdluser *rel_user,
377 struct ctdlroom *rel_room);
378 void CtdlSetRelationship(visit *newvisit,
379 struct ctdluser *rel_user,
380 struct ctdlroom *rel_room);
381 void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
383 int CtdlLoginExistingUser(char *authname, const char *username);
386 * Values which may be returned by CtdlLoginExistingUser()
390 pass_already_logged_in,
396 int CtdlTryPassword(const char *password, long len);
398 * Values which may be returned by CtdlTryPassword()
402 login_already_logged_in,
403 login_too_many_users,
407 void CtdlUserLogout(void);
413 * Expose API calls from msgbase.c
415 char *CtdlGetSysConfig(char *sysconfname);
416 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
422 * Expose API calls from euidindex.c
424 long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
427 #endif /* CTDL_MODULE_H */