summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-12-06 05:55:46 +0000
committertrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2004-12-06 05:55:46 +0000
commit8433084035a1d4b4ff0e800518ac152d3220c152 (patch)
treec5b553469a75135837e888ca411518cece56f824 /src
parent0df82a3dcf7c525dc6a6195e09f2b893802736ce (diff)
BUILD : 1.7.6 (478) BUGS : N/A NOTES : 1. CS CLEAR strips +q/+a 2. CS CLEAR uses SVSMODE with Unreal to strip +q/a/o/h/v 3. SVSMODE unban works again on Viagra 4. Adds anope_cmd_svsmode_chan() to for SVSMODE on channels 5. OS CLEARMODES uses SVSMODE with Unreal to strip +q/a/o/h/v 6. memory.c, servers.c, slist.c, sockutil.c, misc. is doxygen ready 7. Unreal32 pseduo clients use SJOIN now to join the channels 8. clean out the process() buffers before we start to use them, maybe less garbage in them when we do bts 9. Few memory cleans up in hostserv do_setall() 10. Tons of clean up, only a handful left when you make strict
git-svn-id: svn://svn.anope.org/anope/trunk@478 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@332 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/bahamut.c17
-rw-r--r--src/base64.c5
-rw-r--r--src/botserv.c2
-rw-r--r--src/chanserv.c86
-rw-r--r--src/dreamforge.c10
-rw-r--r--src/hostserv.c3
-rw-r--r--src/hybrid.c10
-rw-r--r--src/memory.c34
-rw-r--r--src/memoserv.c2
-rw-r--r--src/misc.c288
-rw-r--r--src/news.c2
-rw-r--r--src/nickserv.c4
-rw-r--r--src/operserv.c145
-rw-r--r--src/process.c9
-rw-r--r--src/ptlink.c10
-rw-r--r--src/rageircd.c18
-rw-r--r--src/servers.c8
-rw-r--r--src/sessions.c4
-rw-r--r--src/slist.c94
-rw-r--r--src/sockutil.c179
-rw-r--r--src/solidircd.c17
-rw-r--r--src/ultimate2.c10
-rw-r--r--src/ultimate3.c18
-rw-r--r--src/unreal31.c11
-rw-r--r--src/unreal32.c47
-rw-r--r--src/users.c11
-rw-r--r--src/viagra.c17
27 files changed, 804 insertions, 257 deletions
diff --git a/src/bahamut.c b/src/bahamut.c
index d4a2d1a30..772a716c8 100644
--- a/src/bahamut.c
+++ b/src/bahamut.c
@@ -102,8 +102,7 @@ IRCDVar ircd[] = {
1, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
- 0, /* Services Client mode */
- 0, /* not p10 */
+ 0, /* Can remove User Channel Modes with SVSMODE */
}
,
{NULL}
@@ -485,7 +484,19 @@ void anope_cmd_release_svshold(char *nick)
/* SVSMODE -b */
void anope_cmd_unban(char *name, char *nick)
{
- send_cmd(ServerName, "SVSMODE %s -b %s", name, nick);
+ anope_cmd_svsmode_chan(name, "-b", nick);
+}
+
+
+/* SVSMODE channel modes */
+
+void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+{
+ if (nick) {
+ send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
+ } else {
+ send_cmd(ServerName, "SVSMODE %s %s", name, mode);
+ }
}
void anope_cmd_bot_chan_mode(char *nick, char *chan)
diff --git a/src/base64.c b/src/base64.c
index 6349eebfd..6eb8e57ac 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -103,8 +103,7 @@ static const char Pad64 = '=';
characters followed by one "=" padding character.
*/
-int b64_encode(unsigned char const *src, size_t srclength, char *target,
- size_t targsize)
+int b64_encode(char *src, size_t srclength, char *target, size_t targsize)
{
size_t datalength = 0;
u_char input[3];
@@ -163,7 +162,7 @@ int b64_encode(unsigned char const *src, size_t srclength, char *target,
it returns the number of data bytes stored at the target, or -1 on error.
*/
-int b64_decode(char const *src, unsigned char *target, size_t targsize)
+int b64_decode(char *src, char *target, size_t targsize)
{
int tarindex, state, ch;
char *pos;
diff --git a/src/botserv.c b/src/botserv.c
index 1e9ad3067..8b1fc120f 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -611,7 +611,7 @@ void load_bs_dbase(void)
{
dbFILE *f;
int c, ver;
- int16 tmp16;
+ uint16 tmp16;
uint32 tmp32;
BotInfo *bi;
int failed = 0;
diff --git a/src/chanserv.c b/src/chanserv.c
index a4edae96e..7a855e5ee 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -635,7 +635,7 @@ void load_cs_dbase(void)
ver = get_file_version(f);
for (i = 0; i < 256 && !failed; i++) {
- int16 tmp16;
+ uint16 tmp16;
uint32 tmp32;
int n_levels;
char *s;
@@ -6004,18 +6004,62 @@ static int do_clear(User * u)
char *av[3];
struct c_userlist *cu, *next;
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_OP))
- continue;
+ if (ircd->svsmode_ucmode) {
av[0] = sstrdup(chan);
- av[1] = sstrdup("-o");
- av[2] = sstrdup(cu->user->nick);
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]);
- do_cmode(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
+ anope_cmd_svsmode_chan(av[0], "-o", NULL);
+ if (ircd->owner) {
+ anope_cmd_svsmode_chan(av[0], "-q", NULL);
+ }
+ if (ircd->protect || ircd->admin) {
+ anope_cmd_svsmode_chan(av[0], "-a", NULL);
+ }
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ av[0] = sstrdup(chan);
+ if (!chan_has_user_status(c, cu->user, CUS_OP)) {
+ if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
+ if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
+ continue;
+ } else {
+ av[1] = sstrdup("-qo");
+ }
+ } else {
+ av[1] = sstrdup("-ao");
+ }
+ } else {
+ av[1] = sstrdup("-o");
+ }
+ av[2] = sstrdup(cu->user->nick);
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ av[0] = sstrdup(chan);
+ if (!chan_has_user_status(c, cu->user, CUS_OP)) {
+ if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
+ if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
+ continue;
+ } else {
+ av[1] = sstrdup("-qo");
+ }
+ } else {
+ av[1] = sstrdup("-ao");
+ }
+ } else {
+ av[1] = sstrdup("-o");
+ }
+ av[2] = sstrdup(cu->user->nick);
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
}
notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan);
} else if (ircd->halfop && stricmp(what, "hops") == 0) {
@@ -6029,7 +6073,14 @@ static int do_clear(User * u)
av[0] = sstrdup(chan);
av[1] = sstrdup("-h");
av[2] = sstrdup(cu->user->nick);
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]);
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(av[0], av[1], NULL);
+ do_cmode(s_ChanServ, 3, av);
+ break;
+ } else {
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ }
do_cmode(s_ChanServ, 3, av);
free(av[2]);
free(av[1]);
@@ -6047,7 +6098,14 @@ static int do_clear(User * u)
av[0] = sstrdup(chan);
av[1] = sstrdup("-v");
av[2] = sstrdup(cu->user->nick);
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]);
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(av[0], av[1], NULL);
+ do_cmode(s_ChanServ, 3, av);
+ break;
+ } else {
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ }
do_cmode(s_ChanServ, 3, av);
free(av[2]);
free(av[1]);
diff --git a/src/dreamforge.c b/src/dreamforge.c
index a13e0ca7c..d16e744dd 100644
--- a/src/dreamforge.c
+++ b/src/dreamforge.c
@@ -100,8 +100,7 @@ IRCDVar ircd[] = {
0, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
- 0, /* Services Client mode */
- 0, /* not p10 */
+ 0, /* Can remove User Channel Modes with SVSMODE */
}
,
{NULL}
@@ -1262,6 +1261,13 @@ void anope_cmd_unban(char *name, char *nick)
/* Not Supported by this IRCD */
}
+/* SVSMODE channel modes */
+
+void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+{
+ /* Not Supported by this IRCD */
+}
+
void anope_cmd_vhost_off(User * u)
{
/* Not Supported by this IRCD */
diff --git a/src/hostserv.c b/src/hostserv.c
index 11ee42984..1a3feb9b2 100644
--- a/src/hostserv.c
+++ b/src/hostserv.c
@@ -16,7 +16,6 @@
#include "services.h"
#include "pseudo.h"
-#define HOST_VERSION 3
#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
void load_hs_dbase_v1(dbFILE * f);
@@ -700,6 +699,7 @@ int do_setall(User * u)
if (!isValidHost(hostmask, 3)) {
notice_lang(s_HostServ, u, HOST_SET_ERROR);
+ free(hostmask);
return MOD_CONT;
}
@@ -708,6 +708,7 @@ int do_setall(User * u)
if ((na = findnick(nick))) {
if (na->status & NS_VERBOTEN) {
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
+ free(hostmask);
return MOD_CONT;
}
if (vIdent && ircd->vident) {
diff --git a/src/hybrid.c b/src/hybrid.c
index 265d3260f..64008b387 100644
--- a/src/hybrid.c
+++ b/src/hybrid.c
@@ -100,8 +100,7 @@ IRCDVar ircd[] = {
0, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
- 0, /* Services Client mode */
- 0, /* not p10 */
+ 0, /* Can remove User Channel Modes with SVSMODE */
}
,
{NULL}
@@ -1374,6 +1373,13 @@ void anope_cmd_unban(char *name, char *nick)
/* Not Supported by this IRCD */
}
+/* SVSMODE channel modes */
+
+void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+{
+ /* Not Supported by this IRCD */
+}
+
/* SVSMODE +d */
/* sent if svid is something weird */
void anope_cmd_svid_umode(char *nick, time_t ts)
diff --git a/src/memory.c b/src/memory.c
index 504bbaabe..38e734aab 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -14,9 +14,6 @@
#include "services.h"
-/*************************************************************************/
-/*************************************************************************/
-
/* smalloc, scalloc, srealloc, sstrdup:
* Versions of the memory allocation functions which will cause the
* program to terminate with an "Out of memory" error if the memory
@@ -24,6 +21,13 @@
* is never NULL.)
*/
+/*************************************************************************/
+
+/**
+ * malloc, replacement so we can trap for "out of memory"
+ * @param size to allocate
+ * @return void
+ */
void *smalloc(long size)
{
void *buf;
@@ -41,6 +45,14 @@ void *smalloc(long size)
return buf;
}
+/*************************************************************************/
+
+/**
+ * calloc, replacement so we can trap for "out of memory"
+ * @param elsize to allocate
+ * @param els size of members
+ * @return void
+ */
void *scalloc(long elsize, long els)
{
void *buf;
@@ -58,6 +70,14 @@ void *scalloc(long elsize, long els)
return buf;
}
+/*************************************************************************/
+
+/**
+ * realloc, replacement so we can trap for "out of memory"
+ * @param oldptr Old Pointer
+ * @param newsize Size of new pointer
+ * @return void
+ */
void *srealloc(void *oldptr, long newsize)
{
void *buf;
@@ -75,6 +95,14 @@ void *srealloc(void *oldptr, long newsize)
return buf;
}
+/*************************************************************************/
+
+/**
+ * strdup, replacement so we can trap for "out of memory"
+ * @param oldptr Old Pointer
+ * @param newsize Size of new pointer
+ * @return void
+ */
char *sstrdup(const char *src)
{
char *ret = NULL;
diff --git a/src/memoserv.c b/src/memoserv.c
index 0b32cff83..4210925fe 100644
--- a/src/memoserv.c
+++ b/src/memoserv.c
@@ -1106,7 +1106,7 @@ static int do_info(User * u)
notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD,
name, mi->memocount, count);
}
- if (mi->memomax >= 0) {
+ if (mi->memomax) {
if (hardmax)
notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name,
mi->memomax);
diff --git a/src/misc.c b/src/misc.c
index b2943a8de..0b2d5af10 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -27,38 +27,55 @@ struct arc4_stream {
/*************************************************************************/
-/* toupper/tolower: Like the ANSI functions, but make sure we return an
+/**
+ * toupper: Like the ANSI functions, but make sure we return an
* int instead of a (signed) char.
+ * @param c Char
+ * @return int
*/
-
int toupper(char c)
{
- if (islower(c))
+ if (islower(c)) {
return (unsigned char) c - ('a' - 'A');
- else
+ } else {
return (unsigned char) c;
+ }
}
+/*************************************************************************/
+
+/**
+ * tolower: Like the ANSI functions, but make sure we return an
+ * int instead of a (signed) char.
+ * @param c Char
+ * @return int
+ */
int tolower(char c)
{
- if (isupper(c))
+ if (isupper(c)) {
return (unsigned char) c + ('a' - 'A');
- else
+ } else {
return (unsigned char) c;
+ }
}
/*************************************************************************/
-/* strscpy: Copy at most len-1 characters from a string to a buffer, and
+/**
+ * strscpy: Copy at most len-1 characters from a string to a buffer, and
* add a null terminator after the last character copied.
+ * @param d Buffer to copy into
+ * @param s Data to copy int
+ * @param len Length of data
+ * @return updated buffer
*/
-
char *strscpy(char *d, const char *s, size_t len)
{
char *d_orig = d;
- if (!len)
+ if (!len) {
return d;
+ }
while (--len && (*d++ = *s++));
*d = '\0';
return d_orig;
@@ -66,11 +83,14 @@ char *strscpy(char *d, const char *s, size_t len)
/*************************************************************************/
-/* stristr: Search case-insensitively for string s2 within string s1,
+/**
+ * stristr: Search case-insensitively for string s2 within string s1,
* returning the first occurrence of s2 or NULL if s2 was not
* found.
+ * @param s1 String 1
+ * @param s2 String 2
+ * @return first occurrence of s2
*/
-
char *stristr(char *s1, char *s2)
{
register char *s = s1, *d = s2;
@@ -91,12 +111,17 @@ char *stristr(char *s1, char *s2)
/*************************************************************************/
-/* strnrepl: Replace occurrences of `old' with `new' in string `s'. Stop
+/**
+ * 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.
+ * @param s String
+ * @param size size of s
+ * @param old character to replace
+ * @param new character to replace with
+ * @return updated s
*/
-
char *strnrepl(char *s, int32 size, const char *old, const char *new)
{
char *ptr = s;
@@ -124,13 +149,15 @@ char *strnrepl(char *s, int32 size, const char *old, const char *new)
}
/*************************************************************************/
-/*************************************************************************/
-/* merge_args: Take an argument count and argument vector and merge them
+/**
+ * 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.
+ * @param int Number of Args
+ * @param argv Array
+ * @return string of the merged array
*/
-
char *merge_args(int argc, char **argv)
{
int i;
@@ -145,13 +172,16 @@ char *merge_args(int argc, char **argv)
}
/*************************************************************************/
-/*************************************************************************/
-/* match_wild: Attempt to match a string to a pattern which might contain
+/**
+ * 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.
+ * @param pattern To be matched
+ * @param str String in which the pattern is to be matched
+ * @param docase Case In/Senstive
+ * @return 1 if the string matches the pattern, 0 if not.
*/
-
static int do_match_wild(const char *pattern, const char *str, int docase)
{
char c;
@@ -195,21 +225,36 @@ static int do_match_wild(const char *pattern, const char *str, int docase)
}
}
+/*************************************************************************/
+/**
+ * match_wild: Case Senstive wild card search
+ * @param pattern To be matched
+ * @param str String in which the pattern is to be matched
+ * @return 1 if the string matches the pattern, 0 if not.
+ */
int match_wild(const char *pattern, const char *str)
{
return do_match_wild(pattern, str, 1);
}
+/*************************************************************************/
+
+/**
+ * match_wild: Case Insenstive wild card search
+ * @param pattern To be matched
+ * @param str String in which the pattern is to be matched
+ * @return 1 if the string matches the pattern, 0 if not.
+ */
int match_wild_nocase(const char *pattern, const char *str)
{
return do_match_wild(pattern, str, 0);
}
/*************************************************************************/
-/*************************************************************************/
-/* Process a string containing a number/range list in the form
+/**
+ * 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.
@@ -218,8 +263,13 @@ int match_wild_nocase(const char *pattern, const char *str)
*
* The callback should be of type range_callback_t, which is defined as:
* int (*range_callback_t)(User *u, int num, va_list args)
+ * @param numstr
+ * @param count_ret
+ * @param callback Call back function
+ * @param u User Struct
+ * @param ... various args
+ * @return int
*/
-
int process_numlist(const char *numstr, int *count_ret,
range_callback_t callback, User * u, ...)
{
@@ -279,15 +329,17 @@ int process_numlist(const char *numstr, int *count_ret,
/*************************************************************************/
-/* dotime: Return the number of seconds corresponding to the given time
+/**
+ * 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).
+ * @param s String to convert
+ * @return int
*/
-
int dotime(const char *s)
{
int amount;
@@ -317,9 +369,15 @@ int dotime(const char *s)
/*************************************************************************/
-/* Expresses in a string the period of time represented by a given amount
- of seconds (with days/hours/minutes). */
-
+/**
+ * Expresses in a string the period of time represented by a given amount
+ * of seconds (with days/hours/minutes).
+ * @param na Nick Alias
+ * @param buf buffer to store result into
+ * @param bufsize Size of the buffer
+ * @param seconds time in seconds
+ * @return buffer
+ */
char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds)
{
int days = 0, hours = 0, minutes = 0;
@@ -380,8 +438,14 @@ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds)
/*************************************************************************/
-/* Generates a human readable string of type "expires in ..." */
-
+/**
+ * Generates a human readable string of type "expires in ..."
+ * @param na Nick Alias
+ * @param buf buffer to store result into
+ * @param bufsize Size of the buffer
+ * @param seconds time in seconds
+ * @return buffer
+ */
char *expire_left(NickAlias * na, char *buf, int len, time_t expires)
{
time_t now = time(NULL);
@@ -429,17 +493,18 @@ char *expire_left(NickAlias * na, char *buf, int len, time_t expires)
return buf;
}
+
+/*************************************************************************/
+
/**
- * Return 1 if a host is valid, 0 if it isnt.
- * host = string to check
- * type = format, 1 = ip4addr, 2 = hostname
- *
+ * Validate the host
* shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit )
* hostname = shortname *( "." shortname )
* ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
- *
- **/
-
+ * @param host = string to check
+ * @param type = format, 1 = ip4addr, 2 = hostname
+ * @return 1 if a host is valid, 0 if it isnt.
+ */
int doValidHost(const char *host, int type)
{
int idx = 0;
@@ -517,16 +582,14 @@ int doValidHost(const char *host, int type)
return 1;
}
+/*************************************************************************/
+
/**
- * Return 1 if a host is valid, 0 if it isnt.
- * host = string to check
- * type = format, 1 = ip4addr, 2 = hostname, 3 = either
- *
- * shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit )
- * hostname = shortname *( "." shortname )
- * ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
- *
- **/
+ * Front end to doValidHost
+ * @param host = string to check
+ * @param type = format, 1 = ip4addr, 2 = hostname
+ * @return 1 if a host is valid, 0 if it isnt.
+ */
int isValidHost(const char *host, int type)
{
int status = 0;
@@ -540,6 +603,13 @@ int isValidHost(const char *host, int type)
return status;
}
+/*************************************************************************/
+
+/**
+ * Valid character check
+ * @param c Charaacter to check
+ * @return 1 if a host is valid, 0 if it isnt.
+ */
int isvalidchar(const char c)
{
if (((c >= 'A') && (c <= 'Z')) ||
@@ -550,6 +620,16 @@ int isvalidchar(const char c)
return 0;
}
+
+/*************************************************************************/
+
+/**
+ * Get the token
+ * @param str String to search in
+ * @param dilim Character to search for
+ * @param token_number the token number
+ * @return token
+ */
char *myStrGetToken(const char *str, const char dilim, int token_number)
{
int len, idx, counter = 0, start_pos = 0;
@@ -572,6 +652,15 @@ char *myStrGetToken(const char *str, const char dilim, int token_number)
return substring;
}
+/*************************************************************************/
+
+/**
+ * Get the token only
+ * @param str String to search in
+ * @param dilim Character to search for
+ * @param token_number the token number
+ * @return token
+ */
char *myStrGetOnlyToken(const char *str, const char dilim,
int token_number)
{
@@ -598,6 +687,15 @@ char *myStrGetOnlyToken(const char *str, const char dilim,
return substring;
}
+/*************************************************************************/
+
+/**
+ * Get the Remaining tokens
+ * @param str String to search in
+ * @param dilim Character to search for
+ * @param token_number the token number
+ * @return token
+ */
char *myStrGetTokenRemainder(const char *str, const char dilim,
int token_number)
{
@@ -622,6 +720,15 @@ char *myStrGetTokenRemainder(const char *str, const char dilim,
return substring;
}
+/*************************************************************************/
+
+/**
+ * Get the string between point A and point B
+ * @param str String to search in
+ * @param start Point A
+ * @param end Point B
+ * @return the string in between
+ */
char *myStrSubString(const char *src, int start, int end)
{
char *substring = NULL;
@@ -640,6 +747,13 @@ char *myStrSubString(const char *src, int start, int end)
return substring;
}
+/*************************************************************************/
+
+/**
+ * Clean up the buffer for extra spaces
+ * @param str to clean up
+ * @return void
+ */
void doCleanBuffer(char *str)
{
char *in, *out;
@@ -669,6 +783,14 @@ void doCleanBuffer(char *str)
*out = ch; /* == '\0' */
}
+/*************************************************************************/
+
+/**
+ * Kill the user to enforce the sqline
+ * @param nick to kill
+ * @param killer whom is doing the killing
+ * @return void
+ */
void EnforceQlinedNick(char *nick, char *killer)
{
User *u2;
@@ -681,6 +803,14 @@ void EnforceQlinedNick(char *nick, char *killer)
}
}
+/*************************************************************************/
+
+/**
+ * Is the given nick a network service
+ * @param nick to check
+ * @param int Check if botserv bots
+ * @return int
+ */
int nickIsServices(char *nick, int bot)
{
int found = 0;
@@ -742,6 +872,12 @@ int nickIsServices(char *nick, int bot)
return found;
}
+/*************************************************************************/
+
+/**
+ * arc4 init
+ * @return void
+ */
static void arc4_init(void)
{
int n;
@@ -751,6 +887,14 @@ static void arc4_init(void)
rs.j = 0;
}
+/*************************************************************************/
+
+/**
+ * arc4 addrandom
+ * @param data
+ * @param dalen Data Length
+ * @return void
+ */
static void arc4_addrandom(void *dat, int datlen)
{
int n;
@@ -766,6 +910,12 @@ static void arc4_addrandom(void *dat, int datlen)
}
}
+/*************************************************************************/
+
+/**
+ * random init
+ * @return void
+ */
void rand_init(void)
{
int n;
@@ -797,7 +947,7 @@ void rand_init(void)
/* unix/bsd: time */
gettimeofday(&rdat.nowt, NULL);
/* unix/bsd: /dev/urandom */
- fd = open("/dev/urandom", "r");
+ fd = open("/dev/urandom", O_RDONLY);
if (fd) {
n = read(fd, &rdat.rnd, sizeof(rdat.rnd));
close(fd);
@@ -812,6 +962,12 @@ void rand_init(void)
arc4_addrandom(&rdat, sizeof(rdat));
}
+/*************************************************************************/
+
+/**
+ * Setup the random numbers
+ * @return void
+ */
void add_entropy_userkeys(void)
{
arc4_addrandom(&UserKey1, sizeof(UserKey1));
@@ -820,6 +976,12 @@ void add_entropy_userkeys(void)
/* UserKey3 is also used in mysql_rand() */
}
+/*************************************************************************/
+
+/**
+ * Get the random numbers 8 byte deep
+ * @return char
+ */
u_char getrandom8(void)
{
u_char si, sj;
@@ -833,6 +995,12 @@ u_char getrandom8(void)
return (rs.s[(si + sj) & 0xff]);
}
+/*************************************************************************/
+
+/**
+ * Get the random numbers 16 byte deep
+ * @return char
+ */
u_int16_t getrandom16(void)
{
u_int16_t val;