Skip to content

Commit

Permalink
Merge pull request #10 from kazuki0824/fix/widechar
Browse files Browse the repository at this point in the history
Windows+MinGWでのみ発生する文字列型の不一致・ヘッダを解消
  • Loading branch information
tsukumijima authored Aug 16, 2024
2 parents f4a1d2b + 9ec119f commit bb8b1b7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
15 changes: 7 additions & 8 deletions aribb25/b_cas_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include <winscard.h>
#if defined(_WIN32)
# include <windows.h>
# include <tchar.h>
#else
# define TCHAR char
# if !defined(__CYGWIN__)
# include <wintypes.h>
# endif
Expand All @@ -20,6 +18,7 @@
# endif
# define _tcslen strlen
# define _tcscmp strcmp
# define _tcscpy strcpy
# define _T(x) x
#endif

Expand Down Expand Up @@ -102,7 +101,7 @@ static const uint8_t EMM_RECEIVE_CMD_HEADER[] = {
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
static void release_b_cas_card(void *bcas);
static int init_b_cas_card(void *bcas);
static int init_b_cas_card_with_name(void *bcas, const char * card_reader_name);
static int init_b_cas_card_with_name(void *bcas, const TCHAR * card_reader_name);
static int get_init_status_b_cas_card(void *bcas, B_CAS_INIT_STATUS *stat);
static int get_id_b_cas_card(void *bcas, B_CAS_ID *dst);
static int get_pwr_on_ctrl_b_cas_card(void *bcas, B_CAS_PWR_ON_CTRL_INFO *dst);
Expand Down Expand Up @@ -140,10 +139,10 @@ B_CAS_CARD *create_b_cas_card(void)
return r;
}

static char pattern[1024] = "";
int override_card_reader_name_pattern(const char * name) {
static const TCHAR pattern[1024] = _T("");
int override_card_reader_name_pattern(const TCHAR * name) {
if (_tcslen(name) > 0 && _tcslen(name) < 1024) {
strcpy(pattern, name);
_tcscpy(pattern, name);
return 0;
} else {
return -1;
Expand Down Expand Up @@ -222,11 +221,11 @@ static int init_b_cas_card(void *bcas)
}
#endif
else {
return init_b_cas_card_with_name(bcas, "");
return init_b_cas_card_with_name(bcas, _T(""));
}
}

static int init_b_cas_card_with_name(void *bcas, const char * card_reader_name)
static int init_b_cas_card_with_name(void *bcas, const TCHAR * card_reader_name)
{
int m;
long ret;
Expand Down
7 changes: 6 additions & 1 deletion aribb25/b_cas_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ typedef struct {
extern "C" {
#endif

#if defined(_WIN32)
# include <tchar.h>
#else
# define TCHAR char
#endif
extern B_CAS_CARD *create_b_cas_card(void);
extern int override_card_reader_name_pattern(const char * name);
extern int override_card_reader_name_pattern(const TCHAR * name);

#ifdef __cplusplus
}
Expand Down
7 changes: 6 additions & 1 deletion aribb25/version_b1.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <stdio.h>
#include <config.h>

// See https://github.com/open62541/open62541/commit/ea258bc825e7b01bc92544ac83d8215fe0c72a07
#if defined(_WIN32)
#include <stdlib.h>
#else
#include <unistd.h>
#endif
#if defined(__GNUC__) || defined(__clang__)
# if !defined(__APPLE__)
const char elf_interp[] __attribute__((section(".interp"))) = ELF_INTERP;
# endif
#include <unistd.h>

void show_version(void)
{
Expand Down
7 changes: 6 additions & 1 deletion aribb25/version_b25.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <stdio.h>
#include <config.h>

// See https://github.com/open62541/open62541/commit/ea258bc825e7b01bc92544ac83d8215fe0c72a07
#if defined(_WIN32)
#include <stdlib.h>
#else
#include <unistd.h>
#endif
#if defined(__GNUC__) || defined(__clang__)
# if !defined(__APPLE__)
const char elf_interp[] __attribute__((section(".interp"))) = ELF_INTERP;
# endif
#include <unistd.h>

void show_version(void)
{
Expand Down

0 comments on commit bb8b1b7

Please sign in to comment.