/[cvs]/eggdrop1.9/src/users.h
ViewVC logotype

Contents of /eggdrop1.9/src/users.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Wed Oct 10 10:44:04 2001 UTC (18 years ago) by tothwolf
Branch: MAIN
Changes since 1.8: +1 -11 lines
File MIME type: text/x-csrc
all expmem functions and support removed
all memory status/debugging code removed
all #ifdef DEBUG_MEM code removed

nmalloc macro/n_malloc function removed, use malloc() now
mod_malloc function removed
my_strdup function removed, use malloc_strcpy macro now
channel_malloc removed, use malloc_memset macro now
n_malloc_null function removed, use malloc_memset macro now
user_malloc macro/_user_malloc function removed, use malloc() now

nrealloc macro/n_realloc function removed, use realloc() now
mod_realloc function removed

nfree macro/n_free function removed, use free() now
mod_free function removed
my_free macro removed, use free_null macro now
Tcl_Free compat macro now uses free() instead of removed n_free function

malloc->strcpy now uses malloc_strcpy macro
free(ptr);ptr=NULL; now uses free_null macro
malloc->bzero now uses malloc_memset macro
get_data_ptr macro/_get_data_ptr function removed, use malloc_memset macro now

compat memcpy removed
compat memset removed
egg_memcpy/my_memcpy misuse/mess changed to memcpy
egg_bzero/bzero macro removed, use memset() now

many uninitialized pointers now default to NULL

match.c is now compiled on it's own instead of being included into tclhash.c
match.c cleanup, removed broken/incomplete ircII compat code
wild_match macro removed, _wild_match function renamed to wild_match
wild_match_per function no longer declared static
added prototypes for wild_match and wild_match_per functions

Major function/macro changes:
  nmalloc -> malloc()
  nrealloc -> realloc()
  nfree -> free()

Bugs found and fixed during audit:
  buffer overflow in adduser()

Bugs fixed when code was removed:
  typo in filedb3.c: EBUG_MEM -> DEBUG_MEM
  extra egg_bzero call from filesys.c

1 /*
2 * users.h
3 * structures and definitions used by users.c and userrec.c
4 *
5 * $Id: users.h,v 1.8 2001/04/12 02:39:44 guppy Exp $
6 */
7 /*
8 * Copyright (C) 1997 Robey Pointer
9 * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #ifndef _EGG_USERS_H
27 #define _EGG_USERS_H
28
29 /* List functions :) , next *must* be the 1st item in the struct */
30 struct list_type {
31 struct list_type *next;
32 char *extra;
33 };
34
35 #define list_insert(a,b) { \
36 (b)->next = *(a); \
37 *(a) = (b); \
38 }
39 int list_append(struct list_type **, struct list_type *);
40 int list_delete(struct list_type **, struct list_type *);
41 int list_contains(struct list_type *, struct list_type *);
42
43
44 /* New userfile format stuff
45 */
46 struct userrec;
47 struct user_entry;
48 struct user_entry_type {
49 struct user_entry_type *next;
50 int (*got_share) (struct userrec *, struct user_entry *, char *, int);
51 int (*dup_user) (struct userrec *, struct userrec *,
52 struct user_entry *);
53 int (*unpack) (struct userrec *, struct user_entry *);
54 int (*pack) (struct userrec *, struct user_entry *);
55 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
56 int (*kill) (struct user_entry *);
57 void *(*get) (struct userrec *, struct user_entry *);
58 int (*set) (struct userrec *, struct user_entry *, void *);
59 int (*tcl_get) (Tcl_Interp *, struct userrec *, struct user_entry *,
60 int, char **);
61 int (*tcl_set) (Tcl_Interp *, struct userrec *, struct user_entry *,
62 int, char **);
63 void (*display) (int idx, struct user_entry *);
64 char *name;
65 };
66
67
68 #ifndef MAKING_MODS
69 extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
70 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
71 USERENTRY_PASS, USERENTRY_BOTFL;
72 #endif
73
74
75 struct laston_info {
76 time_t laston;
77 char *lastonplace;
78 };
79
80 struct bot_addr {
81 int telnet_port;
82 int relay_port;
83 char *address;
84 };
85
86 struct user_entry {
87 struct user_entry *next;
88 struct user_entry_type *type;
89 union {
90 char *string;
91 void *extra;
92 struct list_type *list;
93 unsigned long ulong;
94 } u;
95 char *name;
96 };
97
98 struct xtra_key {
99 struct xtra_key *next;
100 char *key;
101 char *data;
102 };
103
104 struct filesys_stats {
105 int uploads;
106 int upload_ks;
107 int dnloads;
108 int dnload_ks;
109 };
110
111 int add_entry_type(struct user_entry_type *);
112 int del_entry_type(struct user_entry_type *);
113 struct user_entry_type *find_entry_type(char *);
114 struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
115 void *get_user(struct user_entry_type *, struct userrec *);
116 int set_user(struct user_entry_type *, struct userrec *, void *);
117
118 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
119 #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
120 #define is_master(u) ((u) && ((u)->flags & USER_MASTER))
121 #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
122
123 /* Fake users used to store ignores and bans
124 */
125 #define IGNORE_NAME "*ignore"
126 #define BAN_NAME "*ban"
127 #define EXEMPT_NAME "*exempt"
128 #define INVITE_NAME "*Invite"
129
130 /* Channel-specific info
131 */
132 struct chanuserrec {
133 struct chanuserrec *next;
134 char channel[81];
135 time_t laston;
136 unsigned long flags;
137 unsigned long flags_udef;
138 char *info;
139 };
140
141 /* New-style userlist
142 */
143 struct userrec {
144 struct userrec *next;
145 char handle[HANDLEN + 1];
146 unsigned long flags;
147 unsigned long flags_udef;
148 struct chanuserrec *chanrec;
149 struct user_entry *entries;
150 };
151
152 struct igrec {
153 struct igrec *next;
154 char *igmask;
155 time_t expire;
156 char *user;
157 time_t added;
158 char *msg;
159 int flags;
160 };
161 extern struct igrec *global_ign;
162
163 #define IGREC_PERM 2
164
165 /*
166 * Note: Flags are in eggdrop.h
167 */
168
169 struct userrec *adduser();
170 struct userrec *get_user_by_handle(struct userrec *, char *);
171 struct userrec *get_user_by_host(char *);
172 struct userrec *get_user_by_nick(char *);
173 struct userrec *check_chanlist();
174 struct userrec *check_chanlist_hand();
175
176 /* All the default userentry stuff, for code re-use
177 */
178 int def_unpack(struct userrec *u, struct user_entry *e);
179 int def_pack(struct userrec *u, struct user_entry *e);
180 int def_kill(struct user_entry *e);
181 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
182 void *def_get(struct userrec *u, struct user_entry *e);
183 int def_set(struct userrec *u, struct user_entry *e, void *buf);
184 int def_gotshare(struct userrec *u, struct user_entry *e,
185 char *data, int idx);
186 int def_tcl_get(Tcl_Interp *interp, struct userrec *u,
187 struct user_entry *e, int argc, char **argv);
188 int def_tcl_set(Tcl_Interp *irp, struct userrec *u,
189 struct user_entry *e, int argc, char **argv);
190 void def_display(int idx, struct user_entry *e);
191 int def_dupuser(struct userrec *new, struct userrec *old,
192 struct user_entry *e);
193
194 #endif /* _EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23