6 #include <libcitadel.h>
8 #include "sysdep_decls.h"
12 * define macros for module init stuff
15 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
17 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
19 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
21 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
25 * Prototype for making log entries in Citadel.
28 void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
30 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
33 * Hook functions available to modules.
36 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
37 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
39 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
40 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
42 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
43 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
45 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
47 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
50 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
51 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
53 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
54 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
56 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
57 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
59 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
60 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
62 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
64 void CtdlRegisterServiceHook(int tcp_port,
66 void (*h_greeting_function) (void),
67 void (*h_command_function) (void),
68 void (*h_async_function) (void),
69 const char *ServiceName
71 void CtdlUnregisterServiceHook(int tcp_port,
73 void (*h_greeting_function) (void),
74 void (*h_command_function) (void),
75 void (*h_async_function) (void)
78 void CtdlRegisterFixedOutputHook(char *content_type,
79 void (*output_function) (char *supplied_data, int len)
81 void CtdlUnRegisterFixedOutputHook(char *content_type);
83 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
85 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
89 * Directory services hooks for LDAP etc
92 #define DIRECTORY_USER_DEL 1 // Delete a user entry
93 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
94 #define DIRECTORY_CREATE_OBJECT 3 // Create a new object for directory entry
95 #define DIRECTORY_ATTRIB_ADD 4 // Add an attribute to the directory entry object
96 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
97 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
99 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
100 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
102 /* TODODRW: This needs to be changed into a hook type interface
103 * for now we have this horrible hack
105 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
109 * Citadel Threads API
111 struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
112 struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
113 void CtdlThreadSleep(int secs);
114 void CtdlThreadStop(struct CtdlThreadNode *thread);
115 int CtdlThreadCheckStop(void);
116 /* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */
117 const char *CtdlThreadName(const char *name);
118 struct CtdlThreadNode *CtdlThreadSelf(void);
119 int CtdlThreadGetCount(void);
120 int CtdlThreadGetWorkers(void);
121 double CtdlThreadGetWorkerAvg(void);
122 double CtdlThreadGetLoadAvg(void);
123 void CtdlThreadGC(void);
124 void CtdlThreadStopAll(void);
125 int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
126 void CtdlThreadAllocTSD(void);
128 #define CTDLTHREAD_BIGSTACK 0x0001
129 #define CTDLTHREAD_WORKER 0x0002
131 /* Macros to speed up getting outr thread */
133 #define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
134 #define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
135 #define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
137 /** return the current context list as an array and do it in a safe manner
138 * The returned data is a copy so only reading is useful
139 * The number of contexts is returned in count.
140 * Beware, this does not copy any of the data pointed to by the context.
141 * This means that you can not rely on things like the redirect buffer being valid.
142 * You must free the returned pointer when done.
144 struct CitContext *CtdlGetContextArray (int *count);
145 void CtdlFillSystemContext(struct CitContext *context, char *name);
147 int CtdlTrySingleUser(void);
148 void CtdlEndSingleUser(void);
149 int CtdlWantSingleUser(void);
150 int CtdlIsSingleUser(void);
154 * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
155 * This provides a quick way to initialise a variable that might be used to indicate
156 * messages that should not be processed. EG. a new Sieve 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, char *room_name);
176 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
177 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
178 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
179 int *result, int *view);
180 void CtdlPutRoomLock(struct ctdlroom *qrbuf);
181 void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
183 void CtdlDeleteRoom(struct ctdlroom *qrbuf);
184 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
185 void CtdlUserGoto (char *where, int display_result, int transiently,
186 int *msgs, int *new);
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 int CtdlIsNonEditable(struct ctdlroom *qrbuf);
192 void CtdlPutRoom(struct ctdlroom *);
195 * Possible return values for CtdlRenameRoom()
198 crr_ok, /* success */
199 crr_room_not_found, /* room not found */
200 crr_already_exists, /* new name already exists */
201 crr_noneditable, /* cannot edit this room */
202 crr_invalid_floor, /* target floor does not exist */
203 crr_access_denied /* not allowed to edit this room */
206 #endif /* CTDL_MODULE_H */