#include <sys/stat.h>
#include "main.h"
#include "users.h"
#include "chan.h"
#include "modules.h"
#include "tandem.h"
Go to the source code of this file.
Functions | |
char ((char *) global[118])[] | |
struct userrec *(*) | struct (global[95]))=0 |
maskrec *(*)*(*) | maskrec (global[220]))=0 |
maskrec *(*)*(*)*(*) | maskrec (global[221]))=0 |
struct igrec *(*) | struct (global[97]))=0 |
void * | _user_malloc (int size, const char *file, int line) |
void * | _user_realloc (void *ptr, int size, const char *file, int line) |
int | expmem_mask (struct maskrec *m) |
int | expmem_users () |
int ((int(*)(struct userrec *)) global[62])(struct userrec *bu) | |
char *char *char | global (char *s) |
struct userrec * | check_dcclist_hand (char *handle) |
struct userrec *struct userrec *struct | global (struct userrec *bu, char *handle) |
void | correct_handle (char *handle) |
void | clear_masks (maskrec *m) |
void ((void(*)(struct userrec *)) global[61])(struct userrec *bu) | |
struct userrec * | get_user_by_equal_host (char *host) |
int ((int(*)(struct userrec *, char *)) global[38])(struct userrec *u | |
struct userrec *struct userrec *struct | global (struct userrec *bu, char *handle, char *host, char *pass, int flags) |
void | freeuser (struct userrec *u) |
int ((int(*)(char *)) global[51])(char *handle) | |
int ((int(*)(char *, char *)) global[53])(char *handle | |
Variables | |
struct dcc_t *struct | global [92] = 0 |
struct chanset_t *(* | struct )(global[93])) |
int int | default_uflags |
int int | quiet_save |
int(* | int )(global[107])) = 1 |
int | sort_users = 0 |
maskrec *(* | maskrec )(global[96]))=0 |
int | cache_hit = 0 |
int | cache_miss = 0 |
int | strict_host = 1 |
void* _user_malloc | ( | int | size, | |
const char * | file, | |||
int | line | |||
) |
Definition at line 52 of file userrec.c.
References n_malloc(), nmalloc, and simple_sprintf.
00053 { 00054 #ifdef DEBUG_MEM 00055 char x[1024]; 00056 const char *p; 00057 00058 p = strrchr(file, '/'); 00059 simple_sprintf(x, "userrec.c:%s", p ? p + 1 : file); 00060 return n_malloc(size, x, line); 00061 #else 00062 return nmalloc(size); 00063 #endif 00064 }
void* _user_realloc | ( | void * | ptr, | |
int | size, | |||
const char * | file, | |||
int | line | |||
) |
Definition at line 66 of file userrec.c.
References n_realloc(), nrealloc, and simple_sprintf.
00067 { 00068 #ifdef DEBUG_MEM 00069 char x[1024]; 00070 const char *p; 00071 00072 p = strrchr(file, '/'); 00073 simple_sprintf(x, "userrec.c:%s", p ? p + 1 : file); 00074 return n_realloc(ptr, size, x, line); 00075 #else 00076 return nrealloc(ptr, size); 00077 #endif 00078 }
char | ( | (char *) | global[118] | ) |
struct userrec* check_dcclist_hand | ( | char * | handle | ) | [read] |
Definition at line 190 of file userrec.c.
References dcc_total, egg_strcasecmp, NULL, and dcc_t::user.
Referenced by global().
00191 { 00192 int i; 00193 00194 for (i = 0; i < dcc_total; i++) 00195 if (!egg_strcasecmp(dcc[i].nick, handle)) 00196 return dcc[i].user; 00197 return NULL; 00198 }
void clear_masks | ( | maskrec * | m | ) |
Definition at line 251 of file userrec.c.
References maskrec::desc, maskrec::mask, maskrec::next, nfree, NULL, and maskrec::user.
Referenced by void().
00252 { 00253 maskrec *temp = NULL; 00254 00255 for (; m; m = temp) { 00256 temp = m->next; 00257 if (m->mask) 00258 nfree(m->mask); 00259 if (m->user) 00260 nfree(m->user); 00261 if (m->desc) 00262 nfree(m->desc); 00263 nfree(m); 00264 } 00265 }
void correct_handle | ( | char * | handle | ) |
Definition at line 238 of file userrec.c.
References get_user_by_handle, userrec::handle, and NULL.
Referenced by botlink(), cmd_su(), and dcc_telnet_id().
00239 { 00240 struct userrec *u; 00241 00242 u = get_user_by_handle(userlist, handle); 00243 if (u == NULL || handle == u->handle) 00244 return; 00245 strcpy(handle, u->handle); 00246 }
int expmem_mask | ( | struct maskrec * | m | ) | [inline] |
Definition at line 80 of file userrec.c.
References maskrec::desc, maskrec::mask, maskrec::next, and maskrec::user.
Referenced by expmem_users().
00081 { 00082 int result = 0; 00083 00084 for (; m; m = m->next) { 00085 result += sizeof(struct maskrec); 00086 result += strlen(m->mask) + 1; 00087 if (m->user) 00088 result += strlen(m->user) + 1; 00089 if (m->desc) 00090 result += strlen(m->desc) + 1; 00091 } 00092 00093 return result; 00094 }
int expmem_users | ( | ) |
Definition at line 98 of file userrec.c.
References chanset_t::bans, userrec::chanrec, userrec::entries, chanset_t::exempts, user_entry_type::expmem, expmem_mask(), global_exempts, global_invites, igrec::igmask, chanuserrec::info, chanset_t::invites, user_entry::list, list_type_expmem(), igrec::msg, user_entry::name, igrec::next, chanset_t::next, user_entry::next, chanuserrec::next, userrec::next, NULL, user_entry::type, user_entry::u, and igrec::user.
Referenced by debug_mem_to_dcc(), and expected_memory().
00099 { 00100 int tot; 00101 struct userrec *u; 00102 struct chanuserrec *ch; 00103 struct chanset_t *chan; 00104 struct user_entry *ue; 00105 struct igrec *i; 00106 00107 tot = 0; 00108 for (u = userlist; u; u = u->next) { 00109 for (ch = u->chanrec; ch; ch = ch->next) { 00110 tot += sizeof(struct chanuserrec); 00111 00112 if (ch->info != NULL) 00113 tot += strlen(ch->info) + 1; 00114 } 00115 tot += sizeof(struct userrec); 00116 00117 for (ue = u->entries; ue; ue = ue->next) { 00118 tot += sizeof(struct user_entry); 00119 00120 if (ue->name) { 00121 tot += strlen(ue->name) + 1; 00122 tot += list_type_expmem(ue->u.list); 00123 } else 00124 tot += ue->type->expmem(ue); 00125 } 00126 } 00127 /* Account for each channel's masks */ 00128 for (chan = chanset; chan; chan = chan->next) { 00129 00130 /* Account for each channel's ban-list user */ 00131 tot += expmem_mask(chan->bans); 00132 00133 /* Account for each channel's exempt-list user */ 00134 tot += expmem_mask(chan->exempts); 00135 00136 /* Account for each channel's invite-list user */ 00137 tot += expmem_mask(chan->invites); 00138 } 00139 00140 tot += expmem_mask(global_bans); 00141 tot += expmem_mask(global_exempts); 00142 tot += expmem_mask(global_invites); 00143 00144 for (i = global_ign; i; i = i->next) { 00145 tot += sizeof(struct igrec); 00146 00147 tot += strlen(i->igmask) + 1; 00148 if (i->user) 00149 tot += strlen(i->user) + 1; 00150 if (i->msg) 00151 tot += strlen(i->msg) + 1; 00152 } 00153 return tot; 00154 }
void freeuser | ( | struct userrec * | u | ) |
Definition at line 704 of file userrec.c.
References userrec::chanrec, userrec::entries, list_type::extra, chanuserrec::info, user_entry_type::kill, user_entry::list, user_entry::name, list_type::next, user_entry::next, chanuserrec::next, nfree, NULL, user_entry::type, user_entry::u, and ut.
Referenced by int(), and void().
00705 { 00706 struct user_entry *ue, *ut; 00707 struct chanuserrec *ch, *z; 00708 00709 if (u == NULL) 00710 return; 00711 00712 ch = u->chanrec; 00713 while (ch) { 00714 z = ch; 00715 ch = ch->next; 00716 if (z->info != NULL) 00717 nfree(z->info); 00718 nfree(z); 00719 } 00720 u->chanrec = NULL; 00721 for (ue = u->entries; ue; ue = ut) { 00722 ut = ue->next; 00723 if (ue->name) { 00724 struct list_type *lt, *ltt; 00725 00726 for (lt = ue->u.list; lt; lt = ltt) { 00727 ltt = lt->next; 00728 nfree(lt->extra); 00729 nfree(lt); 00730 } 00731 nfree(ue->name); 00732 nfree(ue); 00733 } else 00734 ue->type->kill(ue); 00735 } 00736 nfree(u); 00737 }
struct userrec* get_user_by_equal_host | ( | char * | host | ) | [read] |
Definition at line 348 of file userrec.c.
References list_type::extra, get_user, list_type::next, userrec::next, NULL, rfc_casecmp, and USERENTRY_HOSTS.
00349 { 00350 struct userrec *u; 00351 struct list_type *q; 00352 00353 for (u = userlist; u; u = u->next) 00354 for (q = get_user(&USERENTRY_HOSTS, u); q; q = q->next) 00355 if (!rfc_casecmp(q->extra, host)) 00356 return u; 00357 return NULL; 00358 }
struct userrec* struct userrec* struct global | ( | struct userrec * | bu, | |
char * | handle, | |||
char * | host, | |||
char * | pass, | |||
int | flags | |||
) | [read] |
Definition at line 617 of file userrec.c.
References build_flags, userrec::chanrec, clear_chanlist, xtra_key::data, default_flags, default_uflags, userrec::entries, fixfrom, userrec::flags, userrec::flags_udef, FR_GLOBAL, flag_record::global, userrec::handle, xtra_key::key, userrec::next, nfree, nmalloc, noshare, now, NULL, set_user, shareout, strncpyz, flag_record::udef_global, USER_DEFAULT, USER_UNSHARED, USERENTRY_HOSTS, USERENTRY_PASS, and USERENTRY_XTRA.
00619 { 00620 struct userrec *u, *x; 00621 struct xtra_key *xk; 00622 int oldshare = noshare; 00623 long tv; 00624 00625 noshare = 1; 00626 u = nmalloc(sizeof *u); 00627 00628 /* u->next=bu; bu=u; */ 00629 strncpyz(u->handle, handle, sizeof u->handle); 00630 u->next = NULL; 00631 u->chanrec = NULL; 00632 u->entries = NULL; 00633 if (flags != USER_DEFAULT) { /* drummer */ 00634 u->flags = flags; 00635 u->flags_udef = 0; 00636 } else { 00637 u->flags = default_flags; 00638 u->flags_udef = default_uflags; 00639 } 00640 set_user(&USERENTRY_PASS, u, pass); 00641 if (!noxtra) { 00642 char *now2; 00643 xk = nmalloc(sizeof *xk); 00644 xk->key = nmalloc(8); 00645 strcpy(xk->key, "created"); 00646 now2 = nmalloc(15); 00647 tv = now; 00648 sprintf(now2, "%li", tv); 00649 xk->data = nmalloc(strlen(now2) + 1); 00650 sprintf(xk->data, "%li", tv); 00651 set_user(&USERENTRY_XTRA, u, xk); 00652 nfree(now2); 00653 } 00654 /* Strip out commas -- they're illegal */ 00655 if (host && host[0]) { 00656 char *p; 00657 00658 /* About this fixfrom(): 00659 * We should use this fixfrom before every call of adduser() 00660 * but its much easier to use here... (drummer) 00661 * Only use it if we have a host :) (dw) 00662 */ 00663 host = fixfrom(host); 00664 00665 p = strchr(host, ','); 00666 while (p != NULL) { 00667 *p = '?'; 00668 p = strchr(host, ','); 00669 } 00670 set_user(&USERENTRY_HOSTS, u, host); 00671 } else 00672 set_user(&USERENTRY_HOSTS, u, "none"); 00673 if (bu == userlist) 00674 clear_chanlist(); 00675 noshare = oldshare; 00676 if ((!noshare) && (handle[0] != '*') && (!(flags & USER_UNSHARED)) && 00677 (bu == userlist)) { 00678 struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 }; 00679 char x[100]; 00680 00681 fr.global = u->flags; 00682 00683 fr.udef_global = u->flags_udef; 00684 build_flags(x, &fr, 0); 00685 shareout(NULL, "n %s %s %s %s\n", handle, host && host[0] ? host : "none", 00686 pass, x); 00687 } 00688 if (bu == NULL) 00689 bu = u; 00690 else { 00691 if ((bu == userlist) && (lastuser != NULL)) 00692 x = lastuser; 00693 else 00694 x = bu; 00695 while (x->next != NULL) 00696 x = x->next; 00697 x->next = u; 00698 if (bu == userlist) 00699 lastuser = u; 00700 } 00701 return bu; 00702 }
Definition at line 200 of file userrec.c.
References cache_hit, cache_miss, check_chanlist_hand(), check_dcclist_hand(), egg_strcasecmp, userrec::handle, userrec::next, NULL, and rmspace.
00201 { 00202 struct userrec *u, *ret; 00203 00204 if (!handle) 00205 return NULL; 00206 /* FIXME: This should be done outside of this function. */ 00207 rmspace(handle); 00208 if (!handle[0] || (handle[0] == '*')) 00209 return NULL; 00210 if (bu == userlist) { 00211 if (lastuser && !egg_strcasecmp(lastuser->handle, handle)) { 00212 cache_hit++; 00213 return lastuser; 00214 } 00215 ret = check_dcclist_hand(handle); 00216 if (ret) { 00217 cache_hit++; 00218 return ret; 00219 } 00220 ret = check_chanlist_hand(handle); 00221 if (ret) { 00222 cache_hit++; 00223 return ret; 00224 } 00225 cache_miss++; 00226 } 00227 for (u = bu; u; u = u->next) 00228 if (!egg_strcasecmp(u->handle, handle)) { 00229 if (bu == userlist) 00230 lastuser = u; 00231 return u; 00232 } 00233 return NULL; 00234 }
char* char* char global | ( | char * | s | ) | [read] |
Definition at line 308 of file userrec.c.
References cache_hit, cache_miss, check_chanlist(), list_type::extra, fixfrom, get_user, match_useraddr, list_type::next, userrec::next, NULL, rmspace, set_chanlist(), strncpyz, UHOSTLEN, and USERENTRY_HOSTS.
00309 { 00310 struct userrec *u, *ret; 00311 struct list_type *q; 00312 int cnt, i; 00313 char host2[UHOSTLEN]; 00314 00315 if (host == NULL) 00316 return NULL; 00317 rmspace(host); 00318 if (!host[0]) 00319 return NULL; 00320 ret = check_chanlist(host); 00321 cnt = 0; 00322 if (ret != NULL) { 00323 cache_hit++; 00324 return ret; 00325 } 00326 cache_miss++; 00327 strncpyz(host2, host, sizeof host2); 00328 host = fixfrom(host); 00329 for (u = userlist; u; u = u->next) { 00330 q = get_user(&USERENTRY_HOSTS, u); 00331 for (; q; q = q->next) { 00332 i = match_useraddr(q->extra, host); 00333 if (i > cnt) { 00334 ret = u; 00335 cnt = i; 00336 } 00337 } 00338 } 00339 if (ret != NULL) { 00340 lastuser = ret; 00341 set_chanlist(host2, ret); 00342 } 00343 return ret; 00344 }
int | ( | (int(*)(char *, char *)) | global[53] | ) |
int | ( | (int(*)(char *)) | global[51] | ) |
Definition at line 739 of file userrec.c.
References clear_chanlist, egg_strcasecmp, userrec::flags, freeuser(), userrec::handle, userrec::next, noshare, NULL, shareout, dcc_t::user, user, and USER_UNSHARED.
00740 { 00741 struct userrec *u = userlist, *prev = NULL; 00742 int fnd = 0; 00743 00744 while ((u != NULL) && (!fnd)) { 00745 if (!egg_strcasecmp(u->handle, handle)) 00746 fnd = 1; 00747 else { 00748 prev = u; 00749 u = u->next; 00750 } 00751 } 00752 if (!fnd) 00753 return 0; 00754 if (prev == NULL) 00755 userlist = u->next; 00756 else 00757 prev->next = u->next; 00758 if (!noshare && (handle[0] != '*') && !(u->flags & USER_UNSHARED)) 00759 shareout(NULL, "k %s\n", handle); 00760 for (fnd = 0; fnd < dcc_total; fnd++) 00761 if (dcc[fnd].user == u) 00762 dcc[fnd].user = 0; /* Clear any dcc users for this entry, 00763 * null is safe-ish */ 00764 clear_chanlist(); 00765 freeuser(u); 00766 lastuser = NULL; 00767 return 1; 00768 }
int | ( | (int(*)(struct userrec *, char *)) | global[38] | ) |
int | ( | (int(*)(struct userrec *)) | global[62] | ) |
Definition at line 156 of file userrec.c.
References userrec::next.
struct igrec*(*) struct | ( | global | [97] | ) | [read, pure virtual] |
struct userrec*(*) struct | ( | global | [95] | ) | [read, pure virtual] |
void | ( | (void(*)(struct userrec *)) | global[61] | ) |
Definition at line 267 of file userrec.c.
References chanset_t::bans, clear_chanlist, clear_masks(), dcc_total, delignore, chanset_t::exempts, freeuser(), global_exempts, global_invites, igrec::igmask, chanset_t::invites, chanset_t::next, userrec::next, NULL, and user.
00268 { 00269 struct userrec *u, *v; 00270 int i; 00271 00272 for (u = bu; u; u = v) { 00273 v = u->next; 00274 freeuser(u); 00275 } 00276 if (userlist == bu) { 00277 struct chanset_t *cst; 00278 00279 for (i = 0; i < dcc_total; i++) 00280 dcc[i].user = NULL; 00281 clear_chanlist(); 00282 lastuser = NULL; 00283 00284 while (global_ign) 00285 delignore(global_ign->igmask); 00286 00287 clear_masks(global_bans); 00288 clear_masks(global_exempts); 00289 clear_masks(global_invites); 00290 global_exempts = global_invites = global_bans = NULL; 00291 00292 for (cst = chanset; cst; cst = cst->next) { 00293 clear_masks(cst->bans); 00294 clear_masks(cst->exempts); 00295 clear_masks(cst->invites); 00296 00297 cst->bans = cst->exempts = cst->invites = NULL; 00298 } 00299 } 00300 /* Remember to set your userlist to NULL after calling this */ 00301 }
int cache_hit = 0 |
Definition at line 47 of file userrec.c.
Referenced by global(), main(), and tell_verbose_status().
int cache_miss = 0 |
Definition at line 47 of file userrec.c.
Referenced by global(), main(), and tell_verbose_status().
int int default_uflags |
Definition at line 104 of file main.c.
Referenced by global(), and tcl_eggint().
int(* int)(global[107])) = 1 [read] |
Definition at line 91 of file modules.c.
Referenced by base64_to_int(), cmd_languagedump(), daysdur(), msg_status(), share_feats(), strftime(), tell_verbose_status(), tell_verbose_uptime(), and uptime_report().
int int quiet_save |
int sort_users = 0 |
int strict_host = 1 |
Definition at line 48 of file userrec.c.
Referenced by add_bot_hostmask(), and cmd_adduser().
struct igrec*(* struct)(global[97]))=0 | ( | global | [93] | ) | [read] |