From 501cdbd7e092ab28769c472fce523ba7630bc770 Mon Sep 17 00:00:00 2001 From: okir Date: Mon, 20 Jan 2003 10:12:28 +0000 Subject: [PATCH] - Get opensc.conf from %windir% rather than hard-coded C:\\WINNT (Stef) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@875 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/include/winconfig.h | 5 ++++- src/libopensc/ctx.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/include/winconfig.h b/src/include/winconfig.h index f991d98a..aeef6c90 100644 --- a/src/include/winconfig.h +++ b/src/include/winconfig.h @@ -40,7 +40,10 @@ #define HAVE_IO_H #define HAVE_GETPASS -#define OPENSC_CONF_PATH "C:\\WINNT\\opensc.conf" +/* %windir% is replaced by the path of the Windows directory, + * this is C:\WINNT or C:\WINDOWS on most systems. + */ +#define OPENSC_CONF_PATH "%windir%\\opensc.conf" #define PATH_MAX _MAX_PATH diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index 68638c08..eab60090 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -27,6 +27,9 @@ #include #include /* for mkdir */ #include +#ifdef _WIN32 +#include +#endif int _sc_add_reader(struct sc_context *ctx, struct sc_reader *reader) { @@ -325,9 +328,19 @@ void process_config_file(struct sc_context *ctx, struct _sc_ctx_options *opts) { int i, r, count = 0; scconf_block **blocks; + char *conf_path = OPENSC_CONF_PATH; memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks)); - ctx->conf = scconf_new(OPENSC_CONF_PATH); +#ifdef _WIN32 + if (!strncmp(conf_path, "%windir%", 8)) { + static char temp_path[PATH_MAX]; + + GetWindowsDirectory(opensc_conf_path, sizeof(temp_path)); + strcat(opensc_conf_path, conf_path + 8); + conf_path = temp_path; + } +#endif + ctx->conf = scconf_new(conf_path); if (ctx->conf == NULL) return; r = scconf_parse(ctx->conf);