33 void setenv(
const char *name,
const char *value,
int overwrite)
35 if (overwrite || NULL == getenv(name)) {
36 char *
str =
SCMalloc(strlen(name) + strlen(value) + 2);
39 snprintf(
str, strlen(name) + strlen(value) + 1,
"%s=%s", name, value);
50 snprintf(
str, strlen(name) + 1,
"%s=", name);
56 #if NTDDI_VERSION < NTDDI_VISTA
57 const char* inet_ntop(
int af,
const void *
src,
char *
dst, uint32_t
cnt)
61 struct sockaddr_in in;
62 memset(&in, 0,
sizeof(in));
63 in.sin_family = AF_INET;
64 memcpy(&in.sin_addr,
src,
sizeof(
struct in_addr));
65 if (0 == getnameinfo((
struct sockaddr *)&in,
sizeof(
struct sockaddr_in),
dst,
cnt, NULL, 0, NI_NUMERICHOST))
68 else if (
af == AF_INET6)
70 struct sockaddr_in6 in6;
71 memset(&in6, 0,
sizeof(in6));
72 in6.sin6_family = AF_INET6;
73 memcpy(&in6.sin6_addr,
src,
sizeof(
struct in_addr6));
74 if (0 == getnameinfo((
struct sockaddr *)&in6,
sizeof(
struct sockaddr_in6),
dst,
cnt, NULL, 0, NI_NUMERICHOST))
80 int inet_pton(
int af,
const char *
src,
void *
dst)
82 struct addrinfo hints;
83 memset(&hints, 0,
sizeof(
struct addrinfo));
92 }
else if (
af == AF_INET6) {
97 struct addrinfo* result = NULL;
98 if (0 != getaddrinfo(
src, NULL, &hints, &result))
102 if (result->ai_family == AF_INET) {
103 struct sockaddr_in* in = (
struct sockaddr_in*)result->ai_addr;
104 memcpy(
dst, &in->sin_addr, 4);
106 else if (result->ai_family == AF_INET6) {
107 struct sockaddr_in6* in6 = (
struct sockaddr_in6*)result->ai_addr;
108 memcpy(
dst, &in6->sin6_addr, 16);
111 freeaddrinfo(result);
115 freeaddrinfo(result);