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 #ifndef _EGG_MOD_CHANNELS_CHANNELS_H
00026 #define _EGG_MOD_CHANNELS_CHANNELS_H
00027
00028
00029 #define UDEF_FLAG 1
00030 #define UDEF_INT 2
00031 #define UDEF_STR 3
00032
00033 #define MASKREASON_MAX 307
00034 #define MASKREASON_LEN (MASKREASON_MAX + 1)
00035
00036
00037 #define CHAN_RESETMODES 0x01
00038 #define CHAN_RESETWHO 0x02
00039 #define CHAN_RESETTOPIC 0x04
00040 #define CHAN_RESETBANS 0x08
00041 #define CHAN_RESETEXEMPTS 0x10
00042 #define CHAN_RESETINVITED 0x20
00043 #define CHAN_RESETALL 0x3F
00044
00045 #ifdef MAKING_CHANNELS
00046
00047
00048
00049
00050 struct udef_chans {
00051 struct udef_chans *next;
00052 char *chan;
00053 intptr_t value;
00054 };
00055
00056
00057
00058 struct udef_struct {
00059 struct udef_struct *next;
00060 char *name;
00061 int defined;
00062
00063
00064 int type;
00065 struct udef_chans *values;
00066
00067 };
00068
00069 static void del_chanrec(struct userrec *u, char *);
00070 static struct chanuserrec *get_chanrec(struct userrec *u, char *chname);
00071 static struct chanuserrec *add_chanrec(struct userrec *u, char *chname);
00072 static void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname);
00073 static void get_handle_chaninfo(char *handle, char *chname, char *s);
00074 static void set_handle_chaninfo(struct userrec *bu, char *handle,
00075 char *chname, char *info);
00076 static void set_handle_laston(char *chan, struct userrec *u, time_t n);
00077 static int u_sticky_mask(maskrec *u, char *uhost);
00078 static int u_setsticky_mask(struct chanset_t *chan, maskrec *m, char *uhost,
00079 int sticky, char *botcmd);
00080
00081 static int u_equals_mask(maskrec *u, char *uhost);
00082 static int u_match_mask(struct maskrec *rec, char *mask);
00083 static int u_delexempt(struct chanset_t *c, char *who, int doit);
00084 static int u_addexempt(struct chanset_t *chan, char *exempt, char *from,
00085 char *note, time_t expire_time, int flags);
00086 static int u_delinvite(struct chanset_t *c, char *who, int doit);
00087 static int u_addinvite(struct chanset_t *chan, char *invite, char *from,
00088 char *note, time_t expire_time, int flags);
00089 static int u_delban(struct chanset_t *c, char *who, int doit);
00090 static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
00091 time_t expire_time, int flags);
00092 static void tell_bans(int idx, int show_inact, char *match);
00093 static int write_bans(FILE *f, int idx);
00094 static void check_expired_bans(void);
00095 static void tell_exempts(int idx, int show_inact, char *match);
00096 static int write_exempts(FILE *f, int idx);
00097 static void check_expired_exempts(void);
00098 static void tell_invites(int idx, int show_inact, char *match);
00099 static int write_invites(FILE *f, int idx);
00100 static void check_expired_invites(void);
00101 static void write_channels(void);
00102 static void read_channels(int, int);
00103 static void clear_channel(struct chanset_t *, int);
00104 static void get_mode_protect(struct chanset_t *chan, char *s);
00105 static void set_mode_protect(struct chanset_t *chan, char *set);
00106 static int ismasked(masklist *m, char *user);
00107 static int ismodeline(masklist *m, char *user);
00108 static int tcl_channel_modify(Tcl_Interp *irp, struct chanset_t *chan,
00109 int items, char **item);
00110 static int tcl_channel_add(Tcl_Interp *irp, char *, char *);
00111 static char *convert_element(char *src, char *dst);
00112 static int expmem_udef(struct udef_struct *);
00113 static int expmem_udef_chans (int, struct udef_chans *);
00114 static void free_udef(struct udef_struct *);
00115 static void free_udef_chans(struct udef_chans *, int);
00116 static intptr_t getudef(struct udef_chans *, char *);
00117 static void initudef(int type, char *, int);
00118 static void setudef(struct udef_struct *, char *, intptr_t);
00119 static void remove_channel(struct chanset_t *);
00120 static intptr_t ngetudef(char *, char *);
00121 static int expired_mask(struct chanset_t *chan, char *who);
00122 inline static int chanset_unlink(struct chanset_t *chan);
00123
00124 #else
00125
00126
00127 #define u_setsticky_mask ((int (*)(struct chanset_t *, maskrec *, char *, int, char *))channels_funcs[4])
00128 #define u_delban ((int (*)(struct chanset_t *, char *, int))channels_funcs[5])
00129 #define u_addban ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[6])
00130 #define write_bans ((int (*)(FILE *, int))channels_funcs[7])
00131
00132 #define get_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[8])
00133 #define add_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[9])
00134 #define del_chanrec ((void (*)(struct userrec *, char *))channels_funcs[10])
00135 #define set_handle_chaninfo ((void (*)(struct userrec *, char *, char *, char *))channels_funcs[11])
00136
00137 #define channel_malloc(x) ((void *(*)(int, char *, int))channels_funcs[12])(x,__FILE__,__LINE__)
00138 #define u_match_mask ((int (*)(maskrec *, char *))channels_funcs[13])
00139 #define u_equals_mask ((int (*)(maskrec *, char *))channels_funcs[14])
00140 #define clear_channel ((void (*)(struct chanset_t *, int))channels_funcs[15])
00141
00142 #define set_handle_laston ((void (*)(char *,struct userrec *,time_t))channels_funcs[16])
00143
00144 #define use_info (*(int *)(channels_funcs[18]))
00145 #define get_handle_chaninfo ((void (*)(char *, char *, char *))channels_funcs[19])
00146
00147 #define u_sticky_mask ((int (*)(maskrec *, char *))channels_funcs[20])
00148 #define ismasked ((int (*)(masklist *, char *))channels_funcs[21])
00149 #define add_chanrec_by_handle ((void (*)(struct userrec *, char *, char *))channels_funcs[22])
00150
00151
00152
00153
00154
00155
00156
00157
00158 #define u_delexempt ((int (*)(struct chanset_t *, char *, int))channels_funcs[29])
00159 #define u_addexempt ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[30])
00160
00161
00162
00163
00164
00165 #define u_delinvite ((int (*)(struct chanset_t *, char *, int))channels_funcs[35])
00166
00167 #define u_addinvite ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[36])
00168 #define tcl_channel_add ((int (*)(Tcl_Interp *, char *, char *))channels_funcs[37])
00169 #define tcl_channel_modify ((int (*)(Tcl_Interp *, struct chanset_t *, int, char **))channels_funcs[38])
00170 #define write_exempts ((int (*)(FILE *, int))channels_funcs[39])
00171
00172 #define write_invites ((int (*)(FILE *, int))channels_funcs[40])
00173 #define ismodeline ((int(*)(masklist *, char *))channels_funcs[41])
00174 #define initudef ((void(*)(int, char *,int))channels_funcs[42])
00175 #define ngetudef ((int(*)(char *, char *))channels_funcs[43])
00176
00177 #define expired_mask ((int (*)(struct chanset_t *, char *))channels_funcs[44])
00178 #define remove_channel ((void (*)(struct chanset_t *))channels_funcs[45])
00179 #define global_ban_time (*(int *)(channels_funcs[46]))
00180 #define global_exempt_time (*(int *)(channels_funcs[47]))
00181
00182 #define global_invite_time (*(int *)(channels_funcs[48]))
00183
00184 #endif
00185
00186
00187
00188
00189 #define isbanned(chan, user) ismasked((chan)->channel.ban, user)
00190 #define isexempted(chan, user) ismasked((chan)->channel.exempt, user)
00191 #define isinvited(chan, user) ismasked((chan)->channel.invite, user)
00192
00193 #define ischanban(chan, user) ismodeline((chan)->channel.ban, user)
00194 #define ischanexempt(chan, user) ismodeline((chan)->channel.exempt, user)
00195 #define ischaninvite(chan, user) ismodeline((chan)->channel.invite, user)
00196
00197 #define u_setsticky_ban(chan, host, sticky) u_setsticky_mask(chan, ((struct chanset_t *)chan) ? ((struct chanset_t *)chan)->bans : global_bans, host, sticky, "s")
00198 #define u_setsticky_exempt(chan, host, sticky) u_setsticky_mask(chan, ((struct chanset_t *)chan) ? ((struct chanset_t *)chan)->exempts : global_exempts, host, sticky, "se")
00199 #define u_setsticky_invite(chan, host, sticky) u_setsticky_mask(chan, ((struct chanset_t *)chan) ? ((struct chanset_t *)chan)->invites : global_invites, host, sticky, "sInv")
00200
00201 #define CHKFLAG_POS(x,y,z) (!strcmp(setting, y)) { \
00202 if (z & x) \
00203 simple_sprintf(s, "%d", 1); \
00204 else \
00205 simple_sprintf(s, "%d", 0); \
00206 }
00207
00208 #define CHKFLAG_NEG(x,y,z) (!strcmp(setting, y)) { \
00209 if (z & x) \
00210 simple_sprintf(s, "%d", 0); \
00211 else \
00212 simple_sprintf(s, "%d", 1); \
00213 }
00214
00215 #endif