Added an entry point to the modules init stuff.
[citadel.git] / citadel / include / ctdl_module.h
1 /* $Id$ */
2
3 #ifndef CTDL_MODULE_H
4 #define CTDL_MODULE_H
5
6 #include "server.h"
7 #include "sysdep_decls.h"
8 #include "msgbase.h"
9
10 /*
11  * define macros for module init stuff
12  */
13  
14 #define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (int threading)
15
16 #define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
17
18 #define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
19
20 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
21
22
23 /*
24  * Prototype for making log entries in Citadel.
25  */
26
27 void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
28
29 /*
30  * Fix the interface to aide_message so that it complies with the Coding style
31  */
32  
33 #define CtdlAideMessage(TEXT, SUBJECT) aide_message(TEXT, SUBJECT)
34
35 /*
36  * Hook functions available to modules.
37  */
38
39 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
40 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
41
42 void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
43 void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
44
45 void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
46 void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
47
48 void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
49                                                         int EventType);
50 void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
51                                                         int EventType);
52
53 void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
54 void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) );
55
56 void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
57 void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
58
59 void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
60 void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
61
62 void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
63 void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
64
65 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
66 void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd);
67
68 void CtdlRegisterServiceHook(int tcp_port,
69                              char *sockpath,
70                              void (*h_greeting_function) (void),
71                              void (*h_command_function) (void),
72                              void (*h_async_function) (void),
73                              const char *ServiceName
74 );
75 void CtdlUnregisterServiceHook(int tcp_port,
76                         char *sockpath,
77                         void (*h_greeting_function) (void),
78                         void (*h_command_function) (void),
79                         void (*h_async_function) (void)
80 );
81
82 void CtdlRegisterFixedOutputHook(char *content_type,
83                         void (*output_function) (char *supplied_data, int len)
84 );
85 void CtdlUnRegisterFixedOutputHook(char *content_type);
86
87 void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
88
89 void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
90
91
92 /*
93  * Directory services hooks for LDAP etc
94  */
95
96 #define DIRECTORY_USER_DEL 1    // Delete a user entry
97 #define DIRECTORY_CREATE_HOST 2 // Create a host entry if not already there.
98 #define DIRECTORY_CREATE_OBJECT 3       // Create a new object for directory entry
99 #define DIRECTORY_ATTRIB_ADD 4  // Add an attribute to the directory entry object
100 #define DIRECTORY_SAVE_OBJECT 5 // Save the object to the directory service
101 #define DIRECTORY_FREE_OBJECT 6 // Free the object and its attributes
102
103 int CtdlRegisterDirectoryServiceFunc(int (*func)(char *cn, char *ou, void **object), int cmd, char *module);
104 int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, int cmd);
105
106 /* TODODRW: This needs to be changed into a hook type interface
107  * for now we have this horrible hack
108  */
109 void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response);
110
111
112 /*
113  * Citadel Threads API
114  */
115 struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
116 void CtdlThreadSleep(int secs);
117 void CtdlThreadStop(struct CtdlThreadNode *thread);
118 int CtdlThreadCheckStop(struct CtdlThreadNode *this_thread);
119 void CtdlThreadCancel(struct CtdlThreadNode *thread);
120 char *CtdlThreadName(struct CtdlThreadNode *thread, char *name);
121 struct CtdlThreadNode *CtdlThreadSelf(void);
122 int CtdlThreadGetCount(void);
123 int CtdlThreadGetWorkers(void);
124 double CtdlThreadGetWorkerAvg(void);
125 double CtdlThreadGetLoadAvg(void);
126 void CtdlThreadGC(void);
127 void CtdlThreadStopAll(void);
128 int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, struct CtdlThreadNode *self);
129
130 /* Macros to speed up getting outr thread */
131 #define CT _this_cit_thread
132 #define CT_PUSH() \
133         struct CtdlThreadNode *_this_cit_thread;\
134         _this_cit_thread = CtdlThreadSelf()
135
136 #endif /* CTDL_MODULE_H */