00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _EGG_USERS_H
00027 #define _EGG_USERS_H
00028
00029
00030 struct list_type {
00031 struct list_type *next;
00032 char *extra;
00033 };
00034
00035 #define list_insert(a,b) { \
00036 (b)->next = *(a); \
00037 *(a) = (b); \
00038 }
00039 int egg_list_append(struct list_type **, struct list_type *);
00040 int egg_list_delete(struct list_type **, struct list_type *);
00041 int egg_list_contains(struct list_type *, struct list_type *);
00042
00043
00044
00045
00046 struct userrec;
00047 struct user_entry;
00048 struct user_entry_type {
00049 struct user_entry_type *next;
00050 int (*got_share) (struct userrec *, struct user_entry *, char *, int);
00051 int (*dup_user) (struct userrec *, struct userrec *, struct user_entry *);
00052 int (*unpack) (struct userrec *, struct user_entry *);
00053 int (*pack) (struct userrec *, struct user_entry *);
00054 int (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
00055 int (*kill) (struct user_entry *);
00056 void *(*get) (struct userrec *, struct user_entry *);
00057 int (*set) (struct userrec *, struct user_entry *, void *);
00058 int (*tcl_get) (Tcl_Interp *, struct userrec *, struct user_entry *,
00059 int, char **);
00060 int (*tcl_set) (Tcl_Interp *, struct userrec *, struct user_entry *,
00061 int, char **);
00062 int (*expmem) (struct user_entry *);
00063 void (*display) (int idx, struct user_entry *);
00064 char *name;
00065 };
00066
00067
00068 #ifndef MAKING_MODS
00069 extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
00070 USERENTRY_XTRA, USERENTRY_INFO, USERENTRY_BOTADDR, USERENTRY_HOSTS,
00071 USERENTRY_PASS, USERENTRY_BOTFL;
00072 #endif
00073
00074
00075 struct laston_info {
00076 time_t laston;
00077 char *lastonplace;
00078 };
00079
00080 struct bot_addr {
00081 int telnet_port;
00082 int relay_port;
00083 char *address;
00084 };
00085
00086 struct user_entry {
00087 struct user_entry *next;
00088 struct user_entry_type *type;
00089 union {
00090 char *string;
00091 void *extra;
00092 struct list_type *list;
00093 unsigned long ulong;
00094 } u;
00095 char *name;
00096 };
00097
00098 struct xtra_key {
00099 struct xtra_key *next;
00100 char *key;
00101 char *data;
00102 };
00103
00104 struct filesys_stats {
00105 int uploads;
00106 int upload_ks;
00107 int dnloads;
00108 int dnload_ks;
00109 };
00110
00111 void *_user_malloc(int size, const char *file, int line);
00112 void *_user_realloc(void *ptr, int size, const char *file, int line);
00113
00114 #ifndef MAKING_MODS
00115 # define user_malloc(x) _user_malloc(x, __FILE__, __LINE__)
00116 # define user_realloc(x, y) _user_realloc(x, y, __FILE__, __LINE__)
00117 #endif
00118
00119 int add_entry_type(struct user_entry_type *);
00120 int del_entry_type(struct user_entry_type *);
00121 struct user_entry_type *find_entry_type(char *);
00122 struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
00123 void *get_user(struct user_entry_type *, struct userrec *);
00124 int set_user(struct user_entry_type *, struct userrec *, void *);
00125
00126 #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
00127 #define is_bot(u) ((u) && ((u)->flags & USER_BOT))
00128 #define is_owner(u) ((u) && ((u)->flags & USER_OWNER))
00129
00130
00131
00132 #define IGNORE_NAME "*ignore"
00133 #define BAN_NAME "*ban"
00134 #define EXEMPT_NAME "*exempt"
00135 #define INVITE_NAME "*Invite"
00136
00137
00138
00139 struct chanuserrec {
00140 struct chanuserrec *next;
00141 char channel[81];
00142 time_t laston;
00143 unsigned long flags;
00144 unsigned long flags_udef;
00145 char *info;
00146 };
00147
00148
00149
00150 struct userrec {
00151 struct userrec *next;
00152 char handle[HANDLEN + 1];
00153 unsigned long flags;
00154 unsigned long flags_udef;
00155 struct chanuserrec *chanrec;
00156 struct user_entry *entries;
00157 };
00158
00159 struct igrec {
00160 struct igrec *next;
00161 char *igmask;
00162 time_t expire;
00163 char *user;
00164 time_t added;
00165 char *msg;
00166 int flags;
00167 };
00168 extern struct igrec *global_ign;
00169
00170 #define IGREC_PERM 2
00171
00172
00173
00174
00175
00176 struct userrec *adduser();
00177 struct userrec *get_user_by_handle(struct userrec *, char *);
00178 struct userrec *get_user_by_host(char *);
00179 struct userrec *get_user_by_nick(char *);
00180 struct userrec *check_chanlist();
00181 struct userrec *check_chanlist_hand();
00182
00183
00184
00185 int def_unpack(struct userrec *u, struct user_entry *e);
00186 int def_pack(struct userrec *u, struct user_entry *e);
00187 int def_kill(struct user_entry *e);
00188 int def_write_userfile(FILE *f, struct userrec *u, struct user_entry *e);
00189 void *def_get(struct userrec *u, struct user_entry *e);
00190 int def_set(struct userrec *u, struct user_entry *e, void *buf);
00191 int def_gotshare(struct userrec *u, struct user_entry *e, char *data, int idx);
00192 int def_tcl_get(Tcl_Interp *interp, struct userrec *u,
00193 struct user_entry *e, int argc, char **argv);
00194 int def_tcl_set(Tcl_Interp *irp, struct userrec *u,
00195 struct user_entry *e, int argc, char **argv);
00196 int def_expmem(struct user_entry *e);
00197 void def_display(int idx, struct user_entry *e);
00198 int def_dupuser(struct userrec *new, struct userrec *old, struct user_entry *e);
00199
00200 #endif