16 #define SCRIPT_HANDLE_UNBIND -666
17 #define MAX_ARGS QUERY_ARGS_MAX+1
123 #define SCRIPT_FINDER(bool)\
124 script_t *scr = NULL;\
125 scriptlang_t *slang = NULL;\
127 for (scr = scripts; scr; scr = scr->next) {\
144 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
146 #define SCRIPT_DEFINE(x, y)\
147 extern int x##_load(script_t *);\
148 extern int x##_unload(script_t *);\
150 extern int x##_commands(script_t *, script_command_t *, char **);\
151 extern int x##_timers(script_t *, script_timer_t *, int );\
152 extern int x##_variable_changed(script_t *, script_var_t *, char *);\
153 extern int x##_query(script_t *, script_query_t *, void **);\
154 extern int x##_watches(script_t *, script_watch_t *, int, int, long int);\
155 void x##_dummy_sanity_check() { BUILD_BUG_ON(sizeof(void *) > sizeof(long)); };\
157 extern int x##_bind_free(script_t *, void *, int type, void *, ...);\
159 scriptlang_t x##_lang = { \
161 plugin: &x##_plugin, \
164 init: x##_initialize,\
165 deinit: x##_finalize, \
167 script_load: x##_load, \
168 script_unload: x##_unload, \
169 script_free_bind: x##_bind_free,\
171 script_handler_query : x##_query,\
172 script_handler_command: x##_commands,\
173 script_handler_timer : x##_timers,\
174 script_handler_var : x##_variable_changed,\
175 script_handler_watch : x##_watches,\
178 #define script_private_get(s) (s->priv_data)
179 #define script_private_set(s, p) (s->priv_data = p)
181 #ifndef EKG2_WIN32_NOFUNCTION
213 #define SCRIPT_UNBIND_HANDLER(type, args...) \
215 SCRIPT_HANDLER_HEADER(script_free_bind_t);\
216 SCRIPT_HANDLER_FOOTER(script_free_bind, type, temp->priv_data, args);\
221 #define SCRIPT_BIND_HEADER(x) \
223 if (scr && scr->inited != 1) {\
224 debug_error("[script_bind_error] script not inited!\n"); \
227 temp = xmalloc(sizeof(x)); \
229 temp->priv_data = handler;
231 #define SCRIPT_BIND_FOOTER(y) \
233 debug("[script_bind_error] (before adding to %s) ERROR! retcode = 0x%x\n", #y, temp->self);\
241 #define SCRIPT_HANDLER_HEADER(x) \
243 scriptlang_t *_slang;\
245 int ret = SCRIPT_HANDLE_UNBIND;
248 #define SCRIPT_HANDLER_FOOTER(y, _args...) \
249 if ((_scr = temp->scr) && ((_slang = _scr->lang))) _handler = _slang->y;\
250 else _handler = temp->priv_data;\
252 ret = _handler(_scr, temp, _args); \
254 debug("[%s] (_handler == NULL)\n", #y);\
255 ret = SCRIPT_HANDLE_UNBIND;\
258 if (ret == SCRIPT_HANDLE_UNBIND) { debug("[%s] script or scriptlang want to delete this handler\n", #y); }\
259 if (ret == SCRIPT_HANDLE_UNBIND)
261 #define SCRIPT_HANDLER_MULTI_FOOTER(y, _args...)\
263 SCRIPT_HANDLER_FOOTER(y, _args)
void script_variables_write()
Definition: scripts.c:453
int( script_handler_var_t)(script_t *, script_var_t *, char *)
Definition: scripts.h:93
int( script_unload_t)(script_t *)
Definition: scripts.h:90
script_free_bind_t * script_free_bind
Definition: scripts.h:111
int script_var_unbind(script_var_t *data, int free)
Definition: scripts.c:556
#define MAX_ARGS
Definition: scripts.h:17
script_t * scr
Definition: scripts.h:63
struct scriptlang * next
Definition: scripts.h:100
struct scriptlang scriptlang_t
void * priv_data
Definition: scripts.h:84
void * priv_data
Definition: scripts.h:69
script_query_t * script_query_bind(scriptlang_t *s, script_t *scr, char *qname, void *handler)
Definition: scripts.c:652
int script_unload_name(scriptlang_t *s, char *name)
Definition: scripts.c:297
script_t * scr
Definition: scripts.h:74
Definition: commands.h:63
int script_list(scriptlang_t *s)
Definition: scripts.c:176
int hack
Definition: scripts.h:70
int script_load(scriptlang_t *s, char *name)
Definition: scripts.c:337
int script_timer_unbind(script_timer_t *stimer, int free)
Definition: scripts.c:535
script_handler_var_t * script_handler_var
Definition: scripts.h:116
char * path
Definition: scripts.h:34
int argc
Definition: scripts.h:65
int( script_free_bind_t)(script_t *, void *, int, void *,...)
Definition: scripts.h:97
script_t * scr
Definition: scripts.h:54
int script_unload_lang(scriptlang_t *s)
Definition: scripts.c:319
int removed
Definition: scripts.h:82
script_handler_timer_t * script_handler_timer
Definition: scripts.h:115
script_watch_t * script_watch_add(scriptlang_t *s, script_t *scr, int fd, int type, void *handler, void *data)
Definition: scripts.c:644
script_t * scripts
Definition: scripts.c:21
script_command_t * script_command_bind(scriptlang_t *s, script_t *scr, char *command, char *params, char *possibilities, void *handler)
Definition: scripts.c:615
struct script * next
Definition: scripts.h:30
void * priv_data
Definition: scripts.h:59
void * priv_data
Definition: scripts.h:44
char * name
Definition: scripts.h:102
script_plugin_t * script_plugin_init(scriptlang_t *s, script_t *scr, char *name, plugin_class_t pclass, void *handler)
Definition: scripts.c:622
int real_argc
Definition: scripts.h:68
int scriptlang_unregister(scriptlang_t *s)
Definition: scripts.c:76
script_var_t * script_var_add_full(scriptlang_t *s, script_t *scr, char *name, int type, char *value, void *handler)
Definition: scripts.c:566
void script_variables_free()
Definition: scripts.c:437
int script_watch_unbind(script_watch_t *temp, int free)
Definition: scripts.c:545
#define params(x)
Definition: irc.c:1893
int script_query_unbind(script_query_t *squery, int from)
Definition: scripts.c:508
void * lang
Definition: scripts.h:32
char * value
Definition: scripts.h:58
plugin_class_t
Definition: plugins.h:40
script_t * scr
Definition: scripts.h:41
int script_command_unbind(script_command_t *scr_comm, int free)
Definition: scripts.c:498
script_type_t
Definition: scripts.h:19
void * priv_data
Definition: scripts.h:50
script_handler_query_t * script_handler_query
Definition: scripts.h:113
int( scriptlang_finalize_t)()
Definition: scripts.h:88
int( script_handler_command_t)(script_t *, script_command_t *, char **)
Definition: scripts.h:91
int inited
Definition: scripts.h:36
scriptlang_initialize_t * init
Definition: scripts.h:106
script_timer_t * script_timer_bind(scriptlang_t *s, script_t *scr, int freq, void *handler)
Definition: scripts.c:634
void * priv_data
Definition: scripts.h:35
script_t * script_find(scriptlang_t *s, char *name)
Definition: scripts.c:292
const char * name
Definition: remote.c:88
scriptlang_t * scriptlang
Definition: scripts.c:27
char * ext
Definition: scripts.h:103
int( script_handler_timer_t)(script_t *, script_timer_t *, int)
Definition: scripts.h:92
int removed
Definition: scripts.h:43
int( script_handler_watch_t)(script_t *, script_watch_t *, int, int, int)
Definition: scripts.h:95
Definition: plugins.h:140
script_unload_t * script_unload
Definition: scripts.h:110
int( script_load_t)(script_t *)
Definition: scripts.h:89
script_t * scr
Definition: scripts.h:48
plugin_t * plugin
Definition: scripts.h:104
scriptlang_finalize_t * deinit
Definition: scripts.h:107
script_handler_command_t * script_handler_command
Definition: scripts.h:114
int( script_handler_query_t)(script_t *, script_query_t *, void **)
Definition: scripts.h:94
void * data
Definition: scripts.h:83
char * name
Definition: scripts.h:33
char * name
Definition: scripts.h:57
abort_handler handler
Definition: abort.c:24
int scripts_init()
Definition: scripts.c:951
script_load_t * script_load
Definition: scripts.h:109
void * priv_data
Definition: scripts.h:76
script_var_t * script_var_add(scriptlang_t *s, script_t *scr, char *name, char *value, void *handler)
Definition: scripts.c:610
script_handler_watch_t * script_handler_watch
Definition: scripts.h:117
script_t * scr
Definition: scripts.h:80
int( scriptlang_initialize_t)()
Definition: scripts.h:87
void * priv_data
Definition: scripts.h:119
int scriptlang_register(scriptlang_t *s)
Definition: scripts.c:65