src: multiple Windows fixes

- Cross platform implementations of sleep and snprintf.
This commit is contained in:
Santiago Gimeno
2015-05-22 14:32:13 +02:00
parent 0c5e07e0e5
commit 1a3c7dec1c
3 changed files with 24 additions and 2 deletions

View File

@@ -11,6 +11,10 @@
#include <winscard.h> #include <winscard.h>
#endif #endif
#ifdef _WIN32
#define MAX_ATR_SIZE 33
#endif
static v8::Persistent<v8::String> name_symbol; static v8::Persistent<v8::String> name_symbol;
static v8::Persistent<v8::String> connected_symbol; static v8::Persistent<v8::String> connected_symbol;

View File

@@ -3,7 +3,26 @@
#define ERR_MSG_MAX_LEN 512 #define ERR_MSG_MAX_LEN 512
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#define Sleep(x) usleep((x)*1000)
#endif
#ifdef _WIN32
#define snprintf _snprintf
#endif
namespace { namespace {
#ifdef _WIN32
const char *pcsc_stringify_error(const LONG) {
return "";
}
#endif
std::string error_msg(const char* method, LONG result) { std::string error_msg(const char* method, LONG result) {
char msg[ERR_MSG_MAX_LEN]; char msg[ERR_MSG_MAX_LEN];
snprintf(msg, snprintf(msg,

View File

@@ -1,4 +1,3 @@
#include <unistd.h>
#include "pcsclite.h" #include "pcsclite.h"
#include "common.h" #include "common.h"
@@ -193,7 +192,7 @@ void PCSCLite::HandlerFunction(void* arg) {
uv_mutex_unlock(&pcsclite->m_mutex); uv_mutex_unlock(&pcsclite->m_mutex);
} else { } else {
/* If PnP is not supported, just wait for 1 second */ /* If PnP is not supported, just wait for 1 second */
sleep(1); Sleep(1000);
} }
} }