[libdvdcss-devel] [PATCH] Win32: use directly SHGetFolderPath

Diego Biurrun diego at biurrun.de
Sat Mar 23 05:41:54 CET 2013


On Sat, Mar 23, 2013 at 05:27:06AM +0100, Diego Biurrun wrote:
> From: Jean-Baptiste Kempf <jb at videolan.org>
> 
> This drops support for IE < 5.0
> --- a/configure.ac
> +++ b/configure.ac
> @@ -112,10 +112,10 @@ case x"${host_os}" in
>      ;;
>    x*msvc*)
>      SYS_MSVC=1
> -    AC_DEFINE([_WIN32_IE], 0x0401, [Define to '0x0401' for IE 4.01 (and shell) APIs.])
> +    AC_DEFINE([_WIN32_IE], 0x0500, [Define to '0x0500' for IE 5.0 (and shell) APIs.])
>      ;;
>    x*mingw* | *wince* | *mingwce*)
> -    AC_DEFINE([_WIN32_IE], 0x0401, [Define to '0x0401' for IE 4.01 (and shell) APIs.])
> +    AC_DEFINE([_WIN32_IE], 0x0500, [Define to '0x0500' for IE 5.0 (and shell) APIs.])
>      ;;
>    x*)
>      ;;
> --- a/src/libdvdcss.c
> +++ b/src/libdvdcss.c
> @@ -238,46 +242,15 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
>       */
>      if( psz_cache == NULL || psz_cache[0] == '\0' )
>      {
> -#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
> -        typedef HRESULT( WINAPI *SHGETFOLDERPATH )
> -                       ( HWND, int, HANDLE, DWORD, LPTSTR );
> -
> -#   define CSIDL_FLAG_CREATE 0x8000
> -#   define CSIDL_APPDATA 0x1A
> -#   define SHGFP_TYPE_CURRENT 0
> -
> +#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
>          char psz_home[MAX_PATH];
> -        HINSTANCE p_dll;
> -        SHGETFOLDERPATH p_getpath;
> -
> -        *psz_home = '\0';
> -
> -        /* Load the shfolder DLL to retrieve SHGetFolderPath */
> -        p_dll = LoadLibrary( "shfolder.dll" );
> -        if( p_dll )
> -        {
> -            p_getpath = (void*)GetProcAddress( p_dll, "SHGetFolderPathA" );
> -            if( p_getpath )
> -            {
> -                /* Get the "Application Data" folder for the current user */
> -                if( p_getpath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
> -                               NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK )
> -                {
> -                    FreeLibrary( p_dll );
> -                }
> -                else
> -                {
> -                    *psz_home = '\0';
> -                }
> -            }
> -            FreeLibrary( p_dll );
> -        }
>  
>          /* Cache our keys in
>           * C:\Documents and Settings\$USER\Application Data\dvdcss\ */
> -        if( *psz_home )
> +        if (SHGetFolderPathA (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
> +                              NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK)
>          {
> -            snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
> +            snprintf( psz_buffer, PATH_MAX, "%s\\dvdcss", psz_home );
>              psz_buffer[PATH_MAX-1] = '\0';
>              psz_cache = psz_buffer;
>          }

This breaks Cygwin:

make[1]: Entering directory `/home/diego/src/libdvdcss'
  CC       src/libdvdcss.lo
src/libdvdcss.c: In function 'dvdcss_open':
src/libdvdcss.c:250:9: warning: implicit declaration of function 'SHGetFolderPathA'
src/libdvdcss.c:250:37: error: 'CSIDL_APPDATA' undeclared (first use in this function)
src/libdvdcss.c:250:37: note: each undeclared identifier is reported only once for each function it appears in
src/libdvdcss.c:250:53: error: 'CSIDL_FLAG_CREATE' undeclared (first use in this function)
src/libdvdcss.c:251:37: error: 'SHGFP_TYPE_CURRENT' undeclared (first use in this function)
Makefile:507: recipe for target `src/libdvdcss.lo' failed
make[1]: *** [src/libdvdcss.lo] Error 1
make[1]: Leaving directory `/home/diego/src/libdvdcss'
Makefile:349: recipe for target `all' failed
make: *** [all] Error 2

Not sure how to fix it yet ...

Diego


More information about the libdvdcss-devel mailing list