Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
wine
wine-winehq
Commits
cfdaa7fd
Commit
cfdaa7fd
authored
Apr 30, 2021
by
Zebediah Figura
Committed by
Alexandre Julliard
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Move service lookup functions to protocol.c.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5d9fe036
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
160 deletions
+121
-160
protocol.c
dlls/ws2_32/protocol.c
+121
-0
socket.c
dlls/ws2_32/socket.c
+0
-160
No files found.
dlls/ws2_32/protocol.c
View file @
cfdaa7fd
...
@@ -1532,3 +1532,124 @@ struct WS_protoent * WINAPI WS_getprotobynumber( int number )
...
@@ -1532,3 +1532,124 @@ struct WS_protoent * WINAPI WS_getprotobynumber( int number )
TRACE
(
"%d ret %p
\n
"
,
number
,
retval
);
TRACE
(
"%d ret %p
\n
"
,
number
,
retval
);
return
retval
;
return
retval
;
}
}
static
char
*
strdup_lower
(
const
char
*
str
)
{
char
*
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
int
i
;
if
(
ret
)
{
for
(
i
=
0
;
str
[
i
];
i
++
)
ret
[
i
]
=
tolower
(
str
[
i
]
);
ret
[
i
]
=
0
;
}
else
SetLastError
(
WSAENOBUFS
);
return
ret
;
}
static
struct
WS_servent
*
get_servent_buffer
(
int
size
)
{
struct
per_thread_data
*
data
=
get_per_thread_data
();
if
(
data
->
se_buffer
)
{
if
(
data
->
se_len
>=
size
)
return
data
->
se_buffer
;
HeapFree
(
GetProcessHeap
(),
0
,
data
->
se_buffer
);
}
data
->
se_len
=
size
;
data
->
se_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
data
->
se_buffer
)
SetLastError
(
WSAENOBUFS
);
return
data
->
se_buffer
;
}
static
struct
WS_servent
*
servent_from_unix
(
const
struct
servent
*
p_se
)
{
char
*
p
;
struct
WS_servent
*
p_to
;
int
size
=
(
sizeof
(
*
p_se
)
+
strlen
(
p_se
->
s_proto
)
+
1
+
strlen
(
p_se
->
s_name
)
+
1
+
list_size
(
p_se
->
s_aliases
,
0
));
if
(
!
(
p_to
=
get_servent_buffer
(
size
)))
return
NULL
;
p_to
->
s_port
=
p_se
->
s_port
;
p
=
(
char
*
)(
p_to
+
1
);
p_to
->
s_name
=
p
;
strcpy
(
p
,
p_se
->
s_name
);
p
+=
strlen
(
p
)
+
1
;
p_to
->
s_proto
=
p
;
strcpy
(
p
,
p_se
->
s_proto
);
p
+=
strlen
(
p
)
+
1
;
p_to
->
s_aliases
=
(
char
**
)
p
;
list_dup
(
p_se
->
s_aliases
,
p_to
->
s_aliases
,
0
);
return
p_to
;
}
/***********************************************************************
* getservbyname (ws2_32.55)
*/
struct
WS_servent
*
WINAPI
WS_getservbyname
(
const
char
*
name
,
const
char
*
proto
)
{
struct
WS_servent
*
retval
=
NULL
;
struct
servent
*
serv
;
char
*
name_str
;
char
*
proto_str
=
NULL
;
if
(
!
(
name_str
=
strdup_lower
(
name
)))
return
NULL
;
if
(
proto
&&
*
proto
)
{
if
(
!
(
proto_str
=
strdup_lower
(
proto
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
name_str
);
return
NULL
;
}
}
EnterCriticalSection
(
&
csWSgetXXXbyYYY
);
serv
=
getservbyname
(
name_str
,
proto_str
);
if
(
serv
)
retval
=
servent_from_unix
(
serv
);
else
SetLastError
(
WSANO_DATA
);
LeaveCriticalSection
(
&
csWSgetXXXbyYYY
);
HeapFree
(
GetProcessHeap
(),
0
,
proto_str
);
HeapFree
(
GetProcessHeap
(),
0
,
name_str
);
TRACE
(
"%s, %s ret %p
\n
"
,
debugstr_a
(
name
),
debugstr_a
(
proto
),
retval
);
return
retval
;
}
/***********************************************************************
* getservbyport (ws2_32.56)
*/
struct
WS_servent
*
WINAPI
WS_getservbyport
(
int
port
,
const
char
*
proto
)
{
struct
WS_servent
*
retval
=
NULL
;
#ifdef HAVE_GETSERVBYPORT
struct
servent
*
serv
;
char
*
proto_str
=
NULL
;
if
(
proto
&&
*
proto
)
{
if
(
!
(
proto_str
=
strdup_lower
(
proto
)))
return
NULL
;
}
EnterCriticalSection
(
&
csWSgetXXXbyYYY
);
if
((
serv
=
getservbyport
(
port
,
proto_str
)))
retval
=
servent_from_unix
(
serv
);
else
SetLastError
(
WSANO_DATA
);
LeaveCriticalSection
(
&
csWSgetXXXbyYYY
);
HeapFree
(
GetProcessHeap
(),
0
,
proto_str
);
#endif
TRACE
(
"%d (i.e. port %d), %s ret %p
\n
"
,
port
,
(
int
)
ntohl
(
port
),
debugstr_a
(
proto
),
retval
);
return
retval
;
}
dlls/ws2_32/socket.c
View file @
cfdaa7fd
...
@@ -225,7 +225,6 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
...
@@ -225,7 +225,6 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
lpCompletionRoutine
,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
lpCompletionRoutine
,
LPWSABUF
lpControlBuffer
);
LPWSABUF
lpControlBuffer
);
DECLARE_CRITICAL_SECTION
(
csWSgetXXXbyYYY
);
DECLARE_CRITICAL_SECTION
(
cs_if_addr_cache
);
DECLARE_CRITICAL_SECTION
(
cs_if_addr_cache
);
DECLARE_CRITICAL_SECTION
(
cs_socket_list
);
DECLARE_CRITICAL_SECTION
(
cs_socket_list
);
...
@@ -609,7 +608,6 @@ int num_startup;
...
@@ -609,7 +608,6 @@ int num_startup;
static
FARPROC
blocking_hook
=
(
FARPROC
)
WSA_DefaultBlockingHook
;
static
FARPROC
blocking_hook
=
(
FARPROC
)
WSA_DefaultBlockingHook
;
/* function prototypes */
/* function prototypes */
static
struct
WS_servent
*
WS_dup_se
(
const
struct
servent
*
p_se
);
static
int
ws_protocol_info
(
SOCKET
s
,
int
unicode
,
WSAPROTOCOL_INFOW
*
buffer
,
int
*
size
);
static
int
ws_protocol_info
(
SOCKET
s
,
int
unicode
,
WSAPROTOCOL_INFOW
*
buffer
,
int
*
size
);
int
WSAIOCTL_GetInterfaceCount
(
void
);
int
WSAIOCTL_GetInterfaceCount
(
void
);
...
@@ -1340,22 +1338,6 @@ static int convert_sockopt(INT *level, INT *optname)
...
@@ -1340,22 +1338,6 @@ static int convert_sockopt(INT *level, INT *optname)
return
0
;
return
0
;
}
}
/* ----------------------------------- Per-thread info (or per-process?) */
static
char
*
strdup_lower
(
const
char
*
str
)
{
int
i
;
char
*
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
if
(
ret
)
{
for
(
i
=
0
;
str
[
i
];
i
++
)
ret
[
i
]
=
tolower
(
str
[
i
]);
ret
[
i
]
=
0
;
}
else
SetLastError
(
WSAENOBUFS
);
return
ret
;
}
/* Utility: get the SO_RCVTIMEO or SO_SNDTIMEO socket option
/* Utility: get the SO_RCVTIMEO or SO_SNDTIMEO socket option
* from an fd and return the value converted to milli seconds
* from an fd and return the value converted to milli seconds
* or 0 if there is an infinite time out */
* or 0 if there is an infinite time out */
...
@@ -1564,19 +1546,6 @@ void WINAPI WSASetLastError(INT iError) {
...
@@ -1564,19 +1546,6 @@ void WINAPI WSASetLastError(INT iError) {
SetLastError
(
iError
);
SetLastError
(
iError
);
}
}
static
struct
WS_servent
*
check_buffer_se
(
int
size
)
{
struct
per_thread_data
*
ptb
=
get_per_thread_data
();
if
(
ptb
->
se_buffer
)
{
if
(
ptb
->
se_len
>=
size
)
return
ptb
->
se_buffer
;
HeapFree
(
GetProcessHeap
(),
0
,
ptb
->
se_buffer
);
}
ptb
->
se_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
ptb
->
se_len
=
size
)
);
if
(
!
ptb
->
se_buffer
)
SetLastError
(
WSAENOBUFS
);
return
ptb
->
se_buffer
;
}
static
inline
BOOL
supported_pf
(
int
pf
)
static
inline
BOOL
supported_pf
(
int
pf
)
{
{
switch
(
pf
)
switch
(
pf
)
...
@@ -5722,68 +5691,6 @@ SOCKET WINAPI WS_socket(int af, int type, int protocol)
...
@@ -5722,68 +5691,6 @@ SOCKET WINAPI WS_socket(int af, int type, int protocol)
/***********************************************************************
/***********************************************************************
* getservbyname (WS2_32.55)
*/
struct
WS_servent
*
WINAPI
WS_getservbyname
(
const
char
*
name
,
const
char
*
proto
)
{
struct
WS_servent
*
retval
=
NULL
;
struct
servent
*
serv
;
char
*
name_str
;
char
*
proto_str
=
NULL
;
if
(
!
(
name_str
=
strdup_lower
(
name
)))
return
NULL
;
if
(
proto
&&
*
proto
)
{
if
(
!
(
proto_str
=
strdup_lower
(
proto
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
name_str
);
return
NULL
;
}
}
EnterCriticalSection
(
&
csWSgetXXXbyYYY
);
serv
=
getservbyname
(
name_str
,
proto_str
);
if
(
serv
!=
NULL
)
{
retval
=
WS_dup_se
(
serv
);
}
else
SetLastError
(
WSANO_DATA
);
LeaveCriticalSection
(
&
csWSgetXXXbyYYY
);
HeapFree
(
GetProcessHeap
(),
0
,
proto_str
);
HeapFree
(
GetProcessHeap
(),
0
,
name_str
);
TRACE
(
"%s, %s ret %p
\n
"
,
debugstr_a
(
name
),
debugstr_a
(
proto
),
retval
);
return
retval
;
}
/***********************************************************************
* getservbyport (WS2_32.56)
*/
struct
WS_servent
*
WINAPI
WS_getservbyport
(
int
port
,
const
char
*
proto
)
{
struct
WS_servent
*
retval
=
NULL
;
#ifdef HAVE_GETSERVBYPORT
struct
servent
*
serv
;
char
*
proto_str
=
NULL
;
if
(
proto
&&
*
proto
)
{
if
(
!
(
proto_str
=
strdup_lower
(
proto
)))
return
NULL
;
}
EnterCriticalSection
(
&
csWSgetXXXbyYYY
);
if
(
(
serv
=
getservbyport
(
port
,
proto_str
))
!=
NULL
)
{
retval
=
WS_dup_se
(
serv
);
}
else
SetLastError
(
WSANO_DATA
);
LeaveCriticalSection
(
&
csWSgetXXXbyYYY
);
HeapFree
(
GetProcessHeap
(),
0
,
proto_str
);
#endif
TRACE
(
"%d (i.e. port %d), %s ret %p
\n
"
,
port
,
(
int
)
ntohl
(
port
),
debugstr_a
(
proto
),
retval
);
return
retval
;
}
/***********************************************************************
* WSAEnumNetworkEvents (WS2_32.36)
* WSAEnumNetworkEvents (WS2_32.36)
*/
*/
int
WINAPI
WSAEnumNetworkEvents
(
SOCKET
s
,
WSAEVENT
hEvent
,
LPWSANETWORKEVENTS
lpEvent
)
int
WINAPI
WSAEnumNetworkEvents
(
SOCKET
s
,
WSAEVENT
hEvent
,
LPWSANETWORKEVENTS
lpEvent
)
...
@@ -6187,73 +6094,6 @@ INT WINAPI WSAUnhookBlockingHook(void)
...
@@ -6187,73 +6094,6 @@ INT WINAPI WSAUnhookBlockingHook(void)
}
}
/* ----------------------------------- end of API stuff */
/* ----------------------------------- helper functions -
*
* TODO: Merge WS_dup_..() stuff into one function that
* would operate with a generic structure containing internal
* pointers (via a template of some kind).
*/
static
int
list_size
(
char
**
l
,
int
item_size
)
{
int
i
,
j
=
0
;
if
(
l
)
{
for
(
i
=
0
;
l
[
i
];
i
++
)
j
+=
(
item_size
)
?
item_size
:
strlen
(
l
[
i
])
+
1
;
j
+=
(
i
+
1
)
*
sizeof
(
char
*
);
}
return
j
;
}
static
int
list_dup
(
char
**
l_src
,
char
**
l_to
,
int
item_size
)
{
char
*
p
;
int
i
;
for
(
i
=
0
;
l_src
[
i
];
i
++
)
;
p
=
(
char
*
)(
l_to
+
i
+
1
);
for
(
i
=
0
;
l_src
[
i
];
i
++
)
{
int
count
=
(
item_size
)
?
item_size
:
strlen
(
l_src
[
i
])
+
1
;
memcpy
(
p
,
l_src
[
i
],
count
);
l_to
[
i
]
=
p
;
p
+=
count
;
}
l_to
[
i
]
=
NULL
;
return
p
-
(
char
*
)
l_to
;
}
/* ----- servent */
static
struct
WS_servent
*
WS_dup_se
(
const
struct
servent
*
p_se
)
{
char
*
p
;
struct
WS_servent
*
p_to
;
int
size
=
(
sizeof
(
*
p_se
)
+
strlen
(
p_se
->
s_proto
)
+
1
+
strlen
(
p_se
->
s_name
)
+
1
+
list_size
(
p_se
->
s_aliases
,
0
));
if
(
!
(
p_to
=
check_buffer_se
(
size
)))
return
NULL
;
p_to
->
s_port
=
p_se
->
s_port
;
p
=
(
char
*
)(
p_to
+
1
);
p_to
->
s_name
=
p
;
strcpy
(
p
,
p_se
->
s_name
);
p
+=
strlen
(
p
)
+
1
;
p_to
->
s_proto
=
p
;
strcpy
(
p
,
p_se
->
s_proto
);
p
+=
strlen
(
p
)
+
1
;
p_to
->
s_aliases
=
(
char
**
)
p
;
list_dup
(
p_se
->
s_aliases
,
p_to
->
s_aliases
,
0
);
return
p_to
;
}
/***********************************************************************
/***********************************************************************
* WSARecv (WS2_32.67)
* WSARecv (WS2_32.67)
*/
*/
...
...
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