]> git.sesse.net Git - vlc/blob - src/misc/win32_specific.c
* ALL: the first libvlc commit.
[vlc] / src / misc / win32_specific.c
1 /*****************************************************************************
2  * win32_specific.c: Win32 specific features 
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: win32_specific.c,v 1.8 2002/06/01 12:32:02 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Gildas Bazin <gbazin@netcourrier.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24 #include <errno.h>                                                 /* ENOMEM */
25 #include <string.h>                                              /* strdup() */
26 #include <stdlib.h>                                                /* free() */
27 #include <fcntl.h>
28
29 #include <winsock2.h>
30
31 #include <vlc/vlc.h>
32
33 /*****************************************************************************
34  * system_Init: initialize winsock and misc other things.
35  *****************************************************************************/
36 void system_Init( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[] )
37 {
38     WSADATA Data;
39     int i_err;
40     HINSTANCE hInstLib;
41
42     /* Allocate structure */
43     p_this->p_vlc->p_sys = malloc( sizeof( main_sys_t ) );
44     if( p_this->p_vlc->p_sys == NULL )
45     {
46         fprintf( stderr, "error: out of memory\n" );
47         exit(-1);
48     }
49
50     /* dynamically get the address of SignalObjectAndWait */
51     hInstLib = LoadLibrary( "kernel32" );
52     p_this->p_vlc->p_sys->SignalObjectAndWait =
53         (SIGNALOBJECTANDWAIT)GetProcAddress( hInstLib, "SignalObjectAndWait" );
54
55     /* WinSock Library Init. */
56     i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
57
58     if( i_err )
59     {
60         fprintf( stderr, "error: can't initiate WinSocks, error %i\n", i_err );
61     }
62
63     _fmode = _O_BINARY;  /* sets the default file-translation mode */
64 }
65
66 /*****************************************************************************
67  * system_Configure: check for system specific configuration options.
68  *****************************************************************************/
69 void system_Configure( vlc_object_t *p_this )
70 {
71     p_this->p_vlc->p_sys->b_fast_pthread = config_GetInt( p_this,
72                                                           "fast_pthread" );
73 }
74
75 /*****************************************************************************
76  * system_End: terminate winsock.
77  *****************************************************************************/
78 void system_End( vlc_object_t * )
79 {
80     WSACleanup();
81 }