]> git.sesse.net Git - vlc/commitdiff
Merge branch 'master' of git://git.videolan.org/vlc
authorGeoffroy Couprie <geo.couprie@gmail.com>
Tue, 30 Sep 2008 10:08:41 +0000 (12:08 +0200)
committerGeoffroy Couprie <geo.couprie@gmail.com>
Tue, 30 Sep 2008 10:08:41 +0000 (12:08 +0200)
include/vlc_common.h
include/vlc_fixups.h
include/vlc_threads.h
modules/access/screen/win32.c
modules/control/ntservice.c
src/extras/libc.c
src/modules/os.c
src/text/unicode.c

index d409082f7dd3943b6c3f60071d23806891325c8b..c4b4f4e758c139482702960a4af0d2db27e86f18 100644 (file)
@@ -498,11 +498,6 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *,      /* variable's object */
 #if defined( WIN32 ) || defined( UNDER_CE )
 #   define WIN32_LEAN_AND_MEAN
 #   include <windows.h>
-#   if defined( UNDER_CE )
-#      define IS_WINNT 0
-#   else
-#      define IS_WINNT ( GetVersion() < 0x80000000 )
-#   endif
 #endif
 
 #include "vlc_mtime.h"
index c74069f67b14176c05612126555ebeb132552f8d..09c467be5aaf5bf696607e930e8ea071b7959023 100644 (file)
@@ -44,12 +44,54 @@ static inline char *strdup (const char *str)
 # include <stdarg.h>
 static inline int vasprintf (char **strp, const char *fmt, va_list ap)
 {
+#ifndef UNDER_CE
     int len = vsnprintf (NULL, 0, fmt, ap) + 1;
     char *res = (char *)malloc (len);
     if (res == NULL)
         return -1;
     *strp = res;
     return vsprintf (res, fmt, ap);
+#else
+    /* HACK: vsnprintf in the WinCE API behaves like
+     * the one in glibc 2.0 and doesn't return the number of characters
+     * it needed to copy the string.
+     * cf http://msdn.microsoft.com/en-us/library/1kt27hek.aspx
+     * and cf the man page of vsnprintf
+     *
+     Guess we need no more than 50 bytes. */
+    int n, size = 50;
+    char *res, *np;
+
+    if ((res = (char *) malloc (size)) == NULL)
+        return -1;
+
+    while (1)
+    {
+        n = vsnprintf (res, size, fmt, ap);
+
+        /* If that worked, return the string. */
+        if (n > -1 && n < size)
+        {
+            *strp = res;
+            return n;
+        }
+
+        /* Else try again with more space. */
+        if (n == -1)
+            size *= 2;  /* twice the old size */
+
+        if ((np = (char *) realloc (res, size)) == NULL)
+        {
+            free(res);
+            return -1;
+        }
+        else
+        {
+            res = np;
+        }
+
+    }
+#endif /* UNDER_CE */
 }
 #endif
 
index de383f1d080157466e05535b5d5ae721a9610ab7..7b2f07b62d842a9a77fbebbe27ca3fe537e822a4 100644 (file)
 /* Define different priorities for WinNT/2K/XP and Win9x/Me */
 #   define VLC_THREAD_PRIORITY_LOW 0
 #   define VLC_THREAD_PRIORITY_INPUT \
-        (IS_WINNT ? THREAD_PRIORITY_ABOVE_NORMAL : 0)
+        THREAD_PRIORITY_ABOVE_NORMAL
 #   define VLC_THREAD_PRIORITY_AUDIO \
-        (IS_WINNT ? THREAD_PRIORITY_HIGHEST : 0)
-#   define VLC_THREAD_PRIORITY_VIDEO \
-        (IS_WINNT ? 0 : THREAD_PRIORITY_BELOW_NORMAL )
+        THREAD_PRIORITY_HIGHEST
+#   define VLC_THREAD_PRIORITY_VIDEO 0
 #   define VLC_THREAD_PRIORITY_OUTPUT \
-        (IS_WINNT ? THREAD_PRIORITY_ABOVE_NORMAL : 0)
+        THREAD_PRIORITY_ABOVE_NORMAL
 #   define VLC_THREAD_PRIORITY_HIGHEST \
-        (IS_WINNT ? THREAD_PRIORITY_TIME_CRITICAL : 0)
+        THREAD_PRIORITY_TIME_CRITICAL
 
 #else
 #   define VLC_THREAD_PRIORITY_LOW 0
index 6b4ddbfc3b3a610878dcf7fe85bf9075ea65eee7..6ffa9f792d2f0320a996cfb77334707848537784 100644 (file)
@@ -264,7 +264,7 @@ block_t *screen_Capture( demux_t *p_demux )
                  p_sys->fmt.video.i_width, p_data->i_fragment_size,
                  p_data->hdc_src, p_sys->i_left, p_sys->i_top +
                  p_data->i_fragment * p_data->i_fragment_size,
-                 IS_WINNT ? SRCCOPY | CAPTUREBLT : SRCCOPY ) )
+                 SRCCOPY | CAPTUREBLT ) )
     {
         msg_Err( p_demux, "error during BitBlt()" );
         return NULL;
index 4b52a602403a92d3d88bb8035df4055db228bc39..7432db8542240ca820aa06fed6944cd95c7e2df2 100644 (file)
@@ -107,9 +107,6 @@ static int Activate( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
 
-    /* Only works on NT/2K/XP */
-    if( !IS_WINNT ) return VLC_EGENERIC;
-
     p_intf->pf_run = Run;
     return VLC_SUCCESS;
 }
index f20b8a31d5b4e0385d15a72f11c55d708e4814f5..70b5d66c846d52fa943441aff3dd00843e7073e7 100644 (file)
@@ -234,7 +234,7 @@ char *vlc_strsep( char **ppsz_string, const char *psz_delimiters )
  * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
  * when called with an empty argument or just '\'
  *****************************************************************************/
-#if defined(WIN32) && !defined(UNDER_CE)
+#if defined(WIN32)
 #   include <assert.h>
 
 typedef struct vlc_DIR
@@ -330,7 +330,7 @@ void vlc_rewinddir( void *_p_dir )
 /* This one is in the libvlccore exported symbol list */
 int vlc_wclosedir( void *_p_dir )
 {
-#if defined(WIN32) && !defined(UNDER_CE)
+#if defined(WIN32)
     vlc_DIR *p_dir = (vlc_DIR *)_p_dir;
     int i_ret = 0;
 
index 6770a3fdcc78a60da6e3f671944e7179ab3dc165..91a5c12ad2e3dcc6c9345561dcd7d05f24ca5dbd 100644 (file)
@@ -183,16 +183,17 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
     wchar_t psz_wfile[MAX_PATH];
     MultiByteToWideChar( CP_ACP, 0, psz_file, -1, psz_wfile, MAX_PATH );
 
+#ifndef UNDER_CE
     /* FIXME: this is not thread-safe -- Courmisch */
     UINT mode = SetErrorMode (SEM_FAILCRITICALERRORS);
     SetErrorMode (mode|SEM_FAILCRITICALERRORS);
+#endif
 
-#ifdef UNDER_CE
-    handle = LoadLibrary( psz_wfile );
-#else
     handle = LoadLibraryW( psz_wfile );
-#endif
+
+#ifndef UNDER_CE
     SetErrorMode (mode);
+#endif
 
     if( handle == NULL )
     {
index 036027cfdbf2dd5d02261d4c06b543eb50d9359a..299e3668f46fe33c4fed72e0a863a10ff3fd1016 100644 (file)
@@ -262,25 +262,26 @@ char *ToLocaleDup (const char *utf8)
  */
 int utf8_open (const char *filename, int flags, mode_t mode)
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    if (GetVersion() < 0x80000000)
+#ifdef UNDER_CE
+    /*_open translates to wchar internally on WinCE*/
+    return _open (filename, flags, mode);
+#elif defined (WIN32)
+    /* for Windows NT and above */
+    wchar_t wpath[MAX_PATH + 1];
+
+    if (!MultiByteToWideChar (CP_UTF8, 0, filename, -1, wpath, MAX_PATH))
     {
-        /* for Windows NT and above */
-        wchar_t wpath[MAX_PATH + 1];
+        errno = ENOENT;
+        return -1;
+    }
+    wpath[MAX_PATH] = L'\0';
 
-        if (!MultiByteToWideChar (CP_UTF8, 0, filename, -1, wpath, MAX_PATH))
-        {
-            errno = ENOENT;
-            return -1;
-        }
-        wpath[MAX_PATH] = L'\0';
+    /*
+        * open() cannot open files with non-“ANSI” characters on Windows.
+        * We use _wopen() instead. Same thing for mkdir() and stat().
+        */
+    return _wopen (wpath, flags, mode);
 
-        /*
-         * open() cannot open files with non-“ANSI” characters on Windows.
-         * We use _wopen() instead. Same thing for mkdir() and stat().
-         */
-        return _wopen (wpath, flags, mode);
-    }
 #endif
     const char *local_name = ToLocale (filename);
 
@@ -573,22 +574,22 @@ int utf8_scandir( const char *dirname, char ***namelist,
 static int utf8_statEx( const char *filename, struct stat *buf,
                         bool deref )
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    /* retrieve Windows OS version */
-    if( GetVersion() < 0x80000000 )
+#ifdef UNDER_CE
+    /*_stat translates to wchar internally on WinCE*/
+    return _stat( filename, buf );
+#elif defined (WIN32)
+    /* for Windows NT and above */
+    wchar_t wpath[MAX_PATH + 1];
+
+    if( !MultiByteToWideChar( CP_UTF8, 0, filename, -1, wpath, MAX_PATH ) )
     {
-        /* for Windows NT and above */
-        wchar_t wpath[MAX_PATH + 1];
+        errno = ENOENT;
+        return -1;
+    }
+    wpath[MAX_PATH] = L'\0';
 
-        if( !MultiByteToWideChar( CP_UTF8, 0, filename, -1, wpath, MAX_PATH ) )
-        {
-            errno = ENOENT;
-            return -1;
-        }
-        wpath[MAX_PATH] = L'\0';
+    return _wstati64( wpath, buf );
 
-        return _wstati64( wpath, buf );
-    }
 #endif
 #ifdef HAVE_SYS_STAT_H
     const char *local_name = ToLocale( filename );
@@ -636,25 +637,25 @@ int utf8_lstat( const char *filename, struct stat *buf)
  */
 int utf8_unlink( const char *filename )
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    if( GetVersion() < 0x80000000 )
-    {
-        /* for Windows NT and above */
-        wchar_t wpath[MAX_PATH + 1];
-
-        if( !MultiByteToWideChar( CP_UTF8, 0, filename, -1, wpath, MAX_PATH ) )
-        {
-            errno = ENOENT;
-            return -1;
-        }
-        wpath[MAX_PATH] = L'\0';
+#ifdef UNDER_CE
+    /*_open translates to wchar internally on WinCE*/
+    return _unlink( filename );
+#elif defined (WIN32)
+    /* for Windows NT and above */
+    wchar_t wpath[MAX_PATH + 1];
 
-        /*
-         * unlink() cannot open files with non-“ANSI” characters on Windows.
-         * We use _wunlink() instead.
-         */
-        return _wunlink( wpath );
+    if( !MultiByteToWideChar( CP_UTF8, 0, filename, -1, wpath, MAX_PATH ) )
+    {
+        errno = ENOENT;
+        return -1;
     }
+    wpath[MAX_PATH] = L'\0';
+
+    /*
+        * unlink() cannot open files with non-“ANSI” characters on Windows.
+        * We use _wunlink() instead.
+        */
+    return _wunlink( wpath );
 #endif
     const char *local_name = ToLocale( filename );