mirror of
https://github.com/X11Libre/xserver.git
synced 2026-01-26 14:03:17 +00:00
os: generic socket layer init function
Reduce the ifdef-zoo a bit by moving win32 specific socket layer init into a separate function (that's no-op on non-win32). Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
fdf43d4176
commit
fe795fa7b8
11
os/Xtrans.c
11
os/Xtrans.c
@ -46,6 +46,7 @@ from The Open Group.
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <dix-config.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
@ -54,6 +55,8 @@ from The Open Group.
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#include "os/ossock.h"
|
||||
|
||||
/*
|
||||
* The transport table contains a definition for every transport (protocol)
|
||||
* family. All operations that can be made on the transport go through this
|
||||
@ -401,13 +404,7 @@ _XSERVTransOpen (int type, const char *address)
|
||||
|
||||
prmsg (2,"Open(%d,%s)\n", type, address);
|
||||
|
||||
#if defined(WIN32) && defined(TCPCONN)
|
||||
if (_XSERVTransWSAStartup())
|
||||
{
|
||||
prmsg (1,"Open: WSAStartup failed\n");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
ossock_init();
|
||||
|
||||
/* Parse the Address */
|
||||
|
||||
|
||||
@ -297,8 +297,4 @@ int _XSERVTransGetHostname (
|
||||
int /* maxlen */
|
||||
);
|
||||
|
||||
#if defined(WIN32) && defined(TCPCONN)
|
||||
int _XSERVTransWSAStartup(void);
|
||||
#endif
|
||||
|
||||
#endif /* _XTRANS_H_ */
|
||||
|
||||
@ -219,19 +219,6 @@ int _XSERVTransConvertAddress(int *familyp, int *addrlenp, Xtransaddr **addrp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(WIN32) && defined(TCPCONN)
|
||||
int _XSERVTransWSAStartup (void)
|
||||
{
|
||||
static WSADATA wsadata;
|
||||
|
||||
prmsg (2,"WSAStartup()\n");
|
||||
|
||||
if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -13,6 +13,7 @@ srcs_os = [
|
||||
'mitauth.c',
|
||||
'osinit.c',
|
||||
'ospoll.c',
|
||||
'ossock.c',
|
||||
'serverlock.c',
|
||||
'string.c',
|
||||
'utils.c',
|
||||
|
||||
20
os/ossock.c
Normal file
20
os/ossock.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
||||
*/
|
||||
#include <dix-config.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <X11/Xwinsock.h>
|
||||
#endif
|
||||
|
||||
#include "os/ossock.h"
|
||||
|
||||
void ossock_init(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
static WSADATA wsadata;
|
||||
if (!wsadata.wVersion)
|
||||
WSAStartup(0x0202, &wsadata);
|
||||
#endif
|
||||
}
|
||||
13
os/ossock.h
Normal file
13
os/ossock.h
Normal file
@ -0,0 +1,13 @@
|
||||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
||||
*/
|
||||
#ifndef _XSERVER_OS_OSSOCK_H_
|
||||
#define _XSERVER_OS_OSSOCK_H_
|
||||
|
||||
/*
|
||||
* os specific initialization of the socket layer
|
||||
*/
|
||||
void ossock_init(void);
|
||||
|
||||
#endif /* _XSERVER_OS_OSSOCK_H_ */
|
||||
@ -37,6 +37,7 @@
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "os/auth.h"
|
||||
#include "os/ossock.h"
|
||||
|
||||
#include "misc.h"
|
||||
#include "osdep.h"
|
||||
@ -1412,9 +1413,7 @@ get_addr_by_name(const char *argtype,
|
||||
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
|
||||
_Xgethostbynameparams hparams;
|
||||
#endif
|
||||
#if defined(WIN32) && defined(TCPCONN)
|
||||
_XSERVTransWSAStartup();
|
||||
#endif
|
||||
ossock_init();
|
||||
if (!(hep = _XGethostbyname(namestr, hparams))) {
|
||||
FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user