Discussion:
[libdvdcss-devel] [PATCH] Win32: use directly SHGetFolderPath
Diego Biurrun
2013-03-23 04:27:06 UTC
Permalink
From: Jean-Baptiste Kempf <***@videolan.org>

This drops support for IE < 5.0
---
configure.ac | 4 ++--
msvc/config.h | 9 +++++----
src/libdvdcss.c | 43 ++++++++-----------------------------------
3 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3d3a5fe..ae21fcb 100644
--- 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*)
;;
diff --git a/msvc/config.h b/msvc/config.h
index 0d5e3c3..8fb9e5f 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -30,13 +30,14 @@
/* #undef HPUX_SCTL_IO */
#define PACKAGE "libdvdcss"
#define PACKAGE_BUGREPORT ""
-#define PACKAGE_NAME ""
-#define PACKAGE_STRING ""
-#define PACKAGE_TARNAME ""
+#define PACKAGE_NAME "libdvdcss"
+#define PACKAGE_STRING "libdvdcss 1.2.13"
+#define PACKAGE_TARNAME "libdvdcss"
#define PACKAGE_VERSION ""
/* #undef SOLARIS_USCSI */
#define STDC_HEADERS 1
-#define VERSION "1.2.11"
+#define VERSION "1.2.13"
+#define _WIN32_IE 0x0500
/* #undef const */
/* #undef inline */
/* #undef size_t */
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index cbda930..a5014b4 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -119,6 +119,10 @@
# include <limits.h>
#endif

+#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
+# include <shlobj.h>
+#endif
+
#include "dvdcss/dvdcss.h"

#include "common.h"
@@ -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;
}
--
1.7.9.5
Diego Biurrun
2013-03-23 04:41:54 UTC
Permalink
Post by Diego Biurrun
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
Diego Biurrun
2013-03-23 04:53:15 UTC
Permalink
Post by Diego Biurrun
--- 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.])
Adding this define for Cygwin as well fixes compilation.

Diego
Diego Elio Pettenò
2013-03-23 16:03:26 UTC
Permalink
Post by Diego Biurrun
This drops support for IE < 5.0
So if we use localdata on Windows, and somebody does not want to use
cache on Linux, can we at least use XDG_DATA_HOME (.local/share) on Unix?

libbluray is doing that now isn't it?
--
Diego Elio Pettenò — Flameeyes
***@flameeyes.eu — http://blog.flameeyes.eu/
Reimar Döffinger
2013-03-23 18:39:23 UTC
Permalink
Post by Diego Elio Pettenò
Post by Diego Biurrun
This drops support for IE < 5.0
So if we use localdata on Windows, and somebody does not want to use
cache on Linux, can we at least use XDG_DATA_HOME (.local/share) on Unix?
I have no real objection to anything that isn't cache, even though I don't particularly like the xdg stuff.
Diego Biurrun
2013-03-25 10:18:32 UTC
Permalink
Post by Diego Elio Pettenò
Post by Diego Biurrun
This drops support for IE < 5.0
So if we use localdata on Windows, and somebody does not want to use
cache on Linux, can we at least use XDG_DATA_HOME (.local/share) on Unix?
libbluray is doing that now isn't it?
I'm not opposed to any of the XDG stuff, but I'm also somewhat sceptical
about calling the CSS keys cached data that can be removed at any time.
How much of a space saving are we talking about and how hard is it to
recreate the keys? Apparently in some cases the keys are hard to
regenerate.

Diego
Diego Elio Pettenò
2013-03-25 10:39:49 UTC
Permalink
Post by Diego Biurrun
I'm not opposed to any of the XDG stuff, but I'm also somewhat sceptical
about calling the CSS keys cached data that can be removed at any time.
How much of a space saving are we talking about and how hard is it to
recreate the keys? Apparently in some cases the keys are hard to
regenerate.
XDG_DATA_HOME is not a scratch path. It would basically just mean having
the data together with the other data rather than using yet another
top-level dot dir.
--
Diego Elio Pettenò — Flameeyes
***@flameeyes.eu — http://blog.flameeyes.eu/
Diego Biurrun
2013-03-25 10:51:11 UTC
Permalink
Post by Diego Elio Pettenò
Post by Diego Biurrun
I'm not opposed to any of the XDG stuff, but I'm also somewhat sceptical
about calling the CSS keys cached data that can be removed at any time.
How much of a space saving are we talking about and how hard is it to
recreate the keys? Apparently in some cases the keys are hard to
regenerate.
XDG_DATA_HOME is not a scratch path. It would basically just mean having
the data together with the other data rather than using yet another
top-level dot dir.
I don't mind. I've come to stop disliking the XDG stuff.

Diego

Loading...