/[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.15 - (show annotations) (download) (as text)
Fri Sep 20 21:41:49 2002 UTC (17 years, 1 month ago) by stdarg
Branch: MAIN
Changes since 1.14: +1 -2 lines
File MIME type: text/x-csrc
* Mo-Ize removed the botnet code, thanks

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23