Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
bdc11830
Commit
bdc11830
authored
Jan 18, 2016
by
Zachary Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port inet_ntop and inet_pton for WIN32
Without these functions, compilation fails on MinGW
parent
62599542
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
src/socket.c
src/socket.c
+53
-0
No files found.
src/socket.c
View file @
bdc11830
...
...
@@ -41,6 +41,59 @@
#define mrb_cptr_p(o) mrb_voidp_p(o)
#endif
#ifdef _WIN32
const
char
*
inet_ntop
(
int
af
,
const
void
*
src
,
char
*
dst
,
socklen_t
cnt
)
{
if
(
af
==
AF_INET
)
{
struct
sockaddr_in
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin_family
=
AF_INET
;
memcpy
(
&
in
.
sin_addr
,
src
,
sizeof
(
struct
in_addr
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
else
if
(
af
==
AF_INET6
)
{
struct
sockaddr_in6
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin6_family
=
AF_INET6
;
memcpy
(
&
in
.
sin6_addr
,
src
,
sizeof
(
struct
in_addr6
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in6
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
return
NULL
;
}
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
struct
addrinfo
hints
,
*
res
,
*
ressave
;
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
af
;
if
(
getaddrinfo
(
src
,
NULL
,
&
hints
,
&
res
)
!=
0
)
{
printf
(
"Couldn't resolve host %s
\n
"
,
src
);
return
-
1
;
}
ressave
=
res
;
while
(
res
)
{
memcpy
(
dst
,
res
->
ai_addr
,
res
->
ai_addrlen
);
res
=
res
->
ai_next
;
}
freeaddrinfo
(
ressave
);
return
0
;
}
#endif
static
mrb_value
mrb_addrinfo_getaddrinfo
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
...
...
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