/[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.11 - (show annotations) (download) (as text)
Sun May 5 15:19:12 2002 UTC (17 years, 5 months ago) by wingman
Branch: MAIN
Changes since 1.10: +15 -1 lines
File MIME type: text/x-csrc
Changes:

 * removed patch.h
 * added proper <filename>.h to (nearly) all <filename.h>
 * moved fixcolon to server.mod and irc.mod
 * moved ip2long to net.h
 * removed some unused function (forgot the name :-P)

Todo:

 * move config.h #include's away from main.h to files which
   needs them
 * clean up lib/eggdrop/module.h
   (now not just main.h is included but nearly all .h files from
    the core, but i guess this fixes itself when the global func
    table is abandon - then the modules must be revised too and
    we can clean up module.h)

And i'll bet i forgot something... ;-)

1 /*
2 * users.h
3 * structures and definitions used by users.c and userrec.c
4 *
5 * $Id: users.h,v 1.10 2002/02/07 22:19:05 wcc Exp $
6 */
7 /*
8 * Copyright (C) 1997 Robey Pointer
9 * Copyright (C) 1999, 2000, 2001, 2002 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 #include "tclegg.h" /* Tcl_Interp */
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 *,
54 struct user_entry *);
55 int (*unpack) (struct userrec *, struct user_entry *);
56 int (*pack) (struct userrec *, struct user_entry *);
57 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
58 int (*kill) (struct user_entry *);
59 void *(*get) (struct userrec *, struct user_entry *);
60 int (*set) (struct userrec *, struct user_entry *, void *);
61 int (*tcl_get) (Tcl_Interp *, struct userrec *, struct user_entry *,
62 int, char **);
63 int (*tcl_set) (Tcl_Interp *, struct userrec *, struct user_entry *,
64 int, char **);
65 void (*display) (int idx, struct user_entry *);
66 char *name;
67 };
68
69
70 #ifndef MAKING_MODS
71 extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
72 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
73 USERENTRY_PASS, USERENTRY_BOTFL;
74 #endif
75
76
77 struct laston_info {
78 time_t laston;
79 char *lastonplace;
80 };
81
82 struct bot_addr {
83 int telnet_port;
84 int relay_port;
85 char *address;
86 };
87
88 struct user_entry {
89 struct user_entry *next;
90 struct user_entry_type *type;
91 union {
92 char *string;
93 void *extra;
94 struct list_type *list;
95 unsigned long ulong;
96 } u;
97 char *name;
98 };
99
100 struct xtra_key {
101 struct xtra_key *next;
102 char *key;
103 char *data;
104 };
105
106 struct filesys_stats {
107 int uploads;
108 int upload_ks;
109 int dnloads;
110 int dnload_ks;
111 };
112
113 int add_entry_type(struct user_entry_type *);
114 int del_entry_type(struct user_entry_type *);
115 struct user_entry_type *find_entry_type(char *);
116 struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
117 void *get_user(struct user_entry_type *, struct userrec *);
118 int set_user(struct user_entry_type *, struct userrec *, void *);
119
120 void addignore(char *, char *, char *, time_t);
121 int delignore(char *);
122 void tell_ignores(int, char *);
123 int match_ignore(char *);
124 void check_expired_ignores();
125 void autolink_cycle(char *);
126 void tell_file_stats(int, char *);
127 void tell_user_ident(int, char *, int);
128 void tell_users_match(int, char *, int, int, int, char *);
129 int readuserfile(char *, struct userrec **);
130 void backup_userfile(void);
131
132 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
133 #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
134 #define is_master(u) ((u) && ((u)->flags & USER_MASTER))
135 #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
136
137 /* Fake users used to store ignores and bans
138 */
139 #define IGNORE_NAME "*ignore"
140 #define BAN_NAME "*ban"
141 #define EXEMPT_NAME "*exempt"
142 #define INVITE_NAME "*Invite"
143
144 /* Channel-specific info
145 */
146 struct chanuserrec {
147 struct chanuserrec *next;
148 char channel[81];
149 time_t laston;
150 unsigned long flags;
151 unsigned long flags_udef;
152 char *info;
153 };
154
155 /* New-style userlist
156 */
157 struct userrec {
158 struct userrec *next;
159 char handle[HANDLEN + 1];
160 unsigned long flags;
161 unsigned long flags_udef;
162 struct chanuserrec *chanrec;
163 struct user_entry *entries;
164 };
165
166 struct igrec {
167 struct igrec *next;
168 char *igmask;
169 time_t expire;
170 char *user;
171 time_t added;
172 char *msg;
173 int flags;
174 };
175 extern struct igrec *global_ign;
176
177 #define IGREC_PERM 2
178
179 /*
180 * Note: Flags are in eggdrop.h
181 */
182
183 struct userrec *adduser();
184 struct userrec *get_user_by_handle(struct userrec *, char *);
185 struct userrec *get_user_by_host(char *);
186 struct userrec *get_user_by_nick(char *);
187 struct userrec *check_chanlist();
188 struct userrec *check_chanlist_hand();
189
190 /* All the default userentry stuff, for code re-use
191 */
192 int def_unpack(struct userrec *u, struct user_entry *e);
193 int def_pack(struct userrec *u, struct user_entry *e);
194 int def_kill(struct user_entry *e);
195 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
196 void *def_get(struct userrec *u, struct user_entry *e);
197 int def_set(struct userrec *u, struct user_entry *e, void *buf);
198 int def_gotshare(struct userrec *u, struct user_entry *e,
199 char *data, int idx);
200 int def_tcl_get(Tcl_Interp *interp, struct userrec *u,
201 struct user_entry *e, int argc, char **argv);
202 int def_tcl_set(Tcl_Interp *irp, struct userrec *u,
203 struct user_entry *e, int argc, char **argv);
204 void def_display(int idx, struct user_entry *e);
205 int def_dupuser(struct userrec *new, struct userrec *old,
206 struct user_entry *e);
207
208 #endif /* _EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23