b2d556377828e0b1ea0b8631dc398e20386a6c46
[citadel.git] / citadel / serv_extensions.h
1
2 #ifndef SERV_EXTENSIONS_H
3 #define SERV_EXTENSIONS_H
4
5 #include "server.h"
6
7 /*
8  * This is where we declare all of the server extensions we have.
9  * We'll probably start moving these to a more sane location in the near
10  * future.  For now, this just shuts up the compiler.
11  */
12 //void serv_calendar_destroy(void);
13 //char *serv_test_init(void);
14 //char *serv_postfix_tcpdict(void);
15 /*
16  */
17
18  
19  
20 /*
21  * Structure defentitions for hook tables
22  */
23  
24
25 struct LogFunctionHook {
26         struct LogFunctionHook *next;
27         int loglevel;
28         void (*h_function_pointer) (char *);
29 };
30 extern struct LogFunctionHook *LogHookTable;
31
32 struct CleanupFunctionHook {
33         struct CleanupFunctionHook *next;
34         void (*h_function_pointer) (void);
35 };
36 extern struct CleanupFunctionHook *CleanupHookTable;
37
38 struct FixedOutputHook {
39         struct FixedOutputHook *next;
40         char content_type[64];
41         void (*h_function_pointer) (char *, int);
42 };
43 extern struct FixedOutputHook *FixedOutputTable;
44
45
46
47 /*
48  * SessionFunctionHook extensions are used for any type of hook for which
49  * the context in which it's being called (which is determined by the event
50  * type) will make it obvious for the hook function to know where to look for
51  * pertinent data.
52  */
53 struct SessionFunctionHook {
54         struct SessionFunctionHook *next;
55         void (*h_function_pointer) (void);
56         int eventtype;
57 };
58 extern struct SessionFunctionHook *SessionHookTable;
59
60
61 /*
62  * UserFunctionHook extensions are used for any type of hook which implements
63  * an operation on a user or username (potentially) other than the one
64  * operating the current session.
65  */
66 struct UserFunctionHook {
67         struct UserFunctionHook *next;
68         void (*h_function_pointer) (struct ctdluser *usbuf);
69         int eventtype;
70 };
71 extern struct UserFunctionHook *UserHookTable;
72
73 /*
74  * MessageFunctionHook extensions are used for hooks which implement handlers
75  * for various types of message operations (save, read, etc.)
76  */
77 struct MessageFunctionHook {
78         struct MessageFunctionHook *next;
79         int (*h_function_pointer) (struct CtdlMessage *msg);
80         int eventtype;
81 };
82 extern struct MessageFunctionHook *MessageHookTable;
83
84
85 /*
86  * NetprocFunctionHook extensions are used for hooks which implement handlers
87  * for incoming network messages.
88  */
89 struct NetprocFunctionHook {
90         struct NetprocFunctionHook *next;
91         int (*h_function_pointer) (struct CtdlMessage *msg, char *target_room);
92 };
93 extern struct NetprocFunctionHook *NetprocHookTable;
94
95
96 /*
97  * DeleteFunctionHook extensions are used for hooks which get called when a
98  * message is about to be deleted.
99  */
100 struct DeleteFunctionHook {
101         struct DeleteFunctionHook *next;
102         void (*h_function_pointer) (char *target_room, long msgnum);
103 };
104 extern struct DeleteFunctionHook *DeleteHookTable;
105
106
107 /*
108  * ExpressMessageFunctionHook extensions are used for hooks which implement
109  * the sending of an instant message through various channels.  Any function
110  * registered should return the number of recipients to whom the message was
111  * successfully transmitted.
112  */
113 struct XmsgFunctionHook {
114         struct XmsgFunctionHook *next;
115         int (*h_function_pointer) (char *, char *, char *, char *);
116         int order;
117 };
118 extern struct XmsgFunctionHook *XmsgHookTable;
119
120
121
122
123 /*
124  * ServiceFunctionHook extensions are used for hooks which implement various
125  * protocols (either on TCP or on unix domain sockets) directly in the Citadel server.
126  */
127 struct ServiceFunctionHook {
128         struct ServiceFunctionHook *next;
129         int tcp_port;
130         char *sockpath;
131         void (*h_greeting_function) (void) ;
132         void (*h_command_function) (void) ;
133         void (*h_async_function) (void) ;
134         int msock;
135         const char* ServiceName; /* this is just for debugging and logging purposes. */
136 };
137 extern struct ServiceFunctionHook *ServiceHookTable;
138
139
140 /*
141  * RoomFunctionHook extensions are used for hooks which impliment room
142  * processing functions when new messages are added EG. SIEVE.
143  */
144 struct RoomFunctionHook {
145         struct RoomFunctionHook *next;
146         int (*fcn_ptr) (struct ctdlroom *);
147 };
148 extern struct RoomFunctionHook *RoomHookTable;
149
150
151
152 struct SearchFunctionHook {
153         struct SearchFunctionHook *next;
154         void (*fcn_ptr) (int *, long **, const char *);
155         char *name;
156 };
157 extern struct SearchFunctionHook *SearchFunctionHookTable;
158
159  
160  
161 void initialize_server_extensions(void);
162 int DLoader_Exec_Cmd(char *cmdbuf);
163 char *Dynamic_Module_Init(void);
164
165 void CtdlDestroySessionHooks(void);
166 void PerformSessionHooks(int EventType);
167
168 void CtdlDestroyUserHooks(void);
169 void PerformUserHooks(struct ctdluser *usbuf, int EventType);
170
171 int PerformXmsgHooks(char *, char *, char *, char *);
172 void CtdlDestroyXmsgHooks(void);
173
174
175
176 void CtdlDestroyMessageHook(void);
177 int PerformMessageHooks(struct CtdlMessage *, int EventType);
178
179
180 void CtdlDestroyNetprocHooks(void);
181 int PerformNetprocHooks(struct CtdlMessage *, char *);
182
183 void CtdlDestroyRoomHooks(void);
184 int PerformRoomHooks(struct ctdlroom *);
185
186
187 void CtdlDestroyDeleteHooks(void);
188 void PerformDeleteHooks(char *, long);
189
190
191 void CtdlDestroyCleanupHooks(void);
192
193 void CtdlDestroyProtoHooks(void);
194
195 void CtdlDestroyServiceHook(void);
196
197 void CtdlDestroySearchHooks(void);
198
199 void CtdlDestroyFixedOutputHooks(void);
200 int PerformFixedOutputHooks(char *, char *, int);
201
202
203 #endif /* SERV_EXTENSIONS_H */