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

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

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


Revision 1.3 - (show annotations) (download) (as text)
Mon Nov 1 22:38:34 2010 UTC (8 years, 8 months ago) by pseudo
Branch: MAIN
CVS Tags: HEAD
Branch point for: gettext
Changes since 1.2: +3 -1 lines
File MIME type: text/x-csrc
Made it possible to specify ssl independently for telnet and user ports when modifying bot addresses.
Changed the syntax of .chaddr and .+bot to use space as a port separator instead of ':'.
Changed the syntax of server list entries to enclose literal IPv6 addresses in square brackets, instead of using a comma to separate the port.

1 /*
2 * users.h
3 * structures and definitions used by users.c and userrec.c
4 *
5 * $Id: users.h,v 1.2 2010/10/19 12:13:33 pseudo Exp $
6 */
7 /*
8 * Copyright (C) 1997 Robey Pointer
9 * Copyright (C) 1999 - 2010 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 /* List functions :) , next *must* be the 1st item in the struct */
30 struct list_type {
31 struct list_type *next;
32 char *extra;
33 };
34
35 #define list_insert(a,b) { \
36 (b)->next = *(a); \
37 *(a) = (b); \
38 }
39 int egg_list_append(struct list_type **, struct list_type *);
40 int egg_list_delete(struct list_type **, struct list_type *);
41 int egg_list_contains(struct list_type *, struct list_type *);
42
43
44 /* New userfile format stuff
45 */
46 struct userrec;
47 struct user_entry;
48 struct user_entry_type {
49 struct user_entry_type *next;
50 int (*got_share) (struct userrec *, struct user_entry *, char *, int);
51 int (*dup_user) (struct userrec *, struct userrec *, struct user_entry *);
52 int (*unpack) (struct userrec *, struct user_entry *);
53 int (*pack) (struct userrec *, struct user_entry *);
54 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
55 int (*kill) (struct user_entry *);
56 void *(*get) (struct userrec *, struct user_entry *);
57 int (*set) (struct userrec *, struct user_entry *, void *);
58 int (*tcl_get) (Tcl_Interp *, struct userrec *, struct user_entry *,
59 int, char **);
60 int (*tcl_set) (Tcl_Interp *, struct userrec *, struct user_entry *,
61 int, char **);
62 int (*expmem) (struct user_entry *);
63 void (*display) (int idx, struct user_entry *);
64 char *name;
65 };
66
67
68 #ifndef MAKING_MODS
69 extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
70 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
71 USERENTRY_PASS, USERENTRY_BOTFL;
72 #ifdef TLS
73 extern struct user_entry_type USERENTRY_FPRINT;
74 #endif
75 #endif
76
77
78 struct laston_info {
79 time_t laston;
80 char *lastonplace;
81 };
82
83 struct bot_addr {
84 int telnet_port;
85 int relay_port;
86 char *address;
87 #ifdef TLS
88 # define TLS_BOT 1
89 # define TLS_RELAY 2
90 int ssl;
91 #endif
92 };
93
94 struct user_entry {
95 struct user_entry *next;
96 struct user_entry_type *type;
97 union {
98 char *string;
99 void *extra;
100 struct list_type *list;
101 unsigned long ulong;
102 } u;
103 char *name;
104 };
105
106 struct xtra_key {
107 struct xtra_key *next;
108 char *key;
109 char *data;
110 };
111
112 struct filesys_stats {
113 int uploads;
114 int upload_ks;
115 int dnloads;
116 int dnload_ks;
117 };
118
119 void *_user_malloc(int size, const char *file, int line);
120 void *_user_realloc(void *ptr, int size, const char *file, int line);
121
122 #ifndef MAKING_MODS
123 # define user_malloc(x) _user_malloc(x, __FILE__, __LINE__)
124 # define user_realloc(x, y) _user_realloc(x, y, __FILE__, __LINE__)
125 #endif
126
127 int add_entry_type(struct user_entry_type *);
128 int del_entry_type(struct user_entry_type *);
129 struct user_entry_type *find_entry_type(char *);
130 struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
131 void *get_user(struct user_entry_type *, struct userrec *);
132 int set_user(struct user_entry_type *, struct userrec *, 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_owner(u) ((u) && ((u)->flags & USER_OWNER))
137
138 /* Fake users used to store ignores and bans
139 */
140 #define IGNORE_NAME "*ignore"
141 #define BAN_NAME "*ban"
142 #define EXEMPT_NAME "*exempt"
143 #define INVITE_NAME "*Invite"
144
145 /* Channel-specific info
146 */
147 struct chanuserrec {
148 struct chanuserrec *next;
149 char channel[81];
150 time_t laston;
151 unsigned long flags;
152 unsigned long flags_udef;
153 char *info;
154 };
155
156 /* New-style userlist
157 */
158 struct userrec {
159 struct userrec *next;
160 char handle[HANDLEN + 1];
161 unsigned long flags;
162 unsigned long flags_udef;
163 struct chanuserrec *chanrec;
164 struct user_entry *entries;
165 };
166
167 struct igrec {
168 struct igrec *next;
169 char *igmask;
170 time_t expire;
171 char *user;
172 time_t added;
173 char *msg;
174 int flags;
175 };
176 extern struct igrec *global_ign;
177
178 #define IGREC_PERM 2
179
180 /*
181 * Note: Flags are in eggdrop.h
182 */
183
184 struct userrec *adduser();
185 struct userrec *get_user_by_handle(struct userrec *, char *);
186 struct userrec *get_user_by_host(char *);
187 struct userrec *get_user_by_nick(char *);
188 struct userrec *check_chanlist();
189 struct userrec *check_chanlist_hand();
190
191 /* All the default userentry stuff, for code re-use
192 */
193 int def_unpack(struct userrec *u, struct user_entry *e);
194 int def_pack(struct userrec *u, struct user_entry *e);
195 int def_kill(struct user_entry *e);
196 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
197 void *def_get(struct userrec *u, struct user_entry *e);
198 int def_set(struct userrec *u, struct user_entry *e, void *buf);
199 int def_gotshare(struct userrec *u, struct user_entry *e, 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 int def_expmem(struct user_entry *e);
205 void def_display(int idx, struct user_entry *e);
206 int def_dupuser(struct userrec *new, struct userrec *old, struct user_entry *e);
207
208 #endif /* _EGG_USERS_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23