aboutsummaryrefslogtreecommitdiff
path: root/src/irc.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-10-02 21:36:39 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-10-07 14:38:37 +0200
commit6032e4f4e7c1892a4e3f0a1a2007e4cd0fe99937 (patch)
tree45117631344c248ef87b7c92b2a832c2810729a5 /src/irc.cpp
parentee0b64853699c08602fed81cdefc62d7e8dcdce2 (diff)
get rid of strlcpy.h
Don't use hand-rolled string manipulation routine with a fixed buffer in the bitcoin core, instead make use of c++ strings and boost.
Diffstat (limited to 'src/irc.cpp')
-rw-r--r--src/irc.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/irc.cpp b/src/irc.cpp
index ec7eea3cf4..17d5ff1a5a 100644
--- a/src/irc.cpp
+++ b/src/irc.cpp
@@ -5,9 +5,10 @@
#include "irc.h"
#include "net.h"
-#include "strlcpy.h"
#include "base58.h"
+#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
+
using namespace std;
using namespace boost;
@@ -324,30 +325,27 @@ void ThreadIRCSeed2(void* parg)
if (vWords.size() < 2)
continue;
- char pszName[10000];
- pszName[0] = '\0';
+ std::string strName;
if (vWords[1] == "352" && vWords.size() >= 8)
{
// index 7 is limited to 16 characters
// could get full length name at index 10, but would be different from join messages
- strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));
+ strName = vWords[7].c_str();
printf("IRC got who\n");
}
if (vWords[1] == "JOIN" && vWords[0].size() > 1)
{
// :username!username@50000007.F000000B.90000002.IP JOIN :#channelname
- strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
- if (strchr(pszName, '!'))
- *strchr(pszName, '!') = '\0';
+ strName = vWords[0].substr(1, vWords[0].find('!', 1) - 1);
printf("IRC got join\n");
}
- if (pszName[0] == 'u')
+ if (boost::algorithm::starts_with(strName, "u"))
{
CAddress addr;
- if (DecodeAddress(pszName, addr))
+ if (DecodeAddress(strName, addr))
{
addr.nTime = GetAdjustedTime();
if (addrman.Add(addr, addrConnect, 51 * 60))