Anope IRC Services
Version 1.8
|
Go to the source code of this file.
Data Structures | |
struct | arc4_stream |
Macros | |
#define | issp(c) ((c) == 32) |
Functions | |
int | toupper (char c) |
int | tolower (char c) |
void | binary_to_hex (unsigned char *bin, char *hex, int length) |
char * | strscpy (char *d, const char *s, size_t len) |
char * | stristr (char *s1, char *s2) |
char * | strnrepl (char *s, int32 size, const char *old, const char *new) |
char * | merge_args (int argc, char **argv) |
static int | do_match_wild (const char *pattern, const char *str, int docase) |
int | match_wild (const char *pattern, const char *str) |
int | match_wild_nocase (const char *pattern, const char *str) |
int | process_numlist (const char *numstr, int *count_ret, range_callback_t callback, User *u,...) |
int | dotime (const char *s) |
char * | duration (NickAlias *na, char *buf, int bufsize, time_t seconds) |
char * | expire_left (NickAlias *na, char *buf, int len, time_t expires) |
int | doValidHost (const char *host, int type) |
int | isValidHost (const char *host, int type) |
int | isvalidchar (const char c) |
char * | myStrGetToken (const char *str, const char dilim, int token_number) |
char * | myStrGetOnlyToken (const char *str, const char dilim, int token_number) |
char * | myStrGetTokenRemainder (const char *str, const char dilim, int token_number) |
char * | myStrSubString (const char *src, int start, int end) |
void | protocol_debug (char *source, char *cmd, int argc, char **argv) |
void | doCleanBuffer (char *str) |
void | EnforceQlinedNick (char *nick, char *killer) |
int | nickIsServices (char *tempnick, int bot) |
static void | arc4_init (void) |
static void | arc4_addrandom (void *dat, int datlen) |
void | rand_init (void) |
void | add_entropy_userkeys (void) |
unsigned char | getrandom8 (void) |
u_int16_t | getrandom16 (void) |
u_int32_t | getrandom32 (void) |
char * | send_token (char *token1, char *token2) |
int | myNumToken (const char *str, const char dilim) |
char * | host_resolve (char *host) |
char * | str_signed (unsigned char *str) |
char * | stripModePrefix (const char *str) |
void | ntoa (struct in_addr addr, char *ipaddr, int len) |
char ** | buildStringList (char *src, int *number) |
size_t | strlcat (char *dst, const char *src, size_t siz) |
size_t | strlcpy (char *dst, const char *src, size_t siz) |
uint32 | cidr_to_netmask (uint16 cidr) |
uint16 | netmask_to_cidr (uint32 mask) |
int | str_is_wildcard (const char *str) |
int | str_is_pure_wildcard (const char *str) |
uint32 | str_is_ip (char *str) |
int | str_is_cidr (char *str, uint32 *ip, uint32 *mask, char **host) |
Variables | |
struct arc4_stream | rs |
Definition at line 19 of file misc.c.
Referenced by doCleanBuffer().
void add_entropy_userkeys | ( | void | ) |
Setup the random numbers
Definition at line 1028 of file misc.c.
References arc4_addrandom(), UserKey1, UserKey2, and UserKey3.
Referenced by init_secondary().
|
static |
arc4 addrandom
data | |
dalen | Data Length |
Definition at line 956 of file misc.c.
References arc4_stream::i, arc4_stream::j, rs, and arc4_stream::s.
Referenced by add_entropy_userkeys(), and rand_init().
|
static |
arc4 init
Definition at line 939 of file misc.c.
References arc4_stream::i, arc4_stream::j, rs, and arc4_stream::s.
Referenced by rand_init().
void binary_to_hex | ( | unsigned char * | bin, |
char * | hex, | ||
int | length | ||
) |
Simple function to convert binary data to hex. Taken from hybrid-ircd ( http://ircd-hybrid.com/ )
Definition at line 67 of file misc.c.
Referenced by md5_encrypt(), and sha1_encrypt().
char** buildStringList | ( | char * | src, |
int * | number | ||
) |
Build a string list from a given source string. This is usually used for parsing out values from the config file, but could be used for other things. NOTE: this function uses strtok(), be aware it will break any buffer you think you have in there ;)
Definition at line 1211 of file misc.c.
References srealloc(), and sstrdup().
Referenced by read_config().
Turn a cidr value into a netmask
cidr | CIDR value |
Definition at line 1501 of file misc.c.
Referenced by str_is_cidr().
|
static |
do_match_wild: Attempt to match a string to a pattern which might contain '*' or '?' wildcards. Return 1 if the string matches the pattern, 0 if not.
pattern | To be matched |
str | String in which the pattern is to be matched |
docase | Case In/Senstive |
Definition at line 204 of file misc.c.
Referenced by match_wild(), and match_wild_nocase().
void doCleanBuffer | ( | char * | str | ) |
Clean up the buffer for extra spaces
str | to clean up |
Definition at line 800 of file misc.c.
References issp.
Referenced by event_message_process(), and process().
int dotime | ( | const char * | s | ) |
dotime: Return the number of seconds corresponding to the given time string. If the given string does not represent a valid time, return -1.
A time string is either a plain integer (representing a number of seconds), or an integer followed by one of these characters: "s" (seconds), "m" (minutes), "h" (hours), or "d" (days).
s | String to convert |
Definition at line 364 of file misc.c.
Referenced by AnopeInit(), do_akill(), do_chankill(), do_exception(), do_ignoreuser(), do_nick(), do_sgline(), do_sqline(), do_szline(), do_tban(), main(), parse_directive(), and resetDefCon().
int doValidHost | ( | const char * | host, |
int | type | ||
) |
Validate the host shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit ) hostname = shortname *( "." shortname ) ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
host | = string to check |
type | = format, 1 = ip4addr, 2 = hostname |
Ultimate3 dosnt like a non-dotted hosts at all, nor does unreal, so just dont allow them.
Definition at line 529 of file misc.c.
References HOSTMAX.
Referenced by isValidHost().
char* duration | ( | NickAlias * | na, |
char * | buf, | ||
int | bufsize, | ||
time_t | seconds | ||
) |
Expresses in a string the period of time represented by a given amount of seconds (with days/hours/minutes).
na | Nick Alias |
buf | buffer to store result into |
bufsize | Size of the buffer |
seconds | time in seconds |
Definition at line 402 of file misc.c.
References getstring, and snprintf().
Referenced by do_fantasy(), do_recover(), and myHelpResonse().
void EnforceQlinedNick | ( | char * | nick, |
char * | killer | ||
) |
Kill the user to enforce the sqline
nick | to kill |
killer | whom is doing the killing |
Definition at line 837 of file misc.c.
References alog(), finduser(), user_::host, kill_user(), user_::nick, and user_::username.
Referenced by bahamut_cmd_bot_nick(), bahamut_cmd_nick(), charybdis_cmd_bot_nick(), charybdis_cmd_nick(), do_bot(), dreamforge_cmd_bot_nick(), dreamforge_cmd_nick(), hybrid_cmd_bot_nick(), hybrid_cmd_nick(), plexus_cmd_bot_nick(), plexus_cmd_nick(), ptlink_cmd_bot_nick(), ptlink_cmd_nick(), rageircd_cmd_bot_nick(), rageircd_cmd_nick(), ratbox_cmd_bot_nick(), ratbox_cmd_nick(), shadowircd_cmd_bot_nick(), shadowircd_cmd_nick(), solidircd_cmd_bot_nick(), solidircd_cmd_nick(), ultimate2_cmd_bot_nick(), ultimate2_cmd_nick(), ultimate3_cmd_bot_nick(), ultimate3_cmd_nick(), unreal_cmd_bot_nick(), unreal_cmd_nick(), viagra_cmd_bot_nick(), and viagra_cmd_nick().
char* expire_left | ( | NickAlias * | na, |
char * | buf, | ||
int | len, | ||
time_t | expires | ||
) |
Generates a human readable string of type "expires in ..."
na | Nick Alias |
buf | buffer to store result into |
bufsize | Size of the buffer |
seconds | time in seconds |
Definition at line 470 of file misc.c.
References getstring, and snprintf().
Referenced by akill_view(), exception_view(), sgline_view(), sqline_view(), and szline_view().
u_int16_t getrandom16 | ( | void | ) |
Get the random numbers 16 byte deep
Definition at line 1061 of file misc.c.
References getrandom8().
Referenced by collide(), and do_register().
u_int32_t getrandom32 | ( | void | ) |
Get the random numbers 32 byte deep
Definition at line 1076 of file misc.c.
References getrandom8().
unsigned char getrandom8 | ( | void | ) |
Get the random numbers 8 byte deep
Definition at line 1042 of file misc.c.
References arc4_stream::i, arc4_stream::j, rs, and arc4_stream::s.
Referenced by getrandom16(), and getrandom32().
char* host_resolve | ( | char * | host | ) |
Resolve a host to an IP
host | to convert |
Definition at line 1134 of file misc.c.
References alog(), debug, ntoa(), and sstrdup().
Referenced by _common_unban(), and _elist_match_user().
int isvalidchar | ( | const char | c | ) |
Valid character check
c | Character to check |
Definition at line 634 of file misc.c.
Referenced by do_setall(), and myDoSet().
int isValidHost | ( | const char * | host, |
int | type | ||
) |
Front end to doValidHost
host | = string to check |
type | = format, 1 = ip4addr, 2 = hostname |
Definition at line 614 of file misc.c.
References doValidHost().
Referenced by do_bot(), do_jupe(), do_setall(), hs_do_request(), and myDoSet().
int match_wild | ( | const char * | pattern, |
const char * | str | ||
) |
match_wild: Case Senstive wild card search
pattern | To be matched |
str | String in which the pattern is to be matched |
Definition at line 255 of file misc.c.
References do_match_wild().
Referenced by do_access(), and do_noop().
int match_wild_nocase | ( | const char * | pattern, |
const char * | str | ||
) |
match_wild: Case Insenstive wild card search
pattern | To be matched |
str | String in which the pattern is to be matched |
Definition at line 268 of file misc.c.
References do_match_wild().
Referenced by _match_usermask(), add_akill(), add_sgline(), add_sqline(), add_szline(), check_akill(), check_chan_sqline(), check_sgline(), check_sqline(), check_szline(), do_access(), do_admin(), do_akick(), do_akill(), do_badwords(), do_chanlist(), do_exception(), do_list(), do_oper(), do_sgline(), do_sqline(), do_szline(), do_userlist(), do_xop(), entry_match(), find_host_exception(), find_hostip_exception(), get_ignore(), is_on_access(), is_stuck(), listOut(), load_old_akill(), match_userip(), sqline(), and stick_mask().
char* merge_args | ( | int | argc, |
char ** | argv | ||
) |
merge_args: Take an argument count and argument vector and merge them into a single string in which each argument is separated by a space.
int | Number of Args |
argv | Array |
Definition at line 180 of file misc.c.
References snprintf().
Referenced by anope_event_fjoin(), anope_event_tburst(), anope_event_topic(), chan_set_modes(), do_cmode(), do_join(), do_kick(), do_part(), do_quit(), do_topic(), do_umode(), do_umode2(), and inspircd_cmd_svsmode().
int myNumToken | ( | const char * | str, |
const char | dilim | ||
) |
Number of tokens in a string
str | String |
dilim | Dilimiter |
Definition at line 1112 of file misc.c.
Referenced by anope_event_bmask().
char* myStrGetOnlyToken | ( | const char * | str, |
const char | dilim, | ||
int | token_number | ||
) |
Get the token only
str | String to search in |
dilim | Character to search for |
token_number | the token number |
Definition at line 685 of file misc.c.
References myStrSubString().
Referenced by anope_event_newmask(), do_list(), do_setall(), hs_do_request(), listOut(), moduleGetConfigDirective(), and myDoSet().
char* myStrGetToken | ( | const char * | str, |
const char | dilim, | ||
int | token_number | ||
) |
Get the token
str | String to search in |
dilim | Character to search for |
token_number | the token number |
Definition at line 654 of file misc.c.
References myStrSubString().
Referenced by anope_event_bmask(), anope_event_capab(), anope_event_fjoin(), anope_event_server(), anope_event_tburst(), base64dects(), capab_parse(), do_fantasy(), do_sjoin(), do_tban(), do_topic(), hs_do_activate(), hs_do_reject(), hs_do_request(), hsreq_load_db(), inspircd_cmd_211(), inspircd_cmd_242(), inspircd_cmd_243(), inspircd_cmd_250(), inspircd_cmd_307(), inspircd_cmd_311(), inspircd_cmd_312(), inspircd_cmd_317(), m_privmsg(), mLoadData(), my_cs_appendtopic(), my_cs_enforce(), my_ns_register(), my_ns_set(), myAddChanInfo(), myAddNickInfo(), myChanInfo(), and myNickInfo().
char* myStrGetTokenRemainder | ( | const char * | str, |
const char | dilim, | ||
int | token_number | ||
) |
Get the Remaining tokens
str | String to search in |
dilim | Character to search for |
token_number | the token number |
Definition at line 720 of file misc.c.
References myStrSubString().
Referenced by anope_event_newmask(), anope_event_server(), capab_parse(), do_fantasy(), do_list(), do_setall(), hs_do_reject(), hs_do_request(), listOut(), mLoadData(), moduleGetConfigDirective(), my_cs_appendtopic(), myAddChanInfo(), myAddNickInfo(), and myDoSet().
char* myStrSubString | ( | const char * | src, |
int | start, | ||
int | end | ||
) |
Get the string between point A and point B
str | String to search in |
start | Point A |
end | Point B |
Definition at line 753 of file misc.c.
Referenced by myStrGetOnlyToken(), myStrGetToken(), and myStrGetTokenRemainder().
int nickIsServices | ( | char * | tempnick, |
int | bot | ||
) |
Is the given nick a network service
nick | to check |
int | Check if botserv bots |
Definition at line 857 of file misc.c.
References botlists, botinfo_::next, botinfo_::nick, s_BotServ, s_BotServAlias, s_ChanServ, s_ChanServAlias, s_DevNull, s_DevNullAlias, s_GlobalNoticer, s_GlobalNoticerAlias, s_HelpServ, s_HelpServAlias, s_HostServ, s_HostServAlias, s_MemoServ, s_MemoServAlias, s_NickServ, s_NickServAlias, s_OperServ, s_OperServAlias, ServerName, sstrdup(), and stricmp().
void ntoa | ( | struct in_addr | addr, |
char * | ipaddr, | ||
int | len | ||
) |
Definition at line 1198 of file misc.c.
References snprintf().
Referenced by do_nick(), and host_resolve().
int process_numlist | ( | const char * | numstr, |
int * | count_ret, | ||
range_callback_t | callback, | ||
User * | u, | ||
... | |||
) |
Process a string containing a number/range list in the form "n1[-n2][,n3[-n4]]...", calling a caller-specified routine for each number in the list. If the callback returns -1, stop immediately. Returns the sum of all nonnegative return values from the callback. If `count' is non-NULL, it will be set to the total number of times the callback was called.
The callback should be of type range_callback_t, which is defined as: int (*range_callback_t)(User *u, int num, va_list args)
numstr | |
count_ret | |
callback | Call back function |
u | User Struct |
... | various args |
Definition at line 292 of file misc.c.
References VA_COPY.
Referenced by do_access(), do_akick(), do_badwords(), do_del(), do_exception(), do_list(), do_read(), and do_xop().
void protocol_debug | ( | char * | source, |
char * | cmd, | ||
int | argc, | ||
char ** | argv | ||
) |
Definition at line 773 of file misc.c.
References alog(), and protocoldebug.
Referenced by process().
void rand_init | ( | void | ) |
random init
Definition at line 977 of file misc.c.
References arc4_addrandom(), arc4_init(), and mysql_rand().
Referenced by init_secondary().
char* send_token | ( | char * | token1, |
char * | token2 | ||
) |
Determine if we need to send the TOKEN
token1 | |
token2 |
Definition at line 1095 of file misc.c.
References ircd, ircdcap, ircdvars_::token, ircdcapab_::token, and UseTokens.
Referenced by unreal_cmd_akill(), unreal_cmd_bot_nick(), unreal_cmd_chg_nick(), unreal_cmd_chghost(), unreal_cmd_chgident(), unreal_cmd_ctcp(), unreal_cmd_eob(), unreal_cmd_global(), unreal_cmd_global_legacy(), unreal_cmd_guest_nick(), unreal_cmd_invite(), unreal_cmd_join(), unreal_cmd_kick(), unreal_cmd_mode(), unreal_cmd_netinfo(), unreal_cmd_nick(), unreal_cmd_notice(), unreal_cmd_notice2(), unreal_cmd_notice_ops(), unreal_cmd_part(), unreal_cmd_pong(), unreal_cmd_privmsg(), unreal_cmd_privmsg2(), unreal_cmd_quit(), unreal_cmd_release_svshold(), unreal_cmd_remove_akill(), unreal_cmd_serv_notice(), unreal_cmd_serv_privmsg(), unreal_cmd_sgline(), unreal_cmd_sqline(), unreal_cmd_squit(), unreal_cmd_svid_umode(), unreal_cmd_svshold(), unreal_cmd_svsjoin(), unreal_cmd_svskill(), unreal_cmd_svsmode(), unreal_cmd_svsmode_chan(), unreal_cmd_svsnick(), unreal_cmd_svsnoop(), unreal_cmd_svso(), unreal_cmd_svspart(), unreal_cmd_svswatch(), unreal_cmd_swhois(), unreal_cmd_szline(), unreal_cmd_topic(), unreal_cmd_unsgline(), unreal_cmd_unsqline(), and unreal_cmd_unszline().
Check if the given string is an IP or CIDR mask, and fill the given ip/cidr params if so.
str | String to check |
ip | The ipmask to fill when a CIDR is found |
mask | The CIDR mask to fill when a CIDR is found |
host | Displayed host |
Definition at line 1602 of file misc.c.
References cidr_to_netmask(), snprintf(), and sstrdup().
Referenced by entry_create().
uint32 str_is_ip | ( | char * | str | ) |
Check if the given string is an IP, and return the IP.
str | String to check |
Definition at line 1565 of file misc.c.
Referenced by _common_unban(), and _elist_match_user().
int str_is_pure_wildcard | ( | const char * | str | ) |
Check if the given string is a pure wildcard
str | String to check |
Definition at line 1547 of file misc.c.
Referenced by entry_create().
int str_is_wildcard | ( | const char * | str | ) |
Check if the given string is some sort of wildcard
str | String to check |
Definition at line 1531 of file misc.c.
Referenced by entry_create().
char* str_signed | ( | unsigned char * | str | ) |
Change an unsigned string to a signed string, overwriting the original string.
input | string |
Definition at line 1169 of file misc.c.
Referenced by encode_ip().
char* stripModePrefix | ( | const char * | str | ) |
Strip the mode prefix from the given string. Useful for using the modes stored in things like ircd->ownerset etc..
Definition at line 1188 of file misc.c.
References sstrdup().
Referenced by chan_set_correct_modes(), check_should_owner(), check_should_protect(), and check_valid_op().
char* stristr | ( | char * | s1, |
char * | s2 | ||
) |
stristr: Search case-insensitively for string s2 within string s1, returning the first occurrence of s2 or NULL if s2 was not found.
s1 | String 1 |
s2 | String 2 |
Definition at line 113 of file misc.c.
References tolower().
Referenced by botchanmsgs(), do_group(), and do_register().
size_t strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Definition at line 1263 of file misc.c.
Referenced by anope_event_fjoin(), and plexus_cmd_svid_umode3().
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Definition at line 1293 of file misc.c.
Referenced by plexus_cmd_svid_umode3().
char* strnrepl | ( | char * | s, |
int32 | size, | ||
const char * | old, | ||
const char * | new | ||
) |
strnrepl: Replace occurrences of `old' with `new' in string `s'. Stop replacing if a replacement would cause the string to exceed `size' bytes (including the null terminator). Return the string.
s | String |
size | size of s |
old | character to replace |
new | character to replace with |
Definition at line 144 of file misc.c.
Referenced by do_act(), lang_sanitize(), notice_help(), strftime_lang(), and unreal_cmd_sgline().
char* strscpy | ( | char * | d, |
const char * | s, | ||
size_t | len | ||
) |
int tolower | ( | char | c | ) |
tolower: Like the ANSI functions, but make sure we return an int instead of a (signed) char.
c | Char |
Definition at line 52 of file misc.c.
References c.
Referenced by do_match_wild(), and stristr().
int toupper | ( | char | c | ) |
struct arc4_stream rs |
Referenced by arc4_addrandom(), arc4_init(), and getrandom8().