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

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

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


Revision 1.8 - (show annotations) (download) (as text)
Wed Dec 15 02:32:58 1999 UTC (19 years, 8 months ago) by guppy
Branch: MAIN
Changes since 1.7: +26 -11 lines
File MIME type: text/x-csrc
id-header patch, finally, we have id tags for each file

1 /*
2 * users.h
3 * structures and definitions used by users.c and userrec.c
4 *
5 * $Id$
6 */
7 /*
8 * Copyright (C) 1997 Robey Pointer
9 * Copyright (C) 1999 Eggheads
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 #ifndef _EGG_USERS_H
26 #define _EGG_USERS_H
27
28 /* list functions :) , next *must* be the 1st item in the struct */
29 struct list_type {
30 struct list_type *next;
31 char *extra;
32 };
33
34 #define list_insert(a,b) { b->next = *a; *a = b; }
35 int list_append(struct list_type **, struct list_type *);
36 int list_delete(struct list_type **, struct list_type *);
37 int list_contains(struct list_type *, struct list_type *);
38
39 /* new userfile format stuff */
40 struct userrec;
41 struct user_entry;
42 struct user_entry_type {
43 struct user_entry_type *next;
44 int (*got_share) (struct userrec *, struct user_entry *, char *, int);
45 int (*dup_user) (struct userrec *, struct userrec *,
46 struct user_entry *);
47 int (*unpack) (struct userrec *, struct user_entry *);
48 int (*pack) (struct userrec *, struct user_entry *);
49 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
50 int (*kill) (struct user_entry *);
51 void *(*get) (struct userrec *, struct user_entry *);
52 int (*set) (struct userrec *, struct user_entry *, void *);
53 int (*tcl_get) (Tcl_Interp *, struct userrec *, struct user_entry *,
54 int, char **);
55 int (*tcl_set) (Tcl_Interp *, struct userrec *, struct user_entry *,
56 int, char **);
57 int (*expmem) (struct user_entry *);
58 void (*display) (int idx, struct user_entry *);
59 char *name;
60 };
61
62 #ifndef MAKING_MODS
63 extern struct user_entry_type USERENTRY_EMAIL, USERENTRY_COMMENT, USERENTRY_LASTON,
64 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
65 USERENTRY_PASS, USERENTRY_BOTFL, USERENTRY_URL;
66
67 #endif
68
69 struct laston_info {
70 time_t laston;
71 char *lastonplace;
72 };
73
74 struct bot_addr {
75 int telnet_port;
76 int relay_port;
77 char *address;
78 };
79
80 struct user_entry {
81 struct user_entry *next;
82 struct user_entry_type *type;
83 union {
84 char *string;
85 void *extra;
86 struct list_type *list;
87 unsigned long ulong;
88 } u;
89 char *name;
90 };
91
92 struct xtra_key {
93 struct xtra_key *next;
94 char *key;
95 char *data;
96 };
97
98 struct filesys_stats {
99 int uploads;
100 int upload_ks;
101 int dnloads;
102 int dnload_ks;
103 };
104
105 void *_user_malloc(int, char *, int);
106 void *_user_realloc(void *, int, char *, int);
107
108 #ifndef MAKING_MODS
109 #define user_malloc(x) _user_malloc(x,__FILE__,__LINE__)
110 #define user_realloc(x,y) _user_realloc(x,y,__FILE__,__LINE__)
111 #endif
112 int add_entry_type(struct user_entry_type *);
113 int del_entry_type(struct user_entry_type *);
114 struct user_entry_type *find_entry_type(char *);
115 struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
116 void *get_user(struct user_entry_type *, struct userrec *);
117 int set_user(struct user_entry_type *, struct userrec *, void *);
118
119 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL,u))
120 #define is_bot(u) (u && (u->flags & USER_BOT))
121 #define is_master(u) (u && (u->flags & USER_MASTER))
122 #define is_owner(u) (u && (u->flags & USER_OWNER))
123
124 /* fake users used to store ignores and bans */
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 struct chanuserrec {
132 struct chanuserrec *next;
133 char channel[81];
134 time_t laston;
135 unsigned long flags;
136 unsigned long flags_udef;
137 char *info;
138 };
139
140 /* new-style userlist */
141 struct userrec {
142 struct userrec *next;
143 char handle[HANDLEN + 1];
144 unsigned long flags;
145 unsigned long flags_udef;
146 struct chanuserrec *chanrec;
147 struct user_entry *entries;
148 };
149
150 struct igrec {
151 struct igrec *next;
152 char *igmask;
153 time_t expire;
154 char *user;
155 time_t added;
156 char *msg;
157 int flags;
158 };
159 extern struct igrec *global_ign;
160
161 #define IGREC_PERM 2
162
163 /* flags are in eggdrop.h */
164
165 struct userrec *adduser();
166 struct userrec *get_user_by_handle(struct userrec *, char *);
167 struct userrec *get_user_by_host(char *);
168 struct userrec *get_user_by_nick(char *);
169 struct userrec *check_chanlist();
170 struct userrec *check_chanlist_hand();
171
172 /* all the default userentry stuff, for code re-use */
173 int def_unpack(struct userrec *u, struct user_entry *e);
174 int def_pack(struct userrec *u, struct user_entry *e);
175 int def_kill(struct user_entry *e);
176 int def_write_userfile(FILE * f, struct userrec *u, struct user_entry *e);
177 void *def_get(struct userrec *u, struct user_entry *e);
178 int def_set(struct userrec *u, struct user_entry *e, void *buf);
179 int def_gotshare(struct userrec *u, struct user_entry *e,
180 char *data, int idx);
181 int def_tcl_get(Tcl_Interp * interp, struct userrec *u,
182 struct user_entry *e, int argc, char **argv);
183 int def_tcl_set(Tcl_Interp * irp, struct userrec *u,
184 struct user_entry *e, int argc, char **argv);
185 int def_expmem(struct user_entry *e);
186 void def_display(int idx, struct user_entry *e);
187 int def_dupuser(struct userrec *new, struct userrec *old,
188 struct user_entry *e);
189
190 #endif /* _EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23