Go to the source code of this file.
Data Structures | |
struct | bind_list_t |
struct | event_owner_b |
struct | bind_entry_b |
struct | bind_table_b |
Defines | |
#define | MATCH_PARTIAL 1 |
#define | MATCH_EXACT 2 |
#define | MATCH_MASK 4 |
#define | MATCH_CASE 8 |
#define | MATCH_NONE 16 |
#define | MATCH_FLAGS_AND 32 |
#define | MATCH_FLAGS_OR 64 |
#define | MATCH_FLAGS 96 |
#define | BIND_WANTS_CD 1 |
#define | BIND_BREAKABLE 6 |
#define | BIND_STACKABLE 4 |
#define | BIND_DELETED 8 |
#define | BIND_FAKE 16 |
#define | BIND_RET_LOG 1 |
#define | BIND_RET_BREAK 2 |
#define | BIND_RET_LOG_COMMAND 3 |
Typedefs | |
typedef struct event_owner_b | event_owner_t |
typedef struct bind_entry_b | bind_entry_t |
typedef struct bind_table_b | bind_table_t |
Functions | |
void | bind_killall () |
int | bind_check (bind_table_t *table, flags_t *user_flags, const char *match,...) |
int | bind_check_hits (bind_table_t *table, flags_t *user_flags, const char *match, int *hits,...) |
bind_table_t * | bind_table_add (const char *name, int nargs, const char *syntax, int match_type, int flags) |
void | bind_table_del (bind_table_t *table) |
int | kill_binds_by_owner (struct egg_module *module, void *script) |
bind_table_t * | bind_table_lookup (const char *name) |
bind_table_t * | bind_table_lookup_or_fake (const char *name) |
int | bind_entry_add (bind_table_t *table, const char *user_flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data, event_owner_t *owner) |
int | bind_entry_del (bind_table_t *table, const char *mask, const char *function_name, Function callback) |
int | bind_entry_modify (bind_table_t *table, const char *mask, const char *function_name, const char *newflags, const char *newmask) |
int | bind_entry_overwrite (bind_table_t *table, const char *mask, const char *function_name, Function callback, void *client_data, event_owner_t *owner) |
void | bind_add_list (const char *table_name, bind_list_t *cmds) |
void | bind_add_simple (const char *table_name, const char *flags, const char *mask, Function callback) |
void | bind_rem_list (const char *table_name, bind_list_t *cmds) |
void | bind_rem_simple (const char *table_name, const char *flags, const char *mask, Function callback) |
bind_table_t * | bind_table_list (void) |
#define BIND_BREAKABLE 6 |
Definition at line 37 of file binds.h.
Referenced by bind_vcheck_hits(), botnet_init(), and server_binds_init().
#define BIND_DELETED 8 |
Definition at line 39 of file binds.h.
Referenced by bind_entry_del(), bind_entry_exec(), bind_entry_lookup(), bind_table_del(), bind_table_lookup(), bind_vcheck_hits(), internal_bind_cleanup(), and kill_binds_by_owner().
#define BIND_FAKE 16 |
Definition at line 40 of file binds.h.
Referenced by bind_table_add(), and bind_table_lookup_or_fake().
#define BIND_RET_BREAK 2 |
Definition at line 48 of file binds.h.
Referenced by bind_vcheck_hits(), channel_set(), check_ctcp_ctcr(), check_flag_change(), config_set_int(), config_set_str(), do_link(), do_output(), got001(), got_actchan(), got_away(), got_bcast(), got_botbroadcast(), got_botmsg(), got_bye(), got_chat(), got_endlink(), got_handshake(), got_idle(), got_join(), got_link(), got_motd(), got_nickchange(), got_nlinked(), got_part(), got_ping(), got_pong(), got_privmsg(), got_thisbot(), got_unlink(), got_unlinked(), got_versions(), got_who(), gotmsg(), gotnotice(), gotwall(), party_loadmod(), party_unloadmod(), partyline_on_command(), server_parse_input(), and user_set_setting().
#define BIND_RET_LOG 1 |
Definition at line 47 of file binds.h.
Referenced by check_tcl_fil(), core_shutdown(), gotmsg(), party_act(), party_addlog(), party_binds(), party_chaninfo(), party_chanmembermode(), party_channels(), party_chansave(), party_chanset(), party_chhandle(), party_dump(), party_js(), party_jump(), party_list_masks(), party_loadmod(), party_match(), party_minus_bot(), party_minus_chan(), party_minus_mask(), party_minus_obot(), party_minus_server(), party_modules(), party_msg(), party_perl(), party_pls_chan(), party_plus_mask(), party_plus_server(), party_python(), party_restart(), party_servers(), party_tcl(), party_timers(), party_unloadmod(), and partyline_on_command().
#define BIND_RET_LOG_COMMAND 3 |
#define BIND_STACKABLE 4 |
Definition at line 38 of file binds.h.
Referenced by bind_entry_add(), botnet_init(), chanserv_init(), config_init(), core_binds_init(), eggdrop_init(), irc_init(), logging_init(), oldbotnet_init(), partychan_init(), partymember_init(), server_binds_init(), start(), and user_init().
#define BIND_WANTS_CD 1 |
Definition at line 36 of file binds.h.
Referenced by bind_entry_exec(), channel_events_init(), and script_bind().
#define MATCH_CASE 8 |
#define MATCH_EXACT 2 |
#define MATCH_FLAGS 96 |
Definition at line 33 of file binds.h.
Referenced by bind_vcheck_hits(), partyline_init(), and server_binds_init().
#define MATCH_FLAGS_AND 32 |
#define MATCH_FLAGS_OR 64 |
#define MATCH_MASK 4 |
Definition at line 28 of file binds.h.
Referenced by bind_entry_exec(), bind_vcheck_hits(), chanserv_init(), config_init(), core_binds_init(), eggdrop_init(), irc_init(), module_init(), oldbotnet_init(), partymember_init(), server_binds_init(), start(), and user_init().
#define MATCH_NONE 16 |
Definition at line 30 of file binds.h.
Referenced by bind_entry_exec(), bind_vcheck_hits(), core_binds_init(), logging_init(), partychan_init(), partyline_init(), partymember_init(), server_binds_init(), and user_init().
#define MATCH_PARTIAL 1 |
Definition at line 26 of file binds.h.
Referenced by bind_entry_exec(), bind_vcheck_hits(), and partyline_init().
typedef struct bind_entry_b bind_entry_t |
typedef struct bind_table_b bind_table_t |
typedef struct event_owner_b event_owner_t |
void bind_add_list | ( | const char * | table_name, | |
bind_list_t * | cmds | |||
) |
Definition at line 459 of file binds.c.
References bind_entry_add(), bind_table_lookup_or_fake(), bind_list_t::callback, bind_list_t::mask, bind_table_b::name, NULL, and bind_list_t::user_flags.
Referenced by channel_events_init(), core_party_init(), irc_init(), javascript_LTX_start(), oldbotnet_init(), partyline_init(), partymember_init(), perlscript_LTX_start(), pythonscript_LTX_start(), server_binds_init(), and tclscript_LTX_start().
00460 { 00461 char name[50]; 00462 bind_table_t *table; 00463 00464 table = bind_table_lookup_or_fake(table_name); 00465 00466 for (; cmds->callback; cmds++) { 00467 snprintf(name, 50, "*%s:%s", table->name, cmds->mask ? cmds->mask : ""); 00468 name[49] = 0; 00469 bind_entry_add(table, cmds->user_flags, cmds->mask, name, 0, cmds->callback, NULL, NULL); 00470 } 00471 }
void bind_add_simple | ( | const char * | table_name, | |
const char * | flags, | |||
const char * | mask, | |||
Function | callback | |||
) |
Definition at line 473 of file binds.c.
References bind_entry_add(), bind_table_lookup_or_fake(), bind_table_b::name, and NULL.
Referenced by bot_init(), chanserv_init(), dcc_init(), events_init(), logfile_init(), oldbotnet_init(), proxy_init(), and user_init().
00474 { 00475 char name[50]; 00476 bind_table_t *table; 00477 00478 table = bind_table_lookup_or_fake(table_name); 00479 00480 snprintf(name, sizeof(name), "*%s:%s", table->name, mask ? mask : ""); 00481 name[sizeof(name)-1] = 0; 00482 00483 bind_entry_add(table, flags, mask, name, 0, callback, NULL, NULL); 00484 }
int bind_check | ( | bind_table_t * | table, | |
flags_t * | user_flags, | |||
const char * | match, | |||
... | ||||
) |
Definition at line 367 of file binds.c.
References bind_vcheck_hits(), and NULL.
Referenced by botnet_botbroadcast(), botnet_botmsg(), botnet_extension(), botnet_link(), botnet_new(), botnet_recursive_delete(), chan_msg(), channel_on_leave(), channel_set(), chanserv_update_stats(), check_bind_init(), check_bind_secondly(), check_bind_shutdown(), check_bind_status(), check_bind_time(), check_ctcp_ctcr(), check_flag_change(), config_save(), config_set_int(), config_set_str(), do_output(), eggdrop_event(), got_chat(), got_send(), gotjoin(), gotkick(), gotmode(), gotmsg(), gotnick(), gotnotice(), gotpart(), gotquit(), gotwall(), irc_on_read(), module_load(), module_unload(), oldbotnet_on_read(), parse_chan_mode(), partychan_join(), partychan_part(), partymember_delete(), partymember_new(), partymember_set_nick(), putlog(), server_parse_input(), user_delete(), and user_set_setting().
00368 { 00369 va_list args; 00370 int ret; 00371 00372 va_start(args, match); 00373 ret = bind_vcheck_hits(table, user_flags, match, NULL, args); 00374 va_end(args); 00375 00376 return ret; 00377 }
int bind_check_hits | ( | bind_table_t * | table, | |
flags_t * | user_flags, | |||
const char * | match, | |||
int * | hits, | |||
... | ||||
) |
Definition at line 379 of file binds.c.
References bind_vcheck_hits().
Referenced by partyline_on_command().
00380 { 00381 va_list args; 00382 int ret; 00383 00384 va_start(args, hits); 00385 ret = bind_vcheck_hits(table, user_flags, match, hits, args); 00386 va_end(args); 00387 00388 return ret; 00389 }
int bind_entry_add | ( | bind_table_t * | table, | |
const char * | user_flags, | |||
const char * | mask, | |||
const char * | function_name, | |||
int | bind_flags, | |||
Function | callback, | |||
void * | client_data, | |||
event_owner_t * | owner | |||
) |
Definition at line 278 of file binds.c.
References bind_entry_lookup(), BIND_STACKABLE, bind_entry_b::callback, bind_entry_b::client_data, bind_table_b::entries, flag_from_str(), bind_entry_b::flags, bind_table_b::flags, bind_entry_b::function_name, bind_entry_b::mask, bind_entry_b::next, NULL, event_owner_b::on_delete, bind_entry_b::owner, bind_entry_b::prev, and bind_entry_b::user_flags.
Referenced by bind_add_list(), bind_add_simple(), channel_events_init(), and script_bind().
00279 { 00280 bind_entry_t *entry, *old_entry; 00281 00282 old_entry = bind_entry_lookup(table, mask, function_name, NULL); 00283 00284 if (old_entry) { 00285 if (table->flags & BIND_STACKABLE) { 00286 entry = calloc(1, sizeof(*entry)); 00287 entry->prev = old_entry; 00288 entry->next = old_entry->next; 00289 old_entry->next = entry; 00290 if (entry->next) entry->next->prev = entry; 00291 } 00292 else { 00293 entry = old_entry; 00294 if (entry->owner && entry->owner->on_delete) entry->owner->on_delete(entry->owner, entry->client_data); 00295 if (entry->function_name) free(entry->function_name); 00296 if (entry->mask) free(entry->mask); 00297 } 00298 } 00299 else { 00300 for (old_entry = table->entries; old_entry && old_entry->next; old_entry = old_entry->next) { 00301 ; /* empty loop */ 00302 } 00303 entry = calloc(1, sizeof(*entry)); 00304 if (old_entry) old_entry->next = entry; 00305 else table->entries = entry; 00306 entry->prev = old_entry; 00307 } 00308 00309 if (flags) flag_from_str(&entry->user_flags, flags); 00310 if (mask) entry->mask = strdup(mask); 00311 if (function_name) entry->function_name = strdup(function_name); 00312 entry->callback = callback; 00313 entry->client_data = client_data; 00314 entry->flags = bind_flags; 00315 entry->owner = owner; 00316 00317 return(0); 00318 }
int bind_entry_del | ( | bind_table_t * | table, | |
const char * | mask, | |||
const char * | function_name, | |||
Function | callback | |||
) |
Definition at line 206 of file binds.c.
References BIND_DELETED, bind_entry_lookup(), bind_table_b::entries, bind_entry_b::flags, bind_entry_b::function_name, LOG_DEBUG, bind_entry_b::mask, bind_table_b::name, bind_entry_b::next, NULL, putlog(), and schedule_bind_cleanup().
Referenced by bind_rem_list(), bind_rem_simple(), and script_unbind().
00207 { 00208 bind_entry_t *entry; 00209 00210 entry = bind_entry_lookup(table, mask, function_name, callback); 00211 00212 /* better to issue a warning message than silently ignoring 00213 * that this entry is not found...at least for now */ 00214 if (entry == NULL) { 00215 if (table) { 00216 putlog(LOG_DEBUG, "*", "A bind entry '%s/%s' is marked for destroying but isn't found in table '%s'.", 00217 mask, function_name, table->name); 00218 putlog(LOG_DEBUG, "*", "Current entries are:"); 00219 for (entry = table->entries; entry; entry = entry->next) { 00220 putlog(LOG_DEBUG, "*", " %s/%s", entry->mask, entry->function_name); 00221 } 00222 } else { 00223 putlog(LOG_DEBUG, "*", "A bind entry '%s/%s' is marked for destroying but isn't found in any table.", 00224 mask, function_name); 00225 } 00226 return -1; 00227 } 00228 /*if (!entry) return(-1);*/ 00229 00230 /* Delete it. */ 00231 entry->flags |= BIND_DELETED; 00232 schedule_bind_cleanup(); 00233 return(0); 00234 }
int bind_entry_modify | ( | bind_table_t * | table, | |
const char * | mask, | |||
const char * | function_name, | |||
const char * | newflags, | |||
const char * | newmask | |||
) |
Definition at line 249 of file binds.c.
References bind_entry_lookup(), flag_from_str(), bind_entry_b::mask, NULL, str_redup(), and bind_entry_b::user_flags.
Referenced by script_rebind().
00250 { 00251 bind_entry_t *entry; 00252 00253 entry = bind_entry_lookup(table, mask, function_name, NULL); 00254 if (!entry) return(-1); 00255 00256 /* Modify it. */ 00257 if (newflags) flag_from_str(&entry->user_flags, newflags); 00258 if (newmask) str_redup(&entry->mask, newmask); 00259 00260 return(0); 00261 }
int bind_entry_overwrite | ( | bind_table_t * | table, | |
const char * | mask, | |||
const char * | function_name, | |||
Function | callback, | |||
void * | client_data, | |||
event_owner_t * | owner | |||
) |
Definition at line 264 of file binds.c.
References bind_entry_lookup(), bind_entry_b::client_data, NULL, event_owner_b::on_delete, and bind_entry_b::owner.
00265 { 00266 bind_entry_t *entry; 00267 00268 entry = bind_entry_lookup(table, mask, function_name, NULL); 00269 if (!entry) return(-1); 00270 00271 if ((entry->client_data != client_data || entry->owner != owner) && entry->owner && entry->owner->on_delete) entry->owner->on_delete(entry->owner, entry->client_data); 00272 callback = callback; 00273 entry->client_data = client_data; 00274 entry->owner = owner; 00275 return(0); 00276 }
void bind_killall | ( | ) |
void bind_rem_list | ( | const char * | table_name, | |
bind_list_t * | cmds | |||
) |
Definition at line 486 of file binds.c.
References bind_entry_del(), bind_table_lookup(), bind_list_t::callback, bind_list_t::mask, and bind_table_b::name.
Referenced by channel_events_destroy(), javascript_close(), oldbotnet_close(), partyline_shutdown(), partymember_shutdown(), perlscript_close(), pythonscript_close(), server_close(), and tclscript_close().
00487 { 00488 char name[50]; 00489 bind_table_t *table; 00490 00491 table = bind_table_lookup(table_name); 00492 if (!table) return; 00493 00494 for (; cmds->callback; cmds++) { 00495 snprintf(name, sizeof(name), "*%s:%s", table->name, cmds->mask ? cmds->mask : ""); 00496 name[sizeof(name)-1] = 0; 00497 bind_entry_del(table, cmds->mask, name, cmds->callback); 00498 } 00499 }
void bind_rem_simple | ( | const char * | table_name, | |
const char * | flags, | |||
const char * | mask, | |||
Function | callback | |||
) |
Definition at line 501 of file binds.c.
References bind_entry_del(), bind_table_lookup(), and bind_table_b::name.
Referenced by bot_close(), events_shutdown(), logfile_shutdown(), oldbotnet_close(), and server_close().
00502 { 00503 char name[50]; 00504 bind_table_t *table; 00505 00506 table = bind_table_lookup(table_name); 00507 if (!table) return; 00508 00509 snprintf(name, sizeof(name), "*%s:%s", table->name, mask ? mask : ""); 00510 name[sizeof(name)-1] = 0; 00511 bind_entry_del(table, mask, name, callback); 00512 }
bind_table_t* bind_table_add | ( | const char * | name, | |
int | nargs, | |||
const char * | syntax, | |||
int | match_type, | |||
int | flags | |||
) |
Definition at line 90 of file binds.c.
References BIND_FAKE, bind_table_b::flags, bind_table_b::match_type, bind_table_b::name, bind_table_b::nargs, bind_table_b::next, and bind_table_b::syntax.
Referenced by bind_table_lookup_or_fake(), botnet_init(), chanserv_init(), config_init(), core_binds_init(), eggdrop_init(), irc_init(), logging_init(), module_init(), oldbotnet_init(), partychan_init(), partyline_init(), partymember_init(), server_binds_init(), start(), and user_init().
00091 { 00092 bind_table_t *table; 00093 00094 for (table = bind_table_list_head; table; table = table->next) { 00095 if (!strcmp(table->name, name)) break; 00096 } 00097 00098 /* If it doesn't exist, create it. */ 00099 if (!table) { 00100 table = calloc(1, sizeof(*table)); 00101 table->name = strdup(name); 00102 table->next = bind_table_list_head; 00103 bind_table_list_head = table; 00104 } 00105 else if (!(table->flags & BIND_FAKE)) return(table); 00106 00107 table->nargs = nargs; 00108 if (syntax) table->syntax = strdup(syntax); 00109 table->match_type = match_type; 00110 table->flags = flags; 00111 return(table); 00112 }
void bind_table_del | ( | bind_table_t * | table | ) |
Definition at line 114 of file binds.c.
References BIND_DELETED, egg_assert, bind_table_b::flags, bind_table_b::name, bind_table_b::next, NULL, and schedule_bind_cleanup().
Referenced by botnet_shutdown(), chanserv_shutdown(), config_shutdown(), core_binds_shutdown(), eggdrop_shutdown(), filesys_close(), kill_binds(), logging_shutdown(), module_shutdown(), oldbotnet_close(), partychan_shutdown(), partyline_shutdown(), partymember_shutdown(), server_binds_destroy(), and user_shutdown().
00115 { 00116 bind_table_t *cur; 00117 00118 for (cur = bind_table_list_head; cur; cur = cur->next) { 00119 if (!strcmp(table->name, cur->name)) break; 00120 } 00121 00122 egg_assert(cur != NULL); 00123 00124 /* Now mark it as deleted. */ 00125 table->flags |= BIND_DELETED; 00126 schedule_bind_cleanup(); 00127 }
bind_table_t* bind_table_list | ( | void | ) |
Definition at line 36 of file binds.c.
Referenced by party_binds().
00037 { 00038 return bind_table_list_head; 00039 }
bind_table_t* bind_table_lookup | ( | const char * | name | ) |
Definition at line 160 of file binds.c.
References BIND_DELETED, bind_table_b::flags, bind_table_b::name, and bind_table_b::next.
Referenced by bind_rem_list(), bind_rem_simple(), bind_table_lookup_or_fake(), script_bind(), script_rebind(), and script_unbind().
00161 { 00162 bind_table_t *table; 00163 00164 for (table = bind_table_list_head; table; table = table->next) { 00165 if (!(table->flags & BIND_DELETED) && !strcmp(table->name, name)) break; 00166 } 00167 return(table); 00168 }
bind_table_t* bind_table_lookup_or_fake | ( | const char * | name | ) |
Definition at line 170 of file binds.c.
References BIND_FAKE, bind_table_add(), bind_table_lookup(), and NULL.
Referenced by bind_add_list(), bind_add_simple(), and channel_events_init().
00171 { 00172 bind_table_t *table; 00173 00174 table = bind_table_lookup(name); 00175 if (!table) table = bind_table_add(name, 0, NULL, 0, BIND_FAKE); 00176 return(table); 00177 }
int kill_binds_by_owner | ( | struct egg_module * | module, | |
void * | script | |||
) |
Definition at line 70 of file binds.c.
References BIND_DELETED, event_owner_b::client_data, bind_table_b::entries, bind_entry_b::flags, bind_table_b::flags, internal_bind_cleanup(), event_owner_b::module, bind_entry_b::next, bind_table_b::next, and bind_entry_b::owner.
Referenced by script_remove_events_by_owner().
00071 { 00072 int deleted = 0; 00073 bind_entry_t *entry; 00074 bind_table_t *table; 00075 00076 for (table = bind_table_list_head; table; table = table->next) { 00077 if (table->flags & BIND_DELETED) continue; 00078 for (entry = table->entries; entry; entry = entry->next) { 00079 if (entry->flags & BIND_DELETED) continue; 00080 if (entry->owner && entry->owner->module == module && (!script || entry->owner->client_data == script)) { 00081 deleted++; 00082 entry->flags |= BIND_DELETED; 00083 } 00084 } 00085 } 00086 internal_bind_cleanup(); 00087 return deleted; 00088 }