- Timestamp:
- 08/01/10 11:27:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/ifd_azbox.c
r2885 r2887 1 1 2 2 #include "ifd_azbox.h" 3 #include"icc_async.h" 4 5 int _GetStatus(struct s_reader *reader, int *in) 6 { 7 unsigned char tmp[512]; 8 memset (tmp, 0, sizeof(tmp)); 9 10 return ioctl(reader->handle, SCARD_IOC_CHECKCARD, &tmp); 11 } 3 12 4 13 int Azbox_Init(struct s_reader *reader) 5 14 { 6 if ((reader->handle = openxcas_get_smartcard_device(0)) < 0) 7 return 0; 15 cs_debug("openxcas sc: init"); 8 16 9 return 1; 17 if ((reader->handle = openxcas_get_smartcard_device(0)) < 0) { 18 cs_debug("openxcas sc: init failed (%d)", reader->handle); 19 return FALSE; 20 } 21 22 cs_debug("openxcas sc: init succeeded"); 23 24 return OK; 10 25 } 11 26 … … 15 30 memset (tmp, 0, sizeof(tmp)); 16 31 17 int status = ioctl(reader->handle, SCARD_IOC_CHECKCARD, &tmp);32 int status = _GetStatus(reader, in); 18 33 19 if (status != 1 && status != 3 && in != NULL) 20 *in = 0; 21 else 22 *in = 1; 34 if (in) { 35 if (status != 1 && status != 3) 36 *in = 0; 37 else 38 *in = 1; 23 39 24 return status; 40 cs_debug("openxcas sc: get status = %d", *in); 41 } 42 43 return OK; 25 44 } 26 45 … … 38 57 cs_sleepms(500); 39 58 40 while ((status = Azbox_GetStatus(reader, NULL)) != 3)59 while ((status = _GetStatus(reader, NULL)) != 3) 41 60 cs_sleepms(50); 42 61 … … 46 65 int atr_len = ioctl(reader->handle, SCARD_IOC_CHECKCARD, &tmp); 47 66 if (ATR_InitFromArray(atr, tmp, atr_len) != ATR_OK) 48 return 0;67 return FALSE; 49 68 50 69 cs_sleepms(500); 51 70 52 return 1;71 return OK; 53 72 } 54 73 … … 56 75 { 57 76 if (write(reader->handle, buffer, size) != size) 58 return 0;77 return FALSE; 59 78 60 return 1;79 return OK; 61 80 } 62 81 … … 64 83 { 65 84 if (read(reader->handle, buffer, size) != size) 66 return 0;85 return FALSE; 67 86 68 return 1;87 return OK; 69 88 } 70 89 … … 73 92 openxcas_release_smartcard_device(0); 74 93 75 return 1;94 return OK; 76 95 }
Note:
See TracChangeset
for help on using the changeset viewer.