Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
b1dbfa84
Commit
b1dbfa84
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Move getaddrinfo() stuff into sockwrap.h
Fix inet_addrtop() for Win32.
parent
e9f87f95
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/xpdev/multisock.c
+1
-14
1 addition, 14 deletions
src/xpdev/multisock.c
src/xpdev/sockwrap.c
+8
-2
8 additions, 2 deletions
src/xpdev/sockwrap.c
src/xpdev/sockwrap.h
+11
-3
11 additions, 3 deletions
src/xpdev/sockwrap.h
with
20 additions
and
19 deletions
src/xpdev/multisock.c
+
1
−
14
View file @
b1dbfa84
...
...
@@ -7,17 +7,6 @@
#include
<sockwrap.h>
#include
<multisock.h>
#ifdef _WIN32
#undef socklen_t
#include
<ws2tcpip.h>
# ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0x400 // Vista or later
# endif
# ifndef AI_NUMERICSERV
# define AI_NUMERICSERV 0 // Not supported by Win32
# endif
#endif
struct
xpms_set
*
xpms_create
(
unsigned
int
retries
,
unsigned
int
wait_secs
,
int
(
*
lprintf
)(
int
level
,
const
char
*
fmt
,
...))
{
...
...
@@ -70,10 +59,8 @@ BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type,
hints
.
ai_family
=
domain
;
hints
.
ai_socktype
=
type
;
hints
.
ai_protocol
=
protocol
;
hints
.
ai_flags
=
AI_NUMERICSERV
;
#ifdef AI_ADDRCONFIG
hints
.
ai_flags
|=
AI_NUMERICSERV
;
hints
.
ai_flags
|=
AI_ADDRCONFIG
;
#endif
sprintf
(
port_str
,
"%hu"
,
port
);
if
((
ret
=
getaddrinfo
(
addr
,
port_str
,
&
hints
,
&
res
))
!=
0
)
{
if
(
xpms_set
->
lprintf
)
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/sockwrap.c
+
8
−
2
View file @
b1dbfa84
...
...
@@ -42,8 +42,6 @@
#include
<stdio.h>
/* SEEK_SET */
#include
<string.h>
#if defined(_WIN32)
#undef socklen_t
#include
<ws2tcpip.h>
#include
<malloc.h>
/* alloca() on Win32 */
#endif
...
...
@@ -391,6 +389,13 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
const
char
*
inet_addrtop
(
SOCKADDR
*
in
,
char
*
dest
,
size_t
size
)
{
#ifdef _WIN32
DWORD
dsize
=
size
;
if
(
WSAAddressToString
(
in
,
SOCK_MAXADDRLEN
,
NULL
,
dest
,
&
dsize
)
==
SOCKET_ERROR
)
return
NULL
;
return
dest
;
#else
switch
(
in
->
sa_family
)
{
case
AF_INET
:
return
inet_ntop
(
in
->
sa_family
,
&
((
struct
sockaddr_in
*
)
in
)
->
sin_addr
,
dest
,
size
);
...
...
@@ -400,6 +405,7 @@ const char *inet_addrtop(SOCKADDR *in, char *dest, size_t size)
safe_snprintf
(
dest
,
size
,
"<unknown address>"
);
return
NULL
;
}
#endif
}
uint16_t
inet_addrport
(
SOCKADDR
*
in
)
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/sockwrap.h
+
11
−
3
View file @
b1dbfa84
...
...
@@ -48,8 +48,10 @@
#ifndef _WINSOCKAPI_
#include
<winsock2.h>
/* socket/bind/etc. */
#include
<mswsock.h>
/* Microsoft WinSock2 extensions */
#include
<ws2tcpip.h>
/* More stuff */
#define SOCK_MAXADDRLEN sizeof(SOCKADDR_STORAGE)
/* Let's agree on a standard WinSock symbol here, people */
#define _WINSOCKAPI_
#define _WINSOCKAPI_
#endif
#elif defined __unix__
/* Unix-variant */
...
...
@@ -150,12 +152,18 @@ typedef struct {
#define s_addr S_un.S_addr
#define socklen_t int
static
int
wsa_error
;
#define ERROR_VALUE ((wsa_error=WSAGetLastError())>0 ? wsa_error-WSABASEERR : wsa_error)
#define sendsocket(s,b,l) send(s,b,l,0)
/* For getaddrinfo() */
#ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0x400 // Vista or later
#endif
#ifndef AI_NUMERICSERV
# define AI_NUMERICSERV 0 // Not supported by Win32
#endif
#else
/* BSD sockets */
/* WinSock-isms */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment