mirror of
https://github.com/pissnet/pissircd.git
synced 2025-07-29 22:42:24 +01:00
Replace various 90% identical functions with some macro's instead.
This commit is contained in:
parent
19af2c6b5c
commit
cf29aa8feb
6 changed files with 19 additions and 107 deletions
20
include/h.h
20
include/h.h
|
@ -182,9 +182,21 @@ extern int del_silence(aClient *, char *);
|
|||
extern void send_user_joins(aClient *, aClient *);
|
||||
extern void clean_channelname(char *);
|
||||
extern long get_access(aClient *, aChannel *);
|
||||
extern int is_chan_op(aClient *, aChannel *);
|
||||
extern int has_voice(aClient *, aChannel *);
|
||||
extern int is_chanowner(aClient *, aChannel *);
|
||||
#ifdef PREFIX_AQ
|
||||
#define CHFL_CHANOP_OR_HIGHER (CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER)
|
||||
#define CHFL_HALFOP_OR_HIGHER (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP|CHFL_HALFOP)
|
||||
#else
|
||||
#define CHFL_CHANOP_OR_HIGHER (CHFL_CHANOP)
|
||||
#define CHFL_HALFOP_OR_HIGHER (CHFL_CHANOP|CHFL_HALFOP)
|
||||
#endif
|
||||
|
||||
#define is_chan_op(cptr,chptr) (get_access(cptr,chptr) & CHFL_CHANOP_OR_HIGHER)
|
||||
#define is_skochanop(cptr,chptr) (get_access(cptr,chptr) & CHFL_HALFOP_OR_HIGHER)
|
||||
#define has_voice(cptr,chptr) (get_access(cptr,chptr) & CHFL_VOICE)
|
||||
#define is_halfop is_half_op
|
||||
#define is_half_op(cptr,chptr) (get_access(cptr,chptr) & CHFL_HALFOP)
|
||||
#define is_chanowner(cptr,chptr) (get_access(cptr,chptr) & CHFL_CHANOWNER)
|
||||
#define is_chanprot(cptr,chptr) (get_access(cptr,chptr) & CHFL_CHANPROT)
|
||||
extern int ban_check_mask(aClient *, aChannel *, char *, int, char **, char **, int);
|
||||
extern int extban_is_ok_nuh_extban(aClient *, aChannel *, char *, int, int, int);
|
||||
extern char *extban_conv_param_nuh_or_extban(char *);
|
||||
|
@ -471,8 +483,6 @@ extern int Auth_Check(aClient *cptr, anAuthStruct *as, char *para);
|
|||
extern char *Auth_Make(short type, char *para);
|
||||
extern int Auth_CheckError(ConfigEntry *ce);
|
||||
|
||||
extern int is_chanownprotop(aClient *cptr, aChannel *chptr);
|
||||
extern int is_skochanop(aClient *cptr, aChannel *chptr);
|
||||
extern char *make_virthost(aClient *sptr, char *curr, char *new, int mode);
|
||||
extern int channel_canjoin(aClient *sptr, char *name);
|
||||
extern char *collapse(char *pattern);
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
/* channel.c */
|
||||
extern int sendmodeto_one(aClient *cptr, char *from, char *name, char *mode, char *param, TS creationtime);
|
||||
extern void make_cmodestr(void);
|
||||
extern int is_halfop(aClient *cptr, aChannel *chptr);
|
||||
extern int is_chanprot(aClient *cptr, aChannel *chptr);
|
||||
|
||||
/* lusers.c */
|
||||
extern void init_ircstats(void);
|
||||
|
|
|
@ -1704,7 +1704,6 @@ struct liststructprio {
|
|||
#define MODE_RGSTR 0x8000
|
||||
#define MODE_INVEX 0x8000000
|
||||
|
||||
#define is_halfop is_half_op
|
||||
/*
|
||||
* mode flags which take another parameter (With PARAmeterS)
|
||||
*/
|
||||
|
|
|
@ -639,103 +639,6 @@ long get_access(aClient *cptr, aChannel *chptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int is_chan_op(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
/* chanop/halfop ? */
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
#ifdef PREFIX_AQ
|
||||
return ((lp->flags & (CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER)));
|
||||
#else
|
||||
return ((lp->flags & CHFL_CHANOP));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int has_voice(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
return (lp->flags & CHFL_VOICE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int is_halfop(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
if (!(lp->flags & CHFL_CHANOP))
|
||||
return (lp->flags & CHFL_HALFOP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_chanowner(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
return (lp->flags & CHFL_CHANOWNER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_chanownprotop(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
if (lp->flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_skochanop(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (IsServer(cptr))
|
||||
return 1;
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
#ifdef PREFIX_AQ
|
||||
if (lp->flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP|CHFL_HALFOP))
|
||||
#else
|
||||
if (lp->flags & (CHFL_CHANOP|CHFL_HALFOP))
|
||||
#endif
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_chanprot(aClient *cptr, aChannel *chptr)
|
||||
{
|
||||
Membership *lp;
|
||||
|
||||
if (chptr)
|
||||
if ((lp = find_membership_link(cptr->user->channel, chptr)))
|
||||
return (lp->flags & CHFL_CHANPROT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Returns 1 if channel has this channel mode set and 0 if not */
|
||||
int has_channel_mode(aChannel *chptr, char mode)
|
||||
{
|
||||
|
|
|
@ -71,8 +71,10 @@ int nonickchange_check (aClient *sptr, aChannel *chptr)
|
|||
{
|
||||
if (!IsOper(sptr) && !IsULine(sptr)
|
||||
&& IsNoNickChange(chptr)
|
||||
&& !is_chanownprotop(sptr, chptr))
|
||||
&& !is_chan_op(sptr, chptr))
|
||||
{
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
return HOOK_ALLOW;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ CMD_FUNC(m_part)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!ValidatePermissionsForPath("channel:override:banpartmsg",sptr,NULL,chptr,NULL) && !is_chanownprotop(sptr, chptr)) {
|
||||
if (!ValidatePermissionsForPath("channel:override:banpartmsg",sptr,NULL,chptr,NULL) && !is_chan_op(sptr, chptr)) {
|
||||
/* Banned? No comment allowed ;) */
|
||||
if (comment && is_banned(sptr, chptr, BANCHK_MSG, &comment, NULL))
|
||||
comment = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue