ekg2
Strona główna
Dodatkowe strony
Moduły
Struktury Danych
Pliki
Lista plików
Globalne
All
Struktury Danych
Pliki
Funkcje
Zmienne
Definicje typów
Wyliczenia
Wartości wyliczeń
Definicje
Grupay
Strony
ekg
plugins.h
Idź do dokumentacji tego pliku.
1
/* $Id$ */
2
3
/*
4
* (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License Version 2 as
8
* published by the Free Software Foundation.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*/
19
20
#ifndef __EKG_PLUGINS_H
21
#define __EKG_PLUGINS_H
22
23
#include <sys/types.h>
24
#include <stdarg.h>
25
26
#include "
dynstuff.h
"
27
#include "
sessions.h
"
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#define EKG_ABI_VER 4921
34
35
#define EXPORT __attribute__ ((visibility("default")))
36
37
typedef
enum
{
38
PLUGIN_ANY
= 0,
39
PLUGIN_GENERIC
,
40
PLUGIN_PROTOCOL
,
41
PLUGIN_UI
,
42
PLUGIN_LOG
,
43
PLUGIN_SCRIPTING
,
44
PLUGIN_AUDIO
,
45
PLUGIN_CODEC
,
46
PLUGIN_CRYPT
47
}
plugin_class_t
;
48
49
typedef
int (*
plugin_destroy_func_t
)(void);
50
typedef
int (*
plugin_theme_init_func_t
)(void);
51
typedef
void (
plugin_notify_func_t
)(
session_t
*,
const
char
*);
52
53
#define PLUGIN_VAR_ADD(name, type, value, secret, notify) { name, value, secret, type, notify }
54
#define PLUGIN_VAR_END() { NULL, NULL, 0, -1, NULL }
55
extern
int
plugin_abi_version
(
int
plugin_abi_ver,
const
char
* plugin_name);
56
#define PLUGIN_CHECK_VER(name) { if (!plugin_abi_version(EKG_ABI_VER, name)) return -1; }
57
58
typedef
struct
{
59
char
*
key
;
/* name */
60
char
*
value
;
/* value */
61
int
secret
;
/* should it be hidden ? */
62
int
type
;
/* type */
63
plugin_notify_func_t
*
notify
;
/* notify */
64
}
plugins_params_t
;
65
66
struct
protocol_plugin_priv
{
67
const
char
**
protocols
;
/* NULL-terminated list of supported protocols, replacing GET_PLUGIN_PROTOCOLS */
68
const
status_t
*
statuses
;
/* EKG_STATUS_NULL-terminated list of supported statuses */
69
};
70
71
typedef
struct
plugin
{
72
struct
plugin
*
next
;
73
74
char
*
name
;
75
int
prio
;
76
plugin_class_t
pclass
;
77
plugin_destroy_func_t
destroy
;
78
/* lt_dlhandle */
void
*
dl
;
79
plugins_params_t
*
params
;
80
plugin_theme_init_func_t
theme_init
;
81
82
const
void
*
priv
;
83
}
plugin_t
;
84
85
/* Note about plugin_t.statuses:
86
* we currently put every supported status there, including unsettable by user,
87
* we assume that user cannot set states <= EKG_STATUS_NA
88
* [XXX]
89
*/
90
91
#ifndef EKG2_WIN32_NOFUNCTION
92
93
int
plugin_load
(
const
char
*
name
,
int
prio
,
int
quiet
);
94
int
plugin_unload
(
plugin_t
*);
95
int
plugin_register
(
plugin_t
*,
int
prio
);
96
int
plugin_unregister
(
plugin_t
*);
97
plugin_t
*
plugin_find
(
const
char
*
name
);
98
plugin_t
*
plugin_find_uid
(
const
char
*
uid
);
99
int
have_plugin_of_class
(
plugin_class_t
pclass
);
100
int
plugin_var_add
(
plugin_t
*pl,
const
char
*
name
,
int
type
,
const
char
*value,
int
secret,
plugin_notify_func_t
*notify);
101
int
plugin_var_find
(
plugin_t
*pl,
const
char
*
name
);
102
103
void
plugins_unlink
(
plugin_t
*pl);
104
#endif
105
106
#ifdef USINGANANTIQUECOMPILER
107
#define PLUGIN_DEFINE(x, y, z)\
108
static int x##_plugin_destroy(); \
109
\
110
plugin_t x##_plugin = { \
111
NULL, \
112
#x, \
113
0, \
114
y, \
115
x##_plugin_destroy, \
116
NULL, NULL, \
117
z \
118
}
119
#else
120
#define PLUGIN_DEFINE(x, y, z)\
121
static int x##_plugin_destroy(); \
122
\
123
plugin_t x##_plugin = { \
124
.name = #x, \
125
.pclass = y, \
126
.destroy = x##_plugin_destroy, \
127
.theme_init = z \
128
}
129
#endif
/* USINGANANTIQUECOMPILER */
130
131
#define QUERY(x) int x(void *data, va_list ap)
132
typedef
QUERY
(
query_handler_func_t
);
133
134
typedef
struct
queryx
{
135
struct
queryx
*
next
;
136
137
int
id
;
138
plugin_t
*
plugin
;
139
void
*
data
;
140
query_handler_func_t
*
handler
;
141
int
count
;
142
}
query_t
;
143
144
#ifndef EKG2_WIN32_NOFUNCTION
145
146
query_t
*
query_connect
(
plugin_t
*
plugin
,
const
char
*
name
,
query_handler_func_t
*
handler
,
void
*
data
);
147
query_t
*
query_connect_id
(
plugin_t
*
plugin
,
const
int
id
,
query_handler_func_t
*
handler
,
void
*
data
);
148
int
query_free
(
query_t
*q);
149
void
query_external_free
();
150
151
int
query_emit_id
(
plugin_t
*,
const
int
, ...);
152
int
query_emit
(
plugin_t
*,
const
char
*, ...);
153
void
queries_reconnect
();
154
155
const
char
*
query_name
(
const
int
id
);
156
const
struct
query_def
*
query_struct
(
const
int
id
);
157
158
#endif
159
160
typedef
enum
{
161
WATCH_NONE
= 0,
162
WATCH_WRITE
= 1,
163
WATCH_READ
= 2,
164
WATCH_READ_LINE
= 4,
165
WATCH_WRITE_LINE
= 8,
166
}
watch_type_t
;
167
168
#define WATCHER(x) int x(int type, int fd, watch_type_t watch, void *data)
169
#define WATCHER_LINE(x) int x(int type, int fd, const char *watch, void *data)
170
#define WATCHER_SESSION(x) int x(int type, int fd, watch_type_t watch, session_t *s)
171
#define WATCHER_SESSION_LINE(x) int x(int type, int fd, const char *watch, session_t *s)
172
173
typedef
WATCHER
(
watcher_handler_func_t
);
174
/* typedef WATCHER_LINE(watcher_handler_line_func_t); */
175
typedef
WATCHER_SESSION
(
watcher_session_handler_func_t
);
176
177
typedef
struct
watch
{
178
int
fd
;
/* obserwowany deskryptor */
179
watch_type_t
type
;
/* co sprawdzamy */
180
plugin_t
*
plugin
;
/* wtyczka obsługująca deskryptor */
181
void
*
handler
;
/* funkcja wywoływana jeśli są dane itp. */
182
void
*
data
;
/* dane przekazywane powyższym funkcjom. */
183
string_t
buf
;
/* bufor na linię */
184
time_t
timeout
;
/* timeout */
185
time_t
started
;
/* kiedy zaczęto obserwować */
186
int
removed
;
/* wywołano już watch_remove() */
187
188
int
transfer_limit
;
/* XXX, requested by GiM to limit data transmitted to ircd server... currently only to send all data
189
done by serveral calls of watch_write() in one packet... by setting it to -1 and than changing it back to 0
190
if we really want to send packet in that function we ought to do by calling watch_handle_write()
191
[PLEASE NOTE, THAT YOU CANNOT DO watch_write().. cause it will check if there is somethink in write buffor...
192
and if it is, it won't call watch_handle_write()]
193
or it will be
194
executed in next ekg_loop() loop.
195
*/
196
int
is_session
;
/* if set, this watch belongs to session specified in data */
197
}
watch_t
;
198
199
#ifndef EKG2_WIN32_NOFUNCTION
200
201
#ifdef __GNU__
202
int
watch_write
(
watch_t
*w,
const
char
*
format
, ...)
__attribute__
((format (printf, 2, 3)));
203
#else
204
int
watch_write
(
watch_t
*w,
const
char
*format, ...);
205
#endif
206
int
watch_write_data
(
watch_t
*w,
const
char
*buf,
int
len);
207
208
watch_t
*
watch_find
(
plugin_t
*
plugin
,
int
fd,
watch_type_t
type
);
209
void
watch_free
(
watch_t
*w);
210
211
typedef
void
*
watch_handler_func_t
;
212
213
int
watch_timeout_set
(
watch_t
*w, time_t timeout);
214
215
watch_t
*
watch_add
(
plugin_t
*
plugin
,
int
fd,
watch_type_t
type
,
watcher_handler_func_t
*handler,
void
*data);
216
#define watch_add_line(p, fd, type, handler, data) watch_add(p, fd, type, (watcher_handler_func_t *) (handler), data)
217
watch_t
*
watch_add_session
(session_t *session,
int
fd,
watch_type_t
type
,
watcher_session_handler_func_t
*handler);
218
#define watch_add_session_line(s, fd, type, handler) watch_add_session(s, fd, type, (watcher_session_handler_func_t *) (handler))
219
220
int
watch_remove
(
plugin_t
*
plugin
,
int
fd,
watch_type_t
type
);
221
222
void
watch_handle
(
watch_t
*w);
223
void
watch_handle_line
(
watch_t
*w);
224
int
watch_handle_write
(
watch_t
*w);
225
int
ekg2_dlinit
();
226
227
#endif
228
229
#ifndef EKG2_WIN32_NOFUNCTION
230
extern
plugin_t
*
plugins
;
231
extern
list_t
watches
;
232
extern
query_t
*
queries
[];
233
#endif
234
235
#ifdef __cplusplus
236
}
237
#endif
238
239
#endif
/* __EKG_PLUGINS_H */
240
241
/*
242
* Local Variables:
243
* mode: c
244
* c-file-style: "k&r"
245
* c-basic-offset: 8
246
* indent-tabs-mode: t
247
* End:
248
*/
Wygenerowano Śr, 10 paź 2012 05:11:33 dla ekg2 programem
1.8.1.1