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_MOD_CHANNELS_CHANNELS_H
00027 #define _EGG_MOD_CHANNELS_CHANNELS_H
00028
00029
00030 #define UDEF_FLAG 1
00031 #define UDEF_INT 2
00032 #define UDEF_STR 3
00033
00034 #define MASKREASON_MAX 307
00035
00036 #define MASKREASON_LEN (MASKREASON_MAX + 1)
00037
00038
00039 #ifdef MAKING_CHANNELS
00040
00041
00042
00043
00044 struct udef_chans {
00045 struct udef_chans *next;
00046 char *chan;
00047 int value;
00048 };
00049
00050
00051
00052 struct udef_struct {
00053 struct udef_struct *next;
00054 char *name;
00055 int defined;
00056
00057
00058 int type;
00059 struct udef_chans *values;
00060
00061 };
00062
00063 static void del_chanrec(struct userrec *u, char *);
00064 static struct chanuserrec *get_chanrec(struct userrec *u, char *chname);
00065 static struct chanuserrec *add_chanrec(struct userrec *u, char *chname);
00066 static void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname);
00067 static void get_handle_chaninfo(char *handle, char *chname, char *s);
00068 static void set_handle_chaninfo(struct userrec *bu, char *handle,
00069 char *chname, char *info);
00070 static void set_handle_laston(char *chan, struct userrec *u, time_t n);
00071 static int u_sticky_mask(maskrec *u, char *uhost);
00072 static int u_setsticky_mask(int type, struct chanset_t *chan, char *uhost,
00073 int sticky);
00074
00075 static int u_equals_mask(maskrec *u, char *uhost);
00076 static int u_match_mask(struct maskrec *rec, char *mask);
00077 static int u_delmask(char type, struct chanset_t *c, char *who, int doit);
00078 static int u_addmask(char type, struct chanset_t *chan, char *who, char *from,
00079 char *note, time_t expire_time, int flags);
00080 static void tell_bans(int idx, int show_inact, char *match);
00081 static int write_bans(FILE * f, int idx);
00082 static void check_expired_bans(void);
00083 static void tell_exempts (int idx, int show_inact, char * match);
00084 static int write_exempts (FILE * f, int idx);
00085 static void check_expired_exempts(void);
00086 static void tell_invites (int idx, int show_inact, char * match);
00087 static int write_invites (FILE * f, int idx);
00088 static void check_expired_invites(void);
00089 static void write_channels(void);
00090 static void read_channels(int);
00091 static void clear_channel(struct chanset_t *, int);
00092 static void get_mode_protect(struct chanset_t *chan, char *s);
00093 static void set_mode_protect(struct chanset_t *chan, char *set);
00094 static int ismasked(masklist *m, char *user);
00095 static int ismodeline(masklist *m, char *user);
00096 static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
00097 int items, char **item);
00098 static int tcl_channel_add(Tcl_Interp * irp, char *, char *);
00099 static char *convert_element(char *src, char *dst);
00100 static void free_udef(struct udef_struct *);
00101 static void free_udef_chans(struct udef_chans *, int);
00102 static int getudef(struct udef_chans *, char *);
00103 static void initudef(int type, char *, int);
00104 static void setudef(struct udef_struct *, char *, int);
00105 static void remove_channel(struct chanset_t *);
00106 static int ngetudef(char *, char *);
00107 static int expired_mask(struct chanset_t *chan, char *who);
00108 inline static int chanset_unlink(struct chanset_t *chan);
00109
00110 #else
00111
00112
00113 #define u_setsticky_mask ((int (*)(int, struct chanset_t *, char *, int))channels_funcs[4])
00114 #define u_delmask ((int (*)(char, struct chanset_t *, char *, int))channels_funcs[5])
00115 #define u_addmask ((int (*)(char, struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[6])
00116 #define write_bans ((int (*)(FILE *, int))channels_funcs[7])
00117
00118 #define get_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[8])
00119 #define add_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[9])
00120 #define del_chanrec ((void (*)(struct userrec *, char *))channels_funcs[10])
00121 #define set_handle_chaninfo ((void (*)(struct userrec *, char *, char *, char *))channels_funcs[11])
00122
00123
00124 #define u_match_mask ((int (*)(maskrec *, char *))channels_funcs[13])
00125 #define u_equals_mask ((int (*)(maskrec *, char *))channels_funcs[14])
00126 #define clear_channel ((void (*)(struct chanset_t *, int))channels_funcs[15])
00127
00128 #define set_handle_laston ((void (*)(char *,struct userrec *,time_t))channels_funcs[16])
00129
00130 #define use_info (*(int *)(channels_funcs[18]))
00131 #define get_handle_chaninfo ((void (*)(char *, char *, char *))channels_funcs[19])
00132
00133 #define u_sticky_mask ((int (*)(maskrec *, char *))channels_funcs[20])
00134 #define ismasked ((int (*)(masklist *, char *))channels_funcs[21])
00135 #define add_chanrec_by_handle ((void (*)(struct userrec *, char *, char *))channels_funcs[22])
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 #define tcl_channel_add ((int (*)(Tcl_Interp *, char *, char *))channels_funcs[37])
00155 #define tcl_channel_modify ((int (*)(Tcl_Interp *, struct chanset_t *, int, char **))channels_funcs[38])
00156 #define write_exempts ((int (*)(FILE *, int))channels_funcs[39])
00157
00158 #define write_invites ((int (*)(FILE *, int))channels_funcs[40])
00159 #define ismodeline ((int(*)(masklist *, char *))channels_funcs[41])
00160 #define initudef ((void(*)(int, char *,int))channels_funcs[42])
00161 #define ngetudef ((int(*)(char *, char *))channels_funcs[43])
00162
00163 #define expired_mask ((int (*)(struct chanset_t *, char *))channels_funcs[44])
00164 #define remove_channel ((void (*)(struct chanset_t *))channels_funcs[45])
00165 #define global_ban_time (*(int *)(channels_funcs[46]))
00166 #define global_exempt_time (*(int *)(channels_funcs[47]))
00167
00168 #define global_invite_time (*(int *)(channels_funcs[48]))
00169
00170 #endif
00171
00172
00173
00174
00175 #define isbanned(chan, user) ismasked((chan)->channel.ban, user)
00176 #define isexempted(chan, user) ismasked((chan)->channel.exempt, user)
00177 #define isinvited(chan, user) ismasked((chan)->channel.invite, user)
00178
00179 #define ischanban(chan, user) ismodeline((chan)->channel.ban, user)
00180 #define ischanexempt(chan, user) ismodeline((chan)->channel.exempt, user)
00181 #define ischaninvite(chan, user) ismodeline((chan)->channel.invite, user)
00182
00183 #define u_setsticky_ban(chan, host, sticky) u_setsticky_mask('b', chan, host, sticky)
00184 #define u_setsticky_exempt(chan, host, sticky) u_setsticky_mask('e', chan, host, sticky)
00185 #define u_setsticky_invite(chan, host, sticky) u_setsticky_mask('I', chan, host, sticky)
00186
00187 #define is_perm_exempted(chan, user) (u_match_mask(chan->exempts, user) || \
00188 (u_match_mask(global_exempts, user) && \
00189 (chan->ircnet_status & CHAN_HONORGLOBALEXEMPTS)))
00190
00191 #endif