mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Win32 updates. Mostly header fixes and defines for windows. Apparently
interface is a reserved word, so we've renamed one variable. There's also no sethostent on win32, and Oddsock seems to think we need DeleteCriticalSection instead of DestroyCriticalSection. I was unable to figure out from msdn.microsoft.com why this was, but I'll trust Oddsock's judgement. svn path=/trunk/net/; revision=2194
This commit is contained in:
parent
dd9da9ddb2
commit
315259ae9f
@ -7,15 +7,18 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#else
|
||||||
|
#include <winsock.h>
|
||||||
|
#define sethostent(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "resolver.h"
|
#include "resolver.h"
|
||||||
@ -156,7 +159,7 @@ void resolver_shutdown(void)
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pthread_mutex_destroy(&_resolver_mutex);
|
pthread_mutex_destroy(&_resolver_mutex);
|
||||||
#else
|
#else
|
||||||
DestroyCriticalSection(&_resolver_mutex);
|
DeleteCriticalSection(&_resolver_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_initialized = 0;
|
_initialized = 0;
|
||||||
|
13
net/sock.c
13
net/sock.c
@ -23,24 +23,25 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
#else
|
#else
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#define vsnprintf _vsnprintf
|
#define vsnprintf _vsnprintf
|
||||||
#define EINPROGRESS WSAEINPROGRESS
|
#define EINPROGRESS WSAEINPROGRESS
|
||||||
#define ENOTSOCK WSAENOTSOCK
|
#define ENOTSOCK WSAENOTSOCK
|
||||||
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
@ -415,7 +416,7 @@ sock_t sock_connect_wto(const char *hostname, const int port, const int timeout)
|
|||||||
** interface. if interface is null, listen on all interfaces.
|
** interface. if interface is null, listen on all interfaces.
|
||||||
** returns the socket, or SOCK_ERROR on failure
|
** returns the socket, or SOCK_ERROR on failure
|
||||||
*/
|
*/
|
||||||
sock_t sock_get_server_socket(const int port, char *interface)
|
sock_t sock_get_server_socket(const int port, char *sinterface)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
struct sockaddr_storage sa;
|
struct sockaddr_storage sa;
|
||||||
@ -435,8 +436,8 @@ sock_t sock_get_server_socket(const int port, char *interface)
|
|||||||
sa_len = sizeof (struct sockaddr_in);
|
sa_len = sizeof (struct sockaddr_in);
|
||||||
|
|
||||||
/* set the interface to bind to if specified */
|
/* set the interface to bind to if specified */
|
||||||
if (interface != NULL) {
|
if (sinterface != NULL) {
|
||||||
if (!resolver_getip(interface, ip, sizeof (ip)))
|
if (!resolver_getip(sinterface, ip, sizeof (ip)))
|
||||||
return SOCK_ERROR;
|
return SOCK_ERROR;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define __SOCK_H
|
#define __SOCK_H
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
typedef SOCKET sock_t
|
typedef SOCKET sock_t
|
||||||
#else
|
#else
|
||||||
typedef int sock_t;
|
typedef int sock_t;
|
||||||
@ -59,7 +59,7 @@ int sock_read_bytes(sock_t sock, char *buff, const int len);
|
|||||||
int sock_read_line(sock_t sock, char *string, const int len);
|
int sock_read_line(sock_t sock, char *string, const int len);
|
||||||
|
|
||||||
/* server socket functions */
|
/* server socket functions */
|
||||||
sock_t sock_get_server_socket(const int port, char *interface);
|
sock_t sock_get_server_socket(const int port, char *sinterface);
|
||||||
int sock_listen(sock_t serversock, int backlog);
|
int sock_listen(sock_t serversock, int backlog);
|
||||||
int sock_accept(sock_t serversock, char *ip, int len);
|
int sock_accept(sock_t serversock, char *ip, int len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user