From d8ef40512b478d2ad3d4fae03a12de05b9601050 Mon Sep 17 00:00:00 2001 From: sth Date: Wed, 23 Apr 2003 11:46:07 +0000 Subject: [PATCH] Extended caching for single-user Windows OSes (Win98) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1069 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/ctx.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index af6949ce..a488143b 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -337,12 +337,13 @@ 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; - +#ifdef _WIN32 + char temp_path[PATH_MAX]; +#endif + memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks)); #ifdef _WIN32 if (!strncmp(conf_path, "%windir%", 8)) { - static char temp_path[PATH_MAX]; - GetWindowsDirectory(temp_path, sizeof(temp_path)); strcat(temp_path, conf_path + 8); conf_path = temp_path; @@ -468,6 +469,9 @@ int sc_get_cache_dir(struct sc_context *ctx, char *buf, size_t bufsize) { char *homedir; const char *cache_dir; +#ifdef _WIN32 + char temp_path[PATH_MAX]; +#endif #ifndef _WIN32 cache_dir = ".eid/cache"; @@ -475,6 +479,12 @@ int sc_get_cache_dir(struct sc_context *ctx, char *buf, size_t bufsize) #else cache_dir = "eid-cache"; homedir = getenv("USERPROFILE"); + /* If USERPROFILE isn't defined, assume it's a single-user OS + * and put the cache dir in the Windows dir (usually C:\\WINDOWS) */ + if (homedir == NULL || homedir[0] == '\0') { + GetWindowsDirectory(temp_path, sizeof(temp_path)); + homedir = temp_path; + } #endif if (homedir == NULL) return SC_ERROR_INTERNAL;