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:
thunder2 2012-04-19 20:44:32 +00:00
parent a9e496f845
commit 4e26884646
14 changed files with 190 additions and 131 deletions

View File

@ -33,8 +33,7 @@
#include "bitdht/bdstddht.h" #include "bitdht/bdstddht.h"
#include "util/bdnet.h" #include "util/bdnet.h"
#include "util/bdrandom.h" #include "util/bdrandom.h"
#include "util/bdstring.h"
#include <sstream>
/* /*
* #define DEBUG_PROXY_CONNECTION 1 * #define DEBUG_PROXY_CONNECTION 1
@ -3377,11 +3376,7 @@ std::string decodeConnectionErrorType(uint32_t errcode)
switch(errtype) switch(errtype)
{ {
default: default:
{ bd_sprintf_append(namedtype, "(%lu)", errtype);
std::ostringstream out;
out << "(" << errtype << ")";
namedtype += out.str();
}
break; break;
case BITDHT_CONNECT_ERROR_GENERIC: case BITDHT_CONNECT_ERROR_GENERIC:
namedtype = "GENERIC"; namedtype = "GENERIC";
@ -3434,11 +3429,7 @@ std::string decodeConnectionErrorSource(uint32_t errcode)
switch(errsrc) switch(errsrc)
{ {
default: default:
{ bd_sprintf_append(namedtype, "(%lu)", errsrc);
std::ostringstream out;
out << "(" << errsrc << ")";
namedtype += out.str();
}
break; break;
case BITDHT_CONNECT_ERROR_SOURCE_START: case BITDHT_CONNECT_ERROR_SOURCE_START:
namedtype = "START"; namedtype = "START";

View File

@ -46,12 +46,12 @@
#include "bitdht/bdfilter.h" #include "bitdht/bdfilter.h"
#include <algorithm> #include <algorithm>
#include <sstream>
#include <iomanip> #include <iomanip>
#include <string.h> #include <string.h>
#include "util/bdnet.h" #include "util/bdnet.h"
#include "util/bdrandom.h" #include "util/bdrandom.h"
#include "util/bdstring.h"
/*** /***
* #define DEBUG_MGR 1 * #define DEBUG_MGR 1
@ -601,10 +601,10 @@ void bdNodeManager::SearchForLocalNet()
for(i = 0; (!filterOk) && (i < MAX_FILTER_ATTEMPTS); i++) for(i = 0; (!filterOk) && (i < MAX_FILTER_ATTEMPTS); i++)
{ {
bdStdRandomNodeId(&targetNodeId); bdStdRandomNodeId(&targetNodeId);
std::ostringstream tststr; std::string tststr;
bdStdPrintNodeId(tststr, &targetNodeId); bdStdPrintNodeId(tststr, &targetNodeId, false);
if (mBloomFilter.test(tststr.str())) if (mBloomFilter.test(tststr))
{ {
filterOk = true; filterOk = true;
} }
@ -1220,26 +1220,23 @@ int bdNodeManager::isBitDhtPacket(char *data, int size, struct sockaddr_in &
std::cerr << std::endl; std::cerr << std::endl;
{ {
/* print the fucker... only way to catch bad ones */ /* print the fucker... only way to catch bad ones */
std::ostringstream out; std::string out;
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
if (isascii(data[i])) if (isascii(data[i]))
{ {
out << data[i]; out += data[i];
} }
else else
{ {
out << "["; bd_sprintf_append(out, "[%02lx]", (uint32_t) data[i]);
out << std::setw(2) << std::setfill('0')
<< std::hex << (uint32_t) data[i];
out << "]";
} }
if ((i % 16 == 0) && (i != 0)) if ((i % 16 == 0) && (i != 0))
{ {
out << std::endl; out += "\n";
} }
} }
std::cerr << out.str(); std::cerr << out;
} }
std::cerr << "bdNodeManager::isBitDhtPacket() *******************************"; std::cerr << "bdNodeManager::isBitDhtPacket() *******************************";
std::cerr << std::endl; std::cerr << std::endl;
@ -1262,26 +1259,23 @@ int bdNodeManager::isBitDhtPacket(char *data, int size, struct sockaddr_in &
std::cerr << std::endl; std::cerr << std::endl;
{ {
/* print the fucker... only way to catch bad ones */ /* print the fucker... only way to catch bad ones */
std::ostringstream out; std::string out;
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
if (isascii(data[i])) if (isascii(data[i]))
{ {
out << data[i]; out += data[i];
} }
else else
{ {
out << "["; bd_sprintf_append(out, "[%02lx]", (uint32_t) data[i]);
out << std::setw(2) << std::setfill('0')
<< std::hex << (uint32_t) data[i];
out << "]";
} }
if ((i % 16 == 0) && (i != 0)) if ((i % 16 == 0) && (i != 0))
{ {
out << std::endl; out += "\n";
} }
} }
std::cerr << out.str(); std::cerr << out;
} }
std::cerr << "bdNodeManager::BadPacket ******************************"; std::cerr << "bdNodeManager::BadPacket ******************************";
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -33,14 +33,13 @@
#include "util/bdnet.h" #include "util/bdnet.h"
#include "util/bdrandom.h" #include "util/bdrandom.h"
#include "util/bdstring.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <sstream>
#define BITDHT_QUERY_START_PEERS 10 #define BITDHT_QUERY_START_PEERS 10
@ -2100,10 +2099,8 @@ void bdNode::genNewToken(bdToken *token)
// XXX is this a good way to do it? // XXX is this a good way to do it?
// Variable length, from 4 chars up to lots... 10? // Variable length, from 4 chars up to lots... 10?
// leave for the moment, but fix. // leave for the moment, but fix.
std::ostringstream out; std::string num;
out << std::setw(4) << std::setfill('0') << bdRandom::random_u32(); bd_sprintf(num, "%04lx", bdRandom::random_u32());
std::string num = out.str();
int len = num.size(); int len = num.size();
if (len > BITDHT_TOKEN_MAX_LEN) if (len > BITDHT_TOKEN_MAX_LEN)
len = BITDHT_TOKEN_MAX_LEN; len = BITDHT_TOKEN_MAX_LEN;
@ -2125,9 +2122,8 @@ void bdNode::genNewTransId(bdToken *token)
fprintf(stderr, ")\n"); fprintf(stderr, ")\n");
#endif #endif
std::ostringstream out; std::string num;
out << std::setw(2) << std::setfill('0') << transIdCounter++; bd_sprintf(num, "%02lx", transIdCounter++);
std::string num = out.str();
int len = num.size(); int len = num.size();
if (len > BITDHT_TOKEN_MAX_LEN) if (len > BITDHT_TOKEN_MAX_LEN)
len = BITDHT_TOKEN_MAX_LEN; len = BITDHT_TOKEN_MAX_LEN;

View File

@ -27,6 +27,7 @@
#include "bitdht/bdstddht.h" #include "bitdht/bdstddht.h"
#include "bitdht/bdpeer.h" #include "bitdht/bdpeer.h"
#include "util/bdrandom.h" #include "util/bdrandom.h"
#include "util/bdstring.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -177,41 +178,53 @@ int bdStdLoadNodeId(bdNodeId *id, std::string input)
std::string bdStdConvertToPrintable(std::string input) std::string bdStdConvertToPrintable(std::string input)
{ {
std::ostringstream out; std::string out;
for(uint32_t i = 0; i < input.length(); i++) for(uint32_t i = 0; i < input.length(); i++)
{
/* sensible chars */
if ((input[i] > 31) && (input[i] < 127))
{ {
/* sensible chars */ out += input[i];
if ((input[i] > 31) && (input[i] < 127))
{
out << input[i];
}
else
{
out << "[0x" << std::hex << (uint32_t) input[i] << "]";
out << std::dec;
}
} }
return out.str(); else
{
bd_sprintf_append(out, "[0x%x]", (uint32_t) input[i]);
}
}
return out;
} }
void bdStdPrintNodeId(std::ostream &out, const bdNodeId *a) void bdStdPrintNodeId(std::ostream &out, const bdNodeId *a)
{ {
for(int i = 0; i < BITDHT_KEY_LEN; i++) std::string s;
{ bdStdPrintNodeId(s, a, true);
out << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) (a->data)[i]; out << s;
}
out << std::dec;
return;
} }
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) void bdStdPrintId(std::ostream &out, const bdId *a)
{ {
bdStdPrintNodeId(out, &(a->id)); std::string s;
out << " ip:" << bdnet_inet_ntoa(a->addr.sin_addr); bdStdPrintId(s, a, false);
out << ":" << ntohs(a->addr.sin_port); out << s;
return; }
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 */ /* returns 0-160 depending on bucket */

View File

@ -55,7 +55,9 @@ void bdStdRandomMidId(const bdNodeId *target, const bdNodeId *other, bdNodeId *m
int bdStdLoadNodeId(bdNodeId *id, std::string input); int bdStdLoadNodeId(bdNodeId *id, std::string input);
void bdStdPrintId(std::ostream &out, const bdId *a); 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::ostream &out, const bdNodeId *a);
void bdStdPrintNodeId(std::string &out, const bdNodeId *a, bool append);
std::string bdStdConvertToPrintable(std::string input); std::string bdStdConvertToPrintable(std::string input);

View File

@ -141,6 +141,7 @@ SOURCES += \
util/bdnet.cc \ util/bdnet.cc \
util/bdthreads.cc \ util/bdthreads.cc \
util/bdrandom.cc \ util/bdrandom.cc \
util/bdstring.cc \
udp/udplayer.cc \ udp/udplayer.cc \
udp/udpstack.cc \ udp/udpstack.cc \
udp/udpbitdht.cc \ udp/udpbitdht.cc \

View File

@ -25,9 +25,9 @@
#include "udp/udplayer.h" #include "udp/udplayer.h"
#include "util/bdrandom.h" #include "util/bdrandom.h"
#include "util/bdstring.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <iomanip> #include <iomanip>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -113,53 +113,45 @@ bool operator<(const struct sockaddr_in &addr, const struct sockaddr_in &addr2)
std::string printPkt(void *d, int size) std::string printPkt(void *d, int size)
{ {
std::ostringstream out; std::string out = "Packet:**********************";
out << "Packet:" << "**********************";
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
if (i % 16 == 0) if (i % 16 == 0)
out << std::endl; out += "\n";
out << std::hex << std::setw(2) << (unsigned int) ((unsigned char *) d)[i] << " "; bd_sprintf_append(out, "%2x ", (unsigned int) ((unsigned char *) d)[i]);
} }
out << std::endl << "**********************"; out += "\n**********************\n";
out << std::endl; return out;
return out.str();
} }
std::string printPktOffset(unsigned int offset, void *d, unsigned int size) std::string printPktOffset(unsigned int offset, void *d, unsigned int size)
{ {
std::ostringstream out; std::string out = "Packet:**********************\n";
out << "Packet:" << "**********************"; bd_sprintf_append(out, "Offset: %x -> %x\n", offset, offset + size);
out << std::endl; out += "Packet:**********************";
out << "Offset: " << std::hex << offset << " -> " << offset + size;
out << std::endl;
out << "Packet:" << "**********************";
unsigned int j = offset % 16; unsigned int j = offset % 16;
if (j != 0) if (j != 0)
{ {
out << std::endl; out += "\n";
out << std::hex << std::setw(6) << (unsigned int) offset - j; bd_sprintf_append(out, "%6x: ", (unsigned int) offset - j);
out << ": ";
for(unsigned int i = 0; i < j; i++) for(unsigned int i = 0; i < j; i++)
{ {
out << "xx "; out += "xx ";
} }
} }
for(unsigned int i = offset; i < offset + size; i++) for(unsigned int i = offset; i < offset + size; i++)
{ {
if (i % 16 == 0) if (i % 16 == 0)
{ {
out << std::endl; out += "\n";
out << std::hex << std::setw(6) << (unsigned int) i; bd_sprintf_append(out, "%6x: ", (unsigned int) i);
out << ": ";
} }
out << std::hex << std::setw(2) << (unsigned int) ((unsigned char *) d)[i-offset] << " "; bd_sprintf(out, "%2x ", (unsigned int) ((unsigned char *) d)[i-offset]);
} }
out << std::endl << "**********************"; out += "\n**********************\n";
out << std::endl; return out;
return out.str();
} }

View File

@ -24,9 +24,9 @@
*/ */
#include "util/bdbloom.h" #include "util/bdbloom.h"
#include "util/bdstring.h"
#include <stdlib.h> #include <stdlib.h>
#include <sstream>
#include <iomanip> #include <iomanip>
#if defined(_WIN32) || defined(__MINGW32__) #if defined(_WIN32) || defined(__MINGW32__)
@ -131,7 +131,6 @@ int bloomFilter::setFilterBits(const std::string &hex)
std::string bloomFilter::getFilter() std::string bloomFilter::getFilter()
{ {
/* extract filter as a hex string */ /* extract filter as a hex string */
std::string output;
int bytes = (mFilterBits / BITS_PER_BYTE); int bytes = (mFilterBits / BITS_PER_BYTE);
if (mFilterBits % BITS_PER_BYTE) if (mFilterBits % BITS_PER_BYTE)
{ {
@ -155,15 +154,15 @@ std::string bloomFilter::getFilter()
} }
} }
std::ostringstream out; std::string out;
for(int i = 0; i < bytes; i++) for(int i = 0; i < bytes; i++)
{ {
out << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) (tmparray)[i]; bd_sprintf_append(out, "%02lx", (uint32_t) (tmparray)[i]);
} }
free(tmparray); free(tmparray);
return out.str(); return out;
} }
void bloomFilter::setBit(int bit) void bloomFilter::setBit(int bit)

View File

@ -25,9 +25,9 @@
*/ */
#include "bdnet.h" #include "bdnet.h"
#include "bdstring.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -361,11 +361,8 @@ void bdsockaddr_clear(struct sockaddr_in *addr)
std::string bdnet_inet_ntoa(struct in_addr in) std::string bdnet_inet_ntoa(struct in_addr in)
{ {
std::ostringstream str; std::string str;
uint8_t *bytes = (uint8_t *) &(in.s_addr); uint8_t *bytes = (uint8_t *) &(in.s_addr);
str << (int) bytes[0] << "."; bd_sprintf(str, "%u.%u.%u.%u", (int) bytes[0], (int) bytes[1], (int) bytes[2], (int) bytes[3]);
str << (int) bytes[1] << "."; return str;
str << (int) bytes[2] << ".";
str << (int) bytes[3];
return str.str();
} }

View File

@ -0,0 +1,83 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2012, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "bdstring.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <stdarg.h>
#include <malloc.h>
#endif
#include <stdio.h>
#ifdef _WIN32
// asprintf() and vasprintf() are missing in Win32
static int vasprintf(char **sptr, const char *fmt, va_list argv)
{
int wanted = __mingw_vsnprintf(*sptr = NULL, 0, fmt, argv);
if ((wanted > 0) && ((*sptr = (char*) malloc(wanted + 1)) != NULL)) {
return __mingw_vsprintf(*sptr, fmt, argv);
}
return wanted;
}
//int asprintf(char **sptr, const char *fmt, ...)
//{
// int retval;
// va_list argv;
// va_start( argv, fmt );
// retval = vasprintf(sptr, fmt, argv);
// va_end(argv);
// return retval;
//}
#endif
int bd_sprintf(std::string &str, const char *fmt, ...)
{
char *buffer;
va_list ap;
va_start(ap, fmt);
int retval = vasprintf(&buffer, fmt, ap);
va_end(ap);
str = buffer;
free(buffer);
return retval;
}
int bd_sprintf_append(std::string &str, const char *fmt, ...)
{
va_list ap;
char *ret;
va_start(ap, fmt);
int retval = vasprintf(&ret, fmt, ap);
va_end(ap);
str.append(ret);
free(ret);
return retval;
}

View File

@ -22,6 +22,8 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <string>
#ifdef WIN32 #ifdef WIN32
// for proper handling of %ll // for proper handling of %ll
#define bd_snprintf __mingw_snprintf #define bd_snprintf __mingw_snprintf
@ -31,5 +33,7 @@
#define bd_fprintf fprintf #define bd_fprintf fprintf
#endif #endif
int bd_sprintf(std::string &str, const char *fmt, ...);
int bd_sprintf_append(std::string &str, const char *fmt, ...);
#endif #endif

View File

@ -269,10 +269,7 @@ void p3BitDht::getRelayRates(float &read, float &write, float &relay)
void convertBdPeerToRsDhtPeer(RsDhtPeer &peer, const bdPeer &int_peer) void convertBdPeerToRsDhtPeer(RsDhtPeer &peer, const bdPeer &int_peer)
{ {
std::ostringstream out; bdStdPrintNodeId(peer.mDhtId, &(int_peer.mPeerId.id), false);
bdStdPrintNodeId(out, &(int_peer.mPeerId.id));
peer.mDhtId = out.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)); rs_sprintf(peer.mAddr, "%s:%u", rs_inet_ntoa(int_peer.mPeerId.addr.sin_addr).c_str(), ntohs(int_peer.mPeerId.addr.sin_port));
@ -287,10 +284,8 @@ void convertBdPeerToRsDhtPeer(RsDhtPeer &peer, const bdPeer &int_peer)
void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDetails &details) void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDetails &details)
{ {
std::ostringstream out; bdStdPrintId(status.mDhtId, &(details.mDhtId), false);
bdStdPrintId(out, &(details.mDhtId));
status.mDhtId = out.str();
status.mRsId = details.mRsId; status.mRsId = details.mRsId;
status.mPeerType = details.mPeerType; status.mPeerType = details.mPeerType;
@ -320,9 +315,7 @@ void convertDhtPeerDetailsToRsDhtNetPeer(RsDhtNetPeer &status, const DhtPeerDeta
} }
//status.mPeerConnectProxyId = details.mPeerConnectProxyId; //status.mPeerConnectProxyId = details.mPeerConnectProxyId;
std::ostringstream out2; bdStdPrintId(status.mPeerConnectProxyId, &(details.mPeerConnectProxyId), false);
bdStdPrintId(out2, &(details.mPeerConnectProxyId));
status.mPeerConnectProxyId = out2.str();
status.mCbPeerMsg = details.mPeerCbMsg; status.mCbPeerMsg = details.mPeerCbMsg;

View File

@ -167,9 +167,8 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
int p3BitDht::PeerCallback(const bdId *id, uint32_t status) int p3BitDht::PeerCallback(const bdId *id, uint32_t status)
{ {
//std::ostringstream str; //std::string str;
//bdStdPrintNodeId(str, &(id->id)); //bdStdPrintNodeId(str, &(id->id));
//std::string strId = str.str();
//std::cerr << "p3BitDht::dhtPeerCallback()"; //std::cerr << "p3BitDht::dhtPeerCallback()";
//std::cerr << std::endl; //std::cerr << std::endl;
@ -628,9 +627,8 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
/* if we get here, we are an endpoint (peer specified in peerId) */ /* if we get here, we are an endpoint (peer specified in peerId) */
/* translate id into string for exclusive mode */ /* translate id into string for exclusive mode */
std::ostringstream idstr; std::string pid;
bdStdPrintNodeId(idstr, &(peerId.id)); bdStdPrintNodeId(pid, &(peerId.id), false);
std::string pid = idstr.str();
switch(cbtype) switch(cbtype)
{ {
@ -1173,9 +1171,8 @@ int p3BitDht::doActions()
bool grabbedExclusivePort = false; bool grabbedExclusivePort = false;
/* translate id into string for exclusive mode */ /* translate id into string for exclusive mode */
std::ostringstream idstr; std::string pid;
bdStdPrintNodeId(idstr, &(action.mDestId.id)); bdStdPrintNodeId(pid, &(action.mDestId.id), false);
std::string pid = idstr.str();
// Parameters that will be used for the Connect Request. // Parameters that will be used for the Connect Request.
@ -2004,13 +2001,11 @@ int p3BitDht::installRelayConnection(const bdId *srcId, const bdId *destId, uint
int relayClass = UDP_RELAY_CLASS_GENERAL; int relayClass = UDP_RELAY_CLASS_GENERAL;
#ifdef DEBUG_PEERNET #ifdef DEBUG_PEERNET
std::ostringstream str; std::string strId1;
bdStdPrintNodeId(str, &(srcId->id)); bdStdPrintNodeId(strId1, &(srcId->id), false);
std::string strId1 = str.str();
str.clear(); std::string strId2;
bdStdPrintNodeId(str, &(destId->id)); bdStdPrintNodeId(strId2, &(destId->id), false);
std::string strId2 = str.str();
#endif #endif
/* grab a socket */ /* grab a socket */
@ -2334,9 +2329,8 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
std::cerr << std::endl; std::cerr << std::endl;
/* translate id into string for exclusive mode */ /* translate id into string for exclusive mode */
std::ostringstream idstr; std::string pid;
bdStdPrintNodeId(idstr, &(dpd->mDhtId.id)); bdStdPrintNodeId(pid, &(dpd->mDhtId.id), false);
std::string pid = idstr.str();
if (dpd->mExclusiveProxyLock) if (dpd->mExclusiveProxyLock)

View File

@ -207,7 +207,7 @@ bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest)
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
// asprintf() and vasprintf() are missing in Win32 // asprintf() and vasprintf() are missing in Win32
int vasprintf(char **sptr, const char *fmt, va_list argv) static int vasprintf(char **sptr, const char *fmt, va_list argv)
{ {
int wanted = __mingw_vsnprintf(*sptr = NULL, 0, fmt, argv); int wanted = __mingw_vsnprintf(*sptr = NULL, 0, fmt, argv);
if ((wanted > 0) && ((*sptr = (char*) malloc(wanted + 1)) != NULL)) { if ((wanted > 0) && ((*sptr = (char*) malloc(wanted + 1)) != NULL)) {
@ -217,7 +217,7 @@ int vasprintf(char **sptr, const char *fmt, va_list argv)
return wanted; return wanted;
} }
//int asprintf(char **sptr, const char *fmt, ...) //static int asprintf(char **sptr, const char *fmt, ...)
//{ //{
// int retval; // int retval;
// va_list argv; // va_list argv;