Removed some std::ostringstream.

To be continued.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5109 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-04-18 21:20:37 +00:00
parent 9aee68a2a9
commit b71eeadf95
9 changed files with 1865 additions and 1925 deletions

View File

@ -274,9 +274,7 @@ void convertBdPeerToRsDhtPeer(RsDhtPeer &peer, const bdPeer &int_peer)
peer.mDhtId = out.str();
std::ostringstream addr;
addr << rs_inet_ntoa(int_peer.mPeerId.addr.sin_addr) << ":" << ntohs(int_peer.mPeerId.addr.sin_port);
peer.mAddr = addr.str();
rs_sprintf(peer.mAddr, "%s:%u", rs_inet_ntoa(int_peer.mPeerId.addr.sin_addr).c_str(), ntohs(int_peer.mPeerId.addr.sin_port));
peer.mLastSendTime = int_peer.mLastSendTime;
peer.mLastRecvTime = int_peer.mLastRecvTime;
@ -333,23 +331,9 @@ void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDeta
void convertUdpRelayEndtoRsDhtRelayEnd(RsDhtRelayEnd &end, const UdpRelayEnd &int_end)
{
{
std::ostringstream addr;
addr << rs_inet_ntoa(int_end.mLocalAddr.sin_addr) << ":" << ntohs(int_end.mLocalAddr.sin_port);
end.mLocalAddr = addr.str();
}
{
std::ostringstream addr;
addr << rs_inet_ntoa(int_end.mProxyAddr.sin_addr) << ":" << ntohs(int_end.mProxyAddr.sin_port);
end.mProxyAddr = addr.str();
}
{
std::ostringstream addr;
addr << rs_inet_ntoa(int_end.mRemoteAddr.sin_addr) << ":" << ntohs(int_end.mRemoteAddr.sin_port);
end.mRemoteAddr = addr.str();
}
rs_sprintf(end.mLocalAddr, "%s:%u", rs_inet_ntoa(int_end.mLocalAddr.sin_addr).c_str(), ntohs(int_end.mLocalAddr.sin_port));
rs_sprintf(end.mProxyAddr, "%s:%u", rs_inet_ntoa(int_end.mProxyAddr.sin_addr).c_str(), ntohs(int_end.mProxyAddr.sin_port));
rs_sprintf(end.mRemoteAddr, "%s:%u", rs_inet_ntoa(int_end.mRemoteAddr.sin_addr).c_str(), ntohs(int_end.mRemoteAddr.sin_port));
end.mCreateTS = 0;
return;
@ -357,26 +341,16 @@ void convertUdpRelayEndtoRsDhtRelayEnd(RsDhtRelayEnd &end, const UdpRelayEnd &in
void convertUdpRelayProxytoRsDhtRelayProxy(RsDhtRelayProxy &proxy, const UdpRelayProxy &int_proxy)
{
{
std::ostringstream addr;
addr << rs_inet_ntoa(int_proxy.mAddrs.mSrcAddr.sin_addr) << ":" << ntohs(int_proxy.mAddrs.mSrcAddr.sin_port);
proxy.mSrcAddr = addr.str();
}
rs_sprintf(proxy.mSrcAddr, "%s:%u", rs_inet_ntoa(int_proxy.mAddrs.mSrcAddr.sin_addr).c_str(), ntohs(int_proxy.mAddrs.mSrcAddr.sin_port));
rs_sprintf(proxy.mDestAddr, "%s:%u", rs_inet_ntoa(int_proxy.mAddrs.mDestAddr.sin_addr).c_str(), ntohs(int_proxy.mAddrs.mDestAddr.sin_port));
{
std::ostringstream addr;
addr << rs_inet_ntoa(int_proxy.mAddrs.mDestAddr.sin_addr) << ":" << ntohs(int_proxy.mAddrs.mDestAddr.sin_port);
proxy.mDestAddr = addr.str();
}
proxy.mBandwidth = int_proxy.mBandwidth;
proxy.mRelayClass = int_proxy.mRelayClass;
proxy.mLastTS = int_proxy.mLastTS;
proxy.mBandwidth = int_proxy.mBandwidth;
proxy.mRelayClass = int_proxy.mRelayClass;
proxy.mLastTS = int_proxy.mLastTS;
proxy.mCreateTS = 0;
//proxy.mDataSize = int_proxy.mDataSize;
//proxy.mLastBandwidthTS = int_proxy.mLastBandwidthTS;
//proxy.mDataSize = int_proxy.mDataSize;
//proxy.mLastBandwidthTS = int_proxy.mLastBandwidthTS;
}
RsDhtPeer::RsDhtPeer()

View File

@ -2169,10 +2169,7 @@ void p3BitDht::Feedback_Connected(std::string pid)
dpd->mConnectLogic.updateCb(CSB_UPDATE_CONNECTED);
std::ostringstream msg;
msg << "Connected in " << dpd->mPeerConnectTS - dpd->mPeerConnectUdpTS;
msg << " secs";
dpd->mPeerConnectMsg = msg.str();
rs_sprintf(dpd->mPeerConnectMsg, "Connected in %ld secs", dpd->mPeerConnectTS - dpd->mPeerConnectUdpTS);
// Remove the Connection Request.
if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)
@ -2290,10 +2287,7 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
dpd->mPeerConnectClosedTS = time(NULL);
std::ostringstream msg;
msg << "Closed, Alive for: " << dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS;
msg << " secs";
dpd->mPeerConnectMsg = msg.str();
rs_sprintf(dpd->mPeerConnectMsg, "Closed, Alive for: %ld secs", dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS);
}

View File

@ -907,17 +907,17 @@ std::string ProcessPGPmeError(gpgme_error_t ERR)
gpgme_err_code_t code = gpgme_err_code(ERR);
gpgme_err_source_t src = gpgme_err_source(ERR);
std::ostringstream ss ;
std::string s ;
if(code > 0)
{
ss << "GPGme ERROR: Code: " << code << " Source: " << src << std::endl;
ss << "GPGme ERROR: " << gpgme_strerror(ERR) << std::endl;
rs_sprintf(s, "GPGme ERROR: Code: %d Source: %d\n", code, src);
rs_sprintf_append(s, "GPGme ERROR: %s\n", gpgme_strerror(ERR));
}
else
return std::string("Unknown error") ;
return ss.str() ;
return s ;
}
void print_pgpme_verify_summary(unsigned int summary)
@ -1844,9 +1844,8 @@ int AuthGPGimpl::privateTrustCertificate(const std::string &id, int trustlvl)
gpgme_key_t trustKey = trustCert.key;
std::string trustString;
std::ostringstream trustStrOut;
trustStrOut << trustlvl;
class TrustParams sparams(trustStrOut.str());
rs_sprintf(trustString, "%d", trustlvl);
class TrustParams sparams(trustString);
class EditParams params(TRUST_START, &sparams);
gpgme_data_t out;
gpg_error_t ERR;
@ -1875,11 +1874,10 @@ static std::string setKeyPairParams(bool useRsa, unsigned int blen,
std::string name, std::string comment, std::string email,
std::string inPassphrase)
{
std::ostringstream params;
params << "<GnupgKeyParms format=\"internal\">"<< std::endl;
std::string params = "<GnupgKeyParms format=\"internal\">\n";
if (useRsa)
{
params << "Key-Type: RSA"<< std::endl;
params += "Key-Type: RSA\n";
if (blen < 1024)
{
#ifdef GPG_DEBUG
@ -1888,23 +1886,23 @@ static std::string setKeyPairParams(bool useRsa, unsigned int blen,
blen = 1024;
}
blen = ((blen / 512) * 512); /* make multiple of 512 */
params << "Key-Length: "<< blen << std::endl;
rs_sprintf_append(params, "Key-Length: %u\n", blen);
}
else
{
params << "Key-Type: DSA"<< std::endl;
params << "Key-Length: 1024"<< std::endl;
params << "Subkey-Type: ELG-E"<< std::endl;
params << "Subkey-Length: 1024"<< std::endl;
params += "Key-Type: DSA\n";
params += "Key-Length: 1024\n";
params += "Subkey-Type: ELG-E\n";
params += "Subkey-Length: 1024\n";
}
params << "Name-Real: "<< name << std::endl;
params << "Name-Comment: "<< comment << std::endl;
params << "Name-Email: "<< email << std::endl;
params << "Expire-Date: 0"<< std::endl;
params << "Passphrase: "<< inPassphrase << std::endl;
params << "</GnupgKeyParms>"<< std::endl;
params += "Name-Real: " + name + "\n";
params += "Name-Comment: " + comment + "\n";
params += "Name-Email: " + email + "\n";
params += "Expire-Date: 0\n";
params += "Passphrase: " + inPassphrase + "\n";
params += "</GnupgKeyParms>\n";
return params.str();
return params;
}

View File

@ -27,6 +27,7 @@
#include "serialiser/rsbaseserial.h"
#include "serialiser/rsserial.h"
#include "util/rsthreads.h"
#include "util/rsstring.h"
#include <math.h>
#include <map>
@ -292,11 +293,11 @@ uint32_t RsSerialiser::size(RsItem *item)
#ifdef RSSERIAL_ERROR_DEBUG
std::cerr << "RsSerialiser::size() ERROR serialiser missing!";
std::ostringstream out;
out << std::hex << item->PacketId() << std::dec;
std::string out;
rs_sprintf(out, "%x", item->PacketId());
std::cerr << "RsSerialiser::size() PacketId: ";
std::cerr << out.str();
std::cerr << out;
std::cerr << std::endl;
#endif
return 0;
@ -305,10 +306,9 @@ uint32_t RsSerialiser::size(RsItem *item)
}
#ifdef RSSERIAL_DEBUG
std::ostringstream out;
out << std::hex << "RsSerialiser::size() Item->PacketId(): " << item->PacketId();
out << " matched to Serialiser Type: " << type;
std::cerr << out.str() << std::endl;
std::string out;
rs_sprintf(out, "RsSerialiser::size() Item->PacketId(): %x matched to Serialiser Type: %lu", item->PacketId(), type);
std::cerr << out << std::endl;
#endif
return (it->second)->size(item);
@ -333,11 +333,11 @@ bool RsSerialiser::serialise (RsItem *item, void *data, uint32_t *size)
#ifdef RSSERIAL_ERROR_DEBUG
std::cerr << "RsSerialiser::serialise() ERROR serialiser missing!";
std::ostringstream out;
out << std::hex << item->PacketId() << std::dec;
std::string out;
rs_sprintf(out, "%x", item->PacketId());
std::cerr << "RsSerialiser::serialise() PacketId: ";
std::cerr << out.str();
std::cerr << out;
std::cerr << std::endl;
#endif
return false;
@ -346,10 +346,9 @@ bool RsSerialiser::serialise (RsItem *item, void *data, uint32_t *size)
}
#ifdef RSSERIAL_DEBUG
std::ostringstream out;
out << std::hex << "RsSerialiser::serialise() Item->PacketId(): " << item->PacketId();
out << " matched to Serialiser Type: " << type;
std::cerr << out.str() << std::endl;
std::string out;
rs_sprintf(out, "RsSerialiser::serialise() Item->PacketId(): %x matched to Serialiser Type: %lu", item->PacketId(), type);
std::cerr << out << std::endl;
#endif
return (it->second)->serialise(item, data, size);
@ -401,12 +400,11 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
#ifdef RSSERIAL_ERROR_DEBUG
std::cerr << "RsSerialiser::deserialise() ERROR deserialiser missing!";
std::ostringstream out;
out << std::hex << getRsItemId(data) << std::dec;
std::string out;
rs_sprintf(out, "%x", getRsItemId(data));
std::cerr << "RsSerialiser::deserialise() PacketId: ";
std::cerr << out.str();
std::cerr << std::endl;
std::cerr << out << std::endl;
#endif
return NULL;
}

View File

@ -34,32 +34,30 @@
/* print out a packet */
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include "serialiser/rstlvbase.h"
#include "serialiser/rstlvtypes.h"
#include "util/utest.h"
#include "util/rsstring.h"
void displayRawPacket(std::ostream &out, void *data, uint32_t size)
{
uint32_t i;
std::ostringstream sout;
sout << "DisplayRawPacket: Size: " << size;
sout << std::hex;
std::string sout;
rs_sprintf(sout, "DisplayRawPacket: Size: %ld", size);
for(i = 0; i < size; i++)
{
if (i % 16 == 0)
{
sout << std::endl;
sout += "\n";
}
sout << std::setw(2) << std::setfill('0')
<< (int) (((unsigned char *) data)[i]) << ":";
rs_sprintf_append(sout, "%02x:", (int) (((unsigned char *) data)[i]));
}
sout << std::endl;
out << sout.str();
out << sout << std::endl;
}

View File

@ -1,7 +1,7 @@
#include <iostream>
#include <iomanip>
#include <sstream>
#include "rstunnelitems.h"
#include "util/rsstring.h"
// -----------------------------------------------------------------------------------//
// -------------------------------- Serialization. --------------------------------- //
@ -184,21 +184,19 @@ bool RsTunnelHandshakeItem::serialize(void *data,uint32_t& pktsize)
void displayRawPacket(std::ostream &out, void *data, uint32_t size)
{
uint32_t i;
std::ostringstream sout;
sout << "DisplayRawPacket: Size: " << size;
sout << std::hex;
std::string sout;
rs_sprintf(sout, "DisplayRawPacket: Size: %ld", size);
for(i = 0; i < size; i++)
{
if (i % 16 == 0)
{
sout << std::endl;
sout += "\n";
}
sout << std::setw(2) << std::setfill('0')
<< (int) (((unsigned char *) data)[i]) << ":";
rs_sprintf_append(sout, "%02x:", (int) (((unsigned char *) data)[i]));
}
sout << std::endl;
out << sout.str();
out << sout << std::endl;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@
#include <map>
#include <string>
#include <sstream>
#include <memory>
#include <vector>
#include <string.h>
@ -194,10 +193,8 @@ CXML_List<T, XML_ELEMENT_NAME, XML_LIST_NAME>::CXML_List(
(*this)[upnpElement->GetKey()] = upnpElement;
++i;
}
std::ostringstream msg;
msg << "\n " << XML_LIST_NAME << ": " <<
std::cerr << "\n " << XML_LIST_NAME << ": " <<
i << " " << XML_ELEMENT_NAME << "s.";
std::cerr << msg;
}

View File

@ -26,7 +26,6 @@
#include "zeroconf/p3zeroconf.h"
#include <openssl/sha.h>
#include <sstream>
#include <iostream>
#include "pqi/authgpg.h"
@ -126,14 +125,9 @@ bool p3ZeroConf::getNetworkStats(uint32_t &netsize, uint32_t &localnetsize)
void p3ZeroConf::createTxtRecord()
{
RsStackMutex stack(mZcMtx); /****** STACK LOCK MUTEX *******/
std::ostringstream gpgidout;
std::ostringstream sslidout;
gpgidout << "gpgid=" << mOwnGpgId;
sslidout << "sslid=" << mOwnSslId;
std::string gpgid = gpgidout.str();
std::string sslid = sslidout.str();
std::string gpgid = "gpgid=" + mOwnGpgId;
std::string sslid = "sslid=" + mOwnSslId;
mTextRecord += (char) gpgid.length();
mTextRecord += gpgid;
@ -1248,110 +1242,110 @@ int p3ZeroConf::locked_stopQueryIp()
std::string displayDNSServiceError(DNSServiceErrorType errcode)
{
std::ostringstream str;
std::string str;
switch(errcode)
{
default:
str << "kDNSServiceErr_??? UNKNOWN-CODE";
str = "kDNSServiceErr_??? UNKNOWN-CODE";
break;
case kDNSServiceErr_NoError:
str << "kDNSServiceErr_NoError";
str = "kDNSServiceErr_NoError";
break;
case kDNSServiceErr_Unknown:
str << "kDNSServiceErr_Unknown";
str = "kDNSServiceErr_Unknown";
break;
case kDNSServiceErr_NoSuchName:
str << "kDNSServiceErr_NoSuchName";
str = "kDNSServiceErr_NoSuchName";
break;
case kDNSServiceErr_NoMemory:
str << "kDNSServiceErr_NoMemory";
str = "kDNSServiceErr_NoMemory";
break;
case kDNSServiceErr_BadParam:
str << "kDNSServiceErr_BadParam";
str = "kDNSServiceErr_BadParam";
break;
case kDNSServiceErr_BadReference:
str << "kDNSServiceErr_BadReference";
str = "kDNSServiceErr_BadReference";
break;
case kDNSServiceErr_BadState:
str << "kDNSServiceErr_BadState";
str = "kDNSServiceErr_BadState";
break;
case kDNSServiceErr_BadFlags:
str << "kDNSServiceErr_BadFlags";
str = "kDNSServiceErr_BadFlags";
break;
case kDNSServiceErr_Unsupported:
str << "kDNSServiceErr_Unsupported";
str = "kDNSServiceErr_Unsupported";
break;
case kDNSServiceErr_NotInitialized:
str << "kDNSServiceErr_NotInitialized";
str = "kDNSServiceErr_NotInitialized";
break;
case kDNSServiceErr_AlreadyRegistered:
str << "kDNSServiceErr_AlreadyRegistered";
str = "kDNSServiceErr_AlreadyRegistered";
break;
case kDNSServiceErr_NameConflict:
str << "kDNSServiceErr_NameConflict";
str = "kDNSServiceErr_NameConflict";
break;
case kDNSServiceErr_Invalid:
str << "kDNSServiceErr_Invalid";
str = "kDNSServiceErr_Invalid";
break;
case kDNSServiceErr_Firewall:
str << "kDNSServiceErr_Firewall";
str = "kDNSServiceErr_Firewall";
break;
case kDNSServiceErr_Incompatible:
str << "kDNSServiceErr_Incompatible";
str = "kDNSServiceErr_Incompatible";
break;
case kDNSServiceErr_BadInterfaceIndex:
str << "kDNSServiceErr_BadInterfaceIndex";
str = "kDNSServiceErr_BadInterfaceIndex";
break;
case kDNSServiceErr_Refused:
str << "kDNSServiceErr_Refused";
str = "kDNSServiceErr_Refused";
break;
case kDNSServiceErr_NoSuchRecord:
str << "kDNSServiceErr_NoSuchRecord";
str = "kDNSServiceErr_NoSuchRecord";
break;
case kDNSServiceErr_NoAuth:
str << "kDNSServiceErr_NoAuth";
str = "kDNSServiceErr_NoAuth";
break;
case kDNSServiceErr_NoSuchKey:
str << "kDNSServiceErr_NoSuchKey";
str = "kDNSServiceErr_NoSuchKey";
break;
case kDNSServiceErr_NATTraversal:
str << "kDNSServiceErr_NATTraversal";
str = "kDNSServiceErr_NATTraversal";
break;
case kDNSServiceErr_DoubleNAT:
str << "kDNSServiceErr_DoubleNAT";
str = "kDNSServiceErr_DoubleNAT";
break;
case kDNSServiceErr_BadTime:
str << "kDNSServiceErr_BadTime";
str = "kDNSServiceErr_BadTime";
break;
case kDNSServiceErr_BadSig:
str << "kDNSServiceErr_BadSig";
str = "kDNSServiceErr_BadSig";
break;
case kDNSServiceErr_BadKey:
str << "kDNSServiceErr_BadKey";
str = "kDNSServiceErr_BadKey";
break;
case kDNSServiceErr_Transient:
str << "kDNSServiceErr_Transient";
str = "kDNSServiceErr_Transient";
break;
case kDNSServiceErr_ServiceNotRunning:
str << "kDNSServiceErr_ServiceNotRunning";
str = "kDNSServiceErr_ServiceNotRunning";
break;
case kDNSServiceErr_NATPortMappingUnsupported:
str << "kDNSServiceErr_NATPortMappingUnsupported";
str = "kDNSServiceErr_NATPortMappingUnsupported";
break;
case kDNSServiceErr_NATPortMappingDisabled:
str << "kDNSServiceErr_NATPortMappingDisabled";
str = "kDNSServiceErr_NATPortMappingDisabled";
break;
#if 0
case kDNSServiceErr_NoRouter:
str << "kDNSServiceErr_NoRouter";
str = "kDNSServiceErr_NoRouter";
break;
case kDNSServiceErr_PollingMode:
str << "kDNSServiceErr_PollingMode";
str = "kDNSServiceErr_PollingMode";
break;
#endif
}
return str.str();
return str;
}