Commit 9c097eee authored by Ralph Giles's avatar Ralph Giles Committed by Ralph Giles

Initial winsock support patch from nu774.

Some tweak might be still needed to take care of OPENSSL_AppLink
to get https support working. In win32, user application of openssl
is required to include openssl/applink.c or something, when openssl
is compiled with OPENSSL_USE_APPLINK.

I don't know how it should be taken care of, from the library point of
view (it must be done by user of libopusfile, since openssl always
searches that function in executable module).

Posted to the hydrogenaudio format 2012 November 19.
http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=97856&view=findpost&p=814582
parent 218518dc
......@@ -12,7 +12,13 @@ libopusfile_la_SOURCES = \
src/http.c src/info.c \
src/internal.c src/internal.h \
src/opusfile.c src/stream.c
if OS_WIN32
libopusfile_la_SOURCES += src/win32/wsockwrapper.c
endif
libopusfile_la_LIBADD = $(DEPS_LIBS)
if OS_WIN32
libopusfile_la_LIBADD += -lws2_32
endif
libopusfile_la_LDFLAGS = -no-undefined \
-version-info @OP_LT_CURRENT@:@OP_LT_REVISION@:@OP_LT_AGE@
......
......@@ -41,12 +41,12 @@ AC_ARG_ENABLE([http],
AS_HELP_STRING([--disable-http], [Disable HTTP support]),,
enable_http=yes)
AS_IF([test "x$enable_http" != "xno"],
AC_CHECK_HEADER([sys/socket.h],,
AC_MSG_WARN([HTTP support requires a posix socket library.])
enable_http=no
)
)
# AS_IF([test "x$enable_http" != "xno"],
# AC_CHECK_HEADER([sys/socket.h],,
# AC_MSG_WARN([HTTP support requires a posix socket library.])
# enable_http=no
# )
# )
AS_IF([test "x$enable_http" != "xno"], [
openssl="openssl"
......@@ -92,8 +92,10 @@ case $host in
*-mingw*)
# -std=c89 causes some warnings under mingw.
CC_CHECK_CFLAGS_APPEND([-U__STRICT_ANSI__])
host_mingw=true
;;
esac
AM_CONDITIONAL(OS_WIN32, test "x$host_mingw" = xtrue)
dnl Check for doxygen
AC_ARG_ENABLE([doc],
......
This diff is collapsed.
#ifndef WINERRNO_H
#define WINERRNO_H
#include <errno.h>
/* XXX: conflicts with MSVC errno definition */
#ifdef ENAMETOOLONG
#undef ENAMETOOLONG
#endif
#ifdef ENOTEMPTY
#undef ENOTEMPTY
#endif
#define EWOULDBLOCK 35
#define EINPROGRESS 36
#define EALREADY 37
#define ENOTSOCK 38
#define EDESTADDRREQ 39
#define EMSGSIZE 40
#define EPROTOTYPE 41
#define ENOPROTOOPT 42
#define EPROTONOSUPPORT 43
#define ESOCKTNOSUPPORT 44
#define EOPNOTSUPP 45
#define EPFNOSUPPORT 46
#define EAFNOSUPPORT 47
#define EADDRINUSE 48
#define EADDRNOTAVAIL 49
#define ENETDOWN 50
#define ENETUNREACH 51
#define ENETRESET 52
#define ECONNABORTED 53
#define ECONNRESET 54
#define ENOBUFS 55
#define EISCONN 56
#define ENOTCONN 57
#define ESHUTDOWN 58
#define ETOOMANYREFS 59
#define ETIMEDOUT 60
#define ECONNREFUSED 61
#define ELOOP 62
#define ENAMETOOLONG 63
#define EHOSTDOWN 64
#define EHOSTUNREACH 65
#define ENOTEMPTY 66
#define EPROCLIM 67
#define EUSERS 68
#define EDQUOT 69
#define ESTALE 70
#define EREMOTE 71
#endif
#include <stdio.h>
#include "wsockwrapper.h"
int win32_poll(struct pollfd *fds, unsigned nfds, int timeout)
{
fd_set ifds, ofds, efds;
struct timeval tv;
unsigned i;
int rc;
FD_ZERO(&ifds);
FD_ZERO(&ofds);
FD_ZERO(&efds);
for (i = 0; i < nfds; ++i) {
fds[i].revents = 0;
if (fds[i].events & POLLIN)
FD_SET(fds[i].fd, &ifds);
if (fds[i].events & POLLOUT)
FD_SET(fds[i].fd, &ofds);
FD_SET(fds[i].fd, &efds);
}
if (timeout >= 0) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
}
rc = select(255, &ifds, &ofds, &efds, timeout < 0 ? 0 : &tv);
if (rc > 0) {
for (i = 0; i < nfds; ++i) {
if (FD_ISSET(fds[i].fd, &ifds))
fds[i].revents |= POLLIN;
if (FD_ISSET(fds[i].fd, &ofds))
fds[i].revents |= POLLOUT;
if (FD_ISSET(fds[i].fd, &efds))
fds[i].revents |= POLLHUP;
}
}
return rc;
}
int win32_ftime(struct timeb *timer)
{
ftime(timer);
return 0;
}
#ifndef WSOCKWRAPPER_H
#define WSOCKWRAPPER_H
#include <winsock2.h>
#include <sys/timeb.h>
#define POLLIN 0x0001 /* There is data to read */
#define POLLPRI 0x0002 /* There is urgent data to read */
#define POLLOUT 0x0004 /* Writing now will not block */
#define POLLERR 0x0008 /* Error condition */
#define POLLHUP 0x0010 /* Hung up */
#define POLLNVAL 0x0020 /* Invalid request: fd not open */
struct pollfd {
SOCKET fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
#define poll(x, y, z) win32_poll(x, y, z)
int win32_poll(struct pollfd *, unsigned int, int);
int win32_ftime(struct timeb *timer);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment