win32: allows UNICODE built.

UNICODE is set by default by Visual Studio (but can be deactived)
The trick is to force ANSI version by appending a A to the function calls.
This commit is contained in:
vletoux 2015-03-28 10:00:47 +01:00 committed by Viktor Tarasov
parent c8d206ece1
commit 3b873adad2
5 changed files with 22 additions and 11 deletions

View File

@ -28,12 +28,12 @@
#include <windows.h>
void *sc_dlopen(const char *filename)
{
return (void *)LoadLibrary(filename);
return (void *)LoadLibraryA(filename);
}
void *sc_dlsym(void *handle, const char *symbol)
{
return GetProcAddress((HANDLE)handle, symbol);
return GetProcAddress((HMODULE)handle, symbol);
}
const char *sc_dlerror()
@ -43,7 +43,7 @@ const char *sc_dlerror()
int sc_dlclose(void *handle)
{
return FreeLibrary((HANDLE)handle);
return FreeLibrary((HMODULE)handle);
}
#else
#include <dlfcn.h>

View File

@ -1183,20 +1183,20 @@ sc_card_sm_load(struct sc_card *card, const char *module_path, const char *in_mo
#ifdef _WIN32
if (!module_path) {
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey );
rc = RegOpenKeyExA( HKEY_CURRENT_USER, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey );
if( rc == ERROR_SUCCESS ) {
temp_len = PATH_MAX;
rc = RegQueryValueEx( hKey, "SmDir", NULL, NULL, (LPBYTE) temp_path, &temp_len);
rc = RegQueryValueExA( hKey, "SmDir", NULL, NULL, (LPBYTE) temp_path, &temp_len);
if( (rc == ERROR_SUCCESS) && (temp_len < PATH_MAX) )
module_path = temp_path;
RegCloseKey( hKey );
}
}
if (!module_path) {
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey );
rc = RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey );
if( rc == ERROR_SUCCESS ) {
temp_len = PATH_MAX;
rc = RegQueryValueEx( hKey, "SmDir", NULL, NULL, (LPBYTE) temp_path, &temp_len);
rc = RegQueryValueExA( hKey, "SmDir", NULL, NULL, (LPBYTE) temp_path, &temp_len);
if(rc == ERROR_SUCCESS && temp_len < PATH_MAX)
module_path = temp_path;
RegCloseKey( hKey );

View File

@ -245,7 +245,7 @@ load_parameters(sc_context_t *ctx, scconf_block *block, struct _sc_ctx_options *
if (val) {
#ifdef _WIN32
expanded_len = PATH_MAX;
expanded_len = ExpandEnvironmentStrings(val, expanded_val, expanded_len);
expanded_len = ExpandEnvironmentStringsA(val, expanded_val, expanded_len);
if (expanded_len > 0)
val = expanded_val;
#endif
@ -552,7 +552,7 @@ static void process_config_file(sc_context_t *ctx, struct _sc_ctx_options *opts)
#ifdef _WIN32
conf_path = getenv("OPENSC_CONF");
if (!conf_path) {
rc = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey);
rc = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\OpenSC Project\\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);
@ -563,7 +563,7 @@ static void process_config_file(sc_context_t *ctx, struct _sc_ctx_options *opts)
}
if (!conf_path) {
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\OpenSC", 0, KEY_QUERY_VALUE, &hKey );
rc = RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\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);
@ -874,7 +874,7 @@ int sc_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize)
/* 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));
GetWindowsDirectoryA(temp_path, sizeof(temp_path));
homedir = temp_path;
}
#endif

View File

@ -20,6 +20,13 @@ typedef unsigned __int8 uint8_t;
#ifdef __APPLE__
#include <wintypes.h>
#endif
// allow unicode built where SCARD_READERSTATE is defined as SCARD_READERSTATEW and SCardGetStatusChange renamed to SCardGetStatusChangeW
#ifdef WIN32
#ifdef UNICODE
#define SCARD_READERSTATE SCARD_READERSTATEA
#undef SCardGetStatusChange
#endif
#endif
#else
/* mingw32 does not have winscard.h */

View File

@ -35,7 +35,11 @@
#include <sys/stat.h>
#ifdef _WIN32
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#endif
#ifdef __APPLE__