mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
PC/SC cleanup.
* g10/apdu.c (pcsc_dword_t): New. It was named as DWORD (double-word) when a word was 16-bit. (struct reader_table_s): Fixes for types. (struct pcsc_readerstate_s) [__APPLE__]: Enable #pragma pack(1). Throughout: Fixes for types. -- GnuPG-bug-id: 1358 This is a backport of commit ae22d629b6028aa994ff09f012e1cb029575eeae.
This commit is contained in:
parent
4239780d5a
commit
60bd6488c0
99
g10/apdu.c
99
g10/apdu.c
@ -83,6 +83,12 @@
|
||||
#define DLSTDCALL
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(_WIN32) || defined(__CYGWIN__)
|
||||
typedef unsinged int pcsc_dword_t;
|
||||
#else
|
||||
typedef unsigned long pcsc_dword_t;
|
||||
#endif
|
||||
|
||||
|
||||
/* Helper to pass parameters related to keypad based operations. */
|
||||
struct pininfo_s
|
||||
@ -116,9 +122,9 @@ struct reader_table_s {
|
||||
ccid_driver_t handle;
|
||||
} ccid;
|
||||
struct {
|
||||
unsigned long context;
|
||||
unsigned long card;
|
||||
unsigned long protocol;
|
||||
long context;
|
||||
long card;
|
||||
pcsc_dword_t protocol;
|
||||
#ifdef NEED_PCSC_WRAPPER
|
||||
int req_fd;
|
||||
int rsp_fd;
|
||||
@ -234,60 +240,67 @@ struct pcsc_io_request_s
|
||||
|
||||
typedef struct pcsc_io_request_s *pcsc_io_request_t;
|
||||
|
||||
#ifdef __APPLE__
|
||||
# pragma pack(1)
|
||||
#endif
|
||||
struct pcsc_readerstate_s
|
||||
{
|
||||
const char *reader;
|
||||
void *user_data;
|
||||
unsigned long current_state;
|
||||
unsigned long event_state;
|
||||
unsigned long atrlen;
|
||||
pcsc_dword_t current_state;
|
||||
pcsc_dword_t event_state;
|
||||
pcsc_dword_t atrlen;
|
||||
unsigned char atr[33];
|
||||
};
|
||||
#ifdef __APPLE__
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
typedef struct pcsc_readerstate_s *pcsc_readerstate_t;
|
||||
|
||||
long (* DLSTDCALL pcsc_establish_context) (unsigned long scope,
|
||||
long (* DLSTDCALL pcsc_establish_context) (pcsc_dword_t scope,
|
||||
const void *reserved1,
|
||||
const void *reserved2,
|
||||
unsigned long *r_context);
|
||||
long (* DLSTDCALL pcsc_release_context) (unsigned long context);
|
||||
long (* DLSTDCALL pcsc_list_readers) (unsigned long context,
|
||||
long *r_context);
|
||||
long (* DLSTDCALL pcsc_release_context) (long context);
|
||||
long (* DLSTDCALL pcsc_list_readers) (long context,
|
||||
const char *groups,
|
||||
char *readers, unsigned long*readerslen);
|
||||
long (* DLSTDCALL pcsc_get_status_change) (unsigned long context,
|
||||
unsigned long timeout,
|
||||
char *readers,
|
||||
pcsc_dword_t *readerslen);
|
||||
long (* DLSTDCALL pcsc_get_status_change) (long context,
|
||||
pcsc_dword_t timeout,
|
||||
pcsc_readerstate_t readerstates,
|
||||
unsigned long nreaderstates);
|
||||
long (* DLSTDCALL pcsc_connect) (unsigned long context,
|
||||
pcsc_dword_t nreaderstates);
|
||||
long (* DLSTDCALL pcsc_connect) (long context,
|
||||
const char *reader,
|
||||
unsigned long share_mode,
|
||||
unsigned long preferred_protocols,
|
||||
unsigned long *r_card,
|
||||
unsigned long *r_active_protocol);
|
||||
long (* DLSTDCALL pcsc_reconnect) (unsigned long card,
|
||||
unsigned long share_mode,
|
||||
unsigned long preferred_protocols,
|
||||
unsigned long initialization,
|
||||
unsigned long *r_active_protocol);
|
||||
long (* DLSTDCALL pcsc_disconnect) (unsigned long card,
|
||||
unsigned long disposition);
|
||||
long (* DLSTDCALL pcsc_status) (unsigned long card,
|
||||
char *reader, unsigned long *readerlen,
|
||||
unsigned long *r_state,
|
||||
unsigned long *r_protocol,
|
||||
unsigned char *atr, unsigned long *atrlen);
|
||||
long (* DLSTDCALL pcsc_begin_transaction) (unsigned long card);
|
||||
long (* DLSTDCALL pcsc_end_transaction) (unsigned long card,
|
||||
unsigned long disposition);
|
||||
long (* DLSTDCALL pcsc_transmit) (unsigned long card,
|
||||
pcsc_dword_t share_mode,
|
||||
pcsc_dword_t preferred_protocols,
|
||||
long *r_card,
|
||||
pcsc_dword_t *r_active_protocol);
|
||||
long (* DLSTDCALL pcsc_reconnect) (long card,
|
||||
pcsc_dword_t share_mode,
|
||||
pcsc_dword_t preferred_protocols,
|
||||
pcsc_dword_t initialization,
|
||||
pcsc_dword_t *r_active_protocol);
|
||||
long (* DLSTDCALL pcsc_disconnect) (long card,
|
||||
pcsc_dword_t disposition);
|
||||
long (* DLSTDCALL pcsc_status) (long card,
|
||||
char *reader, pcsc_dword_t *readerlen,
|
||||
pcsc_dword_t *r_state,
|
||||
pcsc_dword_t *r_protocol,
|
||||
unsigned char *atr, pcsc_dword_t *atrlen);
|
||||
long (* DLSTDCALL pcsc_begin_transaction) (long card);
|
||||
long (* DLSTDCALL pcsc_end_transaction) (long card,
|
||||
pcsc_dword_t disposition);
|
||||
long (* DLSTDCALL pcsc_transmit) (long card,
|
||||
const pcsc_io_request_t send_pci,
|
||||
const unsigned char *send_buffer,
|
||||
unsigned long send_len,
|
||||
pcsc_dword_t send_len,
|
||||
pcsc_io_request_t recv_pci,
|
||||
unsigned char *recv_buffer,
|
||||
unsigned long *recv_len);
|
||||
long (* DLSTDCALL pcsc_set_timeout) (unsigned long context,
|
||||
unsigned long timeout);
|
||||
pcsc_dword_t *recv_len);
|
||||
long (* DLSTDCALL pcsc_set_timeout) (long context,
|
||||
pcsc_dword_t timeout);
|
||||
|
||||
|
||||
/* Prototypes. */
|
||||
@ -990,7 +1003,7 @@ pcsc_send_apdu_direct (int slot, unsigned char *apdu, size_t apdulen,
|
||||
{
|
||||
long err;
|
||||
struct pcsc_io_request_s send_pci;
|
||||
unsigned long recv_len;
|
||||
pcsc_dword_t recv_len;
|
||||
|
||||
if (!reader_table[slot].atrlen
|
||||
&& (err = reset_pcsc_reader (slot)))
|
||||
@ -1276,8 +1289,8 @@ connect_pcsc_card (int slot)
|
||||
else
|
||||
{
|
||||
char reader[250];
|
||||
unsigned long readerlen, atrlen;
|
||||
unsigned long card_state, card_protocol;
|
||||
pcsc_dword_t readerlen, atrlen;
|
||||
long card_state, card_protocol;
|
||||
|
||||
atrlen = DIM (reader_table[0].atr);
|
||||
readerlen = sizeof reader -1 ;
|
||||
@ -1473,7 +1486,7 @@ open_pcsc_reader_direct (const char *portstr)
|
||||
long err;
|
||||
int slot;
|
||||
char *list = NULL;
|
||||
unsigned long nreader;
|
||||
pcsc_dword_t nreader;
|
||||
char *p;
|
||||
|
||||
slot = new_reader_slot ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user