Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / arch / all-mingw32 / bsdsocket / bsdsocket_init.c
blob0fc748b3ed171c2005be598457a6a3a335f889d2
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/symbolsets.h>
7 #include <proto/alib.h>
8 #include <proto/hostlib.h>
10 #include "bsdsocket_intern.h"
12 static const char *ws_functions[] = {
13 "WSAGetLastError",
14 "inet_addr",
15 "inet_ntoa",
16 "getprotobyname",
17 "socket",
18 "closesocket",
19 "ioctlsocket",
20 "setsockopt",
21 "recvfrom",
22 "sendto",
23 "WSAEventSelect",
24 NULL
27 static const char *res_functions[] = {
28 "sock_init",
29 "sock_shutdown",
30 NULL
33 static int bsdsocket_Init(struct bsdsocketBase *SocketBase)
35 APTR HostLibBase = OpenResource("hostlib.resource");
37 if (!HostLibBase)
38 return FALSE;
39 SocketBase->HostLibBase = HostLibBase;
41 SocketBase->winsock = HostLib_Open("Ws2_32.dll", NULL);
42 if (!SocketBase->winsock)
43 return FALSE;
45 SocketBase->resolver = HostLib_Open("Libs\\Host\\bsdsocket.dll", NULL);
46 if (!SocketBase->resolver)
47 return FALSE;
49 SocketBase->WSIFace = (struct WinSockInterface *)HostLib_GetInterface(SocketBase->winsock, ws_functions, NULL);
50 if (!SocketBase->WSIFace)
52 D(bug("[socket] Failed to obtain winsock interface\n"));
53 return FALSE;
56 SocketBase->ResIFace = (struct HostSocketInterface *)HostLib_GetInterface(SocketBase->resolver, res_functions, NULL);
57 if (!SocketBase->ResIFace)
58 return FALSE;
60 NewList((struct List *)&SocketBase->socks);
62 Forbid();
63 SocketBase->ctl = SocketBase->ResIFace->sock_init();
64 Permit();
66 if (!SocketBase->ctl)
67 return FALSE;
69 return TRUE;
72 static int bsdsocket_Cleanup(struct bsdsocketBase *SocketBase)
74 APTR HostLibBase = SocketBase->HostLibBase;
76 D(bug("[socket] Cleanup, HostLibBase is 0x%p\n", HostLibBase));
77 if (!HostLibBase)
78 return TRUE;
80 if (SocketBase->ResIFace)
82 if (SocketBase->ctl)
84 int res;
86 Forbid();
87 res = SocketBase->ResIFace->sock_shutdown(SocketBase->ctl);
88 Permit();
90 if (res)
91 return FALSE;
95 if (SocketBase->WSIFace)
96 HostLib_DropInterface((void **)SocketBase->WSIFace);
98 if (SocketBase->winsock)
99 HostLib_Close(SocketBase->winsock, NULL);
101 return TRUE;
104 ADD2INITLIB(bsdsocket_Init, 0);
105 ADD2EXPUNGELIB(bsdsocket_Cleanup, 0);