mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Removed usages of "std::istringstream" and "std::stringstream".
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5135 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5b23a0e112
commit
3718d6ecfa
@ -34,7 +34,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream> // for std::istringstream
|
||||
#include <iomanip>
|
||||
|
||||
#include <dirent.h>
|
||||
@ -131,9 +130,8 @@ HashCache::HashCache(const std::string& path)
|
||||
|
||||
f.getline(buff,max_line_size,'\n') ; //if(sscanf(buff,"%llu",&info.size) != 1) break ;
|
||||
|
||||
std::istringstream ss(buff) ;
|
||||
info.size = 0 ;
|
||||
ss >> info.size ;
|
||||
sscanf(buff, UINT64FMT, &info.size);
|
||||
|
||||
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.time_stamp) != 1) break ;
|
||||
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.modf_stamp) != 1) break ;
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream> // for std::stringstream
|
||||
#include <tr1/unordered_set>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
@ -725,11 +724,11 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
||||
|
||||
/* load file into memory, close file */
|
||||
char ibuf[512];
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
while(!file.eof())
|
||||
{
|
||||
file.read(ibuf, 512);
|
||||
ss.write(ibuf, file.gcount());
|
||||
s.append(ibuf, file.gcount());
|
||||
}
|
||||
file.close();
|
||||
|
||||
@ -737,7 +736,7 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
||||
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||
SHA_CTX *sha_ctx = new SHA_CTX;
|
||||
SHA1_Init(sha_ctx);
|
||||
SHA1_Update(sha_ctx, ss.str().c_str(), ss.str().length());
|
||||
SHA1_Update(sha_ctx, s.c_str(), s.length());
|
||||
SHA1_Final(&sha_buf[0], sha_ctx);
|
||||
delete sha_ctx;
|
||||
|
||||
@ -757,17 +756,24 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FIND_NEXT(s,start,end,c) end = s.find(c, start); if (end == std::string::npos) end = s.length();
|
||||
|
||||
DirEntry *ndir = NULL;
|
||||
FileEntry *nfile = NULL;
|
||||
std::list<DirEntry *> dirlist;
|
||||
std::string word;
|
||||
char ch;
|
||||
|
||||
while(ss.get(ch))
|
||||
std::string::size_type pos = 0;
|
||||
while (pos < s.length())
|
||||
{
|
||||
ch = s[pos];
|
||||
++pos;
|
||||
if (ch == '-')
|
||||
{
|
||||
ss.ignore(256, '\n');
|
||||
FIND_NEXT(s, pos, pos, '\n');
|
||||
++pos;
|
||||
|
||||
switch(dirlist.size())
|
||||
{
|
||||
/* parse error: out of directory */
|
||||
@ -820,25 +826,27 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
||||
// Ignore comments
|
||||
else if (ch == '#')
|
||||
{
|
||||
ss.ignore(256, '\n');
|
||||
FIND_NEXT(s, pos, pos, '\n');
|
||||
++pos;
|
||||
}
|
||||
|
||||
else {
|
||||
std::vector<std::string> tokens;
|
||||
/* parse line */
|
||||
while(1)
|
||||
std::string::size_type lineend;
|
||||
FIND_NEXT(s, pos, lineend, '\n');
|
||||
std::string line = s.substr(pos, lineend - pos);
|
||||
pos = lineend + 1;
|
||||
|
||||
std::string::size_type start = 0;
|
||||
while (start < line.length())
|
||||
{
|
||||
getline(ss, word, FILE_CACHE_SEPARATOR_CHAR);
|
||||
if (ss.eof())
|
||||
goto error;
|
||||
tokens.push_back(word);
|
||||
if (ss.peek() == '\n')
|
||||
{
|
||||
ss.ignore(256, '\n');
|
||||
break;
|
||||
}
|
||||
|
||||
std::string::size_type end;
|
||||
FIND_NEXT(line, start, end, FILE_CACHE_SEPARATOR_CHAR);
|
||||
tokens.push_back(line.substr(start, end - start));
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
/* create new file and add it to last directory*/
|
||||
if (ch == 'f')
|
||||
{
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h> /* for (u)sleep() */
|
||||
#include <sstream> // for std::istringstream
|
||||
|
||||
/******
|
||||
* #define CONTROL_DEBUG 1
|
||||
@ -2101,17 +2100,15 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
|
||||
|
||||
if (configMap.end() != (mit = configMap.find(active_downloads_size_ss)))
|
||||
{
|
||||
std::istringstream i(mit->second) ;
|
||||
int n=5 ;
|
||||
i >> n ;
|
||||
sscanf(mit->second.c_str(), "%d", &n);
|
||||
std::cerr << "Note: loading active max downloads: " << n << std::endl;
|
||||
setQueueSize(n);
|
||||
}
|
||||
if (configMap.end() != (mit = configMap.find(min_prioritized_downl_ss)))
|
||||
{
|
||||
std::istringstream i(mit->second) ;
|
||||
int n=3 ;
|
||||
i >> n ;
|
||||
sscanf(mit->second.c_str(), "%d", &n);
|
||||
std::cerr << "Note: loading min prioritized downloads: " << n << std::endl;
|
||||
setMinPrioritizedTransfers(n);
|
||||
}
|
||||
@ -2138,14 +2135,12 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
|
||||
|
||||
if (configMap.end() != (mit = configMap.find(free_space_limit_ss)))
|
||||
{
|
||||
std::istringstream in(mit->second) ;
|
||||
uint32_t size ;
|
||||
if (sscanf(mit->second.c_str(), "%u", &size) == 1) {
|
||||
std::cerr << "have read a size limit of " << size <<" MB" << std::endl ;
|
||||
|
||||
in >> size ;
|
||||
|
||||
std::cerr << "have read a size limit of " << size <<" MB" << std::endl ;
|
||||
|
||||
RsDiscSpace::setFreeSpaceLimit(size) ;
|
||||
RsDiscSpace::setFreeSpaceLimit(size) ;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream> // for std::istringstream
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
@ -1192,10 +1191,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
|
||||
if (parsePosition != std::string::npos) {
|
||||
std::string local_port = subCert.substr(0, parsePosition);
|
||||
std::cerr << "Local port : " << local_port << std::endl;
|
||||
std::istringstream instream(local_port);
|
||||
uint16_t local_port_int;
|
||||
instream >> local_port_int;
|
||||
pd.localPort = (local_port_int);
|
||||
sscanf(local_port.c_str(), "%hu", &pd.localPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1218,10 +1214,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
|
||||
if (parsePosition != std::string::npos) {
|
||||
std::string ext_port = subCert.substr(0, parsePosition);
|
||||
std::cerr << "Ext port : " << ext_port << std::endl;
|
||||
std::istringstream instream(ext_port);
|
||||
uint16_t ext_port_int;
|
||||
instream >> ext_port_int;
|
||||
pd.extPort = (ext_port_int);
|
||||
sscanf(ext_port.c_str(), "%hu", &pd.extPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1304,7 +1304,7 @@ bool p3disc::loadList(std::list<RsItem*>& load)
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++)
|
||||
{
|
||||
std::istringstream instream(kit->value);
|
||||
std::istringstream instream(kit->value); // please do not use std::istringstream
|
||||
time_t deleted_time_t;
|
||||
instream >> deleted_time_t;
|
||||
deletedSSLFriendsIds[kit->key] = deleted_time_t;
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include <errno.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <sstream> // for std::istringstream
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
@ -605,12 +604,11 @@ bool p3turtle::loadList(std::list<RsItem*>& load)
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Loaded config default nick name for chat: " << kit->value << std::endl ;
|
||||
#endif
|
||||
std::istringstream is(kit->value) ;
|
||||
|
||||
int val ;
|
||||
is >> val ;
|
||||
|
||||
setMaxTRForwardRate(val) ;
|
||||
if (sscanf(kit->value.c_str(), "%d", &val) == 1)
|
||||
{
|
||||
setMaxTRForwardRate(val) ;
|
||||
}
|
||||
}
|
||||
|
||||
delete vitem ;
|
||||
|
@ -31,6 +31,14 @@ bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest);
|
||||
|
||||
} } // librs::util
|
||||
|
||||
#ifdef WIN32
|
||||
#define INT64FMT "%I64d"
|
||||
#define UINT64FMT "%I64u"
|
||||
#else
|
||||
#define INT64FMT "%lld"
|
||||
#define UINT64FMT "%llu"
|
||||
#endif
|
||||
|
||||
int rs_sprintf(std::string &str, const char *fmt, ...);
|
||||
int rs_sprintf_append(std::string &str, const char *fmt, ...);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user