Commit 7f42e055 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Changing the order of parameters may be needed, but changing the parameters...

Changing the order of parameters may be needed, but changing the parameters themselves is definitely not (it would crash in some cases anyway): add some const qualifiers
parent 6ea1a270
...@@ -37,7 +37,7 @@ struct libvlc_int_t ...@@ -37,7 +37,7 @@ struct libvlc_int_t
/* Global properties */ /* Global properties */
int i_argc; ///< command line arguments count int i_argc; ///< command line arguments count
char ** ppsz_argv; ///< command line arguments const char ** ppsz_argv; ///< command line arguments
char * psz_homedir; ///< user's home directory char * psz_homedir; ///< user's home directory
char * psz_configdir; ///< user's configuration directory char * psz_configdir; ///< user's configuration directory
......
...@@ -250,7 +250,7 @@ VLC_PUBLIC_API int VLC_Create( void ); ...@@ -250,7 +250,7 @@ VLC_PUBLIC_API int VLC_Create( void );
* \param ppsz_argv an array of arguments * \param ppsz_argv an array of arguments
* \return VLC_SUCCESS on success * \return VLC_SUCCESS on success
*/ */
VLC_PUBLIC_API int VLC_Init( int, int, char *[] ); VLC_PUBLIC_API int VLC_Init( int, int, const char *[] );
/** /**
* Add an interface * Add an interface
......
...@@ -90,10 +90,17 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv, ...@@ -90,10 +90,17 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv,
p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) ); p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) );
if( !p_new ) RAISENULL( "Out of memory" ); if( !p_new ) RAISENULL( "Out of memory" );
const char *my_argv[argc + 2];
my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */
for( int i = 0; i < argc; i++ )
my_argv[i + 1] = argv[i];
my_argv[argc + 1] = NULL; /* C calling conventions require a NULL */
/** \todo Look for interface settings. If we don't have any, add -I dummy */ /** \todo Look for interface settings. If we don't have any, add -I dummy */
/* Because we probably don't want a GUI by default */ /* Because we probably don't want a GUI by default */
if( libvlc_InternalInit( p_libvlc_int, argc, argv ) ) if( libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv ) )
RAISENULL( "VLC initialization failed" ); RAISENULL( "VLC initialization failed" );
p_new->p_libvlc_int = p_libvlc_int; p_new->p_libvlc_int = p_libvlc_int;
......
...@@ -39,7 +39,7 @@ extern "C" { ...@@ -39,7 +39,7 @@ extern "C" {
* Internal creation and destruction functions * Internal creation and destruction functions
***************************************************************************/ ***************************************************************************/
VLC_EXPORT (libvlc_int_t *, libvlc_InternalCreate, ( void ) ); VLC_EXPORT (libvlc_int_t *, libvlc_InternalCreate, ( void ) );
VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, char *ppsz_argv[] ) ); VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, const char *ppsz_argv[] ) );
VLC_EXPORT (int, libvlc_InternalCleanup, ( libvlc_int_t * ) ); VLC_EXPORT (int, libvlc_InternalCleanup, ( libvlc_int_t * ) );
VLC_EXPORT (int, libvlc_InternalDestroy, ( libvlc_int_t *, vlc_bool_t ) ); VLC_EXPORT (int, libvlc_InternalDestroy, ( libvlc_int_t *, vlc_bool_t ) );
......
...@@ -105,7 +105,7 @@ static volatile unsigned int i_instances = 0; ...@@ -105,7 +105,7 @@ static volatile unsigned int i_instances = 0;
static void SetLanguage ( char const * ); static void SetLanguage ( char const * );
#endif #endif
static inline int LoadMessages (void); static inline int LoadMessages (void);
static int GetFilenames ( libvlc_int_t *, int, char *[] ); static int GetFilenames ( libvlc_int_t *, int, const char *[] );
static void Help ( libvlc_int_t *, char const *psz_help_name ); static void Help ( libvlc_int_t *, char const *psz_help_name );
static void Usage ( libvlc_int_t *, char const *psz_module_name ); static void Usage ( libvlc_int_t *, char const *psz_module_name );
static void ListModules ( libvlc_int_t *, vlc_bool_t ); static void ListModules ( libvlc_int_t *, vlc_bool_t );
...@@ -235,7 +235,8 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -235,7 +235,8 @@ libvlc_int_t * libvlc_InternalCreate( void )
* - message queue, module bank and playlist initialization * - message queue, module bank and playlist initialization
* - configuration and commandline parsing * - configuration and commandline parsing
*/ */
int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] ) int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
const char *ppsz_argv[] )
{ {
char p_capabilities[200]; char p_capabilities[200];
char * p_tmp = NULL; char * p_tmp = NULL;
...@@ -1238,7 +1239,7 @@ static inline int LoadMessages (void) ...@@ -1238,7 +1239,7 @@ static inline int LoadMessages (void)
* Parse command line for input files as well as their associated options. * Parse command line for input files as well as their associated options.
* An option always follows its associated input and begins with a ":". * An option always follows its associated input and begins with a ":".
*****************************************************************************/ *****************************************************************************/
static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] ) static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, const char *ppsz_argv[] )
{ {
int i_opt, i_options; int i_opt, i_options;
...@@ -1259,7 +1260,7 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -1259,7 +1260,7 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] )
* unnecessary lookups. */ * unnecessary lookups. */
VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[i_opt], VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[i_opt],
(char const **)( i_options ? &ppsz_argv[i_opt + 1] : ( i_options ? &ppsz_argv[i_opt + 1] :
NULL ), i_options, NULL ), i_options,
PLAYLIST_INSERT, 0 ); PLAYLIST_INSERT, 0 );
} }
......
...@@ -115,7 +115,7 @@ int VLC_Create( void ) ...@@ -115,7 +115,7 @@ int VLC_Create( void )
* - message queue, module bank and playlist initialization * - message queue, module bank and playlist initialization
* - configuration and commandline parsing * - configuration and commandline parsing
*****************************************************************************/ *****************************************************************************/
int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) int VLC_Init( int i_object, int i_argc, const char *ppsz_argv[] )
{ {
int i_ret; int i_ret;
LIBVLC_FUNC; LIBVLC_FUNC;
......
...@@ -1401,7 +1401,8 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -1401,7 +1401,8 @@ int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
* because we don't know (and don't want to know) in advance the configuration * because we don't know (and don't want to know) in advance the configuration
* options used (ie. exported) by each module. * options used (ie. exported) by each module.
*****************************************************************************/ *****************************************************************************/
int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
const char *ppsz_argv[],
vlc_bool_t b_ignore_errors ) vlc_bool_t b_ignore_errors )
{ {
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0; int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
...@@ -1480,7 +1481,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], ...@@ -1480,7 +1481,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
* us, ignoring the arity of the options */ * us, ignoring the arity of the options */
if( b_ignore_errors ) if( b_ignore_errors )
{ {
ppsz_argv = (char**)malloc( *pi_argc * sizeof(char *) ); ppsz_argv = (const char**)malloc( *pi_argc * sizeof(char *) );
if( ppsz_argv == NULL ) if( ppsz_argv == NULL )
{ {
msg_Err( p_this, "out of memory" ); msg_Err( p_this, "out of memory" );
...@@ -1588,7 +1589,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], ...@@ -1588,7 +1589,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
*/ */
opterr = 0; opterr = 0;
optind = 0; /* set to 0 to tell GNU getopt to reinitialize */ optind = 0; /* set to 0 to tell GNU getopt to reinitialize */
while( ( i_cmd = getopt_long( *pi_argc, ppsz_argv, psz_shortopts, while( ( i_cmd = getopt_long( *pi_argc, (char **)ppsz_argv, psz_shortopts,
p_longopts, &i_index ) ) != -1 ) p_longopts, &i_index ) ) != -1 )
{ {
/* A long option has been recognized */ /* A long option has been recognized */
......
...@@ -42,7 +42,7 @@ void config_UnsetCallbacks( module_config_t *, size_t ); ...@@ -42,7 +42,7 @@ void config_UnsetCallbacks( module_config_t *, size_t );
#define config_LoadCmdLine(a,b,c,d) __config_LoadCmdLine(VLC_OBJECT(a),b,c,d) #define config_LoadCmdLine(a,b,c,d) __config_LoadCmdLine(VLC_OBJECT(a),b,c,d)
#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b) #define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, char *[], vlc_bool_t ); int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], vlc_bool_t );
char *config_GetHomeDir ( void ); char *config_GetHomeDir ( void );
char *config_GetConfigDir ( libvlc_int_t * ); char *config_GetConfigDir ( libvlc_int_t * );
char *config_GetUserDataDir( libvlc_int_t * ); char *config_GetUserDataDir( libvlc_int_t * );
......
...@@ -59,7 +59,7 @@ static void *SigHandler (void *set); ...@@ -59,7 +59,7 @@ static void *SigHandler (void *set);
/***************************************************************************** /*****************************************************************************
* main: parse command line, start interface and spawn threads. * main: parse command line, start interface and spawn threads.
*****************************************************************************/ *****************************************************************************/
int main( int i_argc, char *ppsz_argv[] ) int main( int i_argc, const char *ppsz_argv[] )
{ {
int i_ret; int i_ret;
......
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