#include "copyright.h"
#include "config.h"
#include "db.h"
#include "rbtree.h"
#include "nametab.h"
Include dependency graph for rbtab.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | rbtable |
Typedefs | |
typedef rbtable | HASHTAB |
typedef rbtable | RBTAB |
typedef rbtable | NHSHTAB |
Functions | |
void | hashinit (RBTAB *, int) |
void | hashreset (RBTAB *) |
int | hashval (char *, int) |
int | get_hashmask (void *) |
void * | hashfind (char *, RBTAB *) |
int | hashadd (char *, void *, RBTAB *) |
void | hashdelete (char *, RBTAB *) |
void | hashflush (RBTAB *, int) |
int | hashrepl (char *, void *, RBTAB *) |
void | hashreplall (void *, void *, RBTAB *) |
char * | hashinfo (const char *, RBTAB *) |
int | search_nametab (dbref, NAMETAB *, char *) |
NAMETAB * | find_nametab_ent (dbref, NAMETAB *, char *) |
void | display_nametab (dbref, NAMETAB *, char *, int) |
void | interp_nametab (dbref, NAMETAB *, int, char *, char *, char *) |
void | listset_nametab (dbref, NAMETAB *, int, char *, int) |
void * | hash_nextentry (RBTAB *htab) |
void * | hash_firstentry (RBTAB *htab) |
char * | hash_firstkey (RBTAB *htab) |
char * | hash_nextkey (RBTAB *htab) |
void | nhashinit (RBTAB *, int) |
void | nhashreset (RBTAB *) |
void * | nhash_nextentry (RBTAB *htab) |
void * | nhash_firstentry (RBTAB *htab) |
char * | nhashinfo (const char *, RBTAB *) |
void * | nhashfind (int, RBTAB *) |
int | nhashadd (int, void *, RBTAB *) |
void | nhashdelete (int, RBTAB *) |
void | nhashflush (RBTAB *, int) |
int | nhashrepl (int, void *, RBTAB *) |
Variables | |
NAMETAB | powers_nametab [] |
Definition at line 58 of file nametab.c.
References alloc_lbuf, check_access(), God, name_table::name, and name_table::perm.
Referenced by do_list(), do_list_file(), and list_cmdswitches().
00060 { 00061 char *buf, *bp, *cp; 00062 NAMETAB *nt; 00063 int got_one; 00064 00065 buf = alloc_lbuf("display_nametab"); 00066 bp = buf; 00067 got_one = 0; 00068 for(cp = prefix; *cp; cp++) 00069 *bp++ = *cp; 00070 for(nt = ntab; nt->name; nt++) { 00071 if(God(player) || check_access(player, nt->perm)) { 00072 *bp++ = ' '; 00073 for(cp = nt->name; *cp; cp++) 00074 *bp++ = *cp; 00075 got_one = 1; 00076 } 00077 } 00078 *bp = '\0'; 00079 if(got_one || list_if_none) 00080 notify(player, buf); 00081 free_lbuf(buf); 00082 }
Definition at line 39 of file nametab.c.
References check_access(), name_table::minlen, minmatch(), name_table::name, and name_table::perm.
Referenced by cf_cmd_alias(), and do_set().
00040 { 00041 NAMETAB *nt; 00042 00043 for(nt = ntab; nt->name; nt++) { 00044 if(minmatch(flagname, nt->name, nt->minlen)) { 00045 if(check_access(player, nt->perm)) { 00046 return nt; 00047 } 00048 } 00049 } 00050 return NULL; 00051 }
int get_hashmask | ( | void * | ) |
void* hash_firstentry | ( | RBTAB * | htab | ) |
Definition at line 187 of file rbtab.c.
References string_dict_entry::data, string_dict_entry::key, rbtable::last, rb_search(), SEARCH_FIRST, and rbtable::tree.
Referenced by do_chanlist(), do_channelnuke(), do_dbclean(), do_listchannels(), fun_clist(), hash_nextentry(), help_write(), helpindex_read(), save_comsystem(), and vattr_first().
00188 { 00189 struct string_dict_entry *ent; 00190 00191 if(htab->last) 00192 free(htab->last); 00193 00194 ent = rb_search(htab->tree, SEARCH_FIRST, NULL); 00195 if(ent) { 00196 htab->last = strdup(ent->key); 00197 return ent->data; 00198 } 00199 htab->last = NULL; 00200 00201 return NULL; 00202 }
char* hash_firstkey | ( | RBTAB * | htab | ) |
Definition at line 224 of file rbtab.c.
References string_dict_entry::key, rbtable::last, rb_search(), SEARCH_FIRST, and rbtable::tree.
Referenced by hash_nextkey().
00225 { 00226 struct string_dict_entry *ent; 00227 if(htab->last) 00228 free(htab->last); 00229 00230 ent = rb_search(htab->tree, SEARCH_FIRST, NULL); 00231 if(ent) { 00232 htab->last = strdup(ent->key); 00233 return ent->key; 00234 } 00235 htab->last = NULL; 00236 00237 return NULL; 00238 }
void* hash_nextentry | ( | RBTAB * | htab | ) |
Definition at line 204 of file rbtab.c.
References string_dict_entry::data, hash_firstentry(), string_dict_entry::key, rbtable::last, rb_search(), SEARCH_GT, and rbtable::tree.
Referenced by do_chanlist(), do_channelnuke(), do_dbclean(), do_listchannels(), fun_clist(), help_write(), helpindex_read(), save_comsystem(), and vattr_next().
00205 { 00206 struct string_dict_entry *ent; 00207 00208 if(!htab->last) { 00209 return hash_firstentry(htab); 00210 } 00211 00212 ent = rb_search(htab->tree, SEARCH_GT, htab->last); 00213 free(htab->last); 00214 00215 if(ent) { 00216 htab->last = strdup(ent->key); 00217 return ent->data; 00218 } else { 00219 htab->last = NULL; 00220 return NULL; 00221 } 00222 }
char* hash_nextkey | ( | RBTAB * | htab | ) |
Definition at line 240 of file rbtab.c.
References hash_firstkey(), string_dict_entry::key, rbtable::last, rb_search(), SEARCH_NEXT, and rbtable::tree.
00241 { 00242 struct string_dict_entry *ent; 00243 00244 if(!htab->last) { 00245 return hash_firstkey(htab); 00246 } 00247 00248 ent = rb_search(htab->tree, SEARCH_NEXT, htab->last); 00249 free(htab->last); 00250 00251 if(ent) { 00252 htab->last = strdup(ent->key); 00253 return ent->key; 00254 } else { 00255 htab->last = NULL; 00256 return NULL; 00257 } 00258 }
int hashadd | ( | char * | , | |
void * | , | |||
RBTAB * | ||||
) |
Definition at line 68 of file rbtab.c.
References string_dict_entry::data, string_dict_entry::key, rb_exists(), rb_insert(), and rbtable::tree.
Referenced by cf_alias(), cf_cmd_alias(), cf_flagalias(), do_createchannel(), helpindex_read(), init_attrtab(), init_btechstats(), init_cmdtab(), init_flagtab(), init_functab(), init_logout_cmdtab(), init_mactab(), init_powertab(), InitSpecialHash(), load_comsystem(), mmdb_db_read(), and vattr_define().
00069 { 00070 struct string_dict_entry *ent = malloc(sizeof(struct string_dict_entry)); 00071 00072 if(rb_exists(htab->tree, str)) 00073 return (-1); 00074 00075 ent->key = strdup(str); 00076 ent->data = hashdata; 00077 00078 rb_insert(htab->tree, ent->key, ent); 00079 return 0; 00080 00081 }
void hashdelete | ( | char * | , | |
RBTAB * | ||||
) |
Definition at line 88 of file rbtab.c.
References string_dict_entry::key, rb_delete(), rb_exists(), and rbtable::tree.
Referenced by do_channelnuke(), do_dbclean(), do_destroychannel(), and vattr_delete().
00089 { 00090 struct string_dict_entry *ent = NULL; 00091 00092 if(!rb_exists(htab->tree, str)) { 00093 return; 00094 } 00095 ent = rb_delete(htab->tree, str); 00096 00097 if(ent) { 00098 if(ent->key) 00099 free(ent->key); 00100 free(ent); 00101 } 00102 00103 return; 00104 }
void* hashfind | ( | char * | , | |
RBTAB * | ||||
) |
Definition at line 50 of file rbtab.c.
References rbtable::checks, string_dict_entry::data, rb_find(), and rbtable::tree.
Referenced by add_player_name(), atr_str(), cf_access(), cf_acmd_access(), cf_alias(), cf_cmd_alias(), cf_flagalias(), cf_set_flags(), char_getvaluecode(), check_command(), decode_power(), delete_player_name(), do_addcommand(), do_command(), do_delcommand(), do_destroychannel(), do_function(), do_listcommands(), do_macro(), do_unauth_command(), exec(), find_flag(), find_matching_short_part(), find_matching_vlong_part(), find_power(), HandledCommand_sub(), help_write(), lookup_player(), process_command(), select_channel(), set_prefix_cmds(), vattr_delete(), vattr_find(), and vattr_rename().
00051 { 00052 int hval, numchecks; 00053 struct string_dict_entry *ent; 00054 00055 htab->checks++; 00056 ent = rb_find(htab->tree, str); 00057 if(ent) { 00058 return ent->data; 00059 } else 00060 return (void *)ent; 00061 }
void hashflush | ( | RBTAB * | , | |
int | ||||
) |
Definition at line 119 of file rbtab.c.
References hrbtab_compare(), rbtable::last, nuke_hash_ent(), rb_destroy(), rb_init(), rb_walk(), rbtable::tree, and WALK_POSTORDER.
Referenced by helpindex_read().
00120 { 00121 rb_walk(htab->tree, WALK_POSTORDER, nuke_hash_ent, NULL); 00122 rb_destroy(htab->tree); 00123 htab->tree = rb_init((void *)hrbtab_compare, NULL); 00124 if(htab->last) 00125 free(htab->last); 00126 htab->last = NULL; 00127 }
char* hashinfo | ( | const char * | , | |
RBTAB * | ||||
) |
Definition at line 174 of file rbtab.c.
References alloc_mbuf, rb_size(), and rbtable::tree.
00175 { 00176 char *buff; 00177 00178 buff = alloc_mbuf("hashinfo"); 00179 sprintf(buff, "%-15s %8d", tab_name, rb_size(htab->tree)); 00180 return buff; 00181 }
void hashinit | ( | RBTAB * | , | |
int | ||||
) |
Definition at line 25 of file rbtab.c.
References hrbtab_compare(), rbtable::last, rb_init(), and rbtable::tree.
Referenced by helpindex_init(), init_attrtab(), init_btechstats(), init_chantab(), init_cmdtab(), init_flagtab(), init_functab(), init_logout_cmdtab(), init_mactab(), init_powertab(), initialize_partname_tables(), InitSpecialHash(), main(), and vattr_init().
00026 { 00027 memset(htab, 0, sizeof(RBTAB)); 00028 htab->tree = rb_init((void *)hrbtab_compare, NULL); 00029 htab->last = NULL; 00030 }
int hashrepl | ( | char * | , | |
void * | , | |||
RBTAB * | ||||
) |
Definition at line 134 of file rbtab.c.
References string_dict_entry::data, rb_find(), and rbtable::tree.
00135 { 00136 struct string_dict_entry *ent; 00137 00138 ent = rb_find(htab->tree, str); 00139 if(!ent) 00140 return 0; 00141 00142 ent->data = hashdata; 00143 return 1; 00144 }
void hashreplall | ( | void * | , | |
void * | , | |||
RBTAB * | ||||
) |
Definition at line 162 of file rbtab.c.
References hashreplall_cb(), rb_walk(), rbtable::tree, and WALK_INORDER.
00163 { 00164 struct hashreplstat repl = { old, new }; 00165 00166 rb_walk(htab->tree, WALK_INORDER, hashreplall_cb, &repl); 00167 }
void hashreset | ( | RBTAB * | ) |
Definition at line 37 of file rbtab.c.
References rbtable::checks, rbtable::hits, and rbtable::scans.
Referenced by helpindex_read(), and main().
int hashval | ( | char * | , | |
int | ||||
) |
Definition at line 89 of file nametab.c.
References alloc_lbuf, check_access(), name_table::flag, God, name, name_table::name, and name_table::perm.
Referenced by do_list().
00091 { 00092 char *buf, *bp, *cp; 00093 NAMETAB *nt; 00094 00095 buf = alloc_lbuf("interp_nametab"); 00096 bp = buf; 00097 for(cp = prefix; *cp; cp++) 00098 *bp++ = *cp; 00099 nt = ntab; 00100 while (nt->name) { 00101 if(God(player) || check_access(player, nt->perm)) { 00102 *bp++ = ' '; 00103 for(cp = nt->name; *cp; cp++) 00104 *bp++ = *cp; 00105 *bp++ = '.'; 00106 *bp++ = '.'; 00107 *bp++ = '.'; 00108 if((flagword & nt->flag) != 0) 00109 cp = true_text; 00110 else 00111 cp = false_text; 00112 while (*cp) 00113 *bp++ = *cp++; 00114 if((++nt)->name) 00115 *bp++ = ';'; 00116 } 00117 } 00118 *bp = '\0'; 00119 notify(player, buf); 00120 free_lbuf(buf); 00121 }
Definition at line 128 of file nametab.c.
References alloc_lbuf, check_access(), name_table::flag, God, name_table::name, and name_table::perm.
Referenced by list_attraccess(), list_cf_access(), list_cmdaccess(), and list_vattrs().
00130 { 00131 char *buf, *bp, *cp; 00132 NAMETAB *nt; 00133 int got_one; 00134 00135 buf = bp = alloc_lbuf("listset_nametab"); 00136 for(cp = prefix; *cp; cp++) 00137 *bp++ = *cp; 00138 nt = ntab; 00139 got_one = 0; 00140 while (nt->name) { 00141 if(((flagword & nt->flag) != 0) && (God(player) || 00142 check_access(player, nt->perm))) { 00143 *bp++ = ' '; 00144 for(cp = nt->name; *cp; cp++) 00145 *bp++ = *cp; 00146 got_one = 1; 00147 } 00148 nt++; 00149 } 00150 *bp = '\0'; 00151 if(got_one || list_if_none) 00152 notify(player, buf); 00153 free_lbuf(buf); 00154 }
void* nhash_firstentry | ( | RBTAB * | htab | ) |
void* nhash_nextentry | ( | RBTAB * | htab | ) |
int nhashadd | ( | int | , | |
void * | , | |||
RBTAB * | ||||
) |
Definition at line 49 of file nrbtab.c.
References rb_exists(), rb_insert(), and rbtable::tree.
Referenced by atr_match1(), find_wild_attrs(), fwdlist_set(), load_mail(), look_atrs1(), and send_mail().
00050 { 00051 if(rb_exists(htab->tree, (void *) val)) 00052 return (-1); 00053 rb_insert(htab->tree, (void *) val, hashdata); 00054 return 0; 00055 00056 }
void nhashdelete | ( | int | , | |
RBTAB * | ||||
) |
Definition at line 63 of file nrbtab.c.
References rb_delete(), and rbtable::tree.
Referenced by do_mail_purge(), and fwdlist_clr().
00064 { 00065 rb_delete(htab->tree, (void *) val); 00066 return; 00067 }
void* nhashfind | ( | int | , | |
RBTAB * | ||||
) |
Definition at line 38 of file nrbtab.c.
References rbtable::checks, rb_find(), and rbtable::tree.
Referenced by atr_match1(), count_mail(), do_mail_file(), do_mail_flags(), do_mail_list(), do_mail_purge(), do_mail_read(), do_mail_retract(), do_mail_review(), dump_mail(), find_wild_attrs(), fwdlist_get(), load_mail(), look_atrs1(), mail_fetch(), send_mail(), and urgent_mail().
00039 { 00040 htab->checks++; 00041 return rb_find(htab->tree, (void *) val); 00042 }
void nhashflush | ( | RBTAB * | , | |
int | ||||
) |
Definition at line 74 of file nrbtab.c.
References rbtable::last, nhrbtab_compare(), rb_destroy(), rb_init(), and rbtable::tree.
Referenced by atr_match(), look_atrs(), and parse_attrib_wild().
00075 { 00076 rb_destroy(htab->tree); 00077 htab->tree = rb_init((void *)nhrbtab_compare, NULL); 00078 htab->last = NULL; 00079 }
char* nhashinfo | ( | const char * | , | |
RBTAB * | ||||
) |
void nhashinit | ( | RBTAB * | , | |
int | ||||
) |
Definition at line 18 of file nrbtab.c.
References rbtable::last, nhrbtab_compare(), rb_init(), and rbtable::tree.
Referenced by main().
00019 { 00020 memset(htab, 0, sizeof(RBTAB)); 00021 htab->tree = rb_init((void *) nhrbtab_compare, NULL); 00022 htab->last = NULL; 00023 }
int nhashrepl | ( | int | , | |
void * | , | |||
RBTAB * | ||||
) |
Definition at line 86 of file nrbtab.c.
References rb_insert(), and rbtable::tree.
Referenced by check_mail_expiration(), do_mail_debug(), do_mail_purge(), do_mail_retract(), and fwdlist_set().
00087 { 00088 struct int_dict_entry *ent; 00089 00090 rb_insert(htab->tree, (void *) val, hashdata); 00091 return 1; 00092 }
void nhashreset | ( | RBTAB * | ) |
Definition at line 25 of file nrbtab.c.
References rbtable::checks, rbtable::hits, and rbtable::scans.
Referenced by main().
Definition at line 19 of file nametab.c.
References check_access(), name_table::flag, name_table::minlen, minmatch(), name_table::name, and name_table::perm.
Referenced by cf_bool(), cf_modify_bits(), cf_option(), cf_or_in_bits(), cf_set_bits(), do_attribute(), do_global(), do_list(), do_list_file(), do_set(), fun_set(), fun_setlock(), get_obj_and_lock(), and process_cmdent().
00020 { 00021 NAMETAB *nt; 00022 00023 for(nt = ntab; nt->name; nt++) { 00024 if(minmatch(flagname, nt->name, nt->minlen)) { 00025 if(check_access(player, nt->perm)) { 00026 return nt->flag; 00027 } else 00028 return -2; 00029 } 00030 } 00031 return -1; 00032 }