startup (thanks Meuuh for the tip).
endif
ifneq (,$(findstring mingw32,$(SYS)))
+C_OBJ += src/misc/win32_specific.o
RESOURCE_OBJ := share/vlc_win32_rc.o
endif
--- /dev/null
+/*****************************************************************************
+ * win32_specific.h: Win32 specific features
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: win32_specific.h,v 1.1 2001/11/12 22:42:56 sam Exp $
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+void system_Init ( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] );
+void system_End ( void );
+
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.153 2001/11/12 04:12:37 sam Exp $
+ * $Id: input.c,v 1.154 2001/11/12 22:42:56 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
# include <netdb.h> /* hostent ... */
# include <sys/socket.h>
# include <netinet/in.h>
-# include <arpa/inet.h>
+# ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
+# endif
#endif
#ifdef HAVE_SYS_TIMES_H
struct sockaddr_in sock;
unsigned int i_mc_group;
-#ifdef WIN32
- WSADATA Data;
- int i_err;
-#endif
-
-#ifdef WIN32
- /* WinSock Library Init. */
- i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
-
- if( i_err )
- {
- intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
- return ;
- }
-#endif
-
/* Get the remote server */
if( p_input->p_source != NULL )
{
intf_WarnMsg( 2, "input: closing network target `%s'", p_input->p_source );
close( p_input->i_handle );
-
-#ifdef WIN32
- WSACleanup();
-#endif
}
/*****************************************************************************
struct sockaddr_in sock;
char psz_buffer[256];
-#ifdef WIN32
- WSADATA Data;
- int i_err;
-#endif
-
-#ifdef WIN32
- /* WinSock Library Init. */
- i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
-
- if( i_err )
- {
- intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
- return ;
- }
-#endif
-
/* Get the remote server */
if( p_input->p_source != NULL )
{
* and spawn threads.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: main.c,v 1.123 2001/11/12 20:16:33 sam Exp $
+ * $Id: main.c,v 1.124 2001/11/12 22:42:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
# include "darwin_specific.h"
#endif
+#ifdef WIN32
+# include "win32_specific.h"
+#endif
+
#include "netutils.h" /* network_ChannelJoin */
#include "main.h"
/*
* System specific initialization code
*/
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
system_Init( &i_argc, ppsz_argv, ppsz_env );
#elif defined( WIN32 )
/*
* System specific cleaning code
*/
-#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
system_End();
#endif
* netutils.c: various network functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: netutils.c,v 1.42 2001/11/12 20:16:33 sam Exp $
+ * $Id: netutils.c,v 1.43 2001/11/12 22:42:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr>
#endif
#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* gethostname() */
+# include <unistd.h> /* gethostname() */
#elif defined( _MSC_VER ) && defined( _WIN32 )
-#include <io.h>
+# include <io.h>
#endif
#if !defined( _MSC_VER )
#include <sys/time.h> /* gettimeofday */
#endif
-#if !defined( WIN32 )
-#include <netdb.h> /* gethostbyname() */
-#include <netinet/in.h> /* BSD: struct in_addr */
-#include <sys/socket.h> /* BSD: struct sockaddr */
-#endif
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
+#ifdef WIN32
+# include <winsock2.h>
+#elif !defined( SYS_BEOS ) && !defined( SYS_NTO )
+# include <netdb.h> /* hostent ... */
+# include <sys/socket.h> /* BSD: struct sockaddr */
+# include <netinet/in.h> /* BSD: struct in_addr */
+# ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
+# endif
#endif
#ifdef SYS_LINUX
/* Initializing the socket */
i_fd = socket( AF_INET, SOCK_DGRAM, 0 );
+ if( i_fd < 0 )
+ {
+ intf_ErrMsg( "network error: unable to create vlcs socket (%s)",
+ strerror( errno ) );
+ return -1;
+ }
/* Getting information about the channel server */
psz_vlcs = main_GetPszVariable( INPUT_CHANNEL_SERVER_VAR,
i_port = main_GetIntVariable( INPUT_CHANNEL_PORT_VAR,
INPUT_CHANNEL_PORT_DEFAULT );
- intf_WarnMsg( 6, "network: vlcs '%s', port %d", psz_vlcs, i_port );
+ intf_WarnMsg( 5, "network: socket %i, vlcs '%s', port %d",
+ i_fd, psz_vlcs, i_port );
memset( &sa_client, 0x00, sizeof(struct sockaddr_in) );
memset( &sa_server, 0x00, sizeof(struct sockaddr_in) );
#endif
/* Bind the socket */
- i_dummy = bind( i_fd, (struct sockaddr *)(&sa_client),
- sizeof(struct sockaddr) );
- if ( i_dummy )
+ if( bind( i_fd, (struct sockaddr*)(&sa_client), sizeof(sa_client) ) )
{
- intf_ErrMsg( "network: unable to bind vlcs socket: %i", i_dummy );
+ intf_ErrMsg( "network: unable to bind vlcs socket (%s)",
+ strerror( errno ) );
+ close( i_fd );
return -1;
}
if( GetMacAddress( i_fd, psz_mac ) )
{
intf_ErrMsg( "network error: failed getting MAC address" );
+ close( i_fd );
return -1;
}
delay.tv_usec = 0;
FD_ZERO( &fds );
FD_SET( i_fd, &fds );
- i_dummy = select( i_fd + 1, &fds, NULL, NULL, &delay );
- switch( i_dummy )
+ switch( select( i_fd + 1, &fds, NULL, NULL, &delay ) )
{
case 0:
intf_ErrMsg( "network error: no answer from vlcs" );
#else
intf_ErrMsg( "network error: channels not supported on this platform" );
- return NULL;
+ return -1;
#endif
}
--- /dev/null
+/*****************************************************************************
+ * win32_specific.c: Win32 specific features
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: win32_specific.c,v 1.1 2001/11/12 22:42:56 sam Exp $
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+#include "defs.h"
+
+#include <string.h> /* strdup() */
+#include <stdlib.h> /* free() */
+
+#include <winsock2.h>
+
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+
+#include "win32_specific.h"
+
+/*****************************************************************************
+ * system_Init: initialize winsock.
+ *****************************************************************************/
+void system_Init( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
+{
+ WSADATA Data;
+ int i_err;
+
+ /* WinSock Library Init. */
+ i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
+
+ if( i_err )
+ {
+ fprintf( stderr, "error: can't initiate WinSocks, error %i", i_err );
+ }
+}
+
+/*****************************************************************************
+ * system_End: terminate winsock.
+ *****************************************************************************/
+void system_End( void )
+{
+ WSACleanup();
+}
+