Start moving parts of join to channels.c so they can be used in more places.

This commit is contained in:
JD Horelick 2010-02-23 02:41:26 -05:00
parent 2c489d8e65
commit 080bb5cf25
3 changed files with 41 additions and 39 deletions

View File

@ -271,5 +271,7 @@ extern int match_extban(const char *banstr, struct Client *client_p, struct Chan
extern int valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type);
const char * get_extban_string(void);
extern struct Channel * check_forward(struct Client *source_p, struct Channel *chptr, char *key)
#endif /* INCLUDED_channel_h */

View File

@ -84,45 +84,6 @@ static const char *para[MAXMODEPARAMS];
static char *mbuf;
static int pargs;
/* Check what we will forward to, without sending any notices to the user
* -- jilles
*/
static struct Channel *
check_forward(struct Client *source_p, struct Channel *chptr,
char *key)
{
int depth = 0, i;
/* User is +Q */
if (IsNoForward(source_p))
return NULL;
while (depth < 16)
{
chptr = find_channel(chptr->mode.forward);
/* Can only forward to existing channels */
if (chptr == NULL)
return NULL;
/* Already on there, show original error message */
if (IsMember(source_p, chptr))
return NULL;
/* Juped. Sending a warning notice would be unfair */
if (hash_find_resv(chptr->chname))
return NULL;
/* Don't forward to +Q channel */
if (chptr->mode.mode & MODE_DISFORWARD)
return NULL;
i = can_join(source_p, chptr, key);
if (i == 0)
return chptr;
if (i != ERR_INVITEONLYCHAN && i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_CHANNELISFULL)
return NULL;
depth++;
}
return NULL;
}
/*
* m_join
* parv[1] = channel

View File

@ -1357,3 +1357,42 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
}
}
/* Check what we will forward to, without sending any notices to the user
* -- jilles
*/
struct Channel *
check_forward(struct Client *source_p, struct Channel *chptr,
char *key)
{
int depth = 0, i;
/* User is +Q */
if (IsNoForward(source_p))
return NULL;
while (depth < 16)
{
chptr = find_channel(chptr->mode.forward);
/* Can only forward to existing channels */
if (chptr == NULL)
return NULL;
/* Already on there, show original error message */
if (IsMember(source_p, chptr))
return NULL;
/* Juped. Sending a warning notice would be unfair */
if (hash_find_resv(chptr->chname))
return NULL;
/* Don't forward to +Q channel */
if (chptr->mode.mode & MODE_DISFORWARD)
return NULL;
i = can_join(source_p, chptr, key);
if (i == 0)
return chptr;
if (i != ERR_INVITEONLYCHAN && i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_CHANNELISFULL)
return NULL;
depth++;
}
return NULL;
}