mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Removed some std::ostringstream.
To be continued. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5105 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
470951d664
commit
33f4d4f2b8
@ -34,7 +34,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream> // for std::istringstream
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@ -915,10 +915,10 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
|||||||
// rather send a completion ratio based on the size of files vs/ total size.
|
// rather send a completion ratio based on the size of files vs/ total size.
|
||||||
//
|
//
|
||||||
FileEntry fe(to_hash[i].fentries[j]) ; // copied, because hashFile updates the hash member
|
FileEntry fe(to_hash[i].fentries[j]) ; // copied, because hashFile updates the hash member
|
||||||
std::ostringstream tmpout;
|
std::string tmpout;
|
||||||
tmpout << cnt+1 << "/" << n_files << " (" << friendlyUnit(size) << " - " << int(size/double(total_size)*100.0) << "%) : " << fe.name ;
|
rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", cnt+1, n_files, friendlyUnit(size).c_str(), int(size/double(total_size)*100.0), fe.name.c_str()) ;
|
||||||
|
|
||||||
cb->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout.str()) ;
|
cb->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout) ;
|
||||||
|
|
||||||
std::string real_path = RsDirUtil::makePath(to_hash[i].realpath, fe.name);
|
std::string real_path = RsDirUtil::makePath(to_hash[i].realpath, fe.name);
|
||||||
|
|
||||||
@ -991,14 +991,12 @@ void FileIndexMonitor::locked_saveFileIndexes()
|
|||||||
// Two files are saved: one with only browsable dirs, which will be shared by the cache system,
|
// Two files are saved: one with only browsable dirs, which will be shared by the cache system,
|
||||||
// and one with the complete file collection.
|
// and one with the complete file collection.
|
||||||
//
|
//
|
||||||
std::ostringstream out;
|
std::string tmpname_browsable;
|
||||||
out << "fc-own-" << time(NULL) << ".rsfb";
|
rs_sprintf(tmpname_browsable, "fc-own-%ld.rsfb", time(NULL));
|
||||||
std::string tmpname_browsable = out.str();
|
|
||||||
std::string fname_browsable = path + "/" + tmpname_browsable;
|
std::string fname_browsable = path + "/" + tmpname_browsable;
|
||||||
|
|
||||||
std::ostringstream out2;
|
std::string tmpname_total;
|
||||||
out2 << "fc-own-" << time(NULL) << ".rsfc";
|
rs_sprintf(tmpname_total, "fc-own-%ld.rsfc", time(NULL));
|
||||||
std::string tmpname_total = out2.str();
|
|
||||||
std::string fname_total = path + "/" + tmpname_total;
|
std::string fname_total = path + "/" + tmpname_total;
|
||||||
|
|
||||||
#ifdef FIM_DEBUG
|
#ifdef FIM_DEBUG
|
||||||
@ -1232,9 +1230,7 @@ bool FileIndexMonitor::internal_setSharedDirectories()
|
|||||||
std::string tst_dir = top_dir;
|
std::string tst_dir = top_dir;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
rs_sprintf_append(tst_dir, "-%d", i);
|
||||||
out << "-" << i;
|
|
||||||
tst_dir += out.str();
|
|
||||||
}
|
}
|
||||||
if (directoryMap.end()== (cit=directoryMap.find(tst_dir)))
|
if (directoryMap.end()== (cit=directoryMap.find(tst_dir)))
|
||||||
{
|
{
|
||||||
|
@ -25,12 +25,13 @@
|
|||||||
#include "dbase/findex.h"
|
#include "dbase/findex.h"
|
||||||
#include "retroshare/rsexpr.h"
|
#include "retroshare/rsexpr.h"
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
#include "util/rsstring.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream> // for std::stringstream
|
||||||
#include <tr1/unordered_set>
|
#include <tr1/unordered_set>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -476,34 +477,27 @@ FileEntry *DirEntry::updateFile(const FileEntry& fe, time_t utime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FileEntry::print(std::ostream &out)
|
int FileEntry::print(std::string &out)
|
||||||
{
|
{
|
||||||
/* print this dir, then subdirs, then files */
|
/* print this dir, then subdirs, then files */
|
||||||
|
|
||||||
out << "file ";
|
rs_sprintf_append(out, "file %03d [%ld/%ld] : ", row, updtime, modtime);
|
||||||
out << std::setw(3) << std::setfill('0') << row;
|
|
||||||
out << " [" << updtime << "/" << modtime << "] : ";
|
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
out << parent->path;
|
out += parent->path;
|
||||||
else
|
else
|
||||||
out << "[MISSING PARENT]";
|
out += "[MISSING PARENT]";
|
||||||
|
|
||||||
|
rs_sprintf_append(out, " %s [ s: %lld ] ==> [ %s ]\n", name.c_str(), size, hash.c_str());
|
||||||
|
|
||||||
out << " " << name;
|
|
||||||
out << " [ s: " << size << " ] ==> ";
|
|
||||||
out << " [ " << hash << " ]";
|
|
||||||
out << std::endl;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DirEntry::print(std::ostream &out)
|
int DirEntry::print(std::string &out)
|
||||||
{
|
{
|
||||||
/* print this dir, then subdirs, then files */
|
/* print this dir, then subdirs, then files */
|
||||||
out << "dir ";
|
rs_sprintf_append(out, "dir %03d [%ld] : %s\n", row, updtime, path.c_str());
|
||||||
out << std::setw(3) << std::setfill('0') << row;
|
|
||||||
out << " [" << updtime << "] : " << path;
|
|
||||||
out << std::endl;
|
|
||||||
|
|
||||||
std::map<std::string, DirEntry *>::iterator it;
|
std::map<std::string, DirEntry *>::iterator it;
|
||||||
for(it = subdirs.begin(); it != subdirs.end(); it++)
|
for(it = subdirs.begin(); it != subdirs.end(); it++)
|
||||||
@ -710,9 +704,9 @@ int FileIndex::cleanOldEntries(time_t old) /* removes entries older than old */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int FileIndex::printFileIndex(std::ostream &out)
|
int FileIndex::printFileIndex(std::string &out)
|
||||||
{
|
{
|
||||||
out << "FileIndex::printFileIndex()" << std::endl;
|
out += "FileIndex::printFileIndex()\n";
|
||||||
root->print(out);
|
root->print(out);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -747,13 +741,13 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
|||||||
SHA1_Final(&sha_buf[0], sha_ctx);
|
SHA1_Final(&sha_buf[0], sha_ctx);
|
||||||
delete sha_ctx;
|
delete sha_ctx;
|
||||||
|
|
||||||
std::ostringstream tmpout;
|
std::string tmpout;
|
||||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||||
{
|
{
|
||||||
tmpout << std::setw(2) << std::setfill('0') << std::hex << (unsigned int) (sha_buf[i]);
|
rs_sprintf_append(tmpout, "%02x", (unsigned int) (sha_buf[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expectedHash != "" && expectedHash != tmpout.str())
|
if (expectedHash != "" && expectedHash != tmpout)
|
||||||
{
|
{
|
||||||
#ifdef FI_DEBUG
|
#ifdef FI_DEBUG
|
||||||
std::cerr << "FileIndex::loadIndex expected hash does not match" << std::endl;
|
std::cerr << "FileIndex::loadIndex expected hash does not match" << std::endl;
|
||||||
@ -923,19 +917,19 @@ int FileIndex::saveIndex(const std::string& filename, std::string &fileHash, uin
|
|||||||
{
|
{
|
||||||
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||||
std::string filenametmp = filename + ".tmp" ;
|
std::string filenametmp = filename + ".tmp" ;
|
||||||
std::ostringstream oss;
|
std::string s;
|
||||||
|
|
||||||
size = 0 ;
|
size = 0 ;
|
||||||
fileHash = "" ;
|
fileHash = "" ;
|
||||||
|
|
||||||
/* print version and header */
|
/* print version and header */
|
||||||
oss << "# FileIndex version 0.1" << std::endl;
|
s += "# FileIndex version 0.1\n";
|
||||||
oss << "# Dir: d name, path, parent, size, modtime, pop, updtime;" << std::endl;
|
s += "# Dir: d name, path, parent, size, modtime, pop, updtime;\n";
|
||||||
oss << "# File: f name, hash, size, modtime, pop, updtime;" << std::endl;
|
s += "# File: f name, hash, size, modtime, pop, updtime;\n";
|
||||||
oss << "#" << std::endl;
|
s += "#\n";
|
||||||
|
|
||||||
/* begin recusion */
|
/* begin recusion */
|
||||||
root->writeDirInfo(oss) ;
|
root->writeDirInfo(s) ;
|
||||||
|
|
||||||
std::map<std::string, DirEntry *>::iterator it;
|
std::map<std::string, DirEntry *>::iterator it;
|
||||||
for(it = root->subdirs.begin(); it != root->subdirs.end(); it++)
|
for(it = root->subdirs.begin(); it != root->subdirs.end(); it++)
|
||||||
@ -954,28 +948,26 @@ int FileIndex::saveIndex(const std::string& filename, std::string &fileHash, uin
|
|||||||
#ifdef FI_DEBUG
|
#ifdef FI_DEBUG
|
||||||
std::cerr << " will be saved." << std::endl ;
|
std::cerr << " will be saved." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
(it->second)->saveEntry(oss);
|
(it->second)->saveEntry(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root->writeFileInfo(oss) ; // this should never do anything
|
root->writeFileInfo(s) ; // this should never do anything
|
||||||
|
|
||||||
/* signal to pop directory from stack in loadIndex() */
|
/* signal to pop directory from stack in loadIndex() */
|
||||||
oss << "-" << std::endl;
|
s += "-\n";
|
||||||
|
|
||||||
/* calculate sha1 hash */
|
/* calculate sha1 hash */
|
||||||
SHA_CTX *sha_ctx = new SHA_CTX;
|
SHA_CTX *sha_ctx = new SHA_CTX;
|
||||||
SHA1_Init(sha_ctx);
|
SHA1_Init(sha_ctx);
|
||||||
SHA1_Update(sha_ctx, oss.str().c_str(), oss.str().length());
|
SHA1_Update(sha_ctx, s.c_str(), s.length());
|
||||||
SHA1_Final(&sha_buf[0], sha_ctx);
|
SHA1_Final(&sha_buf[0], sha_ctx);
|
||||||
delete sha_ctx;
|
delete sha_ctx;
|
||||||
|
|
||||||
std::ostringstream tmpout;
|
|
||||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||||
{
|
{
|
||||||
tmpout << std::setw(2) << std::setfill('0') << std::hex << (unsigned int) (sha_buf[i]);
|
rs_sprintf_append(fileHash, "%02x", (unsigned int) (sha_buf[i]));
|
||||||
}
|
}
|
||||||
fileHash = tmpout.str();
|
|
||||||
|
|
||||||
/* finally, save to file */
|
/* finally, save to file */
|
||||||
|
|
||||||
@ -985,7 +977,7 @@ int FileIndex::saveIndex(const std::string& filename, std::string &fileHash, uin
|
|||||||
std::cerr << "FileIndex::saveIndex error opening file for writting: " << filename << ". Giving up." << std::endl;
|
std::cerr << "FileIndex::saveIndex error opening file for writting: " << filename << ". Giving up." << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fprintf(file,"%s",oss.str().c_str()) ;
|
fprintf(file,"%s",s.c_str()) ;
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -1023,49 +1015,49 @@ std::string FixName(const std::string& _in)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirEntry::writeDirInfo(std::ostringstream& oss)
|
void DirEntry::writeDirInfo(std::string& s)
|
||||||
{
|
{
|
||||||
/* print node info */
|
/* print node info */
|
||||||
oss << "d";
|
rs_sprintf_append(s, "d%s%c%s%c%lld%c%ld%c%d%c%ld%c\n",
|
||||||
oss << FixName(name) << FILE_CACHE_SEPARATOR_CHAR ;
|
FixName(name).c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << FixName(path) << FILE_CACHE_SEPARATOR_CHAR ;
|
FixName(path).c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << size << FILE_CACHE_SEPARATOR_CHAR ;
|
size, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << modtime << FILE_CACHE_SEPARATOR_CHAR ;
|
modtime, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << pop << FILE_CACHE_SEPARATOR_CHAR ;
|
pop, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << updtime << FILE_CACHE_SEPARATOR_CHAR << std::endl;
|
updtime, FILE_CACHE_SEPARATOR_CHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirEntry::writeFileInfo(std::ostringstream& oss)
|
void DirEntry::writeFileInfo(std::string& s)
|
||||||
{
|
{
|
||||||
/* print file info */
|
/* print file info */
|
||||||
std::map<std::string, FileEntry *>::iterator fit;
|
std::map<std::string, FileEntry *>::iterator fit;
|
||||||
for(fit = files.begin(); fit != files.end(); fit++)
|
for(fit = files.begin(); fit != files.end(); fit++)
|
||||||
{
|
{
|
||||||
oss << "f";
|
rs_sprintf_append(s, "f%s%c%s%c%lld%c%ld%c%d%c%ld%c\n",
|
||||||
oss << FixName((fit->second)->name) << FILE_CACHE_SEPARATOR_CHAR ;
|
FixName((fit->second)->name).c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << (fit->second)->hash << FILE_CACHE_SEPARATOR_CHAR ;
|
(fit->second)->hash.c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << (fit->second)->size << FILE_CACHE_SEPARATOR_CHAR ;
|
(fit->second)->size, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << (fit->second)->modtime << FILE_CACHE_SEPARATOR_CHAR ;
|
(fit->second)->modtime, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << (fit->second)->pop << FILE_CACHE_SEPARATOR_CHAR ;
|
(fit->second)->pop, FILE_CACHE_SEPARATOR_CHAR,
|
||||||
oss << (fit->second)->updtime << FILE_CACHE_SEPARATOR_CHAR << std::endl;
|
(fit->second)->updtime, FILE_CACHE_SEPARATOR_CHAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recusive function for traversing the dir tree in preorder */
|
/* recusive function for traversing the dir tree in preorder */
|
||||||
int DirEntry::saveEntry(std::ostringstream &oss)
|
int DirEntry::saveEntry(std::string &s)
|
||||||
{
|
{
|
||||||
writeDirInfo(oss) ;
|
writeDirInfo(s) ;
|
||||||
|
|
||||||
std::map<std::string, DirEntry *>::iterator it;
|
std::map<std::string, DirEntry *>::iterator it;
|
||||||
for(it = subdirs.begin(); it != subdirs.end(); it++)
|
for(it = subdirs.begin(); it != subdirs.end(); it++)
|
||||||
{
|
{
|
||||||
(it->second)->saveEntry(oss);
|
(it->second)->saveEntry(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileInfo(oss) ;
|
writeFileInfo(s) ;
|
||||||
|
|
||||||
/* signal to pop directory from stack in loadIndex() */
|
/* signal to pop directory from stack in loadIndex() */
|
||||||
oss << "-" << std::endl;
|
s += "-\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "retroshare/rstypes.h"
|
#include "retroshare/rstypes.h"
|
||||||
|
|
||||||
class ostream;
|
|
||||||
|
|
||||||
/******************************************************************************************
|
/******************************************************************************************
|
||||||
* The Key Data Types for the File Index:
|
* The Key Data Types for the File Index:
|
||||||
|
|
||||||
@ -89,7 +87,7 @@ class FileEntry: public RsMemoryManagement::SmallObject
|
|||||||
virtual ~FileEntry() { return; }
|
virtual ~FileEntry() { return; }
|
||||||
virtual uint32_t type() const { return DIR_TYPE_FILE ; }
|
virtual uint32_t type() const { return DIR_TYPE_FILE ; }
|
||||||
|
|
||||||
virtual int print(std::ostream &out);
|
virtual int print(std::string &out);
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
std::string name;
|
std::string name;
|
||||||
@ -142,11 +140,11 @@ DirEntry * findDirectory(const std::string& path);
|
|||||||
int updateDirectories(const std::string& path, int pop, int modtime);
|
int updateDirectories(const std::string& path, int pop, int modtime);
|
||||||
|
|
||||||
/* output */
|
/* output */
|
||||||
int print(std::ostream &out);
|
int print(std::string &out);
|
||||||
|
|
||||||
int saveEntry(std::ostringstream &out);
|
int saveEntry(std::string &out);
|
||||||
void writeDirInfo(std::ostringstream&);
|
void writeDirInfo(std::string&);
|
||||||
void writeFileInfo(std::ostringstream&);
|
void writeFileInfo(std::string&);
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
std::string path; /* full path (includes name) */
|
std::string path; /* full path (includes name) */
|
||||||
@ -227,7 +225,7 @@ class FileIndex
|
|||||||
int cleanOldEntries(time_t old); /* removes entries older than old */
|
int cleanOldEntries(time_t old); /* removes entries older than old */
|
||||||
|
|
||||||
/* debug */
|
/* debug */
|
||||||
int printFileIndex(std::ostream &out);
|
int printFileIndex(std::string &out);
|
||||||
|
|
||||||
/* load/save to file */
|
/* load/save to file */
|
||||||
int loadIndex(const std::string& filename, const std::string& expectedHash, uint64_t size);
|
int loadIndex(const std::string& filename, const std::string& expectedHash, uint64_t size);
|
||||||
|
@ -218,7 +218,6 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string path = CacheSource::getCacheDir();
|
std::string path = CacheSource::getCacheDir();
|
||||||
std::ostringstream out;
|
|
||||||
uint16_t subid;
|
uint16_t subid;
|
||||||
|
|
||||||
|
|
||||||
@ -226,21 +225,21 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
* publishing own or friends...
|
* publishing own or friends...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* determine filename */
|
||||||
|
std::string tmpname;
|
||||||
if (own)
|
if (own)
|
||||||
{
|
{
|
||||||
/* setup to publish own messages */
|
/* setup to publish own messages */
|
||||||
out << "rank-links-" << time(NULL) << ".rsrl";
|
rs_sprintf(tmpname, "rank-links-%ld.rsrl", time(NULL));
|
||||||
subid = 1;
|
subid = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* setup to publish friend messages */
|
/* setup to publish friend messages */
|
||||||
out << "rank-friend-links-" << time(NULL) << ".rsrl";
|
rs_sprintf(tmpname, "rank-friend-links-%ld.rsrl", time(NULL));
|
||||||
subid = 2;
|
subid = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine filename */
|
|
||||||
std::string tmpname = out.str();
|
|
||||||
std::string fname = path + "/" + tmpname;
|
std::string fname = path + "/" + tmpname;
|
||||||
|
|
||||||
#ifdef RANK_DEBUG
|
#ifdef RANK_DEBUG
|
||||||
@ -1100,29 +1099,26 @@ pqistore *createStore(std::string file, std::string src, bool reading)
|
|||||||
|
|
||||||
std::string generateRandomLinkId()
|
std::string generateRandomLinkId()
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::string out;
|
||||||
out << std::hex;
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
out << std::setw(8) << std::setfill('0');
|
|
||||||
uint32_t rint = random();
|
uint32_t rint = random();
|
||||||
out << rint;
|
rs_sprintf_append(out, "%08x", rint);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||||
for(int i = 0; i < 8; i++)
|
for(int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
out << std::setw(4) << std::setfill('0');
|
|
||||||
uint16_t rint = rand(); /* only gives 16 bits */
|
uint16_t rint = rand(); /* only gives 16 bits */
|
||||||
out << rint;
|
rs_sprintf_append(out, "%04x", rint);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
return out.str();
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <serialiser/rsserial.h>
|
#include <serialiser/rsserial.h>
|
||||||
#include <serialiser/rsconfigitems.h>
|
#include <serialiser/rsconfigitems.h>
|
||||||
|
|
||||||
|
#include <sstream> // for std::istringstream
|
||||||
|
|
||||||
#include "services/p3vors.h"
|
#include "services/p3vors.h"
|
||||||
#include "services/rsvoipitems.h"
|
#include "services/rsvoipitems.h"
|
||||||
@ -643,9 +644,7 @@ RsTlvKeyValue p3VoRS::push_int_value(const std::string& key,int value)
|
|||||||
{
|
{
|
||||||
RsTlvKeyValue kv ;
|
RsTlvKeyValue kv ;
|
||||||
kv.key = key ;
|
kv.key = key ;
|
||||||
std::ostringstream s ;
|
rs_sprintf(kv.value, "%d", value);
|
||||||
s << value;
|
|
||||||
kv.value = s.str() ;
|
|
||||||
|
|
||||||
return kv ;
|
return kv ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user