diff options
author | Adam <Adam@anope.org> | 2010-12-06 17:06:57 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:37:03 -0500 |
commit | aed53dbb47822a79eb9a6b61095ad04ec3d67818 (patch) | |
tree | 72d3210b5609ea2163854d14ec7fb2f48d8b4d12 /src/misc.cpp | |
parent | a507816701d136a1c22d2f6779d811840d61577c (diff) |
Cleaned up some things, made the protocol modules use some basic inheritance to cut back on their code duplication. More work can be done in the future to remove even more of it.
Diffstat (limited to 'src/misc.cpp')
-rw-r--r-- | src/misc.cpp | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index c885188f8..51899270b 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -70,68 +70,6 @@ int tolower(char c) /*************************************************************************/ /** - * 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) - return d; - while (--len && (*d++ = *s++)); - *d = '\0'; - return d_orig; -} - -/*************************************************************************/ - -/** - * 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 newstr character to replace with - * @return updated s - */ -char *strnrepl(char *s, int32 size, const char *old, const char *newstr) -{ - char *ptr = s; - int32 left = strlen(s); - int32 avail = size - (left + 1); - int32 oldlen = strlen(old); - int32 newlen = strlen(newstr); - int32 diff = newlen - oldlen; - - while (left >= oldlen) - { - if (strncmp(ptr, old, oldlen)) - { - --left; - ++ptr; - continue; - } - if (diff > avail) - break; - if (diff) - memmove(ptr + oldlen + diff, ptr + oldlen, left + 1 - oldlen); - strncpy(ptr, newstr, newlen); - ptr += newlen; - left -= oldlen; - } - return s; -} - -/*************************************************************************/ - -/** * 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. @@ -576,7 +514,7 @@ void EnforceQlinedNick(const Anope::string &nick, const Anope::string &killer) if (u2) { Log(LOG_NORMAL, "xline") << "Killed Q-lined nick: " << u2->GetMask(); - kill_user(killer, u2->nick, "This nick is reserved for Services. Please use a non Q-Lined nick."); + kill_user(killer, u2, "This nick is reserved for Services. Please use a non Q-Lined nick."); } } |