/[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.14 - (show annotations) (download) (as text)
Fri Sep 20 02:06:25 2002 UTC (17 years ago) by stdarg
Branch: MAIN
Changes since 1.13: +5 -2 lines
File MIME type: text/x-csrc
* Moved several things from the core into libegg
* Server module uses new network code
* Lots of stuff removed from the server module, like flood stuff, which should go into a new module
* Moved some things from irc module to server module (mostly bind stuff, like pub)
* Not everything works right now, but I wanted to get it into cvs in case my computer dies a horrible death. I'm going to combine irc/server (mostly) and make a new one for all the default protection stuff.
* Right now server messages are not queued. I thought the code was pretty much beyond repair. The new queueing code will hopefully be more maintainable.
* I'm not sure I added/removed all the files necessary! Let me know if it doesn't compile for you.

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.13 2002/05/12 15:35:44 ite 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 autolink_cycle(char *);
129 void tell_file_stats(int, char *);
130 void tell_user_ident(int, char *, int);
131 void tell_users_match(int, char *, int, int, int, char *);
132 int readuserfile(char *, struct userrec **);
133 void backup_userfile(void);
134
135 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
136 #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
137 #define is_master(u) ((u) && ((u)->flags & USER_MASTER))
138 #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
139
140 /* Fake users used to store ignores and bans
141 */
142 #define IGNORE_NAME "*ignore"
143 #define BAN_NAME "*ban"
144 #define EXEMPT_NAME "*exempt"
145 #define INVITE_NAME "*Invite"
146
147 /* Channel-specific info
148 */
149 struct chanuserrec {
150 struct chanuserrec *next;
151 char channel[81];
152 time_t laston;
153 unsigned long flags;
154 unsigned long flags_udef;
155 char *info;
156 };
157
158 /* New-style userlist
159 */
160 struct userrec {
161 struct userrec *next;
162 char handle[HANDLEN + 1];
163 unsigned long flags;
164 unsigned long flags_udef;
165 struct chanuserrec *chanrec;
166 struct user_entry *entries;
167 };
168
169 typedef struct userrec user_t;
170
171 struct igrec {
172 struct igrec *next;
173 char *igmask;
174 time_t expire;
175 char *user;
176 time_t added;
177 char *msg;
178 int flags;
179 };
180 extern struct igrec *global_ign;
181
182 #define IGREC_PERM 2
183
184 /*
185 * Note: Flags are in eggdrop.h
186 */
187
188 struct userrec *adduser();
189 struct userrec *get_user_by_handle(struct userrec *, const char *);
190 user_t *get_user_authed(char *handle, char *pass);
191 struct userrec *get_user_by_host(char *);
192 struct userrec *get_user_by_nick(char *);
193 struct userrec *check_chanlist();
194 struct userrec *check_chanlist_hand();
195
196 /* All the default userentry stuff, for code re-use
197 */
198 int def_unpack(struct userrec *u, struct user_entry *e);
199 int def_pack(struct userrec *u, struct user_entry *e);
200 int def_kill(struct user_entry *e);
201 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
202 void *def_get(struct userrec *u, struct user_entry *e);
203 int def_set(struct userrec *u, struct user_entry *e, void *buf);
204 int def_gotshare(struct userrec *u, struct user_entry *e,
205 char *data, int idx);
206 int def_tcl_get(Tcl_Interp *interp, struct userrec *u,
207 struct user_entry *e, int argc, char **argv);
208 int def_tcl_set(Tcl_Interp *irp, struct userrec *u,
209 struct user_entry *e, int argc, char **argv);
210 void def_display(int idx, struct user_entry *e);
211 int def_dupuser(struct userrec *new, struct userrec *old,
212 struct user_entry *e);
213
214 #endif /* !_EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23