#include <eggdrop/eggdrop.h>
Go to the source code of this file.
Functions | |
static int | bind_vcheck_hits (bind_table_t *table, flags_t *user_flags, const char *match, int *hits, va_list args) |
static void | bind_table_really_del (bind_table_t *table) |
static void | bind_entry_really_del (bind_table_t *table, bind_entry_t *entry) |
bind_table_t * | bind_table_list (void) |
static int | internal_bind_cleanup () |
static void | schedule_bind_cleanup () |
void | kill_binds (void) |
int | kill_binds_by_owner (egg_module_t *module, void *script) |
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) |
bind_table_t * | bind_table_lookup (const char *name) |
bind_table_t * | bind_table_lookup_or_fake (const char *name) |
bind_entry_t * | bind_entry_lookup (bind_table_t *table, const char *mask, const char *function_name, Function callback) |
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) |
int | bind_entry_add (bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data, event_owner_t *owner) |
static int | bind_entry_exec (bind_table_t *table, bind_entry_t *entry, void **al) |
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,...) |
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) |
Variables | |
static const char | rcsid [] = "$Id: binds.c,v 1.30 2007-01-13 12:23:39 sven Exp $" |
static bind_table_t * | bind_table_list_head = NULL |
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 * | 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 }
static int bind_entry_exec | ( | bind_table_t * | table, | |
bind_entry_t * | entry, | |||
void ** | al | |||
) | [static] |
Definition at line 321 of file binds.c.
References BIND_DELETED, BIND_WANTS_CD, bind_entry_b::callback, bind_entry_b::client_data, bind_table_b::entries, bind_entry_b::flags, MATCH_MASK, MATCH_NONE, MATCH_PARTIAL, bind_table_b::match_type, bind_entry_b::next, bind_entry_b::nhits, and bind_entry_b::prev.
Referenced by bind_vcheck_hits().
00322 { 00323 bind_entry_t *prev; 00324 int retval; 00325 00326 /* Give this entry a hit. */ 00327 entry->nhits++; 00328 00329 /* Does the callback want client data? */ 00330 if (entry->flags & BIND_WANTS_CD) { 00331 *al = entry->client_data; 00332 } 00333 else al++; 00334 00335 retval = entry->callback(al[0], al[1], al[2], al[3], al[4], al[5], al[6], al[7], al[8], al[9]); 00336 00337 if (table->match_type & (MATCH_MASK | MATCH_PARTIAL | MATCH_NONE)) return(retval); 00338 00339 /* Search for the last entry that isn't deleted. */ 00340 for (prev = entry->prev; prev; prev = prev->prev) { 00341 if (!(prev->flags & BIND_DELETED) && (prev->nhits >= entry->nhits)) break; 00342 } 00343 00344 /* See if this entry is more popular than the preceding one. */ 00345 if (entry->prev != prev) { 00346 /* Remove entry. */ 00347 if (entry->prev) entry->prev->next = entry->next; 00348 else table->entries = entry->next; 00349 if (entry->next) entry->next->prev = entry->prev; 00350 00351 /* Re-add in correct position. */ 00352 if (prev) { 00353 entry->next = prev->next; 00354 if (prev->next) prev->next->prev = entry; 00355 prev->next = entry; 00356 } 00357 else { 00358 entry->next = table->entries; 00359 table->entries = entry; 00360 } 00361 entry->prev = prev; 00362 if (entry->next) entry->next->prev = entry; 00363 } 00364 return(retval); 00365 }
bind_entry_t* bind_entry_lookup | ( | bind_table_t * | table, | |
const char * | mask, | |||
const char * | function_name, | |||
Function | callback | |||
) |
Definition at line 180 of file binds.c.
References BIND_DELETED, bind_entry_b::callback, bind_table_b::entries, bind_entry_b::flags, bind_entry_b::function_name, bind_entry_b::mask, bind_entry_b::next, bind_table_b::next, and NULL.
Referenced by bind_entry_add(), bind_entry_del(), bind_entry_modify(), and bind_entry_overwrite().
00181 { 00182 bind_entry_t *entry = NULL; 00183 int hit, searchall = 0; 00184 00185 if (!table) { 00186 searchall = 1; 00187 table = bind_table_list_head; 00188 } 00189 00190 for (; table; table = table->next) { 00191 for (entry = table->entries; entry; entry = entry->next) { 00192 if (entry->flags & BIND_DELETED) continue; 00193 else { 00194 hit = 0; 00195 if (!entry->mask || !strcmp(entry->mask, mask)) hit++; 00196 if (!entry->function_name || !strcmp(entry->function_name, function_name)) hit++; 00197 if (!callback || entry->callback == callback) hit++; 00198 if (hit == 3) break; 00199 } 00200 } 00201 if (entry || !searchall) break; 00202 } 00203 return(entry); 00204 }
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 }
static void bind_entry_really_del | ( | bind_table_t * | table, | |
bind_entry_t * | entry | |||
) | [static] |
Definition at line 236 of file binds.c.
References bind_entry_b::client_data, bind_table_b::entries, bind_entry_b::function_name, bind_entry_b::mask, bind_entry_b::next, event_owner_b::on_delete, bind_entry_b::owner, and bind_entry_b::prev.
Referenced by internal_bind_cleanup().
00237 { 00238 if (entry->next) entry->next->prev = entry->prev; 00239 if (entry->prev) entry->prev->next = entry->next; 00240 else table->entries = entry->next; 00241 00242 if (entry->owner && entry->owner->on_delete) entry->owner->on_delete(entry->owner, entry->client_data); 00243 if (entry->function_name) free(entry->function_name); 00244 if (entry->mask) free(entry->mask); 00245 free(entry); 00246 }
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 }
static void bind_table_really_del | ( | bind_table_t * | table | ) | [static] |
Definition at line 129 of file binds.c.
References bind_entry_b::client_data, bind_table_b::entries, bind_entry_b::function_name, LOG_DEBUG, bind_entry_b::mask, bind_table_b::name, bind_entry_b::next, bind_table_b::next, NULL, event_owner_b::on_delete, bind_entry_b::owner, putlog(), and bind_table_b::syntax.
Referenced by internal_bind_cleanup().
00130 { 00131 bind_table_t *cur, *prev; 00132 bind_entry_t *entry, *next; 00133 00134 for (prev = NULL, cur = bind_table_list_head; cur; prev = cur, cur = cur->next) { 00135 if (cur == table) 00136 break; 00137 } 00138 00139 if (cur == NULL) { 00140 putlog(LOG_DEBUG, "*", "bind table '%s' is marked for destroying but isn't found.", table->name); 00141 return; 00142 } 00143 00144 /* unlink it from list */ 00145 if (prev == NULL) bind_table_list_head = table->next; 00146 else prev->next = table->next; 00147 00148 for (entry = table->entries; entry; entry = next) { 00149 next = entry->next; 00150 if (entry->owner && entry->owner->on_delete) entry->owner->on_delete(entry->owner, entry->client_data); 00151 if (entry->function_name) free(entry->function_name); 00152 if (entry->mask) free(entry->mask); 00153 free(entry); 00154 } 00155 if (table->name) free(table->name); 00156 if (table->syntax) free(table->syntax); 00157 free(table); 00158 }
static int bind_vcheck_hits | ( | bind_table_t * | table, | |
flags_t * | user_flags, | |||
const char * | match, | |||
int * | hits, | |||
va_list | args | |||
) | [static] |
Definition at line 391 of file binds.c.
References BIND_BREAKABLE, BIND_DELETED, bind_entry_exec(), BIND_RET_BREAK, flags_t::builtin, bind_table_b::entries, flag_match_partial(), flag_match_subset(), bind_table_b::flags, bind_entry_b::flags, bind_entry_b::mask, MATCH_CASE, MATCH_FLAGS, MATCH_FLAGS_AND, MATCH_MASK, MATCH_NONE, MATCH_PARTIAL, bind_table_b::match_type, bind_table_b::nargs, bind_entry_b::next, NULL, flags_t::udef, bind_entry_b::user_flags, and wild_match_per().
Referenced by bind_check(), and bind_check_hits().
00392 { 00393 void *args[11]; 00394 bind_entry_t *entry, *next, *winner = NULL; 00395 int i, cmp, retval; 00396 int tie = 0, matchlen = 0; 00397 00398 for (i = 1; i <= table->nargs; i++) { 00399 args[i] = va_arg(ap, void *); 00400 } 00401 00402 if (hits) (*hits) = 0; 00403 00404 /* Default return value is 0 */ 00405 retval = 0; 00406 00407 /* Check if we're searching for a partial match. */ 00408 if (table->match_type & MATCH_PARTIAL) matchlen = strlen(match); 00409 00410 for (entry = table->entries; entry; entry = next) { 00411 next = entry->next; 00412 if (entry->flags & BIND_DELETED) continue; 00413 00414 /* Check flags. */ 00415 if (table->match_type & MATCH_FLAGS) { 00416 if (!(entry->user_flags.builtin | entry->user_flags.udef)) cmp = 1; 00417 else if (!user_flags) cmp = 0; 00418 else if (entry->flags & MATCH_FLAGS_AND) cmp = flag_match_subset(&entry->user_flags, user_flags); 00419 else cmp = flag_match_partial(user_flags, &entry->user_flags); 00420 if (!cmp) continue; 00421 } 00422 00423 if (table->match_type & MATCH_NONE || !entry->mask) cmp = 0; 00424 else if (table->match_type & MATCH_MASK) { 00425 cmp = !wild_match_per(entry->mask, match); 00426 } 00427 else if (table->match_type & MATCH_PARTIAL) { 00428 cmp = 1; 00429 if (!strncasecmp(match, entry->mask, matchlen)) { 00430 winner = entry; 00431 /* Is it an exact match? */ 00432 if (!entry->mask[matchlen]) { 00433 tie = 1; 00434 break; 00435 } 00436 else tie++; 00437 } 00438 } 00439 else { 00440 if (table->match_type & MATCH_CASE) cmp = strcmp(entry->mask, match); 00441 else cmp = strcasecmp(entry->mask, match); 00442 } 00443 if (cmp) continue; /* Doesn't match. */ 00444 00445 if (hits) (*hits)++; 00446 00447 retval = bind_entry_exec(table, entry, args); 00448 if ((table->flags & BIND_BREAKABLE) && (retval & BIND_RET_BREAK)) break; 00449 } 00450 /* If it's a partial match table, see if we have 1 winner. */ 00451 if (winner && tie == 1) { 00452 if (hits) (*hits)++; 00453 retval = bind_entry_exec(table, winner, args); 00454 } 00455 00456 return(retval); 00457 }
static int internal_bind_cleanup | ( | ) | [static] |
Definition at line 41 of file binds.c.
References BIND_DELETED, bind_entry_really_del(), bind_table_really_del(), bind_table_b::entries, bind_entry_b::flags, bind_table_b::flags, bind_entry_b::next, and bind_table_b::next.
Referenced by kill_binds_by_owner(), and schedule_bind_cleanup().
00042 { 00043 bind_table_t *table, *next_table; 00044 bind_entry_t *entry, *next_entry; 00045 00046 for (table = bind_table_list_head; table; table = next_table) { 00047 next_table = table->next; 00048 if (table->flags & BIND_DELETED) { 00049 bind_table_really_del(table); 00050 continue; 00051 } 00052 for (entry = table->entries; entry; entry = next_entry) { 00053 next_entry = entry->next; 00054 if (entry->flags & BIND_DELETED) bind_entry_really_del(table, entry); 00055 } 00056 } 00057 return(0); 00058 }
void kill_binds | ( | void | ) |
Definition at line 65 of file binds.c.
References bind_table_del().
00066 { 00067 while (bind_table_list_head) bind_table_del(bind_table_list_head); 00068 }
int kill_binds_by_owner | ( | egg_module_t * | 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 }
static void schedule_bind_cleanup | ( | ) | [static] |
Definition at line 60 of file binds.c.
References garbage_add(), GARBAGE_ONCE, internal_bind_cleanup(), and NULL.
Referenced by bind_entry_del(), and bind_table_del().
00061 { 00062 garbage_add(internal_bind_cleanup, NULL, GARBAGE_ONCE); 00063 }
bind_table_t* bind_table_list_head = NULL [static] |
const char rcsid[] = "$Id: binds.c,v 1.30 2007-01-13 12:23:39 sven Exp $" [static] |