]> git.sesse.net Git - vlc/blob - src/misc/win32_specific.c
* ./src/misc/win32_specific.c: under Win32 we retrieve the executable's
[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.21 2003/02/17 05:50:31 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 <string.h>                                              /* strdup() */
25 #include <stdlib.h>                                                /* free() */
26
27 #include <vlc/vlc.h>
28
29 #if !defined( UNDER_CE )
30 #   include <fcntl.h>
31 #   include <winsock2.h>
32 #endif
33
34 /*****************************************************************************
35  * system_Init: initialize winsock and misc other things.
36  *****************************************************************************/
37 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
38 {
39 #if !defined( UNDER_CE )
40     WSADATA Data;
41     int i_err;
42
43     /* Get our full path */
44     if( ppsz_argv[0] )
45     {
46         char psz_path[MAX_PATH];
47         char *psz_vlc;
48
49         GetFullPathName( ppsz_argv[0], MAX_PATH, psz_path, &psz_vlc );
50
51         if( psz_vlc > psz_path && psz_vlc[-1] == '\\' )
52         {
53             psz_vlc[-1] = '\0';
54             p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
55         }
56         else
57         {
58             p_this->p_libvlc->psz_vlcpath = strdup( "" );
59         }
60     }
61     else
62     {
63         p_this->p_libvlc->psz_vlcpath = strdup( "" );
64     }
65
66     /* WinSock Library Init. */
67     i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
68
69     if( i_err )
70     {
71         fprintf( stderr, "error: can't initiate WinSocks, error %i\n", i_err );
72     }
73
74     /* Set the default file-translation mode */
75     _fmode = _O_BINARY;
76 #endif
77 }
78
79 /*****************************************************************************
80  * system_Configure: check for system specific configuration options.
81  *****************************************************************************/
82 void system_Configure( vlc_t *p_this )
83 {
84 #if !defined( UNDER_CE )
85     p_this->p_libvlc->b_fast_mutex = config_GetInt( p_this, "fast-mutex" );
86     p_this->p_libvlc->i_win9x_cv = config_GetInt( p_this, "win9x-cv-method" );
87
88     /* Raise default priority of the current process */
89 #ifndef ABOVE_NORMAL_PRIORITY_CLASS
90 #   define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
91 #endif
92     if( !SetPriorityClass( GetCurrentProcess(),
93                            ABOVE_NORMAL_PRIORITY_CLASS ) )
94     {
95         if( !SetPriorityClass( GetCurrentProcess(),
96                                HIGH_PRIORITY_CLASS ) )
97             msg_Dbg( p_this, "can't raise process priority" );
98         else
99             msg_Dbg( p_this, "raised process priority" );
100     }
101     else
102         msg_Dbg( p_this, "raised process priority" );
103 #endif
104 }
105
106 /*****************************************************************************
107  * system_End: terminate winsock.
108  *****************************************************************************/
109 void system_End( vlc_t *p_this )
110 {
111 #if !defined( UNDER_CE )
112     WSACleanup();
113 #endif
114 }