Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Synchronet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
127
Issues
127
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
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
Main
Synchronet
Commits
f97d9649
Commit
f97d9649
authored
Nov 20, 2020
by
Deucе
👌🏾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add inet_pton() for Win32.
Needed by MinGW32... we'll see if MSVC needs it as well soon.
parent
1cbe4b35
Pipeline
#726
failed with stage
in 5 minutes and 41 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
src/xpdev/sockwrap.c
src/xpdev/sockwrap.c
+36
-0
src/xpdev/sockwrap.h
src/xpdev/sockwrap.h
+4
-0
No files found.
src/xpdev/sockwrap.c
View file @
f97d9649
...
...
@@ -523,3 +523,39 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen)
return
safe_strerror
(
error_number
,
buf
,
buflen
);
#endif
}
#ifdef _WIN32
DLLEXPORT
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
struct
addrinfo
hints
=
{
0
};
struct
addrinfo
*
res
,
*
cur
;
if
(
af
!=
AF_INET
&&
af
!=
AF_INET6
)
{
// TODO: Should set socket_errno to EAFNOSUPPORT
return
-
1
;
}
hints
.
ai_flags
=
AI_NUMERICHOST
|
AI_PASSIVE
;
if
(
getaddrinfo
(
addr_str
,
NULL
,
&
hints
,
&
res
))
return
-
1
;
for
(
cur
=
res
;
cur
;
cur
++
)
{
if
(
cur
->
ai_addr
->
sa_family
==
af
)
break
;
}
if
(
!
cur
)
{
freeaddrinfo
(
res
);
return
0
;
}
switch
(
af
)
{
case
AF_INET
:
memcpy
(
dst
,
((
struct
sockaddr_in
*
)(
cur
->
sin_addr
)),
sizeof
((
struct
sockaddr_in
*
)
cur
->
sin_addr
));
break
;
case
AF_INET6
:
memcpy
(
dst
,
((
struct
sockaddr_in6
*
)(
cur
->
sin6_addr
)),
sizeof
((
struct
sockaddr_in6
*
)
cur
->
sin6_addr
));
break
;
}
freeaddrinfo
(
res
);
return
addr
;
}
#endif
src/xpdev/sockwrap.h
View file @
f97d9649
...
...
@@ -241,6 +241,10 @@ DLLEXPORT void inet_setaddrport(union xp_sockaddr *addr, uint16_t port);
DLLEXPORT
BOOL
inet_addrmatch
(
union
xp_sockaddr
*
addr1
,
union
xp_sockaddr
*
addr2
);
DLLEXPORT
char
*
socket_strerror
(
int
,
char
*
,
size_t
);
#ifdef _WIN32
DLLEXPORT
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
);
#endif
#ifdef __cplusplus
}
#endif
...
...
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