| 1 |
/* |
| 2 |
felicalib - FeliCa access wrapper library |
| 3 |
|
| 4 |
Copyright (c) 2007, Takuya Murakami, All rights reserved. |
| 5 |
|
| 6 |
Redistribution and use in source and binary forms, with or without |
| 7 |
modification, are permitted provided that the following conditions are |
| 8 |
met: |
| 9 |
|
| 10 |
1. Redistributions of source code must retain the above copyright notice, |
| 11 |
this list of conditions and the following disclaimer. |
| 12 |
|
| 13 |
2. Redistributions in binary form must reproduce the above copyright |
| 14 |
notice, this list of conditions and the following disclaimer in the |
| 15 |
documentation and/or other materials provided with the distribution. |
| 16 |
|
| 17 |
3. Neither the name of the project nor the names of its contributors |
| 18 |
may be used to endorse or promote products derived from this software |
| 19 |
without specific prior written permission. |
| 20 |
|
| 21 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 24 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 25 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 26 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 27 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 28 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 29 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 |
*/ |
| 33 |
/** |
| 34 |
@file felicalib.h |
| 35 |
|
| 36 |
���C���w�b�_ |
| 37 |
*/ |
| 38 |
/** |
| 39 |
@mainpage |
| 40 |
|
| 41 |
API �d�l�����������A felicalib.h ���Q���������B |
| 42 |
*/ |
| 43 |
#ifndef _FELICALIB_H |
| 44 |
#define _FELICALIB_H |
| 45 |
|
| 46 |
#include <windows.h> |
| 47 |
#include <tchar.h> |
| 48 |
|
| 49 |
typedef unsigned char uint8; |
| 50 |
typedef unsigned short int uint16; |
| 51 |
|
| 52 |
typedef struct strpasori pasori; |
| 53 |
|
| 54 |
#define MAX_SYSTEM_CODE 8 |
| 55 |
#define MAX_AREA_CODE 16 |
| 56 |
#define MAX_SERVICE_CODE 256 |
| 57 |
|
| 58 |
/** |
| 59 |
@brief FeliCa �n���h�� |
| 60 |
|
| 61 |
FeliCa ���������i�[�����\���� |
| 62 |
*/ |
| 63 |
typedef struct strfelica { |
| 64 |
pasori *p; /**< PaSoRi �n���h�� */ |
| 65 |
uint16 systemcode; /**< �V�X�e���R�[�h */ |
| 66 |
uint8 IDm[8]; /**< IDm */ |
| 67 |
uint8 PMm[8]; /**< PMm */ |
| 68 |
|
| 69 |
/* systemcode */ |
| 70 |
uint8 num_system_code; /**< �����V�X�e���R�[�h�� */ |
| 71 |
uint16 system_code[MAX_SYSTEM_CODE]; /**< �����V�X�e���R�[�h */ |
| 72 |
|
| 73 |
/* area/service codes */ |
| 74 |
uint8 num_area_code; /**< �G���A�R�[�h�� */ |
| 75 |
uint16 area_code[MAX_AREA_CODE]; /**< �G���A�R�[�h */ |
| 76 |
uint16 end_service_code[MAX_AREA_CODE]; /**< �G���h�T�[�r�X�R�[�h */ |
| 77 |
|
| 78 |
uint8 num_service_code; /**< �T�[�r�X�R�[�h�� */ |
| 79 |
uint16 service_code[MAX_SERVICE_CODE]; /**< �T�[�r�X�R�[�h */ |
| 80 |
} felica; |
| 81 |
|
| 82 |
/* constants */ |
| 83 |
/* �V�X�e���R�[�h (�l�b�g���[�N�o�C�g�I�[�_/�r�b�N�G���f�B�A�����\�L) */ |
| 84 |
#define POLLING_ANY 0xffff |
| 85 |
#define POLLING_EDY 0xfe00 /**< �V�X�e���R�[�h: �������� (Edy �������g�p) */ |
| 86 |
#define POLLING_SUICA 0x0003 /**< �V�X�e���R�[�h: �T�C�o�l���� */ |
| 87 |
|
| 88 |
/* endian */ |
| 89 |
/** �o�C�g�I�[�_����(16bit) */ |
| 90 |
#define SW2B(x) (((x) >> 8) & 0xff | ((x) << 8) & 0xff00) |
| 91 |
/** �l�b�g���[�N�o�C�g�I�[�_�����z�X�g�o�C�g�I�[�_��������(16bit) */ |
| 92 |
#define N2HS(x) SW2B(x) |
| 93 |
/** �z�X�g�o�C�g�I�[�_�����l�b�g���[�N�o�C�g�I�[�_��������(16bit) */ |
| 94 |
#define H2NS(x) SW2B(x) |
| 95 |
|
| 96 |
/* APIs */ |
| 97 |
#ifdef __cplusplus |
| 98 |
extern "C" { |
| 99 |
#endif |
| 100 |
|
| 101 |
pasori *pasori_open(char *); |
| 102 |
pasori *pasori_open2(TCHAR *); |
| 103 |
void pasori_close(pasori *); |
| 104 |
|
| 105 |
int pasori_init(pasori *); |
| 106 |
felica* felica_polling(pasori *, uint16, uint8, uint8); |
| 107 |
void felica_free(felica *f); |
| 108 |
void felica_getidm(felica *f, uint8 *buf); |
| 109 |
void felica_getpmm(felica *f, uint8 *buf); |
| 110 |
|
| 111 |
int felica_read_without_encryption02(felica *f, int servicecode, int mode, uint8 addr, uint8 *b); |
| 112 |
|
| 113 |
int felica_write_without_encryption(felica *f, int servicecode, uint8 addr, uint8 *b); // WARNING! NOT TESTED!! |
| 114 |
|
| 115 |
felica * felica_enum_systemcode(pasori *p); |
| 116 |
felica * felica_enum_service(pasori *p, uint16 systemcode); |
| 117 |
|
| 118 |
#ifdef __cplusplus |
| 119 |
} |
| 120 |
#endif |
| 121 |
|
| 122 |
#endif /* _FELICALIB_H */ |
| 123 |
|