2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
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
[] = {
27 static const char *res_functions
[] = {
33 static int bsdsocket_Init(struct bsdsocketBase
*SocketBase
)
35 APTR HostLibBase
= OpenResource("hostlib.resource");
39 SocketBase
->HostLibBase
= HostLibBase
;
41 SocketBase
->winsock
= HostLib_Open("Ws2_32.dll", NULL
);
42 if (!SocketBase
->winsock
)
45 SocketBase
->resolver
= HostLib_Open("Libs\\Host\\bsdsocket.dll", NULL
);
46 if (!SocketBase
->resolver
)
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"));
56 SocketBase
->ResIFace
= (struct HostSocketInterface
*)HostLib_GetInterface(SocketBase
->resolver
, res_functions
, NULL
);
57 if (!SocketBase
->ResIFace
)
60 NewList((struct List
*)&SocketBase
->socks
);
63 SocketBase
->ctl
= SocketBase
->ResIFace
->sock_init();
72 static int bsdsocket_Cleanup(struct bsdsocketBase
*SocketBase
)
74 APTR HostLibBase
= SocketBase
->HostLibBase
;
76 D(bug("[socket] Cleanup, HostLibBase is 0x%p\n", HostLibBase
));
80 if (SocketBase
->ResIFace
)
87 res
= SocketBase
->ResIFace
->sock_shutdown(SocketBase
->ctl
);
95 if (SocketBase
->WSIFace
)
96 HostLib_DropInterface((void **)SocketBase
->WSIFace
);
98 if (SocketBase
->winsock
)
99 HostLib_Close(SocketBase
->winsock
, NULL
);
104 ADD2INITLIB(bsdsocket_Init
, 0);
105 ADD2EXPUNGELIB(bsdsocket_Cleanup
, 0);