Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
60610e90
Commit
60610e90
authored
Apr 01, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/net/TestIPv[46]Address: fix Windows build errors
parent
90184e0c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
TestIPv4Address.cxx
test/net/TestIPv4Address.cxx
+11
-2
TestIPv6Address.cxx
test/net/TestIPv6Address.cxx
+11
-2
No files found.
test/net/TestIPv4Address.cxx
View file @
60610e90
/*
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -34,13 +34,22 @@
...
@@ -34,13 +34,22 @@
#include <stdexcept>
#include <stdexcept>
#ifndef _WIN32
#include <arpa/inet.h>
#include <arpa/inet.h>
#endif
static
std
::
string
static
std
::
string
ToString
(
const
struct
in_addr
&
a
)
ToString
(
const
struct
in_addr
&
a
)
{
{
#ifdef _WIN32
/* on mingw32, the parameter is non-const (PVOID) */
const
auto
p
=
const_cast
<
struct
in_addr
*>
(
&
a
);
#else
const
auto
p
=
&
a
;
#endif
char
buffer
[
256
];
char
buffer
[
256
];
const
char
*
result
=
inet_ntop
(
AF_INET
,
&
a
,
buffer
,
sizeof
(
buffer
));
const
char
*
result
=
inet_ntop
(
AF_INET
,
p
,
buffer
,
sizeof
(
buffer
));
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
throw
std
::
runtime_error
(
"inet_ntop() failed"
);
throw
std
::
runtime_error
(
"inet_ntop() failed"
);
return
result
;
return
result
;
...
...
test/net/TestIPv6Address.cxx
View file @
60610e90
/*
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -34,13 +34,22 @@
...
@@ -34,13 +34,22 @@
#include <stdexcept>
#include <stdexcept>
#ifndef _WIN32
#include <arpa/inet.h>
#include <arpa/inet.h>
#endif
static
std
::
string
static
std
::
string
ToString
(
const
struct
in6_addr
&
a
)
ToString
(
const
struct
in6_addr
&
a
)
{
{
#ifdef _WIN32
/* on mingw32, the parameter is non-const (PVOID) */
const
auto
p
=
const_cast
<
struct
in6_addr
*>
(
&
a
);
#else
const
auto
p
=
&
a
;
#endif
char
buffer
[
256
];
char
buffer
[
256
];
const
char
*
result
=
inet_ntop
(
AF_INET6
,
&
a
,
buffer
,
sizeof
(
buffer
));
const
char
*
result
=
inet_ntop
(
AF_INET6
,
p
,
buffer
,
sizeof
(
buffer
));
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
throw
std
::
runtime_error
(
"inet_ntop() failed"
);
throw
std
::
runtime_error
(
"inet_ntop() failed"
);
return
result
;
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment