Go to the source code of this file.
#define SCRIPT_ARRAY 1024 |
Definition at line 99 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), GetIrcMasks(), script_channel_info(), script_channel_list(), script_channel_mask_list(), script_channel_members(), script_channel_topic(), script_channels(), script_get_ircmasks(), script_list(), script_listmask(), script_net_info(), script_net_listen(), script_server_list(), script_timer_info(), and script_timers().
#define SCRIPT_BYTES 'b' |
Definition at line 114 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), js_to_c_var(), ParameterType(), perl_to_c_var(), python_to_c_var(), and tcl_to_c_var().
#define SCRIPT_CALLBACK 'c' |
Definition at line 109 of file script.h.
Referenced by js_to_c_var(), my_command_handler(), ParameterType(), perl_to_c_var(), python_to_c_var(), and tcl_to_c_var().
#define SCRIPT_CALLBACK_ONCE 1 |
#define SCRIPT_ERROR 2048 |
#define SCRIPT_FREE 256 |
Definition at line 97 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), js_to_c_var(), my_command_handler(), python_to_c_var(), script_channel_get(), script_channel_info(), script_channel_list(), script_channel_mask_list(), script_channel_members(), script_channel_topic(), script_channels(), script_dynamic_string(), script_linked_var_on_write(), script_list(), script_listmask(), script_net_info(), script_net_listen(), script_server_list(), script_timer_info(), script_timers(), and tcl_to_c_var().
#define SCRIPT_FREE_VAR 512 |
Definition at line 98 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), script_int(), script_list(), and script_string().
#define SCRIPT_INTEGER 'i' |
Definition at line 106 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), Cleanup(), js_to_c_var(), my_js_callbacker(), my_perl_callbacker(), my_python_callbacker(), my_tcl_callbacker(), ParameterType(), perl_to_c_var(), python_to_c_var(), script_export(), script_int(), script_linked_var_on_write(), script_net_info(), script_timers(), and tcl_to_c_var().
#define SCRIPT_PARTIER 'P' |
Definition at line 112 of file script.h.
Referenced by c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), ParameterType(), perl_to_c_var(), python_to_c_var(), and tcl_to_c_var().
#define SCRIPT_PASS_ARRAY 8 |
#define SCRIPT_PASS_CDATA 1 |
#define SCRIPT_PASS_COUNT 4 |
#define SCRIPT_PASS_RETVAL 2 |
#define SCRIPT_POINTER 'p' |
Definition at line 108 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), and ParameterType().
#define SCRIPT_READONLY 4096 |
Definition at line 101 of file script.h.
Referenced by my_trace_callback(), SetAttr(), and SetItem().
#define SCRIPT_STRING 's' |
Definition at line 104 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), Cleanup(), Get(), GetFlags(), GetIrcMasks(), js_to_c_var(), my_command_handler(), ParameterType(), perl_to_c_var(), python_to_c_var(), script_channel_get(), script_get_ircmasks(), script_linked_var_on_write(), script_string(), and tcl_to_c_var().
#define SCRIPT_STRING_LIST 'S' |
Definition at line 105 of file script.h.
Referenced by c_to_js_var(), c_to_python_var(), c_to_tcl_var(), and ParameterType().
#define SCRIPT_TYPE_MASK 255 |
Definition at line 117 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), GetVar(), linked_var_to_jsval(), python_to_c_var(), script_linked_var_on_write(), set_linked_var(), and tcl_to_c_var().
#define SCRIPT_UNSIGNED 'u' |
Definition at line 107 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), js_to_c_var(), my_js_callbacker(), my_perl_callbacker(), my_python_callbacker(), my_tcl_callbacker(), ParameterType(), perl_to_c_var(), python_to_c_var(), script_linked_var_on_write(), and tcl_to_c_var().
#define SCRIPT_USER 'U' |
Definition at line 110 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), js_to_c_var(), ParameterType(), perl_to_c_var(), python_to_c_var(), and tcl_to_c_var().
#define SCRIPT_VAR 'v' |
Definition at line 115 of file script.h.
Referenced by c_to_js_var(), c_to_perl_var(), c_to_python_var(), c_to_tcl_var(), ParameterType(), script_channel_info(), script_channel_list(), script_channel_mask_list(), script_channel_members(), script_channel_topic(), script_channels(), script_list(), script_listmask(), script_net_info(), script_net_listen(), script_server_list(), and script_timer_info().
#define SCRIPT_VAR_ARGS 16 |
#define SCRIPT_VAR_FRONT 32 |
typedef struct byte_array_b byte_array_t |
typedef int dns_function_t(const char *query, int timeout, dns_callback_t callback, void *data, event_owner_t *event) |
typedef struct script_args_b script_args_t |
typedef struct script_callback_b script_callback_t |
typedef struct script_command_b script_command_t |
typedef struct script_linked_var_b script_linked_var_t |
typedef struct script_module_b script_module_t |
typedef struct script_var_callbacks_b script_var_callbacks_t |
typedef struct script_var_b script_var_t |
anonymous enum |
SCRIPT_EVENT_LOAD_SCRIPT | |
SCRIPT_EVENT_LINK_VAR | |
SCRIPT_EVENT_UNLINK_VAR | |
SCRIPT_EVENT_CREATE_CMD | |
SCRIPT_EVENT_DELETE_CMD | |
SCRIPT_EVENT_MAX |
Definition at line 28 of file script.h.
00029 { 00030 SCRIPT_EVENT_LOAD_SCRIPT = 0, 00031 SCRIPT_EVENT_LINK_VAR, 00032 SCRIPT_EVENT_UNLINK_VAR, 00033 SCRIPT_EVENT_CREATE_CMD, 00034 SCRIPT_EVENT_DELETE_CMD, 00035 SCRIPT_EVENT_MAX 00036 };
anonymous enum |
Definition at line 39 of file script.h.
00040 { 00041 SCRIPT_OK = 0, 00042 SCRIPT_ERR_NOT_RESPONSIBLE, 00043 SCRIPT_ERR_CODE, 00044 };
script_var_t* script_copy_string | ( | char * | str, | |
int | len | |||
) |
Definition at line 514 of file script.c.
References script_dynamic_string().
00515 { 00516 char *copy; 00517 00518 if (!str) { 00519 str = ""; 00520 len = 0; 00521 } 00522 else if (len < 0) len = strlen(str); 00523 copy = malloc(len+1); 00524 memcpy(copy, str, len); 00525 copy[len] = 0; 00526 return script_dynamic_string(copy, len); 00527 }
int script_create_commands | ( | script_command_t * | table | ) |
Definition at line 445 of file script.c.
References script_raw_command_t::callback, script_raw_command_t::class, script_command_b::class, script_raw_command_t::client_data, cmd, script_module_b::create_command, EVENT_CMD, journal_add(), my_command_handler(), script_raw_command_t::name, script_command_b::name, and nscript_modules.
Referenced by logfile_init(), script_export(), script_init(), script_LTX_start(), server_script_init(), and start().
00446 { 00447 int i; 00448 script_raw_command_t *cmd; 00449 00450 while (table->class && table->name) { 00451 cmd = malloc(sizeof(*cmd)); 00452 cmd->class = table->class; 00453 cmd->name = table->name; 00454 cmd->callback = my_command_handler; 00455 cmd->client_data = table; 00456 00457 journal_add(EVENT_CMD, cmd, table); 00458 for (i = 0; i < nscript_modules; i++) { 00459 script_modules[i]->create_command(script_modules[i]->client_data, cmd); 00460 } 00461 table++; 00462 } 00463 return(0); 00464 }
int script_create_raw_commands | ( | script_raw_command_t * | table | ) |
Definition at line 417 of file script.c.
References script_raw_command_t::class, script_module_b::create_command, EVENT_CMD, journal_add(), script_raw_command_t::name, and nscript_modules.
00418 { 00419 int i; 00420 00421 while (table->class && table->name) { 00422 journal_add(EVENT_CMD, table, table); 00423 for (i = 0; i < nscript_modules; i++) { 00424 script_modules[i]->create_command(script_modules[i]->client_data, table); 00425 } 00426 table++; 00427 } 00428 return(0); 00429 }
int script_delete_commands | ( | script_command_t * | table | ) |
Definition at line 466 of file script.c.
References script_command_b::class, cmd, script_module_b::delete_command, EVENT_CMD, journal_del(), script_command_b::name, and nscript_modules.
Referenced by channels_close(), logfile_shutdown(), script_shutdown(), and server_script_destroy().
00467 { 00468 int i; 00469 script_raw_command_t *cmd; 00470 00471 for (; table->class && table->name; table++) { 00472 cmd = journal_del(EVENT_CMD, table); 00473 if (!cmd) 00474 continue; 00475 00476 for (i = 0; i < nscript_modules; i++) { 00477 script_modules[i]->delete_command(script_modules[i]->client_data, cmd); 00478 } 00479 00480 free(cmd); 00481 } 00482 return(0); 00483 }
int script_delete_raw_commands | ( | script_raw_command_t * | table | ) |
Definition at line 431 of file script.c.
References script_raw_command_t::class, script_module_b::delete_command, EVENT_CMD, journal_del(), script_raw_command_t::name, and nscript_modules.
00432 { 00433 int i; 00434 00435 while (table->class && table->name) { 00436 journal_del(EVENT_CMD, table); 00437 for (i = 0; i < nscript_modules; i++) { 00438 script_modules[i]->delete_command(script_modules[i]->client_data, table); 00439 } 00440 table++; 00441 } 00442 return(0); 00443 }
int script_dns_query | ( | dns_function_t * | function, | |
const char * | host, | |||
script_callback_t * | callback, | |||
char * | text, | |||
int | len | |||
) |
Definition at line 591 of file script.c.
References script_dns_callback_data_t::callback, function, script_dns_callback_data_t::id, script_dns_callback_data_t::len, script_callback_b::owner, script_dns_callback(), script_dns_delete(), script_callback_b::syntax, and script_dns_callback_data_t::text.
Referenced by script_dns_lookup(), and script_dns_reverse().
00592 { 00593 int id; 00594 event_owner_t *event; 00595 script_dns_callback_data_t *data; 00596 00597 event = malloc(sizeof(*event)); 00598 memcpy(event, callback->owner, sizeof(*event)); 00599 event->on_delete = script_dns_delete; 00600 00601 callback->syntax = strdup("isSb"); 00602 data = malloc(sizeof(*data)); 00603 data->callback = callback; 00604 data->id = -1; 00605 data->text = text; 00606 data->len = len; 00607 id = function(host, -1, script_dns_callback, data, event); 00608 if (id == -1) { 00609 /* the query was cached, the callback has already been called and data has been freed */ 00610 return -1; 00611 } 00612 data->id = id; 00613 return id; 00614 }
script_var_t* script_dynamic_string | ( | char * | str, | |
int | len | |||
) |
Definition at line 508 of file script.c.
References SCRIPT_FREE, script_string(), and script_var_b::type.
Referenced by script_copy_string().
00509 { script_var_t *var = script_string(str, len); 00510 var->type |= SCRIPT_FREE; 00511 return(var); 00512 }
int script_get_arg | ( | script_args_t * | args, | |
int | num, | |||
script_var_t * | var, | |||
int | type | |||
) |
Definition at line 485 of file script.c.
References script_module_b::client_data, script_module_b::get_arg, and script_args_b::module.
Referenced by my_command_handler().
00486 { 00487 script_module_t *module; 00488 00489 module = args->module; 00490 return module->get_arg(module->client_data, args, num, var, type); 00491 }
int script_init | ( | void | ) |
Definition at line 56 of file script.c.
References script_create_commands().
Referenced by eggdrop_init().
00057 { 00058 script_create_commands(script_cmds); 00059 00060 return(0); 00061 }
script_var_t* script_int | ( | int | val | ) |
Definition at line 529 of file script.c.
References SCRIPT_FREE_VAR, SCRIPT_INTEGER, script_var_b::type, and script_var_b::value.
Referenced by script_channel_mask_list(), script_channel_topic(), script_listmask(), script_net_info(), script_net_listen(), script_server_list(), and script_timer_info().
00530 { 00531 script_var_t *var = malloc(sizeof(*var)); 00532 var->type = SCRIPT_INTEGER | SCRIPT_FREE_VAR; 00533 var->value = (void *)val; 00534 return(var); 00535 }
int script_link_vars | ( | script_linked_var_t * | table | ) |
Definition at line 389 of file script.c.
References script_linked_var_b::class, EVENT_VAR, journal_add(), script_module_b::link_var, script_linked_var_b::name, and nscript_modules.
Referenced by server_script_init().
00390 { 00391 int i; 00392 00393 while (table->class && table->name) { 00394 journal_add(EVENT_VAR, table, table); 00395 for (i = 0; i < nscript_modules; i++) { 00396 script_modules[i]->link_var(script_modules[i]->client_data, table); 00397 } 00398 table++; 00399 } 00400 return(0); 00401 }
int script_linked_var_on_write | ( | script_linked_var_t * | var, | |
script_var_t * | newval | |||
) |
Definition at line 192 of file script.c.
References script_linked_var_b::callbacks, script_var_callbacks_b::on_write, SCRIPT_FREE, SCRIPT_INTEGER, SCRIPT_STRING, SCRIPT_TYPE_MASK, SCRIPT_UNSIGNED, script_var_b::type, script_linked_var_b::type, script_var_b::value, and script_linked_var_b::value.
Referenced by my_eggvar_set(), my_trace_callback(), and SetVar().
00193 { 00194 int r; 00195 char **charptr; 00196 00197 /* See if the owner provides a write callback. */ 00198 if (var->callbacks && var->callbacks->on_write) { 00199 r = (var->callbacks->on_write)(var, newval); 00200 return(r); 00201 } 00202 00203 /* Provide default handling for strings and ints. */ 00204 switch (var->type & SCRIPT_TYPE_MASK) { 00205 case SCRIPT_UNSIGNED: 00206 case SCRIPT_INTEGER: 00207 *(int *)(var->value) = (int) newval->value; 00208 break; 00209 case SCRIPT_STRING: 00210 charptr = (char **)var->value; 00211 if (*charptr) free(*charptr); 00212 if (newval->type & SCRIPT_FREE) *charptr = newval->value; 00213 else *charptr = strdup(newval->value); 00214 break; 00215 } 00216 return(0); 00217 }
script_var_t* script_list | ( | int | nitems, | |
... | ||||
) |
Definition at line 537 of file script.c.
References script_var_b::len, NULL, SCRIPT_ARRAY, SCRIPT_FREE, SCRIPT_FREE_VAR, SCRIPT_VAR, script_var_b::type, and script_var_b::value.
Referenced by script_channel_mask_list(), script_listmask(), and script_server_list().
00538 { 00539 script_var_t *list; 00540 00541 list = malloc(sizeof(*list)); 00542 list->type = SCRIPT_ARRAY | SCRIPT_FREE | SCRIPT_VAR | SCRIPT_FREE_VAR; 00543 list->len = nitems; 00544 if (nitems > 0) { 00545 list->value = malloc(nitems * sizeof(script_var_t *)); 00546 memmove(list->value, &nitems + 1, nitems * sizeof(script_var_t *)); 00547 } 00548 else list->value = NULL; 00549 return(list); 00550 }
int script_list_append | ( | script_var_t * | list, | |
script_var_t * | item | |||
) |
Definition at line 552 of file script.c.
References script_var_b::len, and script_var_b::value.
Referenced by script_channel_info(), script_channel_list(), script_channel_mask_list(), script_channel_members(), script_channel_topic(), script_channels(), script_listmask(), script_net_info(), script_net_listen(), script_server_list(), and script_timer_info().
00553 { 00554 list->value = realloc(list->value, sizeof(item) * (list->len+1)); 00555 ((script_var_t **)list->value)[list->len] = item; 00556 list->len++; 00557 return(0); 00558 }
int script_load | ( | char * | filename | ) |
Definition at line 347 of file script.c.
References _, egg_assert_val, script_module_b::load_script, LOG_MISC, nscript_modules, NULL, putlog(), SCRIPT_ERR_CODE, SCRIPT_ERR_NOT_RESPONSIBLE, and SCRIPT_OK.
Referenced by core_init().
00348 { 00349 int i, ret; 00350 00351 egg_assert_val (filename != NULL, 0); 00352 00353 /* check if we have at least one script module loaded. */ 00354 if (nscript_modules == 0) { 00355 putlog (LOG_MISC, "*", _("Failed to load script '%s': no script modules loaded."), 00356 filename); 00357 return 0; 00358 } 00359 00360 for (i = 0; i < nscript_modules; i++) { 00361 ret = script_modules[i]->load_script(script_modules[i]->client_data, filename); 00362 00363 switch (ret) { 00364 00365 /* The current module was responsible and everything worked fine 00366 */ 00367 case (SCRIPT_OK): 00368 putlog (LOG_MISC, "*", _("Script loaded: %s"), filename); 00369 return 1; 00370 00371 /* The current module is not responsible for this type of 00372 * script. */ 00373 case (SCRIPT_ERR_NOT_RESPONSIBLE): 00374 break; 00375 00376 /* Code error, script implementation (hopefully) put a log 00377 * message for a detailed error description. */ 00378 case (SCRIPT_ERR_CODE): 00379 return 0; 00380 00381 } 00382 } 00383 00384 putlog (LOG_MISC, "*", _("Failed to load script '%s': no appropiate script module."), filename); 00385 00386 return 0; 00387 }
int script_playback | ( | script_module_t * | module | ) |
Definition at line 145 of file script.c.
References script_module_b::client_data, script_module_b::create_command, journal_event_t::data, EVENT_CMD, EVENT_VAR, script_module_b::link_var, and njournal_events.
Referenced by javascript_LTX_start(), perlscript_LTX_start(), pythonscript_LTX_start(), and tclscript_LTX_start().
00146 { 00147 int i; 00148 00149 for (i = 0; i < njournal_events; i++) { 00150 switch (journal_events[i].event) { 00151 case EVENT_VAR: 00152 module->link_var(module->client_data, journal_events[i].data); 00153 break; 00154 case EVENT_CMD: 00155 module->create_command(module->client_data, journal_events[i].data); 00156 break; 00157 } 00158 } 00159 return(0); 00160 }
int script_register_module | ( | script_module_t * | module | ) |
Definition at line 121 of file script.c.
References nscript_modules.
Referenced by javascript_LTX_start(), perlscript_LTX_start(), pythonscript_LTX_start(), and tclscript_LTX_start().
00122 { 00123 script_modules = realloc(script_modules, sizeof(*script_modules) * (nscript_modules+1)); 00124 script_modules[nscript_modules] = module; 00125 nscript_modules++; 00126 return(0); 00127 }
int script_remove_events_by_owner | ( | egg_module_t * | module, | |
void * | script | |||
) |
Delete all asyncronous events of a module or script.
This functions kills all asyncronous events of a given module or script by calling the *_delete_by_owner() functions of all event types.
module | The module whose bots should be deleted. | |
script | The script whose bots should be deleted. NULL matches everything. |
Definition at line 107 of file script.c.
References botnet_delete_by_owner(), egg_dns_cancel_by_owner(), egg_ident_cancel_by_owner(), kill_binds_by_owner(), partymember_delete_by_owner(), and timer_destroy_by_owner().
Referenced by Cleanup(), and module_really_unload().
00108 { 00109 int removed = 0; 00110 00111 removed += botnet_delete_by_owner(module, script); 00112 removed += partymember_delete_by_owner(module, script); 00113 removed += kill_binds_by_owner(module, script); 00114 removed += timer_destroy_by_owner(module, script); 00115 removed += egg_dns_cancel_by_owner(module, script); 00116 removed += egg_ident_cancel_by_owner(module, script); 00117 return removed; 00118 }
int script_shutdown | ( | void | ) |
Definition at line 63 of file script.c.
References journal_del(), njournal_events, nscript_modules, NULL, script_delete_commands(), and script_unregister_module().
Referenced by eggdrop_shutdown().
00064 { 00065 int i; 00066 00067 script_delete_commands(script_cmds); 00068 00069 /* XXX: this may be the wrong place. This should be handled by module 00070 * XXX: dependencies. E.g. if someone unloads "script", e.g. "tclscript" 00071 * XXX: should be magicly unloaded too */ 00072 if (nscript_modules > 0) { 00073 for (i = nscript_modules - 1; i >= 0; i--) { 00074 script_unregister_module(script_modules[i]); 00075 } 00076 } 00077 if (script_modules) free(script_modules); script_modules = NULL; 00078 00079 /* XXX: this shouldn't be necessary too if everything gets unloaded. */ 00080 if (njournal_events > 0) { 00081 for (i = njournal_events - 1; i >= 0; i--) { 00082 journal_del( 00083 journal_events[i].event, 00084 journal_events[i].key); 00085 } 00086 } 00087 if (journal_events) free(journal_events); journal_events = NULL; 00088 00089 return (0); 00090 }
script_var_t* script_string | ( | char * | str, | |
int | len | |||
) |
Definition at line 493 of file script.c.
References script_var_b::len, SCRIPT_FREE_VAR, SCRIPT_STRING, script_var_b::type, and script_var_b::value.
Referenced by script_channel_info(), script_channel_list(), script_channel_mask_list(), script_channel_members(), script_channel_topic(), script_channels(), script_dynamic_string(), script_listmask(), script_server_list(), and script_timer_info().
00494 { 00495 script_var_t *var = malloc(sizeof(*var)); 00496 00497 var->type = SCRIPT_STRING | SCRIPT_FREE_VAR; 00498 if (!str) { 00499 str = ""; 00500 len = 0; 00501 } 00502 else if (len < 0) len = strlen(str); 00503 var->value = str; 00504 var->len = len; 00505 return(var); 00506 }
int script_unlink_vars | ( | script_linked_var_t * | table | ) |
Definition at line 403 of file script.c.
References script_linked_var_b::class, EVENT_VAR, journal_del(), script_linked_var_b::name, nscript_modules, and script_module_b::unlink_var.
Referenced by server_script_destroy().
00404 { 00405 int i; 00406 00407 while (table->class && table->name) { 00408 journal_del(EVENT_VAR, table); 00409 for (i = 0; i < nscript_modules; i++) { 00410 script_modules[i]->unlink_var(script_modules[i]->client_data, table); 00411 } 00412 table++; 00413 } 00414 return(0); 00415 }
int script_unregister_module | ( | script_module_t * | module | ) |
Definition at line 130 of file script.c.
References nscript_modules.
Referenced by javascript_close(), perlscript_close(), pythonscript_close(), script_shutdown(), and tclscript_close().
00131 { 00132 int i; 00133 00134 for (i = 0; i < nscript_modules; i++) { 00135 if (script_modules[i] == module) break; 00136 } 00137 if (i == nscript_modules) return(-1); 00138 memmove(script_modules+i, script_modules+i+1, sizeof(script_module_t) * (nscript_modules-i-1)); 00139 nscript_modules--; 00140 return(0); 00141 }