]> git.sesse.net Git - vlc/commitdiff
* src/vlc.c: ported to WinCE.
authorGildas Bazin <gbazin@videolan.org>
Fri, 12 Nov 2004 08:27:05 +0000 (08:27 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 12 Nov 2004 08:27:05 +0000 (08:27 +0000)
src/extras/libc.c
src/vlc.c

index 2a1c8b8ab36098a809609dd7eed018d235f71c68..e68ce4d2487046fb0ed78373434aea91f02ea606 100644 (file)
@@ -621,12 +621,12 @@ char **vlc_parse_cmdline( const char *psz_cmdline, int *i_args )
 {
     int argc = 0;
     char **argv = 0;
-    char *s, *psz_parser, *psz_arg;
+    char *s, *psz_parser, *psz_arg, *psz_orig;
     int i_bcount = 0;
 
     if( !psz_cmdline ) return 0;
-    psz_cmdline = strdup( psz_cmdline );
-    psz_arg = psz_parser = s = psz_cmdline;
+    psz_orig = strdup( psz_cmdline );
+    psz_arg = psz_parser = s = psz_orig;
 
     while( *s )
     {
@@ -686,6 +686,6 @@ char **vlc_parse_cmdline( const char *psz_cmdline, int *i_args )
     }
 
     if( i_args ) *i_args = argc;
-    free( psz_cmdline );
+    free( psz_orig );
     return argv;
 }
index b4c1bda17b0f8afd003eaab5b0216f0f32d38ad0..fa6810cf383527a06e27158a45a75ce38028f554 100644 (file)
--- a/src/vlc.c
+++ b/src/vlc.c
@@ -41,7 +41,7 @@
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
-#ifndef WIN32
+#if !defined(WIN32) && !defined(UNDER_CE)
 static void SigHandler  ( int i_signal );
 #endif
 
@@ -80,7 +80,7 @@ int main( int i_argc, char *ppsz_argv[] )
         return i_ret;
     }
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(UNDER_CE)
     /* Set the signal handlers. SIGTERM is not intercepted, because we need at
      * least one method to kill the program when all other methods failed, and
      * when we don't want to use SIGKILL.
@@ -113,7 +113,7 @@ int main( int i_argc, char *ppsz_argv[] )
     return i_ret;
 }
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(UNDER_CE)
 /*****************************************************************************
  * SigHandler: system signal handler
  *****************************************************************************
@@ -155,3 +155,30 @@ static void SigHandler( int i_signal )
     }
 }
 #endif
+
+#if defined(UNDER_CE)
+/*****************************************************************************
+ * WinMain: parse command line, start interface and spawn threads. (WinCE only)
+ *****************************************************************************/
+int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
+                    LPTSTR lpCmdLine, int nCmdShow )
+{
+    char **argv, psz_cmdline[MAX_PATH];
+    int argc, i_ret;
+
+    WideCharToMultiByte( CP_ACP, WC_DEFAULTCHAR, lpCmdLine, -1,
+                         psz_cmdline, MAX_PATH, NULL, NULL );
+
+    argv = vlc_parse_cmdline( psz_cmdline, &argc );
+    argv = realloc( argv, (argc + 1) * sizeof(char *) );
+    if( !argv ) return -1;
+
+    if( argc ) memmove( argv + 1, argv, argc );
+    argv[0] = strdup(""); /* Fake program path */
+
+    i_ret = main( argc, argv );
+
+    /* No need to free the argv memory */
+    return i_ret;
+}
+#endif