/[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.20 - (show annotations) (download) (as text)
Sun May 11 02:40:28 2003 UTC (16 years, 5 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +1 -1 lines
File MIME type: text/x-csrc
FILE REMOVED
* Remove some stray files

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, 2003 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.19 2003/02/25 06:52:19 stdarg Exp $
26 */
27
28 #ifndef _EGG_USERS_H
29 #define _EGG_USERS_H
30
31 /* List functions :) , next *must* be the 1st item in the struct */
32 struct list_type {
33 struct list_type *next;
34 char *extra;
35 };
36
37 #define list_insert(a,b) { \
38 (b)->next = *(a); \
39 *(a) = (b); \
40 }
41 int list_append(struct list_type **, struct list_type *);
42 int list_delete(struct list_type **, struct list_type *);
43 int list_contains(struct list_type *, struct list_type *);
44
45
46 /* New userfile format stuff
47 */
48 struct userrec;
49 struct user_entry;
50 struct user_entry_type {
51 struct user_entry_type *next;
52 int (*got_share) (struct userrec *, struct user_entry *, char *, int);
53 int (*dup_user) (struct userrec *, struct userrec *, struct user_entry *);
54 int (*unpack) (struct userrec *, struct user_entry *);
55 int (*pack) (struct userrec *, struct user_entry *);
56 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
57 int (*kill) (struct user_entry *);
58 void *(*get) (struct userrec *, struct user_entry *);
59 int (*set) (struct userrec *, struct user_entry *, void *);
60 void *ignore1;
61 void *ignore2;
62 void (*display) (int idx, struct user_entry *);
63 char *name;
64 };
65
66
67 #ifndef MAKING_MODS
68 extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
69 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
70 USERENTRY_PASS, USERENTRY_BOTFL;
71 #endif
72
73
74 struct laston_info {
75 time_t laston;
76 char *lastonplace;
77 };
78
79 struct bot_addr {
80 int telnet_port;
81 int relay_port;
82 char *address;
83 };
84
85 struct user_entry {
86 struct user_entry *next;
87 struct user_entry_type *type;
88 union {
89 char *string;
90 void *extra;
91 struct list_type *list;
92 unsigned long ulong;
93 } u;
94 char *name;
95 };
96
97 struct xtra_key {
98 struct xtra_key *next;
99 char *key;
100 char *data;
101 };
102
103 struct filesys_stats {
104 int uploads;
105 int upload_ks;
106 int dnloads;
107 int dnload_ks;
108 };
109
110 int user_init();
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 void addignore(char *, char *, char *, time_t);
119 int delignore(char *);
120 void tell_ignores(int, char *);
121 int match_ignore(char *);
122 void check_expired_ignores();
123 void tell_file_stats(int, char *);
124 void tell_user_ident(int, char *, int);
125 void tell_users_match(int, char *, int, int, int, char *);
126 int readuserfile(char *, struct userrec **);
127 void backup_userfile(void);
128
129 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
130 #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
131 #define is_master(u) ((u) && ((u)->flags & USER_MASTER))
132 #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
133
134 /* Fake users used to store ignores and bans
135 */
136 #define IGNORE_NAME "*ignore"
137 #define BAN_NAME "*ban"
138 #define EXEMPT_NAME "*exempt"
139 #define INVITE_NAME "*Invite"
140
141 /* Channel-specific info
142 */
143 struct chanuserrec {
144 struct chanuserrec *next;
145 char channel[81];
146 time_t laston;
147 unsigned long flags;
148 unsigned long flags_udef;
149 char *info;
150 };
151
152 /* New-style userlist
153 */
154 struct userrec {
155 struct userrec *next;
156 char handle[HANDLEN + 1];
157 unsigned long flags;
158 unsigned long flags_udef;
159 struct chanuserrec *chanrec;
160 struct user_entry *entries;
161 };
162
163 struct igrec {
164 struct igrec *next;
165 char *igmask;
166 time_t expire;
167 char *user;
168 time_t added;
169 char *msg;
170 int flags;
171 };
172 extern struct igrec *global_ign;
173
174 #define IGREC_PERM 2
175
176 /*
177 * Note: Flags are in eggdrop.h
178 */
179
180 struct userrec *adduser();
181 struct userrec *get_user_by_handle(struct userrec *, const char *);
182 user_t *get_user_authed(char *handle, char *pass);
183 struct userrec *get_user_by_host(char *);
184 struct userrec *get_user_by_nick(char *);
185 struct userrec *check_chanlist();
186 struct userrec *check_chanlist_hand();
187
188 /* All the default userentry stuff, for code re-use
189 */
190 int def_unpack(struct userrec *u, struct user_entry *e);
191 int def_pack(struct userrec *u, struct user_entry *e);
192 int def_kill(struct user_entry *e);
193 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
194 void *def_get(struct userrec *u, struct user_entry *e);
195 int def_set(struct userrec *u, struct user_entry *e, void *buf);
196 int def_gotshare(struct userrec *u, struct user_entry *e,
197 char *data, int idx);
198 void def_display(int idx, struct user_entry *e);
199 int def_dupuser(struct userrec *new, struct userrec *old,
200 struct user_entry *e);
201
202 #endif /* !_EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23