mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 13:30:36 -04:00
Removed some std::ostringstream.
To be continued. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5111 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a9e496f845
commit
4e26884646
14 changed files with 190 additions and 131 deletions
|
@ -33,8 +33,7 @@
|
|||
#include "bitdht/bdstddht.h"
|
||||
#include "util/bdnet.h"
|
||||
#include "util/bdrandom.h"
|
||||
|
||||
#include <sstream>
|
||||
#include "util/bdstring.h"
|
||||
|
||||
/*
|
||||
* #define DEBUG_PROXY_CONNECTION 1
|
||||
|
@ -3377,11 +3376,7 @@ std::string decodeConnectionErrorType(uint32_t errcode)
|
|||
switch(errtype)
|
||||
{
|
||||
default:
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "(" << errtype << ")";
|
||||
namedtype += out.str();
|
||||
}
|
||||
bd_sprintf_append(namedtype, "(%lu)", errtype);
|
||||
break;
|
||||
case BITDHT_CONNECT_ERROR_GENERIC:
|
||||
namedtype = "GENERIC";
|
||||
|
@ -3434,11 +3429,7 @@ std::string decodeConnectionErrorSource(uint32_t errcode)
|
|||
switch(errsrc)
|
||||
{
|
||||
default:
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "(" << errsrc << ")";
|
||||
namedtype += out.str();
|
||||
}
|
||||
bd_sprintf_append(namedtype, "(%lu)", errsrc);
|
||||
break;
|
||||
case BITDHT_CONNECT_ERROR_SOURCE_START:
|
||||
namedtype = "START";
|
||||
|
|
|
@ -46,12 +46,12 @@
|
|||
#include "bitdht/bdfilter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/bdnet.h"
|
||||
#include "util/bdrandom.h"
|
||||
#include "util/bdstring.h"
|
||||
|
||||
/***
|
||||
* #define DEBUG_MGR 1
|
||||
|
@ -601,10 +601,10 @@ void bdNodeManager::SearchForLocalNet()
|
|||
for(i = 0; (!filterOk) && (i < MAX_FILTER_ATTEMPTS); i++)
|
||||
{
|
||||
bdStdRandomNodeId(&targetNodeId);
|
||||
std::ostringstream tststr;
|
||||
bdStdPrintNodeId(tststr, &targetNodeId);
|
||||
std::string tststr;
|
||||
bdStdPrintNodeId(tststr, &targetNodeId, false);
|
||||
|
||||
if (mBloomFilter.test(tststr.str()))
|
||||
if (mBloomFilter.test(tststr))
|
||||
{
|
||||
filterOk = true;
|
||||
}
|
||||
|
@ -1220,26 +1220,23 @@ int bdNodeManager::isBitDhtPacket(char *data, int size, struct sockaddr_in &
|
|||
std::cerr << std::endl;
|
||||
{
|
||||
/* print the fucker... only way to catch bad ones */
|
||||
std::ostringstream out;
|
||||
std::string out;
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
if (isascii(data[i]))
|
||||
{
|
||||
out << data[i];
|
||||
out += data[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "[";
|
||||
out << std::setw(2) << std::setfill('0')
|
||||
<< std::hex << (uint32_t) data[i];
|
||||
out << "]";
|
||||
bd_sprintf_append(out, "[%02lx]", (uint32_t) data[i]);
|
||||
}
|
||||
if ((i % 16 == 0) && (i != 0))
|
||||
{
|
||||
out << std::endl;
|
||||
out += "\n";
|
||||
}
|
||||
}
|
||||
std::cerr << out.str();
|
||||
std::cerr << out;
|
||||
}
|
||||
std::cerr << "bdNodeManager::isBitDhtPacket() *******************************";
|
||||
std::cerr << std::endl;
|
||||
|
@ -1262,26 +1259,23 @@ int bdNodeManager::isBitDhtPacket(char *data, int size, struct sockaddr_in &
|
|||
std::cerr << std::endl;
|
||||
{
|
||||
/* print the fucker... only way to catch bad ones */
|
||||
std::ostringstream out;
|
||||
std::string out;
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
if (isascii(data[i]))
|
||||
{
|
||||
out << data[i];
|
||||
out += data[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "[";
|
||||
out << std::setw(2) << std::setfill('0')
|
||||
<< std::hex << (uint32_t) data[i];
|
||||
out << "]";
|
||||
bd_sprintf_append(out, "[%02lx]", (uint32_t) data[i]);
|
||||
}
|
||||
if ((i % 16 == 0) && (i != 0))
|
||||
{
|
||||
out << std::endl;
|
||||
out += "\n";
|
||||
}
|
||||
}
|
||||
std::cerr << out.str();
|
||||
std::cerr << out;
|
||||
}
|
||||
std::cerr << "bdNodeManager::BadPacket ******************************";
|
||||
std::cerr << std::endl;
|
||||
|
|
|
@ -33,14 +33,13 @@
|
|||
|
||||
#include "util/bdnet.h"
|
||||
#include "util/bdrandom.h"
|
||||
|
||||
#include "util/bdstring.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#define BITDHT_QUERY_START_PEERS 10
|
||||
|
@ -2100,10 +2099,8 @@ void bdNode::genNewToken(bdToken *token)
|
|||
// XXX is this a good way to do it?
|
||||
// Variable length, from 4 chars up to lots... 10?
|
||||
// leave for the moment, but fix.
|
||||
std::ostringstream out;
|
||||
out << std::setw(4) << std::setfill('0') << bdRandom::random_u32();
|
||||
|
||||
std::string num = out.str();
|
||||
std::string num;
|
||||
bd_sprintf(num, "%04lx", bdRandom::random_u32());
|
||||
int len = num.size();
|
||||
if (len > BITDHT_TOKEN_MAX_LEN)
|
||||
len = BITDHT_TOKEN_MAX_LEN;
|
||||
|
@ -2125,9 +2122,8 @@ void bdNode::genNewTransId(bdToken *token)
|
|||
fprintf(stderr, ")\n");
|
||||
#endif
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::setw(2) << std::setfill('0') << transIdCounter++;
|
||||
std::string num = out.str();
|
||||
std::string num;
|
||||
bd_sprintf(num, "%02lx", transIdCounter++);
|
||||
int len = num.size();
|
||||
if (len > BITDHT_TOKEN_MAX_LEN)
|
||||
len = BITDHT_TOKEN_MAX_LEN;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "bitdht/bdstddht.h"
|
||||
#include "bitdht/bdpeer.h"
|
||||
#include "util/bdrandom.h"
|
||||
#include "util/bdstring.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -177,41 +178,53 @@ int bdStdLoadNodeId(bdNodeId *id, std::string input)
|
|||
|
||||
std::string bdStdConvertToPrintable(std::string input)
|
||||
{
|
||||
std::ostringstream out;
|
||||
for(uint32_t i = 0; i < input.length(); i++)
|
||||
std::string out;
|
||||
for(uint32_t i = 0; i < input.length(); i++)
|
||||
{
|
||||
/* sensible chars */
|
||||
if ((input[i] > 31) && (input[i] < 127))
|
||||
{
|
||||
/* sensible chars */
|
||||
if ((input[i] > 31) && (input[i] < 127))
|
||||
{
|
||||
out << input[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "[0x" << std::hex << (uint32_t) input[i] << "]";
|
||||
out << std::dec;
|
||||
}
|
||||
out += input[i];
|
||||
}
|
||||
return out.str();
|
||||
else
|
||||
{
|
||||
bd_sprintf_append(out, "[0x%x]", (uint32_t) input[i]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void bdStdPrintNodeId(std::ostream &out, const bdNodeId *a)
|
||||
{
|
||||
for(int i = 0; i < BITDHT_KEY_LEN; i++)
|
||||
{
|
||||
out << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) (a->data)[i];
|
||||
}
|
||||
out << std::dec;
|
||||
|
||||
return;
|
||||
std::string s;
|
||||
bdStdPrintNodeId(s, a, true);
|
||||
out << s;
|
||||
}
|
||||
|
||||
void bdStdPrintNodeId(std::string &out, const bdNodeId *a, bool append)
|
||||
{
|
||||
if (!append)
|
||||
{
|
||||
out.clear();
|
||||
}
|
||||
|
||||
for(int i = 0; i < BITDHT_KEY_LEN; i++)
|
||||
{
|
||||
bd_sprintf_append(out, "%02x", (uint32_t) (a->data)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void bdStdPrintId(std::ostream &out, const bdId *a)
|
||||
{
|
||||
bdStdPrintNodeId(out, &(a->id));
|
||||
out << " ip:" << bdnet_inet_ntoa(a->addr.sin_addr);
|
||||
out << ":" << ntohs(a->addr.sin_port);
|
||||
return;
|
||||
std::string s;
|
||||
bdStdPrintId(s, a, false);
|
||||
out << s;
|
||||
}
|
||||
|
||||
void bdStdPrintId(std::string &out, const bdId *a, bool append)
|
||||
{
|
||||
bdStdPrintNodeId(out, &(a->id), append);
|
||||
bd_sprintf_append(out, " ip:%s:%u", bdnet_inet_ntoa(a->addr.sin_addr).c_str(), ntohs(a->addr.sin_port));
|
||||
}
|
||||
|
||||
/* returns 0-160 depending on bucket */
|
||||
|
|
|
@ -55,7 +55,9 @@ void bdStdRandomMidId(const bdNodeId *target, const bdNodeId *other, bdNodeId *m
|
|||
int bdStdLoadNodeId(bdNodeId *id, std::string input);
|
||||
|
||||
void bdStdPrintId(std::ostream &out, const bdId *a);
|
||||
void bdStdPrintId(std::string &out, const bdId *a, bool append);
|
||||
void bdStdPrintNodeId(std::ostream &out, const bdNodeId *a);
|
||||
void bdStdPrintNodeId(std::string &out, const bdNodeId *a, bool append);
|
||||
|
||||
std::string bdStdConvertToPrintable(std::string input);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue