]> git.sesse.net Git - vlc/commitdiff
Changing the order of parameters may be needed, but changing the parameters themselve...
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 21 Oct 2007 11:06:37 +0000 (11:06 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 21 Oct 2007 11:06:37 +0000 (11:06 +0000)
include/main.h
include/vlc/vlc.h
src/control/core.c
src/control/libvlc_internal.h
src/libvlc-common.c
src/libvlc.c
src/modules/configuration.c
src/modules/configuration.h
src/vlc.c

index 69e290db184f41933835c5e13a9daebdc65495e4..29e90605d60bce7bbea3e5ed61948ab8c04ef905 100644 (file)
@@ -37,7 +37,7 @@ struct libvlc_int_t
 
     /* 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
index 06f3f0b4f3da0e079eee6bdbe57636fed3bbfe95..d8e00dcd9e3b4a78478704b10d5e96d01feac040 100644 (file)
@@ -250,7 +250,7 @@ VLC_PUBLIC_API int     VLC_Create( void );
  *  \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
index a079e2e6bfb6e4c9cdfe4394341d4d0084376994..d52023597f7fec9fea98bfcd12082345a2376e5c 100644 (file)
@@ -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 ) );
     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, argcargv ) )
+    if( libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv ) )
         RAISENULL( "VLC initialization failed" );
 
     p_new->p_libvlc_int = p_libvlc_int;
index 6f07ce07d5e0ecbe3738c87423b26f8c1adbaaf4..f6aa779e6d2b6cdde4068acc3d39d5b6026ea8fa 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
  * 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 ) );
 
index e087faf8eb0628e561995ad52b8e9b3eaec2c93a..e3df03e4fc3685e04fcbd54a4249f3c0f0548f3b 100644 (file)
@@ -105,7 +105,7 @@ static volatile unsigned int i_instances = 0;
 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 );
@@ -235,7 +235,8 @@ libvlc_int_t * libvlc_InternalCreate( void )
  *  - 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;
@@ -1238,7 +1239,7 @@ static inline int LoadMessages (void)
  * 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;
 
@@ -1259,7 +1260,7 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] )
          *       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 );
     }
index 00cc81d9e0819e7fc47e978cb18774e8b9ca20b0..d62a2a9e5a1896f93b4082384b69e8e346e28b21 100644 (file)
@@ -115,7 +115,7 @@ int VLC_Create( void )
  *  - 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;
index e47539c79d2469e1f9b375e48c2cdf772c959084..a5b82fcfea7281b1e89261f66f28951d61634f95 100644 (file)
@@ -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
  * 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;
@@ -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 */
     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" );
@@ -1588,7 +1589,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
      */
     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 */
index 038d65f70bd55a228f1c5d11447d295a64a93f3e..3e02b6be2056f814b458ed47120102f73a750301 100644 (file)
@@ -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_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 * );
index f1d34dcfd9e768c87693be396a73b13b1ba170b9..77dd66f429ad07006b0378eb8406688687d9b6f7 100644 (file)
--- a/src/vlc.c
+++ b/src/vlc.c
@@ -59,7 +59,7 @@ static void *SigHandler (void *set);
 /*****************************************************************************
  * 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;