mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-14 17:39:37 -04:00
Added thread safe function for inet_ntoa in libbitdht.
Used the existing thread safe function for inet_ntoa in libretroshare. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5033 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
117d10eb44
commit
0b1126babf
10 changed files with 24 additions and 9 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "bdnet.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -356,4 +357,15 @@ void bdsockaddr_clear(struct sockaddr_in *addr)
|
|||
memset(addr, 0, sizeof(*addr));
|
||||
}
|
||||
|
||||
/* thread-safe version of inet_ntoa */
|
||||
|
||||
std::string bdnet_inet_ntoa(struct in_addr in)
|
||||
{
|
||||
std::ostringstream str;
|
||||
uint8_t *bytes = (uint8_t *) &(in.s_addr);
|
||||
str << (int) bytes[0] << ".";
|
||||
str << (int) bytes[1] << ".";
|
||||
str << (int) bytes[2] << ".";
|
||||
str << (int) bytes[3];
|
||||
return str.str();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
|
@ -104,6 +105,8 @@ int bdnet_inet_aton(const char *name, struct in_addr *addr);
|
|||
int bdnet_checkTTL(int fd);
|
||||
|
||||
void bdsockaddr_clear(struct sockaddr_in *addr);
|
||||
/* thread-safe version of inet_ntoa */
|
||||
std::string bdnet_inet_ntoa(struct in_addr in);
|
||||
|
||||
/* Extra stuff to declare for windows error handling (mimics unix errno)
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue