Defines | Functions | Variables

channels.c File Reference

#include "services.h"
#include "language.h"
Include dependency graph for channels.c:

Go to the source code of this file.

Defines

#define HASH(chan)   ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0)

Functions

void chan_deluser (User *user, Channel *c)
char * chan_get_modes (Channel *chan, int complete, int plus)
int chan_get_user_status (Channel *chan, User *user)
int chan_has_user_status (Channel *chan, User *user, int16 status)
void chan_remove_user_status (Channel *chan, User *user, int16 status)
void chan_set_modes (const char *source, Channel *chan, int ac, char **av, int check)
void chan_set_user_status (Channel *chan, User *user, int16 status)
Channelfindchan (const char *chan)
Channelfirstchan (void)
Channelnextchan (void)
void get_channel_stats (long *nrec, long *memuse)
int is_on_chan (Channel *c, User *u)
Usernc_on_chan (Channel *c, NickCore *nc)
void do_join (const char *source, int ac, char **av)
void do_kick (const char *source, int ac, char **av)
void do_part (const char *source, int ac, char **av)
void do_sjoin (const char *source, int ac, char **av)
void do_cmode (const char *source, int ac, char **av)
void do_topic (const char *source, int ac, char **av)
void add_ban (Channel *chan, char *mask)
void add_exception (Channel *chan, char *mask)
void add_invite (Channel *chan, char *mask)
void chan_set_correct_modes (User *user, Channel *c, int give_modes)
void chan_adduser2 (User *user, Channel *c)
Channelchan_create (char *chan, time_t ts)
void chan_delete (Channel *c)
void del_ban (Channel *chan, char *mask)
void del_exception (Channel *chan, char *mask)
void del_invite (Channel *chan, char *mask)
char * get_flood (Channel *chan)
char * get_throttle (Channel *chan)
char * get_key (Channel *chan)
char * get_limit (Channel *chan)
char * get_redirect (Channel *chan)
char * get_unkwn (Channel *chan)
Channeljoin_user_update (User *user, Channel *chan, char *name, time_t chants)
void set_flood (Channel *chan, char *value)
void chan_set_throttle (Channel *chan, char *value)
void chan_set_key (Channel *chan, char *value)
void set_limit (Channel *chan, char *value)
void set_redirect (Channel *chan, char *value)
void set_unkwn (Channel *chan, char *value)
void do_mass_mode (char *modes)
void restore_unsynced_topics (void)
Entryentry_create (char *mask)
Entryentry_add (EList *list, char *mask)
void entry_delete (EList *list, Entry *e)
EListlist_create ()
int entry_match (Entry *e, char *nick, char *user, char *host, uint32 ip)
int entry_match_mask (Entry *e, char *mask, uint32 ip)
Entryelist_match (EList *list, char *nick, char *user, char *host, uint32 ip)
Entryelist_match_mask (EList *list, char *mask, uint32 ip)
static Entry_elist_match_user (EList *list, User *u, boolean full)
Entryelist_match_user (EList *list, User *u)
Entryelist_match_user_full (EList *list, User *u, boolean full)
Entryelist_find_mask (EList *list, char *mask)
long get_memuse (EList *list)

Variables

Channelchanlist [1024]
static Channelcurrent
static int next_index

Define Documentation

#define HASH (   chan  )     ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0)

Definition at line 19 of file channels.c.

Referenced by chan_create(), chan_delete(), and findchan().


Function Documentation

static Entry* _elist_match_user ( EList list,
User u,
boolean  full 
) [static]

Check if a user matches an entry on a list.

Parameters:
list EntryList that should be matched against
user The user to match against the entries
full true to match against real host and real IP
Returns:
Returns the first matching entry, if none, NULL is returned.

Definition at line 2400 of file channels.c.

References user_::chost, elist_match(), c_elist::entries, user_::host, host_resolve(), user_::hostip, user_::nick, sstrdup(), str_is_ip(), user_::username, user_::vhost, and user_::vident.

Referenced by elist_match_user(), and elist_match_user_full().

void add_ban ( Channel chan,
char *  mask 
)
void add_exception ( Channel chan,
char *  mask 
)
void add_invite ( Channel chan,
char *  mask 
)
void chan_adduser2 ( User user,
Channel c 
)
Channel* chan_create ( char *  chan,
time_t  ts 
)
void chan_delete ( Channel c  ) 
void chan_deluser ( User user,
Channel c 
)
char* chan_get_modes ( Channel chan,
int  complete,
int  plus 
)
int chan_get_user_status ( Channel chan,
User user 
)

Definition at line 109 of file channels.c.

References user_::chans, and user_::u_chanlist::next.

Referenced by botchanmsgs(), chan_set_correct_modes(), and chan_set_modes().

int chan_has_user_status ( Channel chan,
User user,
int16  status 
)

Definition at line 124 of file channels.c.

References alog(), user_::chans, debug, and user_::u_chanlist::next.

Referenced by do_clear(), do_clearmodes(), and do_register().

void chan_remove_user_status ( Channel chan,
User user,
int16  status 
)
void chan_set_correct_modes ( User user,
Channel c,
int  give_modes 
)

Set the correct modes, or remove the ones granted without permission, for the specified user on ths specified channel. This doesn't give modes to ignored users, but does remove them if needed.

Parameters:
user The user to give/remove modes to/from
c The channel to give/remove modes on
give_modes Set to 1 to give modes, 0 to not give modes
Returns:
void

Definition at line 1434 of file channels.c.

References ircdvars_::admin, ircdvars_::adminset, alog(), anope_cmd_mode(), CA_AUTODEOP, CA_AUTOHALFOP, CA_AUTOOP, CA_AUTOPROTECT, CA_AUTOVOICE, CA_HALFOPME, CA_OPDEOPME, CA_PROTECTME, chan_get_user_status(), chan_remove_user_status(), chan_set_user_status(), check_access(), channel_::ci, CI_SECUREOPS, CI_VERBOTEN, CUS_HALFOP, CUS_OP, CUS_OWNER, CUS_PROTECT, CUS_VOICE, debug, nickcore_::flags, chaninfo_::flags, get_ignore(), GET_USER, ircdvars_::halfop, ircd, is_founder(), is_sync(), is_ulined(), user_::na, server_::name, channel_::name, nickalias_::nc, NI_AUTOOP, user_::nick, ircdvars_::owner, ircdvars_::ownerset, ircdvars_::protect, user_::server, stripModePrefix(), channel_::usercount, and whosends.

Referenced by chan_set_modes(), do_enforce_secureops(), do_join(), do_setmodes(), and do_sjoin().

void chan_set_key ( Channel chan,
char *  value 
)

Definition at line 1981 of file channels.c.

References alog(), debug, channel_::key, channel_::name, and sstrdup().

void chan_set_modes ( const char *  source,
Channel chan,
int  ac,
char **  av,
int  check 
)
void chan_set_throttle ( Channel chan,
char *  value 
)

Definition at line 1968 of file channels.c.

References alog(), debug, channel_::name, sstrdup(), and channel_::throttle.

Referenced by anope_event_capab().

void chan_set_user_status ( Channel chan,
User user,
int16  status 
)
void del_ban ( Channel chan,
char *  mask 
)
void del_exception ( Channel chan,
char *  mask 
)
void del_invite ( Channel chan,
char *  mask 
)
void do_cmode ( const char *  source,
int  ac,
char **  av 
)
void do_join ( const char *  source,
int  ac,
char **  av 
)
void do_kick ( const char *  source,
int  ac,
char **  av 
)
void do_mass_mode ( char *  modes  ) 
void do_part ( const char *  source,
int  ac,
char **  av 
)
void do_sjoin ( const char *  source,
int  ac,
char **  av 
)
void do_topic ( const char *  source,
int  ac,
char **  av 
)
Entry* elist_find_mask ( EList list,
char *  mask 
)

Find a entry identical to the given mask..

Parameters:
list EntryList that should be matched against
mask The *!*@* mask to match
Returns:
Returns the first matching entry, if none, NULL is returned.

Definition at line 2454 of file channels.c.

References c_elist::entries, c_elist_entry::mask, c_elist_entry::next, and stricmp().

Referenced by del_ban(), del_exception(), and del_invite().

Entry* elist_match ( EList list,
char *  nick,
char *  user,
char *  host,
uint32  ip 
)

Match a nick, user, host, and ip to a list entry

Parameters:
e List that should be matched against
nick The nick to match
user The user to match
host The host to match
ip The ip to match
Returns:
Returns the first matching entry, if none, NULL is returned.

Definition at line 2334 of file channels.c.

References c_elist::entries, entry_match(), and c_elist_entry::next.

Referenced by _elist_match_user(), and elist_match_mask().

Entry* elist_match_mask ( EList list,
char *  mask,
uint32  ip 
)

Match a mask and ip to a list.

Parameters:
list EntryList that should be matched against
mask The nick!user mask to match
ip The ip to match
Returns:
Returns the first matching entry, if none, NULL is returned.

Definition at line 2358 of file channels.c.

References elist_match(), c_elist::entries, and sstrdup().

Referenced by is_excepted_mask().

Entry* elist_match_user ( EList list,
User u 
)

Definition at line 2438 of file channels.c.

References _elist_match_user().

Referenced by is_excepted().

Entry* elist_match_user_full ( EList list,
User u,
boolean  full 
)

Definition at line 2443 of file channels.c.

References _elist_match_user().

Entry* entry_add ( EList list,
char *  mask 
)

Create an entry and add it at the beginning of given list.

Parameters:
list The List the mask should be added to
mask The mask to parse and add to the list
Returns:
Pointer to newly added entry. NULL if it fails.

Definition at line 2176 of file channels.c.

References c_elist::count, c_elist::entries, entry_create(), c_elist_entry::next, c_elist_entry::prev, and sstrdup().

Referenced by add_ban(), add_exception(), and add_invite().

Entry* entry_create ( char *  mask  ) 

This handles creating a new Entry. This function destroys and free's the given mask as a side effect.

Parameters:
mask Host/IP/CIDR mask to convert to an entry
Returns:
Entry struct for the given mask, NULL if creation failed

Definition at line 2076 of file channels.c.

References c_elist_entry::cidr_ip, c_elist_entry::cidr_mask, ircdvars_::cidrchanbei, c_elist_entry::host, ircd, c_elist_entry::mask, c_elist_entry::next, c_elist_entry::nick, c_elist_entry::prev, scalloc(), sstrdup(), str_is_cidr(), str_is_pure_wildcard(), str_is_wildcard(), c_elist_entry::type, and c_elist_entry::user.

Referenced by entry_add().

void entry_delete ( EList list,
Entry e 
)

Delete the given entry from a given list.

Parameters:
list Linked list from which entry needs to be removed.
e The entry to be deleted, must be member of list.

Definition at line 2204 of file channels.c.

References c_elist::count, c_elist::entries, c_elist_entry::host, c_elist_entry::mask, c_elist_entry::next, c_elist_entry::nick, c_elist_entry::prev, and c_elist_entry::user.

Referenced by add_ban(), chan_delete(), del_ban(), del_exception(), and del_invite().

int entry_match ( Entry e,
char *  nick,
char *  user,
char *  host,
uint32  ip 
)

Match the given Entry to the given user/host and optional IP addy

Parameters:
e Entry struct to match against
nick Nick to match against
user User to match against
host Host to match against
ip IP to match against, set to 0 to not match this
Returns:
1 for a match, 0 for no match

Definition at line 2255 of file channels.c.

References c_elist_entry::cidr_ip, c_elist_entry::cidr_mask, ircdvars_::cidrchanbei, ENTRYTYPE_CIDR4, ENTRYTYPE_HOST, ENTRYTYPE_HOST_WILD, ENTRYTYPE_NICK, ENTRYTYPE_NICK_WILD, ENTRYTYPE_NONE, ENTRYTYPE_USER, ENTRYTYPE_USER_WILD, c_elist_entry::host, ircd, match_wild_nocase(), c_elist_entry::nick, stricmp(), c_elist_entry::type, and c_elist_entry::user.

Referenced by _common_unban(), add_ban(), bot_join(), elist_match(), and entry_match_mask().

int entry_match_mask ( Entry e,
char *  mask,
uint32  ip 
)

Match the given Entry to the given hostmask and optional IP addy.

Parameters:
e Entry struct to match against
mask Hostmask to match against
ip IP to match against, set to 0 to not match this
Returns:
1 for a match, 0 for no match

Definition at line 2293 of file channels.c.

References entry_match(), and sstrdup().

Referenced by stick_mask().

Channel* findchan ( const char *  chan  ) 
Channel* firstchan ( void   ) 

Definition at line 428 of file channels.c.

References alog(), debug, channel_::name, and next_index.

Referenced by do_mass_mode(), and restore_unsynced_topics().

void get_channel_stats ( long *  nrec,
long *  memuse 
)
char* get_flood ( Channel chan  ) 

Definition at line 1843 of file channels.c.

References channel_::flood.

char* get_key ( Channel chan  ) 

Definition at line 1857 of file channels.c.

References channel_::key.

char* get_limit ( Channel chan  ) 

Definition at line 1864 of file channels.c.

References channel_::limit, and snprintf().

long get_memuse ( EList list  ) 

Gets the total memory use of an entrylit.

Parameters:
list The list we should estimate the mem use of.
Returns:
Returns the memory useage of the given list.

Definition at line 2474 of file channels.c.

References c_elist::count, c_elist::entries, c_elist_entry::host, c_elist_entry::mask, c_elist_entry::next, c_elist_entry::nick, and c_elist_entry::user.

Referenced by get_channel_stats().

char* get_redirect ( Channel chan  ) 

Definition at line 1877 of file channels.c.

References channel_::redirect.

char* get_throttle ( Channel chan  ) 

Definition at line 1850 of file channels.c.

References channel_::throttle.

char* get_unkwn ( Channel chan  ) 

Definition at line 1886 of file channels.c.

int is_on_chan ( Channel c,
User u 
)
Channel* join_user_update ( User user,
Channel chan,
char *  name,
time_t  chants 
)
EList* list_create (  ) 

Create and initialize a new entrylist

Returns:
Pointer to the created EList object

Definition at line 2234 of file channels.c.

References c_elist::count, c_elist::entries, and scalloc().

Referenced by add_ban(), add_exception(), and add_invite().

User* nc_on_chan ( Channel c,
NickCore nc 
)

Definition at line 531 of file channels.c.

References channel_::c_userlist::next, nick_recognized(), and channel_::users.

Referenced by do_fantasy().

Channel* nextchan ( void   ) 

Definition at line 439 of file channels.c.

References alog(), debug, channel_::name, channel_::next, and next_index.

Referenced by do_mass_mode(), and restore_unsynced_topics().

void restore_unsynced_topics ( void   ) 

Definition at line 2058 of file channels.c.

References c, firstchan(), channel_::name, nextchan(), restore_topic(), and channel_::topic_sync.

Referenced by finish_sync().

void set_flood ( Channel chan,
char *  value 
)

Definition at line 1955 of file channels.c.

References alog(), debug, channel_::flood, channel_::name, and sstrdup().

Referenced by anope_event_capab().

void set_limit ( Channel chan,
char *  value 
)

Definition at line 1994 of file channels.c.

References alog(), debug, channel_::limit, and channel_::name.

void set_redirect ( Channel chan,
char *  value 
)

Definition at line 2005 of file channels.c.

References alog(), debug, channel_::name, channel_::redirect, and sstrdup().

Referenced by anope_event_capab().

void set_unkwn ( Channel chan,
char *  value 
)

Definition at line 2020 of file channels.c.

Referenced by anope_event_capab().


Variable Documentation

Channel* chanlist[1024]

Definition at line 17 of file channels.c.

Channel* current [static]
int next_index [static]

Definition at line 426 of file channels.c.

Referenced by firstchan(), and nextchan().