1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include "apr_arch_networkio.h"
18
#include "apr_network_io.h"
19
#include "apr_portable.h"
20
#include "apr_general.h"
23
static int os2_socket_init(int, int ,int);
25
int (*apr_os2_socket)(int, int, int) = os2_socket_init;
26
int (*apr_os2_select)(int *, int, int, int, long) = NULL;
27
int (*apr_os2_sock_errno)() = NULL;
28
int (*apr_os2_accept)(int, struct sockaddr *, int *) = NULL;
29
int (*apr_os2_bind)(int, struct sockaddr *, int) = NULL;
30
int (*apr_os2_connect)(int, struct sockaddr *, int) = NULL;
31
int (*apr_os2_getpeername)(int, struct sockaddr *, int *) = NULL;
32
int (*apr_os2_getsockname)(int, struct sockaddr *, int *) = NULL;
33
int (*apr_os2_getsockopt)(int, int, int, char *, int *) = NULL;
34
int (*apr_os2_ioctl)(int, int, caddr_t, int) = NULL;
35
int (*apr_os2_listen)(int, int) = NULL;
36
int (*apr_os2_recv)(int, char *, int, int) = NULL;
37
int (*apr_os2_send)(int, const char *, int, int) = NULL;
38
int (*apr_os2_setsockopt)(int, int, int, char *, int) = NULL;
39
int (*apr_os2_shutdown)(int, int) = NULL;
40
int (*apr_os2_soclose)(int) = NULL;
41
int (*apr_os2_writev)(int, struct iovec *, int) = NULL;
42
int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int);
43
int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *);
45
static HMODULE hSO32DLL;
47
static int os2_fn_link()
49
DosEnterCritSec(); /* Stop two threads doing this at the same time */
51
if (apr_os2_socket == os2_socket_init) {
55
rc = DosLoadModule(errorstr, sizeof(errorstr), "SO32DLL", &hSO32DLL);
58
return APR_OS2_STATUS(rc);
60
rc = DosQueryProcAddr(hSO32DLL, 0, "SOCKET", &apr_os2_socket);
63
rc = DosQueryProcAddr(hSO32DLL, 0, "SELECT", &apr_os2_select);
66
rc = DosQueryProcAddr(hSO32DLL, 0, "SOCK_ERRNO", &apr_os2_sock_errno);
69
rc = DosQueryProcAddr(hSO32DLL, 0, "ACCEPT", &apr_os2_accept);
72
rc = DosQueryProcAddr(hSO32DLL, 0, "BIND", &apr_os2_bind);
75
rc = DosQueryProcAddr(hSO32DLL, 0, "CONNECT", &apr_os2_connect);
78
rc = DosQueryProcAddr(hSO32DLL, 0, "GETPEERNAME", &apr_os2_getpeername);
81
rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKNAME", &apr_os2_getsockname);
84
rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKOPT", &apr_os2_getsockopt);
87
rc = DosQueryProcAddr(hSO32DLL, 0, "IOCTL", &apr_os2_ioctl);
90
rc = DosQueryProcAddr(hSO32DLL, 0, "LISTEN", &apr_os2_listen);
93
rc = DosQueryProcAddr(hSO32DLL, 0, "RECV", &apr_os2_recv);
96
rc = DosQueryProcAddr(hSO32DLL, 0, "SEND", &apr_os2_send);
99
rc = DosQueryProcAddr(hSO32DLL, 0, "SETSOCKOPT", &apr_os2_setsockopt);
102
rc = DosQueryProcAddr(hSO32DLL, 0, "SHUTDOWN", &apr_os2_shutdown);
105
rc = DosQueryProcAddr(hSO32DLL, 0, "SOCLOSE", &apr_os2_soclose);
108
rc = DosQueryProcAddr(hSO32DLL, 0, "WRITEV", &apr_os2_writev);
111
rc = DosQueryProcAddr(hSO32DLL, 0, "SENDTO", &apr_os2_sendto);
114
rc = DosQueryProcAddr(hSO32DLL, 0, "RECVFROM", &apr_os2_recvfrom);
117
return APR_OS2_STATUS(rc);
126
static int os2_socket_init(int domain, int type, int protocol)
128
int rc = os2_fn_link();
129
if (rc == APR_SUCCESS)
130
return apr_os2_socket(domain, type, protocol);