Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

chanserv.c File Reference

ChanServ Implementation. More...

#include "services.h"
#include "chanserv.h"
#include "nickserv.h"
#include "macro.h"
#include "queue.h"
#include "hash.h"
#include "db.h"
#include "log.h"
#include "email.h"
#include "interp.h"
#include "chantrig.h"
#include "hash/md5pw.h"

Go to the source code of this file.

Classes

struct  _cs_settbl__
 This is a datatype used for creating the /ChanServ SET table. More...


Defines

#define ARGLEN   150
#define DEFIFZERO(value, default)   ((value) ? (value) : (default))
#define process_op_item(x)
 Process an access check on a chanop item.

#define CSO(q)   (((size_t) &((RegChanList *)0)->q))
 /ChanServ Set related macro This is a hack to allow for generalized ChanServ set types such as cs_set_bool and cs_set_string.

#define DMOD_KEY(nm, va)   else if (strcmp(args[i], nm) == 0) {tar=(va); i++; break;}

Typedefs

typedef _cs_settbl__ cs_settbl_t
 This is a datatype used for creating the /ChanServ SET table.


Functions

const char * GetAuthChKey (const char *, const char *, time_t, u_int32_t)
const char * PrintPass (u_char pI[], char enc)
 Print a password appropriately encoded according to its encryption type (if applicable).

char * urlEncode (const char *)
void createGhostChannel (char *)
 Have ChanServ join a channel.

void deleteGhostChannel (char *)
 Remove ChanServ from an enforced channel to end the ghost period.

void deleteTimedGhostChannel (char *)
 Timed ending of a Channel enforcement period.

cmd_return do_chanop (services_cmd_id, UserList *, RegChanList *chan, const char *nick, int level)
 Handle one of the services channel oplist editing commands such as '/ChanServ AOP'.

cmd_return do_chanop_del (UserList *isfrom, RegChanList *chan, const char *cTargetNick, int tarLevel)
 Handle one of the services channel oplist DEL commands such as '/ChanServ AOP DEL'.

cmd_return do_chanop_add (UserList *isfrom, RegChanList *chan, const char *cTargetNick, int tarLevel)
 Handle one of the services channel oplist ADD commands such as '/ChanServ AOP ADD'.

cmd_return do_chanop_list (UserList *isfrom, RegChanList *chan, const char *cTargetNick, int tarLevel)
 Handle one of the services channel oplist LIST commands such as '/ChanServ AOP LIST'.

cmd_return cs_set_passwd (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_memolvl (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_founder (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_string (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_fixed (cs_settbl_t *, UserList *, RegChanList *, char **, int)
 Generic set for a string of fixed length.

cmd_return cs_set_bool (cs_settbl_t *, UserList *, RegChanList *, char **, int)
 Generic set for an on|off flag setting.

cmd_return cs_set_mlock (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_restrict (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_topiclock (cs_settbl_t *, UserList *, RegChanList *, char **, int)
cmd_return cs_set_encrypt (cs_settbl_t *, UserList *, RegChanList *, char **, int)
int BadPwChan (UserList *nick, RegChanList *target)
 Handle a bad password attempt.

void GoodPwChan (UserList *nick, RegChanList *target)
 A user successfully identified to a channel, send them badpw information since their last `login'.

void addChan (ChanList *newchan)
 Add an online channel to the hash table and linked list.

void addRegChan (RegChanList *newchan)
 Add a registered channel to the hash table and linked list.

void addChanUser (ChanList *channel, cNickList *newnick)
 Add an online user to an online channel's user hash and linked list.

void addChanBan (ChanList *channel, cBanList *item)
 Add a ban item to an online channel's banlist.

void addChanAkick (RegChanList *channel, cAkickList *item)
 Add an autokick list item to a registered channel's autokick list.

void addChanOp (RegChanList *channel, cAccessList *item)
 Add an 'access list' item to a registered channel's operator list.

void delChan (ChanList *killme)
 remove a channel from the channel list, and close it up where necessary

void delRegChan (RegChanList *killme)
 Delete a registered channel.

void freeRegChan (RegChanList *killme)
 Frees a registered channel and its data.

void delChanUser (ChanList *channel, cNickList *nick, int doCleanChan)
void delChanBan (ChanList *channel, cBanList *item)
void delChanAkick (RegChanList *channel, cAkickList *item)
void delChanOp (RegChanList *channel, cAccessList *item)
ChanListgetChanData (char *name)
 Find a channel in the list of online channels.

RegChanList * getRegChanData (char *name)
 Find a registered channel in the list.

char ChanGetEnc (RegChanList *rcl)
 Get the encryption status of a registered channel object.

char ChanGetIdent (RegChanList *rcl)
 Get the IDENT flag status of a registered channel object.

cNickListgetChanUserData (ChanList *chan, UserList *data)
 Find a user channel record in an online channel.

int getMiscChanOp (RegChanList *chan, char *nick, int id, char *checkAccessNick)
 Get the channel access level.

int getChanOp (RegChanList *chan, char *nick)
 Get a user's chanop access to a channel.

int getChanOpId (RegChanList *chan, char *nick)
 Get a user's chanop access to a channel requiring that they be identified to have any access.

cAccessListgetChanOpData (const RegChanList *chan, const char *nick)
 Get the chanop data structure of a nick that might be in the access list.

cBanListgetChanBan (ChanList *chan, char *ban)
 Search for a certain ban in a channel (What's this for?).

cAkickListgetChanAkick (RegChanList *chan, char *akick)
 Search for a specific akick in a channel.

void indexAkickItems (RegChanList *chan)
 Re-Index the akick list.

void indexOpItems (RegChanList *chan)
 Re-Index the oplist.

void clearChanIdent (RegChanList *chan)
 Clear channel identification structures (un-identify).

int isFounder (RegChanList *chan, UserList *nick)
 Determine if a user is the founder of a channel.

int is_sn_chan (char *ch_name)
 Reports whether/not this an official SorceryNet channel like #sorcery.

void initRegChanData (RegChanList *chan)
 Initialize (clean) a registered channel object Init data on a registered channel (clean hashes and pointers).

void sendToChanOps (ChanList *chan, char *format,...)
void sendToChanOpsAlways (ChanList *chan, char *format,...)
void banKick (ChanList *chan, UserList *nick, char *format,...)
 Kick and ban a user from a channel.

char * initModeStr (ChanList *chan)
 Generate initial mode string.

void makeModeLockStr (RegChanList *chan, char *modelock)
 Generate mode-lock string.

void addUserToChan (UserList *nick, char *channel)
 Add user to a channel.

void remUserFromChan (UserList *nick, char *channel)
 Removes a user from channel(s).

void remFromAllChans (UserList *nick)
void changeNickOnAllChans (UserList *oldnick, UserList *newnick)
void setChanMode (char **args, int numargs)
 Updates services' idea of what a channel's modes are.

void setChanTopic (char **args, int numargs)
 Tell ChanServ about a topic change.

const char * opLevelName (int level, int x_case)
 Print the name of an op level.

int opNameLevel (const char *name)
 Converts a level name into a number.

void syncChanData (time_t next)
int ValidChannelName (const char *nmtoken)
void expireChans (char *arg)
void sendToChanServ (UserList *nick, char **args, int numargs)
 Parse a ChanServ command.

 CCMD (cs_help)
 CCMD (cs_chanop)
 CCMD (cs_akick)
 CCMD (cs_mdeop)
 CCMD (cs_mkick)
void sendChannelInfo (UserList *nick, RegChanList *chan, int fTerse)
 Print results of a /Chanserv Info to a user.

 CCMD (cs_info)
 CCMD (cs_access)
 Get access level [?of target] on channel.

 CCMD (cs_register)
 CCMD (cs_identify)
 CCMD (cs_addop)
int cleanChopList (RegChanList *chan)
 Clean out bad chanops.

 CCMD (cs_clean)
 CCMD (cs_addak)
 CCMD (cs_wipeak)
 CCMD (cs_wipeop)
 CCMD (cs_delak)
 CCMD (cs_listop)
 CCMD (cs_listak)
 CCMD (cs_drop)
 CCMD (cs_op)
 CCMD (cs_deop)
 CCMD (cs_banish)
 CCMD (cs_close)
 CCMD (cs_hold)
 Hold/unhold a channel from expiration.

 CCMD (cs_mark)
 Mark/unmark a channel (ServOp command).

 CCMD (cs_clist)
 CCMD (cs_whois)
 CCMD (cs_restrict)
 CCMD (cs_topiclock)
 CCMD (cs_modelock)
 CCMD (cs_set)
 CCMD (cs_save)
 CCMD (cs_getpass)
 CCMD (cs_getrealpass)
 CCMD (cs_invite)
 CCMD (cs_unban)
 CCMD (cs_delete)
 CCMD (cs_log)
cmd_return cs_setrealpass (UserList *nick, char **args, int numargs)
 CCMD (cs_trigger)
 CCMD (cs_dmod)

Variables

const int TOPIC_MAX = 350
 Maximum length of a topic.

ChanListfirstChan = NULL
 First listed online channel.

ChanListlastChan = NULL
 Last listed online channel.

RegChanList * firstRegChan = NULL
 First listed registered channel.

RegChanList * lastRegChan = NULL
 Last listed registered channel.

interp::service_cmd_t chanserv_commands []
 ChanServ command parse table.

struct {
   int   lev
   const char *   v [3]
oplev_table []
 Provides the conversions between chanop levels and various names.


Detailed Description

ChanServ Implementation.

Functions related to the manipulation of registered channel data, channel op list handling, and all channel management and internal state data services deals with.

Author:
Chip Norkus

Max Byrd

Greg Poma

James Hess

Date:
1996-2001
Id
chanserv.c,v 1.3 2003/10/22 21:07:50 Mysid Exp

Definition in file chanserv.c.


Define Documentation

#define process_op_item  ) 
 

Value:

{ \
    if (x) { \
        if (checkAccessNick) \
        { \
            strncpyzt(checkAccessNick, tmpNickName, NICKLEN); \
        } \
        if (highest < (x)->uflags) { \
            highest = (x)->uflags; \
        } \
    } \
}
Process an access check on a chanop item.

XXX: Macro abuse This macro is used by getMiscChanop to process access items in a channel.

Definition at line 919 of file chanserv.c.

Referenced by getMiscChanOp().


Function Documentation

void addChan ChanList newchan  ) 
 

Add an online channel to the hash table and linked list.

Parameters:
newchan Pointer to the online channel to be added
Precondition:
Newchan is a pointer to an initialized online channel record that has not yet been listed. The channel name member holds the name of the channel.
Postcondition:
The channel record ``newchan'' is added to the online channels table (has been listed).

Definition at line 285 of file chanserv.c.

References chanhashent::chan, ChanHash, firstChan, getChanData(), getHashKey(), chanlist_struct::hashnext, chanlist_struct::hashprev, lastChan, chanhashent::lastchan, chanlist_struct::name, chanlist_struct::next, and chanlist_struct::previous.

Referenced by addUserToChan().

void addChanAkick RegChanList *  channel,
cAkickList item
 

Add an autokick list item to a registered channel's autokick list.

Parameters:
channel Channel database item that autokick object should be added to
item Autokick object to be added to a registered channel object
Precondition:
Channel is a pointer to a valid REGISTERED channel record, and item is a pointer to a freshly-allocated cAkickList (or ChanServ AutoKick) item that has not yet been stored in a list.
Postcondition:
The ``item'' record is inserted in the ``channel autokick'' linked list.

Definition at line 446 of file chanserv.c.

References indexAkickItems(), cakicklist_struct::next, and cakicklist_struct::previous.

Referenced by readChanData().

void addChanBan ChanList channel,
cBanList item
 

Add a ban item to an online channel's banlist.

Parameters:
channel Online channel that a ban object should be added to
item Ban object to be added to ChanServ's information on a channel's banlist.
Precondition:
Channel is a pointer to a valid online channel record, and item is a pointer to a freshly-allocated cBanList (or channel ban-list entry) record that has not yet been stored in a list.
Postcondition:
The ``item'' record is added to the ``channel'' ban list.

Definition at line 418 of file chanserv.c.

References chanlist_struct::firstBan, chanlist_struct::lastBan, cbanlist_struct::next, and cbanlist_struct::previous.

Referenced by addUserToChan(), banKick(), and setChanMode().

void addChanOp RegChanList *  channel,
cAccessList item
 

Add an 'access list' item to a registered channel's operator list.

Parameters:
channel Registered channel object of item to be added
item Object to be added to the channel access list
Precondition:
Channel is a pointer to a valid REGISTERED channel record, and item is a pointer to a freshly-allocated cAccessList (or ChanServ operator) item that has not yet been stored in a list.
Postcondition:
The ``item'' record is inserted in the ``channel operator'' linked list but has been initialized to contain the appropriate nickname.
Warning:
Once an access list record is listed, the nickname of the record should never be altered.

Definition at line 476 of file chanserv.c.

References RegId::getHashKey(), caccesslist_struct::hashnext, caccesslist_struct::hashprev, indexOpItems(), caccesslist_struct::next, caccesslist_struct::nickId, and caccesslist_struct::previous.

Referenced by readChanData().

void addChanUser ChanList channel,
cNickList newnick
 

Add an online user to an online channel's user hash and linked list.

Parameters:
channel Online channel whom a user is to be added to
newnick A pointer to a channel-nick object to add to the hash table and list of the channel's members
Precondition:
Channel is a pointer to a valid online channel record, and newnick is a pointer to a freshly-allocated cNickList (or channel member entry) record that is not in a list but has been initialized to contain the appropriate nickname.
Postcondition:
The ``newnick'' record is stored in the ``channel'' member list.
Warning:
Once a userlist record is listed, the nickname of the record should never be altered.

Definition at line 371 of file chanserv.c.

References chanlist_struct::firstUser, getHashKey(), cnicklist_struct::hashnext, cnicklist_struct::hashprev, cnicklisthashent_struct::item, cnicklisthashent_struct::lastitem, chanlist_struct::lastUser, cnicklist_struct::next, _userlist::nick, cnicklist_struct::person, cnicklist_struct::previous, and chanlist_struct::users.

Referenced by addUserToChan(), and changeNickOnAllChans().

void addRegChan RegChanList *  newchan  ) 
 

Add a registered channel to the hash table and linked list.

Parameters:
newchan Pointer to a channel database object to add into the list
Precondition:
Newchan is a pointer to an initialized registered channel record that is not yet listed. The channel name member holds the name of the channel.
Postcondition:
The record ``newchan'' is added to the registered channels table (the channel is listed).

Definition at line 326 of file chanserv.c.

References regchanhashent::chan, firstRegChan, freeRegChan(), getHashKey(), getRegChanData(), regchanhashent::lastchan, lastRegChan, and RegChanHash.

Referenced by readChanData().

void addUserToChan UserList nick,
char *  channel
 

Add user to a channel.

Adds a user to the specified channel after a JOIN

Parameters:
nick Pointer to an online user item
channel Name of a channel
Warning:
MAXCHANSPERUSER as used by ircd must be match the value of NICKCHANHASH or desyncs will occur.
Bug:
this depends on maxchans

Definition at line 1584 of file chanserv.c.

References addChan(), addChanBan(), addChanUser(), AOP, cbanlist_struct::ban, banKick(), CBANISH, CCLOSE, CCSJOIN, _userlist::chan, CHANOP, ChanServ, CHANVOICE, CKTOPIC, createGhostChannel(), CTime, DEBUGCHAN, delChanUser(), deleteTimedGhostChannel(), dlogEntry(), chanlist_struct::firstUser, genHostMask(), getChanData(), getChanOp(), getRegChanData(), HELPOPS_CHAN, _userlist::host, initModeStr(), isOper(), makeModeLockStr(), MAOP, cakicklist_struct::mask, match(), MFOUNDER, MM_K, chanlist_struct::name, cakicklist_struct::next, _userlist::nick, NISHELPOP, oalloc(), _userlist::oflags, cnicklist_struct::op, cnicklist_struct::person, PM_I, PM_K, PM_L, chanlist_struct::reg, remFromAllChans(), remUserFromChan(), sSend(), strncpyzt, timer(), and _userlist::user.

Referenced by parseLine().

int BadPwChan UserList nick,
RegChanList *  target
 

Handle a bad password attempt.

Parameters:
nick User who failed to enter password correctly
target Pointer to channel attempt was against
Returns:
1 if the user was killed, 0 if not
Precondition:
nick is a user on IRC, target points to a listed registered channel object.
Postcondition:
A bad password attempt by `nick' has been recorded against `target'. If 1 was returned, then `nick' may no longer be valid or even on IRC.

Definition at line 228 of file chanserv.c.

References addFlood(), _userlist::badpws, ChanServ, _userlist::nick, and sSend().

void banKick ChanList chan,
UserList nick,
char *  format,
... 
 

Kick and ban a user from a channel.

Kicks a user off the specified channel and sets a ban.

Parameters:
chan Pointer to a channel item
nick Pointer to online nickname (target item)
format Kick message format string
... Kick message format argument list
Precondition:
Chan points to a listed, valid online channel record. Nick points to a listed, valid online user record. Format points to a valid NUL-terminated character array, and format and the following parameters form a valid format string and set of arguments for that string.
Postcondition:
An IRC message has been sent to kick and ban the specified online user. This procedure does not perform the internal updates necessary to note a change.
Warning:
This function can cause a channel to be deleted, 'chan' should be treated as no longer valid after a call to this function -- since it is void, there is no way to test if the pointer value is still valid short of a lookup by name in the Channel hash table.

Definition at line 1371 of file chanserv.c.

References addChanBan(), cbanlist_struct::ban, ChanServ, DEBUGCHAN, delChanUser(), getChanUserData(), _userlist::host, mask(), chanlist_struct::name, _userlist::nick, oalloc(), sSend(), strncpyzt, and _userlist::user.

Referenced by addUserToChan().

CCMD cs_trigger   ) 
 

cmd_cs_trigger Command Syntax: a. TRIGGER Show system defaults b. TRIGGER LIST List triggers c. TRIGGER Show trigger levels d. TRIGGER DEFAULTS Remove all triggered data e. TRIGGER MaxAkicks Change max number akicks f. TRIGGER MaxOps Change max number chanops

Definition at line 6955 of file chanserv.c.

CCMD cs_getpass   ) 
 

Todo:
This stuff should be done using ``getopt_long_only''. Parse ChanServ getpass options

Definition at line 6152 of file chanserv.c.

CCMD cs_mark   ) 
 

Mark/unmark a channel (ServOp command).

Author:
--Mysid (James Hess) <mysidia-ss@flame.org>

Definition at line 5010 of file chanserv.c.

CCMD cs_hold   ) 
 

Hold/unhold a channel from expiration.

Author:
--Mysid (James Hess) <mysidia-ss@flame.org>

Definition at line 4930 of file chanserv.c.

CCMD cs_identify   ) 
 

Identify for founder access

Improvements, support for identity using a nick other than listed in /cs info (remote id.) -Mysid

XXX should check nick->caccess maybe?

Definition at line 3480 of file chanserv.c.

CCMD cs_access   ) 
 

Get access level [?of target] on channel.

Improved to always indicate nick used to get access unless not the same as the present nick. -Mysid

Definition at line 3251 of file chanserv.c.

void changeNickOnAllChans UserList oldnick,
UserList newnick
 

Changes a user's nicknames on all channels that they have joined

Parameters:
oldnick Pointer to the original nickname of the user
newnick Pointer to an online user item of the target nickname

Definition at line 2029 of file chanserv.c.

References addChanUser(), _userlist::chan, ChanServ, DEBUGCHAN, delChanUser(), getChanUserData(), _userlist::nick, oalloc(), cnicklist_struct::op, cnicklist_struct::person, and sSend().

Referenced by changeNick().

char ChanGetEnc RegChanList *  rcl  ) 
 

Get the encryption status of a registered channel object.

Returns:
$ for MD5 encrypted, @ for plaintext

Definition at line 861 of file chanserv.c.

References CENCRYPT.

Referenced by IpcType::alterObjMessage(), and IpcType::authObjMessage().

char ChanGetIdent RegChanList *  rcl  ) 
 

Get the IDENT flag status of a registered channel object.

Returns:
1 for IDENT enabled, 0 for disabled

Definition at line 873 of file chanserv.c.

References CIDENT.

void clearChanIdent RegChanList *  chan  ) 
 

Clear channel identification structures (un-identify).

Parameters:
Registered channel to clear identification data for
Precondition:
Chan is a pointer to a valid, listed registered channel record.
Postcondition:
Any identification to the channel by password is cleared.

Definition at line 1218 of file chanserv.c.

Referenced by isFounder().

void createGhostChannel char *  chan  ) 
 

Have ChanServ join a channel.

Parameters:
chan Name of channel to join
Precondition:
Chan points to a valid NUL-terminated character array.
Postcondition:
An IRC message has been sent to join chanserv into the channel, and the registered channel record has been flagged as 'ghosted' if the channel is registered.

Definition at line 1453 of file chanserv.c.

References CCSJOIN, ChanServ, getRegChanData(), and sSend().

Referenced by addUserToChan().

cmd_return cs_set_encrypt cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Encrypt/decrypt a channel password

Definition at line 5756 of file chanserv.c.

References RET_FAIL, and sSend().

cmd_return cs_set_founder cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Change channel founder SET FOUNDER [User must be identified to channel first]

Definition at line 6018 of file chanserv.c.

cmd_return cs_set_memolvl cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Set for channel memo level

Definition at line 6080 of file chanserv.c.

References is_sn_chan(), OGRP, and opFlagged().

cmd_return cs_set_mlock cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Set a channel mode lock

Definition at line 5813 of file chanserv.c.

References ChanServ, MM_K, PM_K, sSend(), and strncpyzt.

cmd_return cs_set_passwd cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Change a channel password

Bug:
4, 15 should be symbolized

Definition at line 5962 of file chanserv.c.

References RET_OK_DB, and sSend().

cmd_return cs_set_restrict cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Set for a channel restrict level

Definition at line 5631 of file chanserv.c.

cmd_return cs_set_string cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Generic: /CS SET <string|*>

Definition at line 5478 of file chanserv.c.

References RET_OK_DB, and sSend().

cmd_return cs_set_topiclock cs_settbl_t cmd,
UserList nick,
RegChanList *  regchan,
char **  args,
int  numargs
 

Set for channel topiclock level

Definition at line 5693 of file chanserv.c.

References RET_OK_DB.

void delChan ChanList killme  ) 
 

remove a channel from the channel list, and close it up where necessary

Parameters:
killme Channel to remove from services' online channels list and destroy
Precondition:
Killme is a pointer to a listed online channel record.
Postcondition:
The channel is unlisted, removed from the table, and the memory area is freed.
Warning:
This does free killme.

Definition at line 519 of file chanserv.c.

References chanhashent::chan, ChanHash, firstChan, getHashKey(), chanlist_struct::hashnext, chanlist_struct::hashprev, lastChan, chanhashent::lastchan, chanlist_struct::name, chanlist_struct::next, and chanlist_struct::previous.

Referenced by delChanUser().

void delChanAkick RegChanList *  channel,
cAkickList item
 

Remove channel akick

Precondition:
Channel points to a valid, listed registered channel record. Item points to a valid cAkickList record that can be found in the autokick list of channel.
Postcondition:
Item is removed from the channel autokick list and the memory area pointed to by item is freed.

Definition at line 732 of file chanserv.c.

References indexAkickItems(), cakicklist_struct::next, and cakicklist_struct::previous.

void delChanBan ChanList channel,
cBanList item
 

Remove a channel ban item

Precondition:
Channel points to a valid, listed channel record. Item points to a valid cBanList channel ban list record that can be found in the ban list of channel.
Postcondition:
Item is removed from the channel banlist and the memory area pointed to by item is freed.

Definition at line 708 of file chanserv.c.

References chanlist_struct::firstBan, chanlist_struct::lastBan, cbanlist_struct::next, and cbanlist_struct::previous.

Referenced by setChanMode().

void delChanOp RegChanList *  channel,
cAccessList item
 

Remove channel operator

Parameters:
channel Channel item to remove an operator from
item Access list entry to remove
Precondition:
Channel points to a valid, listed registered channel record. Item points to a valid cAccessList record that can be found in the channel operator list of channel.
Postcondition:
Item is removed from the channel operator list and the memory area pointed to by item is freed.

Definition at line 759 of file chanserv.c.

References RegId::getHashKey(), caccesslist_struct::hashnext, caccesslist_struct::hashprev, indexOpItems(), caccesslist_struct::next, caccesslist_struct::nickId, and caccesslist_struct::previous.

void delChanUser ChanList channel,
cNickList nick,
int  doCleanChan
 

Now delete the user from the channel, gee is this easy or what? no. :>

Parameters:
channel Channel to delete from
nick User to delete
doCleanChan Clean an empty channel or no?
Precondition:
Channel points to a valid, listed online channel record, and Nick points to a valid cNickList record that can be found in the proper members hash table bucket of the channel record.
Postcondition:
The nick record is removed from the table and the memory pointed to by nick is freed. If no member structures remain, then the entire channel is unlisted and freed if doCleanChan is true.

Definition at line 650 of file chanserv.c.

References _userlist::chan, delChan(), chanlist_struct::firstUser, getHashKey(), cnicklist_struct::hashnext, cnicklist_struct::hashprev, cnicklisthashent_struct::item, cnicklisthashent_struct::lastitem, chanlist_struct::lastUser, cnicklist_struct::next, _userlist::nick, cnicklist_struct::person, cnicklist_struct::previous, and chanlist_struct::users.

Referenced by addUserToChan(), banKick(), changeNickOnAllChans(), remFromAllChans(), and remUserFromChan().

void deleteGhostChannel char *  chan  ) 
 

Remove ChanServ from an enforced channel to end the ghost period.

Parameters:
chan Name of channel to leave
Precondition:
Chan points to a valid NUL-terminated character array that contains the name of a known ghost channel.
Postcondition:
An IRC message has been sent to PART chanserv from the channel, and the registered channel record 'ghosted' flag is removed if the channel is registered.

Definition at line 1473 of file chanserv.c.

References CCSJOIN, ChanServ, getRegChanData(), and sSend().

Referenced by deleteTimedGhostChannel().

void deleteTimedGhostChannel char *  chan  ) 
 

Timed ending of a Channel enforcement period.

Parameters:
chan Name of enforced channel to expire
Warning:
Function frees the 'chan' pointer

Definition at line 1488 of file chanserv.c.

References deleteGhostChannel(), and deleteTimedGhostChannel().

Referenced by addUserToChan(), and deleteTimedGhostChannel().

void delRegChan RegChanList *  killme  ) 
 

Delete a registered channel.

Remove a channel from the registered channel list, and close it up where necessary

Parameters:
killme Registered channel object to be deleted
Precondition:
Killme is a pointer to a listed registered channel record.
Postcondition:
The registration record is unlisted, removed from the table, and the memory area is freed.
Warning:
This procedure does not search for and update the 'reg' member of the online channel record to indicate that it is no longer registered. The caller must do this.

This does free killme.

Definition at line 569 of file chanserv.c.

References regchanhashent::chan, firstRegChan, freeRegChan(), getHashKey(), regchanhashent::lastchan, lastRegChan, RegNickIdMap::nick, and RegChanHash.

Referenced by expireChans().

cmd_return do_chanop services_cmd_id  cmd,
UserList isfrom,
RegChanList *  chan,
const char *  cTargetNick,
int  tarLevel
[static]
 

Handle one of the services channel oplist editing commands such as '/ChanServ AOP'.

Parameters:
services_cmd_id Command interface chosen, #CS_ADDOP, #CS_DELOP, or #CS_LISTOP
isfrom User sending the command
chan Pointer to registered chnanel record to be effected
cTargetNick Nickname to be effected
tarLevel Access level target [to add, remove from, etc]

Definition at line 3640 of file chanserv.c.

cmd_return do_chanop_add UserList isfrom,
RegChanList *  chan,
const char *  cTargetNick,
int  tarLevel
[static]
 

Handle one of the services channel oplist ADD commands such as '/ChanServ AOP ADD'.

Parameters:
isfrom User sending the command
chan Pointer to registered chnanel record to be effected
cTargetNick Nickname to be added
tarLevel Access level to add op at

Definition at line 3708 of file chanserv.c.

References ChanServ, FOUNDER, getChanOpData(), isFounder(), MAOP, MSOP, _userlist::nick, ODMOD, opFlagged(), opLevelName(), OVERRIDE, RET_EFAULT, RET_FAIL, RET_NOPERM, RET_OK_DB, SOP, sSend(), and caccesslist_struct::uflags.

cmd_return do_chanop_del UserList isfrom,
RegChanList *  chan,
const char *  cTargetNick,
int  tarLevel
[static]
 

Handle one of the services channel oplist DEL commands such as '/ChanServ AOP DEL'.

Parameters:
isfrom User sending the command
chan Pointer to registered chnanel record to be effected
cTargetNick Nickname to be deleted
tarLevel Access level to delete ops at

Definition at line 3866 of file chanserv.c.

References RET_NOTARGET.

cmd_return do_chanop_list UserList isfrom,
RegChanList *  chan,
const char *  cTargetNick,
int  tarLevel
[static]
 

Handle one of the services channel oplist LIST commands such as '/ChanServ AOP LIST'.

Parameters:
isfrom User sending the command
chan Pointer to registered chnanel record
cTargetNick Nickname or pattern to search for
tarLevel Access level to list channel operators at

Definition at line 3961 of file chanserv.c.

References ChanServ, mask_structure::host, caccesslist_struct::index, match(), mask_structure::nick, caccesslist_struct::nickId, regnick_ugethost(), sSend(), caccesslist_struct::uflags, and mask_structure::user.

void expireChans char *  arg  ) 
 

Channel Expirations

Definition at line 2503 of file chanserv.c.

References CBANISH, ChanServ, CHOLD, delRegChan(), expireChans(), firstRegChan, getChanData(), SLogfile::log(), mostchans, chanlist_struct::reg, saveChanData(), sSend(), and timer().

Referenced by expireChans(), and parseLine().

void freeRegChan RegChanList *  killme  ) 
 

Frees a registered channel and its data.

Parameters:
killme Registered channel object to release from memory
Precondition:
Killme points to an otherwise valid registered channel record that has been allocated from the heap but is not found in the channel list(s) or table(s).
Postcondition:
The memory area pointed by killme has been freed and all non-null dynamic members of the killme record have been individually freed

Definition at line 623 of file chanserv.c.

Referenced by addRegChan(), and delRegChan().

const char* GetAuthChKey const char *  email,
const char *  password,
time_t  timereg,
u_int32_t  code_arg
 

Precondition:
Email and Password point to valid NUL-terminated character arrays. Timereg is a valid UTC calendar time, and code_arg is a code generated at random.
Returns:
An authentication key for password changes based on a hash of all data
Parameters:
email The user e-mail address
password The value of the nick or channel password structure
code_arg The selected change code

Definition at line 298 of file passwd.c.

cAkickList* getChanAkick RegChanList *  chan,
char *  akick
 

Search for a specific akick in a channel.

Parameters:
chan Pointer to online channel item
akick AutoKick string to look for
Returns:
Null pointer if the specified autokick could not be found, otherwise a pointer to the relevant #cAkickList object.

Definition at line 1163 of file chanserv.c.

References cakicklist_struct::mask, and cakicklist_struct::next.

cBanList* getChanBan ChanList chan,
char *  ban
 

Search for a certain ban in a channel (What's this for?).

Parameters:
chan Pointer to an online channel item to look in
ban Ban to search for
Returns:
NULL if the ban could not be found, or a pointer to the appropriate #cBanList structure if it is found.

Definition at line 1141 of file chanserv.c.

References cbanlist_struct::ban, chanlist_struct::firstBan, and cbanlist_struct::next.

Referenced by setChanMode().

ChanList* getChanData char *  name  ) 
 

Find a channel in the list of online channels.

Parameters:
Name of channel to find
Precondition:
Name points to a valid NUL-terminated character array that is also a valid channel name.
Returns:
Null pointer if no online channel by that name has been listed. #ChanList object if a channel by that name is listed.

Definition at line 803 of file chanserv.c.

References chanhashent::chan, ChanHash, getHashKey(), chanlist_struct::hashnext, and chanlist_struct::name.

Referenced by addChan(), addUserToChan(), expireChans(), gs_roll(), remUserFromChan(), and setChanMode().

int getChanOp RegChanList *  chan,
char *  nick
 

Get a user's chanop access to a channel.

Precondition:
Chan is a null pointer or a pointer to a valid, listed registered channel record. Nick is a null pointer or a pointer to a valid character array.
Returns:
The access level of the specified nickname to the channel.
See also: getMiscChanOp()

Definition at line 1065 of file chanserv.c.

References CIDENT, and getMiscChanOp().

Referenced by addUserToChan(), gs_roll(), remUserFromChan(), setChanMode(), and setChanTopic().

cAccessList* getChanOpData const RegChanList *  chan,
const char *  nick
 

Get the chanop data structure of a nick that might be in the access list.

Parameters:
Pointer to online channel
Name of nickname to find in oplist
Precondition:
Chan is a null pointer or a pointer to a valid, listed registered channel record. Nick is a null pointer or a pointer to a valid character array.
Returns:
A null pointer if the chanop cannot be found, otherwise a pointer to the chanop access object (#cAccessList) is returned.

Definition at line 1105 of file chanserv.c.

References getRegNickData(), caccesslist_struct::hashnext, and caccesslist_struct::nickId.

Referenced by do_chanop_add(), and getMiscChanOp().

int getChanOpId RegChanList *  chan,
char *  nick
 

Get a user's chanop access to a channel requiring that they be identified to have any access.

Precondition:
Chan is a null pointer or a pointer to a valid, listed registered channel record. Nick is a null pointer or a pointer to a valid character array.
Returns:
The access level of the specified nickname to the channel. Identification to an op list item is required for chanop access.
See also: getMiscChanop()

Definition at line 1085 of file chanserv.c.

References getMiscChanOp().

cNickList* getChanUserData ChanList chan,
UserList data
 

Find a user channel record in an online channel.

Parameters:
chan Pointer to an online channel item
data Pointer to an online user item
Precondition:
Chan points to a valid, listed online channel record. Data points to a valid, listed online user record.
Returns:
A null pointer if no channel user record is found for that nickname on the channel. Else a #cNickList record, the membership object for the requested channel for the requested user.

Definition at line 891 of file chanserv.c.

References getHashKey(), cnicklist_struct::hashnext, cnicklisthashent_struct::item, _userlist::nick, cnicklist_struct::person, and chanlist_struct::users.

Referenced by banKick(), changeNickOnAllChans(), gs_roll(), remFromAllChans(), remUserFromChan(), and setChanMode().

int getMiscChanOp RegChanList *  chan,
char *  nick,
int  id,
char *  checkAccessNick
 

Get the channel access level.

Parameters:
chan Pointer to a registered channel item
nick Nickname of user to check access of
#TRUE if user must be identified to have access
checkAccessNick buffer to store information about 'why' a user has access to the channel
Precondition:
Chan points to a valid, listed registered channel record. Nick is a null pointer or points to a valid NUL-terminated character array. Id has a value of 0 or zero, and checkAccessNick is a null pointer or points to a freshly- allocated memory area of size NICKLEN or greater.
Postcondition:
If checkAccessNick was not a null pointer and the highest level of channel access was found through a remote nickname, then that nickname is copied into the checkAccessNick memory area.
Returns:
The access level of the specified nickname to a registered channel, 0 means no access, -1 means AutoKicked, any other value is that of their present chanop access.

Definition at line 950 of file chanserv.c.

References CBANISH, CCLOSE, CFORCEXFER, checkAccess(), FOUNDER, genHostMask(), getChanOpData(), RegId::getNick(), getNickData(), getRegNickData(), _userlist::host, _userlist::id, isFounder(), isIdentified(), isOper(), isRecognized(), cakicklist_struct::mask, match(), cakicklist_struct::next, _userlist::nick, _identifydata::nick, caccesslist_struct::nickId, opFlagged(), OVERRIDE, process_op_item, _userlist::reg, strncpyzt, caccesslist_struct::uflags, and _userlist::user.

Referenced by getChanOp(), and getChanOpId().

RegChanList* getRegChanData char *  name  ) 
 

Find a registered channel in the list.

Parameters:
Name of registered channel to find
Precondition:
Name points to a valid NUL-terminated character array that is also a valid channel name.
Returns:
A pointer to the #RegChanList object for a registered channel record if a registered channel structure by that name has been listed. Otherwise a null pointer.

Definition at line 835 of file chanserv.c.

References regchanhashent::chan, getHashKey(), and RegChanHash.

Referenced by addRegChan(), addUserToChan(), IpcType::alterObjMessage(), IpcType::authObjMessage(), createGhostChannel(), deleteGhostChannel(), readChanData(), and setChanTopic().

void indexAkickItems RegChanList *  chan  ) 
 

Re-Index the akick list.

Parameters:
chan Registered channel to re-index the autokick list of.
Precondition:
Chan is a pointer to a valid, listed registered channel record.
Postcondition:
Autokick items for the channel are renumbered (indexed) starting at 1.

Definition at line 1185 of file chanserv.c.

References cakicklist_struct::index, and cakicklist_struct::next.

Referenced by addChanAkick(), and delChanAkick().

void indexOpItems RegChanList *  chan  ) 
 

Re-Index the oplist.

Parameters:
Registered channel to re-index chanop list of
Precondition:
Chan is a pointer to a valid, listed registered channel record.
Postcondition:
Channel operator items for the channel are renumbered (indexed) starting at 1.

Definition at line 1202 of file chanserv.c.

References caccesslist_struct::index, and caccesslist_struct::next.

Referenced by addChanOp(), and delChanOp().

char* initModeStr ChanList chan  ) 
 

Generate initial mode string.

Returns a pointer to a static buffer holding a copy of the the initial mode string necessary to restore channel modes.

Parameters:
chan Pointer to channel list item
Returns:
A string for initializing a channel's modes

Definition at line 1411 of file chanserv.c.

References initModeStr(), makeModeLockStr(), MM_K, PM_K, PM_L, and chanlist_struct::reg.

Referenced by addUserToChan(), and initModeStr().

void initRegChanData RegChanList *  chan  ) 
 

Initialize (clean) a registered channel object Init data on a registered channel (clean hashes and pointers).

Precondition:
Chan is a pointer to a freshly-allocated registered channel structure that has not yet been listed and has not been used.
Parameters:
chan Registered channel object to be initialized

Definition at line 1284 of file chanserv.c.

Referenced by readChanData().

int is_sn_chan char *  ch_name  ) 
 

Reports whether/not this an official SorceryNet channel like #sorcery.

Precondition:
Chan is a pointer to a valid, NUL-terminated character array.
Returns:
TRUE if that is the case, FALSE if not
bug XXX Use a named constant, not a string constant!

Definition at line 1266 of file chanserv.c.

References LOGCHAN.

Referenced by cs_set_memolvl().

int isFounder RegChanList *  chan,
UserList nick
 

Determine if a user is the founder of a channel.

Is this 'nick' person the founder of the channel or no?

Precondition:
Chan is a pointer to a valid, listed registered channel record.
Parameters:
chan Channel to check
nick Nick to check founder access of
Returns:
1 if yes, 0 if not

Definition at line 1238 of file chanserv.c.

References CFORCEXFER, clearChanIdent(), getNickData(), _userlist::idnum, isRecognized(), _userlist::nick, opFlagged(), OVERRIDE, _userlist::reg, and _userlist::timestamp.

Referenced by do_chanop_add(), and getMiscChanOp().

void makeModeLockStr RegChanList *  chan,
char *  modelock
 

Generate mode-lock string.

Fills the modelock buffer with a copy of the locked modes string

Parameters:
chan Pointer to channel list item
modelock Buffer of at least 80 characters to hold the lock buffer
Precondition:
Chan must point to a valid, listed registered channel. Mode must point to a character memory area of at least 20 characters in length.
Postcondition:
The memory area pointed to by modelock has received a copy of the modelock enforcement string that can be used with an IRC message to enforce channel modes.
Warning:
DON'T add modes to this procedure without first checking that all callers have a large enough buffer. Buffer is assumed 20 units long.

Definition at line 1512 of file chanserv.c.

References MM_I, MM_K, MM_L, MM_M, MM_N, MM_P, MM_S, MM_T, PM_I, PM_K, PM_L, PM_M, PM_N, PM_P, PM_S, and PM_T.

Referenced by addUserToChan(), initModeStr(), and setChanMode().

const char* opLevelName int  level,
int  x_case
 

Print the name of an op level.

Displays the name of a chanop level

Parameters:
level What level to stringify
x_case Value indicates the form of the level name shown type is 0, 1, or 2: type 0 is the short form such as "AOP", type 1 is the lowercase form such as "superop", and type 2 is the uppercase form such as "MiniAop"
Returns:
The name of the specified channel op level, or "op/operator" if invalid or the default is used

Definition at line 2419 of file chanserv.c.

References FOUNDER, and oplev_table.

Referenced by do_chanop_add().

int opNameLevel const char *  name  ) 
 

Converts a level name into a number.

A number is generated from a level name

Parameters:
name Name of the level
Returns:
The chanop access level or -1 to indicate an error

Definition at line 2439 of file chanserv.c.

References FOUNDER, and oplev_table.

const char* PrintPass u_char  pI[],
char  enc
 

Print a password appropriately encoded according to its encryption type (if applicable).

Parameters:
p Password field
enc Encryption status
Precondition:
pI is a NUL-terminated character array.
Returns:
A pointer to a static NUL-terminated character array containing the printable version of a password

Definition at line 440 of file passwd.c.

void remFromAllChans UserList nick  ) 
 

Removes a user from all channels

Parameters:
nick Pointer to online user item

Definition at line 1996 of file chanserv.c.

References _userlist::chan, ChanServ, DEBUGCHAN, delChanUser(), getChanUserData(), _userlist::nick, and sSend().

Referenced by addUserToChan(), and remUser().

void remUserFromChan UserList nick,
char *  channel
 

Removes a user from channel(s).

Removes a user from channel(s) in response to a PART message

Parameters:
nick Pointer to online user item
channel List of channel(s) to remove user from

Definition at line 1918 of file chanserv.c.

References _userlist::chan, ChanServ, DEBUGCHAN, delChanUser(), getChanData(), getChanOp(), getChanUserData(), HELPOPS_CHAN, chanlist_struct::name, _userlist::nick, NISHELPOP, NISOPER, _userlist::oflags, chanlist_struct::reg, and sSend().

Referenced by addUserToChan(), and parseLine().

void sendChannelInfo UserList nick,
RegChanList *  chan,
int  fTerse
 

Print results of a /Chanserv Info to a user.

( Revamped to use tables -Mysid )

Definition at line 2968 of file chanserv.c.

References CQUIET.

void sendToChanOps ChanList chan,
char *  format,
... 
 

Precondition:
Chan is a pointer to a valid, online channel. Format points to a valid NUL-terminated character array, and parameters beyond it follow rules of the format string.
Postcondition:
If the channel is not registered or the QUIET option is not set, then the given message has been sent to all channel operators.
Parameters:
chan Pointer to channel item
format Format string for message
... Format arguments

Definition at line 1307 of file chanserv.c.

References ChanServ, CQUIET, chanlist_struct::name, chanlist_struct::reg, and sSend().

void sendToChanOpsAlways ChanList chan,
char *  format,
... 
 

Todo:
make these two one function. Send a message to channel operators, ignore QUIET
Parameters:
chan Pointer to channel item
format Format string for message
... Format arguments
Precondition:
Chan is a pointer to a valid, online channel. Format points to a valid NUL-terminated character array, and parameters beyond it follow rules of the format string.
Postcondition:
An IRC message has been sent for all operators of the given channel.

Definition at line 1335 of file chanserv.c.

References ChanServ, chanlist_struct::name, and sSend().

void setChanMode char **  args,
int  numargs
 

Updates services' idea of what a channel's modes are.

Parameters:
args The args[] vector of the MODE message of which args[3] is the mode string, args[0] is the setter, args[2] is the channel, and anything beyond args[3] are parameters.
numargs Total number of indices in the args[] vector passed

Definition at line 2065 of file chanserv.c.

References addChanBan(), AOP, cbanlist_struct::ban, CFORCEXFER, CHANOP, ChanServ, CHANVOICE, COPGUARD, CPROTOP, DEBUGCHAN, delChanBan(), chanlist_struct::firstUser, getChanBan(), getChanData(), getChanOp(), getChanUserData(), getNickData(), chanlist_struct::lastUser, makeModeLockStr(), MM_K, chanlist_struct::modes, chanlist_struct::name, oalloc(), cnicklist_struct::op, PM_I, PM_K, PM_L, PM_M, PM_N, PM_P, PM_S, PM_T, chanlist_struct::reg, sSend(), and strncpyzt.

Referenced by parseLine().

void setChanTopic char **  args,
int  numargs
 

Tell ChanServ about a topic change.

Updates services' idea of what a channel's topic is. Enforces topic locks.

Parameters:
args args[] vector from a TOPIC message
numargs numargs from a TOPIC message
Warning:
Assumes TOPIC_MAX < IRCBUF

Definition at line 2355 of file chanserv.c.

References getChanOp(), getRegChanData(), myname, parse_str(), sSend(), strncpyzt, and TOPIC_MAX.

Referenced by parseLine().

void syncChanData time_t  next  ) 
 

Handle timed ChanServ database syncs

Definition at line 2472 of file chanserv.c.

References firstRegChan, nextCsync, and saveChanData().

Referenced by sshutdown(), and sync_cfg().


Generated at Sat Oct 25 20:56:11 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.