• R/O
  • SSH
  • HTTPS

felicalib: Commit


Commit MetaInfo

Revision84 (tree)
Zeit2008-04-19 18:20:07
Autortmurakam

Log Message

x64 環境対応、indentation 修正など

Ändern Zusammenfassung

Diff

--- trunk/src/nanaco/nanaco.c (revision 83)
+++ trunk/src/nanaco/nanaco.c (revision 84)
@@ -1,39 +1,39 @@
11 /*
2- felicalib - FeliCa access wrapper library
2+ felicalib - FeliCa access wrapper library
33
4- Copyright (c) 2007, Takuya Murakami, All rights reserved.
4+ Copyright (c) 2007, Takuya Murakami, All rights reserved.
55
6- Redistribution and use in source and binary forms, with or without
7- modification, are permitted provided that the following conditions are
8- met:
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are
8+ met:
99
10- 1. Redistributions of source code must retain the above copyright notice,
11- this list of conditions and the following disclaimer.
10+ 1. Redistributions of source code must retain the above copyright notice,
11+ this list of conditions and the following disclaimer.
1212
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.
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.
1616
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.
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.
2020
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.
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.
3232 */
3333 /**
34- @file nanaco.c
34+ @file nanaco.c
3535
36- nanaco ダンプ
36+ nanaco ダンプ
3737 */
3838
3939 #include <stdio.h>
@@ -53,33 +53,33 @@
5353
5454 p = pasori_open(NULL);
5555 if (!p) {
56- fprintf(stderr, "PaSoRi open failed.\n");
57- exit(1);
56+ fprintf(stderr, "PaSoRi open failed.\n");
57+ exit(1);
5858 }
5959 pasori_init(p);
6060
6161 f = felica_polling(p, 0xfe00, 0, 0);
6262 if (!f) {
63- fprintf(stderr, "Polling card failed.\n");
64- exit(1);
63+ fprintf(stderr, "Polling card failed.\n");
64+ exit(1);
6565 }
6666
6767 if (felica_read_without_encryption02(f, 0x558b, 0, 0, data)) {
68- fprintf(stderr, "Can't read nanaco ID.\n");
69- exit(1);
68+ fprintf(stderr, "Can't read nanaco ID.\n");
69+ exit(1);
7070 }
7171
7272 printf("nanaco id: ");
7373 for (i = 0; i < 8; i++) {
74- printf("%02x", data[i]);
74+ printf("%02x", data[i]);
7575 }
7676 printf("\n");
7777
7878 for (i = 0; ; i++) {
79- if (felica_read_without_encryption02(f, 0x564f, 0, (uint8)i, data)) {
80- break;
81- }
82- nanaco_dump(data);
79+ if (felica_read_without_encryption02(f, 0x564f, 0, (uint8)i, data)) {
80+ break;
81+ }
82+ nanaco_dump(data);
8383 }
8484
8585 return 0;
@@ -91,14 +91,14 @@
9191
9292 switch (data[0]) {
9393 case 0x47:
94- printf("支払 ");
95- break;
94+ printf("支払 ");
95+ break;
9696 case 0x6f:
97- printf("チャージ ");
98- break;
97+ printf("チャージ ");
98+ break;
9999 default:
100- printf("不明 ");
101- break;
100+ printf("不明 ");
101+ break;
102102 }
103103
104104 value = read4b(data + 1);
@@ -136,5 +136,3 @@
136136 v |= *p;
137137 return v;
138138 }
139-
140-
--- trunk/src/include/felicalib.h (revision 83)
+++ trunk/src/include/felicalib.h (revision 84)
@@ -41,7 +41,7 @@
4141 API 仕様については、 felicalib.h を参照のこと。
4242 */
4343 #ifndef _FELICALIB_H
44-#define _FELICALIB_H
44+#define _FELICALIB_H
4545
4646 #include <windows.h>
4747 #include <tchar.h>
@@ -51,9 +51,9 @@
5151
5252 typedef struct strpasori pasori;
5353
54-#define MAX_SYSTEM_CODE 8
55-#define MAX_AREA_CODE 16
56-#define MAX_SERVICE_CODE 256
54+#define MAX_SYSTEM_CODE 8
55+#define MAX_AREA_CODE 16
56+#define MAX_SERVICE_CODE 256
5757
5858 /**
5959 @brief FeliCa ハンドル
@@ -61,35 +61,37 @@
6161 FeliCa の情報を格納する構造体
6262 */
6363 typedef struct strfelica {
64- pasori *p; /**< PaSoRi ハンドル */
65- uint16 systemcode; /**< システムコード */
66- uint8 IDm[8]; /**< IDm */
67- uint8 PMm[8]; /**< PMm */
64+ pasori *p; /**< PaSoRi ハンドル */
65+ uint16 systemcode; /**< システムコード */
66+ uint8 IDm[8]; /**< IDm */
67+ uint8 PMm[8]; /**< PMm */
6868
6969 /* systemcode */
70- uint8 num_system_code; /**< 列挙システムコード数 */
71- uint16 system_code[MAX_SYSTEM_CODE]; /**< 列挙システムコード */
70+ uint8 num_system_code; /**< 列挙システムコード数 */
71+ uint16 system_code[MAX_SYSTEM_CODE]; /**< 列挙システムコード */
7272
7373 /* area/service codes */
74- uint8 num_area_code; /**< エリアコード数 */
75- uint16 area_code[MAX_AREA_CODE]; /**< エリアコード */
76- uint16 end_service_code[MAX_AREA_CODE]; /**< エンドサービスコード */
74+ uint8 num_area_code; /**< エリアコード数 */
75+ uint16 area_code[MAX_AREA_CODE]; /**< エリアコード */
76+ uint16 end_service_code[MAX_AREA_CODE]; /**< エンドサービスコード */
7777
78- uint8 num_service_code; /**< サービスコード数 */
79- uint16 service_code[MAX_SERVICE_CODE]; /**< サービスコード */
78+ uint8 num_service_code; /**< サービスコード数 */
79+ uint16 service_code[MAX_SERVICE_CODE]; /**< サービスコード */
8080 } felica;
8181
8282 /* constants */
8383 /* システムコード (ネットワークバイトオーダ/ビックエンディアンで表記) */
84-#define POLLING_ANY 0xffff
85-#define POLLING_EDY 0xfe00 /**< システムコード: 共通領域 (Edy などが使用) */
86-#define POLLING_SUICA 0x0003 /**< システムコード: サイバネ領域 */
84+#define POLLING_ANY 0xffff
85+#define POLLING_EDY 0xfe00 /**< システムコード: 共通領域 (Edy などが使用) */
86+#define POLLING_SUICA 0x0003 /**< システムコード: サイバネ領域 */
8787
8888 /* endian */
89+/** バイトオーダ変換(16bit) */
90+#define SW2B(x) (((x) >> 8) & 0xff | ((x) << 8) & 0xff00)
8991 /** ネットワークバイトオーダからホストバイトオーダへの変換(16bit) */
90-#define N2HS(x) (((x) >> 8) & 0xff | ((x) << 8) & 0xff00)
92+#define N2HS(x) SW2B(x)
9193 /** ホストバイトオーダからネットワークバイトオーダへの変換(16bit) */
92-#define H2NS(x) N2HS(x)
94+#define H2NS(x) SW2B(x)
9395
9496 /* APIs */
9597 #ifdef __cplusplus
--- trunk/src/suica/suica.c (revision 83)
+++ trunk/src/suica/suica.c (revision 84)
@@ -60,28 +60,28 @@
6060
6161 p = pasori_open(NULL);
6262 if (!p) {
63- fprintf(stderr, "PaSoRi open failed.\n");
64- exit(1);
63+ fprintf(stderr, "PaSoRi open failed.\n");
64+ exit(1);
6565 }
6666 pasori_init(p);
6767
6868 f = felica_polling(p, POLLING_SUICA, 0, 0);
6969 if (!f) {
70- fprintf(stderr, "Polling card failed.\n");
71- exit(1);
70+ fprintf(stderr, "Polling card failed.\n");
71+ exit(1);
7272 }
7373
7474 printf("IDm: ");
7575 for (i = 0; i < 8; i++) {
76- printf("%02x", f->IDm[i]);
76+ printf("%02x", f->IDm[i]);
7777 }
7878 printf("\n");
7979
8080 for (i = 0; ; i++) {
81- if (felica_read_without_encryption02(f, SERVICE_SUICA_HISTORY, 0, (uint8)i, data)) {
82- break;
83- }
84- suica_dump_history(data);
81+ if (felica_read_without_encryption02(f, SERVICE_SUICA_HISTORY, 0, (uint8)i, data)) {
82+ break;
83+ }
84+ suica_dump_history(data);
8585 }
8686
8787 return 0;
--- trunk/src/ChangeLog.txt (revision 83)
+++ trunk/src/ChangeLog.txt (revision 84)
@@ -1,17 +1,27 @@
1-* 2007/11/05 : v0.1
1+2008-04-19 : Takuya Murakami
2+ * indentation を修正
23
3- - 初版
4+2008-04-15 : Takuya Murakami
5+ * x64 環境で動作しない問題に対処
6+ Program Files フォルダ名が埋め込みだったため。
7+ SHGetSpecialFolderPath を使用するように修正
8+ * C# サンプルのビルドターゲットを Any CPU から x86 に変更
9+ x64環境では Any CPU では動作しないため。
410
5-* 2007/11/10 : v0.2
6-
7- - ライブラリを DLL に分離
8- - nanaco.exe を追加
9- - C# サポートを追加
11+2008-03-06 : Takuya Murakami
12+ * Suica/Edy 読み込みサンプルを追加
1013
11-* 2007/11/18 : v0.3
12-
13- - 非セキュリティエリア書き込み対応
14+2007-11-18 : Takuya Murakami
15+ * ver 0.3
16+ * 非セキュリティエリア書き込み対応
1417
15-* 2008/3/6
18+2007-11-10 : Takuya Murakami
19+ * ver 0.2
20+ * ライブラリを DLL に分離
21+ * nanaco.exe を追加
22+ * C# サポートを追加
1623
17- - Suica/Edy 読み込みサンプルを追加
24+2007-11-05 : Takuya Murakami
25+ * ver 0.1
26+ * 初版
27+
--- trunk/src/dump/dump.c (revision 83)
+++ trunk/src/dump/dump.c (revision 84)
@@ -51,15 +51,15 @@
5151
5252 p = pasori_open(NULL);
5353 if (!p) {
54- fprintf(stderr, "PaSoRi open failed.\n");
55- exit(1);
54+ fprintf(stderr, "PaSoRi open failed.\n");
55+ exit(1);
5656 }
5757 pasori_init(p);
5858
5959 f = felica_polling(p, POLLING_ANY, 0, 0);
6060 if (!f) {
61- fprintf(stderr, "Polling card failed.\n");
62- exit(1);
61+ fprintf(stderr, "Polling card failed.\n");
62+ exit(1);
6363 }
6464 printf("# IDm: ");
6565 hexdump(f->IDm, 8);
@@ -71,7 +71,7 @@
7171
7272 f = felica_enum_systemcode(p);
7373 if (!f) {
74- exit(1);
74+ exit(1);
7575 }
7676
7777 for (i = 0; i < f->num_system_code; i++) {
@@ -93,16 +93,16 @@
9393 printserviceinfo(service);
9494
9595 for (k = 0; k < 255; k++) {
96- uint8 data[16];
96+ uint8 data[16];
9797
98- if (felica_read_without_encryption02(f2, service, 0, (uint8)k, data)) {
99- break;
98+ if (felica_read_without_encryption02(f2, service, 0, (uint8)k, data)) {
99+ break;
100+ }
101+
102+ printf("%04X:%04X ", service, k);
103+ hexdump(data, 16);
104+ printf("\n");
100105 }
101-
102- printf("%04X:%04X ", service, k);
103- hexdump(data, 16);
104- printf("\n");
105- }
106106 }
107107 printf("\n");
108108 }
@@ -115,9 +115,9 @@
115115 char *ident;
116116
117117 switch ((s >> 1) & 0xf) {
118- case 0: ident = "Area Code"; break;
119- case 4: ident = "Random Access R/W"; break;
120- case 5: ident = "Random Access Read only"; break;
118+ case 0: ident = "Area Code"; break;
119+ case 4: ident = "Random Access R/W"; break;
120+ case 5: ident = "Random Access Read only"; break;
121121 case 6: ident = "Cyclic Access R/W"; break;
122122 case 7: ident = "Cyclic Access Read only"; break;
123123 case 8: ident = "Purse (Direct)"; break;
@@ -129,7 +129,7 @@
129129
130130 printf("# Serivce code = %04X : %s", s, ident);
131131 if ((s & 0x1) == 0) {
132- printf(" (Protected)");
132+ printf(" (Protected)");
133133 }
134134 printf("\n");
135135 }
@@ -138,6 +138,6 @@
138138 {
139139 int i;
140140 for (i = 0; i < n; i++) {
141- printf("%02X ", addr[i]);
141+ printf("%02X ", addr[i]);
142142 }
143143 }
--- trunk/src/lib/felicaint.h (revision 83)
+++ trunk/src/lib/felicaint.h (revision 84)
@@ -36,47 +36,47 @@
3636 内部ヘッダ
3737 */
3838
39-#ifndef _FELICAINT_H
40-#define _FELICAINT_H
39+#ifndef _FELICAINT_H
40+#define _FELICAINT_H
4141
4242 /** @brief Polling 構造体 */
4343 typedef struct {
44- uint8* system_code; ///< システムコード (2byte, ネットワークバイトオーダ)
45- uint8 time_slot; ///< タイムスロット (0x00, 0x01, 0x03, 0x07, 0x0f のいずれか)
44+ uint8* system_code; ///< システムコード (2byte, ネットワークバイトオーダ)
45+ uint8 time_slot; ///< タイムスロット (0x00, 0x01, 0x03, 0x07, 0x0f のいずれか)
4646 } POLLING;
4747
4848 /** @brief カード情報構造体 */
4949 typedef struct {
50- uint8* card_idm; ///< カードの IDm (8byte)
51- uint8* card_pmm; ///< カードの PMm (8byte)
50+ uint8* card_idm; ///< カードの IDm (8byte)
51+ uint8* card_pmm; ///< カードの PMm (8byte)
5252 } CARD_INFO;
5353
5454 /** @brief read_block_without_encryption 入力構造体 */
5555 typedef struct {
56- uint8 *card_idm; ///< IDm
57- uint8 number_of_services; ///< サービスコード数
58- uint8 *service_code_list; ///< サービスコードリスト
59- uint8 number_of_blocks; ///< ブロック数
60- uint8 *block_list; ///< ブロックリスト
56+ uint8 *card_idm; ///< IDm
57+ uint8 number_of_services; ///< サービスコード数
58+ uint8 *service_code_list; ///< サービスコードリスト
59+ uint8 number_of_blocks; ///< ブロック数
60+ uint8 *block_list; ///< ブロックリスト
6161 } INSTR_READ_BLOCK;
6262
6363 /** @brief read_block_without_encryption 出力構造体 */
6464 typedef struct {
65- uint8 *status_flag_1; ///< ステータスフラグ1
66- uint8 *status_flag_2; ///< ステータスフラグ2
67- uint8 *result_number_of_blocks; ///< データブロック数
68- uint8 *block_data; ///< データブロック
65+ uint8 *status_flag_1; ///< ステータスフラグ1
66+ uint8 *status_flag_2; ///< ステータスフラグ2
67+ uint8 *result_number_of_blocks; ///< データブロック数
68+ uint8 *block_data; ///< データブロック
6969 } OUTSTR_READ_BLOCK;
7070
7171 /** @brief write_block_without_encryption 入力構造体 */
7272 typedef struct {
73- uint8 *card_idm; ///< IDm
74- uint8 number_of_services; ///< サービスコード数
75- uint8 *service_code_list; ///< サービスコードリスト
76- uint8 number_of_blocks; ///< ブロック数
77- uint8 *block_list; ///< ブロックリスト
78- uint8 *block_data; ///< 書き込みデータ(16byte)
79-} INSTR_WRITE_BLOCK;
73+ uint8 *card_idm; ///< IDm
74+ uint8 number_of_services; ///< サービスコード数
75+ uint8 *service_code_list; ///< サービスコードリスト
76+ uint8 number_of_blocks; ///< ブロック数
77+ uint8 *block_list; ///< ブロックリスト
78+ uint8 *block_data; ///< 書き込みデータ(16byte)
79+} INSTR_WRITE_BLOCK;
8080
8181 /** @brief read_block_without_encryption 出力構造体 */
8282 typedef struct {
@@ -86,29 +86,29 @@
8686
8787 /** @brief polling_and_request_system_code 入力構造体 */
8888 typedef struct {
89- uint8 *card_idm; ///< IDm
89+ uint8 *card_idm; ///< IDm
9090 } INSTR_REQ_SYSTEM_CODE;
9191
9292 /** @brief polling_and_request_system_code 出力構造体 */
9393 typedef struct {
94- uint8 number_of_system_codes; ///< システムコード数
95- uint8 *system_code_list; ///< システムコード配列
94+ uint8 number_of_system_codes; ///< システムコード数
95+ uint8 *system_code_list; ///< システムコード配列
9696 } OUTSTR_REQ_SYSTEM_CODE;
9797
9898 /** @brief polling_and_search_service_code 入力構造体 */
9999 typedef struct {
100- int buffer_size_of_area_codes; ///< エリアコードバッファサイズ
101- int buffer_size_of_service_codes; ///< サービスコードバッファサイズ
102- int offset_of_area_service_index; ///< エリアサービスオフセット(?)
100+ int buffer_size_of_area_codes; ///< エリアコードバッファサイズ
101+ int buffer_size_of_service_codes; ///< サービスコードバッファサイズ
102+ int offset_of_area_service_index; ///< エリアサービスオフセット(?)
103103 } INSTR_SEARCH_SERVICE;
104104
105105 /** @brief polling_and_search_service_code 出力構造体 */
106106 typedef struct {
107- int num_service_codes; ///< サービスコード数
108- uint8 *service_code_list; ///< サービスコード配列
109- int num_area_codes; ///< エリアコード数
110- uint8 *area_code_list; ///< エリアコード配列
111- uint8 *end_service_code_list; ///< エンドサービスコード配列
107+ int num_service_codes; ///< サービスコード数
108+ uint8 *service_code_list; ///< サービスコード配列
109+ int num_area_codes; ///< エリアコード数
110+ uint8 *area_code_list; ///< エリアコード配列
111+ uint8 *end_service_code_list; ///< エンドサービスコード配列
112112 } OUTSTR_SEARCH_SERVICE;
113113
114114 /* DLL entries */
@@ -118,9 +118,9 @@
118118 typedef BOOL (*close_reader_writer_t)(void);
119119 typedef BOOL (*polling_and_get_card_information_t)(POLLING *, unsigned char *, CARD_INFO *);
120120 typedef BOOL (*polling_and_request_system_code_t)(POLLING *, INSTR_REQ_SYSTEM_CODE *,
121- CARD_INFO *, OUTSTR_REQ_SYSTEM_CODE *);
121+ CARD_INFO *, OUTSTR_REQ_SYSTEM_CODE *);
122122 typedef BOOL (*polling_and_search_service_code_t)(POLLING *, INSTR_SEARCH_SERVICE *,
123- CARD_INFO *, OUTSTR_SEARCH_SERVICE *);
123+ CARD_INFO *, OUTSTR_SEARCH_SERVICE *);
124124 typedef BOOL (*read_block_without_encryption_t)(INSTR_READ_BLOCK *, OUTSTR_READ_BLOCK *);
125125 typedef BOOL (*write_block_without_encryption_t)(INSTR_WRITE_BLOCK *, OUTSTR_WRITE_BLOCK *);
126126
@@ -131,9 +131,9 @@
131131 felica.dll の DLL ハンドル、および DLL のエントリポイントを保持する。
132132 */
133133 struct strpasori {
134- HINSTANCE hInstDLL; ///< DLL ハンドル
134+ HINSTANCE hInstDLL; ///< DLL ハンドル
135135
136-#define declare_entry(f) f ## _t f
136+#define declare_entry(f) f ## _t f
137137 declare_entry(initialize_library);
138138 declare_entry(dispose_library);
139139 declare_entry(open_reader_writer_auto);
--- trunk/src/lib/felicalib.c (revision 83)
+++ trunk/src/lib/felicalib.c (revision 84)
@@ -1,39 +1,39 @@
11 /*
2- felicalib - FeliCa access wrapper library
2+ felicalib - FeliCa access wrapper library
33
4- Copyright (c) 2007, Takuya Murakami, All rights reserved.
4+ Copyright (c) 2007, Takuya Murakami, All rights reserved.
55
6- Redistribution and use in source and binary forms, with or without
7- modification, are permitted provided that the following conditions are
8- met:
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are
8+ met:
99
10- 1. Redistributions of source code must retain the above copyright notice,
11- this list of conditions and the following disclaimer.
10+ 1. Redistributions of source code must retain the above copyright notice,
11+ this list of conditions and the following disclaimer.
1212
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.
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.
1616
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.
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.
2020
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.
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.
3232 */
3333 /**
34- @file felicalib.c
34+ @file felicalib.c
3535
36- felicalib 本体
36+ felicalib 本体
3737 */
3838
3939 #include "felicalib.h"
@@ -49,24 +49,24 @@
4949 @retval pasori ハンドル
5050
5151 felica.dll をロード、初期化する
52- */
52+*/
5353 pasori *pasori_open(char *dummy)
5454 {
5555 pasori *p;
56- TCHAR cp[_MAX_PATH], dllpath[_MAX_PATH];
56+ TCHAR cp[_MAX_PATH], dllpath[_MAX_PATH];
5757
58- /* get felica.dll path */
59- SHGetSpecialFolderPath(NULL, cp, CSIDL_PROGRAM_FILES_COMMON, FALSE);
60- _stprintf(dllpath, _T("%s\\Sony Shared\\FeliCaLibrary\\felica.dll"), cp);
58+ /* get felica.dll path */
59+ SHGetSpecialFolderPath(NULL, cp, CSIDL_PROGRAM_FILES_COMMON, FALSE);
60+ _stprintf(dllpath, _T("%s\\Sony Shared\\FeliCaLibrary\\felica.dll"), cp);
6161
6262 /* open felica.dll */
6363 p = (pasori *)malloc(sizeof(pasori));
64- p->hInstDLL = LoadLibrary(dllpath);
64+ p->hInstDLL = LoadLibrary(dllpath);
6565 if (p->hInstDLL == NULL) {
66- free(p);
67- return NULL;
66+ free(p);
67+ return NULL;
6868 }
69-
69+
7070 /* resolve function pointers */
7171 #define resolve_entry(f) p->f = (f ## _t)GetProcAddress(p->hInstDLL, #f)
7272 resolve_entry(initialize_library);
@@ -80,8 +80,8 @@
8080 resolve_entry(write_block_without_encryption);
8181
8282 if (!p->initialize_library()) {
83- free(p);
84- return NULL;
83+ free(p);
84+ return NULL;
8585 }
8686 return p;
8787 }
@@ -106,7 +106,7 @@
106106 int pasori_init(pasori *p)
107107 {
108108 if (!p->open_reader_writer_auto()) {
109- return -1;
109+ return -1;
110110 }
111111 return 0;
112112 }
@@ -146,9 +146,9 @@
146146 card_info.card_pmm = f->PMm;
147147
148148 if (!p->polling_and_get_card_information(&polling, &number_of_cards, &card_info) ||
149- number_of_cards == 0) {
150- free(f);
151- return NULL;
149+ number_of_cards == 0) {
150+ free(f);
151+ return NULL;
152152 }
153153
154154 return f;
@@ -192,11 +192,11 @@
192192 orb.result_number_of_blocks = &result_number_of_blocks;
193193 orb.block_data = data;
194194
195- if (!f->p->read_block_without_encryption(&irb, &orb)) {
196- return -1;
195+ if (!f->p->read_block_without_encryption(&irb, &orb)) {
196+ return -1;
197197 }
198198 if (status_flag1 != 0) {
199- return -1;
199+ return -1;
200200 }
201201 return 0;
202202 }
@@ -241,10 +241,10 @@
241241 orb.status_flag_2 = &status_flag2;
242242
243243 if (!f->p->write_block_without_encryption(&irb, &orb)) {
244- return -1;
244+ return -1;
245245 }
246246 if (status_flag1 != 0) {
247- return -1;
247+ return -1;
248248 }
249249 return 0;
250250 }
@@ -307,8 +307,8 @@
307307 ors.system_code_list = (uint8 *)f->system_code;
308308
309309 if (!f->p->polling_and_request_system_code(&polling, &irs, &card_info, &ors)) {
310- free(f);
311- return NULL;
310+ free(f);
311+ return NULL;
312312 }
313313
314314 f->num_system_code = ors.number_of_system_codes;
@@ -352,8 +352,8 @@
352352 oss.end_service_code_list = (uint8 *)f->end_service_code;
353353
354354 if (!f->p->polling_and_search_service_code(&polling, &iss, &card_info, &oss)) {
355- free(f);
356- return NULL;
355+ free(f);
356+ return NULL;
357357 }
358358
359359 f->num_area_code = oss.num_area_codes;
Show on old repository browser