On Mon, Jun 26, 2006 at 09:00:11PM +0200, Peter Stuge wrote: > On Mon, Jun 26, 2006 at 09:34:35AM +0200, Andreas Jellinghaus wrote: > > diff -udrNPp --exclude=.svn opensc.orig/src/libopensc/ctx.c > > opensc/src/libopensc/ctx.c > > --- opensc.orig/src/libopensc/ctx.c 2006-06-08 09:08:52.000000000 +0200 > > +++ opensc/src/libopensc/ctx.c 2006-06-26 09:28:32.000000000 +0200 > > @@ -555,16 +555,19 @@ static void process_config_file(sc_conte > > Looks good. Perhaps there could be a compiled-in default also for > WIN32, that way the code would be slightly cleaner.
(ie. the getenv() is outside the ifdef..) If there's a good default path for WIN32 as well we could just remove the final check inside the ifdef. //Peter Index: ctx.c =================================================================== --- ctx.c (revision 2977) +++ ctx.c (working copy) @@ -554,17 +554,21 @@ #endif memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks)); + conf_path = getenv("OPENSC_CONF"); + #ifdef _WIN32 - rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\OpenSC", - 0, KEY_QUERY_VALUE, &hKey ); - if( rc == ERROR_SUCCESS ) { - temp_len = PATH_MAX; - rc = RegQueryValueEx( hKey, "ConfigFile", NULL, NULL, - (LPBYTE) temp_path, &temp_len); - if( (rc == ERROR_SUCCESS) && (temp_len < PATH_MAX) ) - conf_path = temp_path; - RegCloseKey( hKey ); - } + if (! conf_path) { + rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\OpenSC", + 0, KEY_QUERY_VALUE, &hKey ); + if( rc == ERROR_SUCCESS ) { + temp_len = PATH_MAX; + rc = RegQueryValueEx( hKey, "ConfigFile", NULL, NULL, + (LPBYTE) temp_path, &temp_len); + if( (rc == ERROR_SUCCESS) && (temp_len < PATH_MAX) ) + conf_path = temp_path; + RegCloseKey( hKey ); + } + } if (! conf_path) { rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\OpenSC", @@ -583,12 +587,9 @@ sc_debug(ctx, "process_config_file doesn't find opensc config file. Please set the registry key."); return; } - -#else - conf_path = getenv("OPENSC_CONF"); +#endif if (!conf_path) conf_path = OPENSC_CONF_PATH; -#endif ctx->conf = scconf_new(conf_path); if (ctx->conf == NULL) return; _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel