/* Global properties */
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_configdir; ///< user's configuration directory
* \param ppsz_argv an array of arguments
* \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
p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) );
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 */
/* 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" );
p_new->p_libvlc_int = p_libvlc_int;
* Internal creation and destruction functions
***************************************************************************/
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_InternalDestroy, ( libvlc_int_t *, vlc_bool_t ) );
static void SetLanguage ( char const * );
#endif
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 Usage ( libvlc_int_t *, char const *psz_module_name );
static void ListModules ( libvlc_int_t *, vlc_bool_t );
* - message queue, module bank and playlist initialization
* - 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_tmp = NULL;
* Parse command line for input files as well as their associated options.
* 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;
* unnecessary lookups. */
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,
PLAYLIST_INSERT, 0 );
}
* - message queue, module bank and playlist initialization
* - 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;
LIBVLC_FUNC;
* because we don't know (and don't want to know) in advance the configuration
* 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 )
{
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
* us, ignoring the arity of the options */
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 )
{
msg_Err( p_this, "out of memory" );
*/
opterr = 0;
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 )
{
/* A long option has been recognized */
#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)
-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_GetConfigDir ( libvlc_int_t * );
char *config_GetUserDataDir( libvlc_int_t * );
/*****************************************************************************
* 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;