• R/O
  • SSH
  • HTTPS

felicalib: Commit


Commit MetaInfo

Revision85 (tree)
Zeit2008-04-19 18:49:45
Autortmurakam

Log Message

バージョンリソース追加、インデント修正など

Ändern Zusammenfassung

Diff

--- trunk/src/CSharp/Sample.cs (revision 84)
+++ trunk/src/CSharp/Sample.cs (revision 85)
@@ -9,32 +9,32 @@
99 {
1010 public static void Main()
1111 {
12- try
13- {
14- using (Felica f = new Felica())
15- {
16- readNanaco(f);
17- }
18- }
19- catch (Exception ex)
20- {
21- Console.WriteLine(ex.Message);
22- }
23- }
12+ try
13+ {
14+ using (Felica f = new Felica())
15+ {
16+ readNanaco(f);
17+ }
18+ }
19+ catch (Exception ex)
20+ {
21+ Console.WriteLine(ex.Message);
22+ }
23+ }
2424
25- private static void readNanaco(Felica f)
26- {
27- f.Polling((int)SystemCode.Common);
28- byte[] data = f.ReadWithoutEncryption(0x558b, 0);
29- if (data == null)
30- {
31- throw new Exception("nanaco ID が読み取れません");
32- }
33- Console.Write("Nanaco ID = ");
34- for (int i = 0; i < 8; i++) {
35- Console.Write(data[i].ToString("X2"));
36- }
37- Console.Write("\n");
25+ private static void readNanaco(Felica f)
26+ {
27+ f.Polling((int)SystemCode.Common);
28+ byte[] data = f.ReadWithoutEncryption(0x558b, 0);
29+ if (data == null)
30+ {
31+ throw new Exception("nanaco ID が読み取れません");
32+ }
33+ Console.Write("Nanaco ID = ");
34+ for (int i = 0; i < 8; i++) {
35+ Console.Write(data[i].ToString("X2"));
36+ }
37+ Console.Write("\n");
3838
3939 for (int i = 0; ; i++)
4040 {
--- trunk/src/CSharp/FelicaLib.cs (revision 84)
+++ trunk/src/CSharp/FelicaLib.cs (revision 85)
@@ -41,112 +41,112 @@
4141 // システムコード
4242 enum SystemCode : int
4343 {
44- Any = 0xffff, // ANY
45- Common = 0xfe00, // 共通領域
46- Cyberne = 0x0003, // サイバネ領域
44+ Any = 0xffff, // ANY
45+ Common = 0xfe00, // 共通領域
46+ Cyberne = 0x0003, // サイバネ領域
4747
48- Edy = 0xfe00, // Edy (=共通領域)
49- Suica = 0x0003, // Suica (=サイバネ領域)
48+ Edy = 0xfe00, // Edy (=共通領域)
49+ Suica = 0x0003, // Suica (=サイバネ領域)
5050 }
5151
5252 public class Felica : IDisposable
5353 {
54- [DllImport("felicalib.dll")]
55- private extern static IntPtr pasori_open(String dummy);
56- [DllImport("felicalib.dll")]
57- private extern static void pasori_close(IntPtr p);
58- [DllImport("felicalib.dll")]
59- private extern static int pasori_init(IntPtr p);
60- [DllImport("felicalib.dll")]
61- private extern static IntPtr felica_polling(IntPtr p, ushort systemcode, byte rfu, byte time_slot);
62- [DllImport("felicalib.dll")]
63- private extern static void felica_free(IntPtr f);
64- [DllImport("felicalib.dll")]
65- private extern static void felica_getidm(IntPtr f, byte[] data);
66- [DllImport("felicalib.dll")]
67- private extern static void felica_getpmm(IntPtr f, byte[] data);
68- [DllImport("felicalib.dll")]
69- private extern static int felica_read_without_encryption02(IntPtr f, int servicecode, int mode, byte addr, byte[] data);
54+ [DllImport("felicalib.dll")]
55+ private extern static IntPtr pasori_open(String dummy);
56+ [DllImport("felicalib.dll")]
57+ private extern static void pasori_close(IntPtr p);
58+ [DllImport("felicalib.dll")]
59+ private extern static int pasori_init(IntPtr p);
60+ [DllImport("felicalib.dll")]
61+ private extern static IntPtr felica_polling(IntPtr p, ushort systemcode, byte rfu, byte time_slot);
62+ [DllImport("felicalib.dll")]
63+ private extern static void felica_free(IntPtr f);
64+ [DllImport("felicalib.dll")]
65+ private extern static void felica_getidm(IntPtr f, byte[] data);
66+ [DllImport("felicalib.dll")]
67+ private extern static void felica_getpmm(IntPtr f, byte[] data);
68+ [DllImport("felicalib.dll")]
69+ private extern static int felica_read_without_encryption02(IntPtr f, int servicecode, int mode, byte addr, byte[] data);
7070
71- private IntPtr pasorip = IntPtr.Zero;
72- private IntPtr felicap = IntPtr.Zero;
71+ private IntPtr pasorip = IntPtr.Zero;
72+ private IntPtr felicap = IntPtr.Zero;
7373
74- public Felica()
75- {
76- pasorip = pasori_open(null);
77- if (pasorip == IntPtr.Zero)
78- {
79- throw new Exception("felicalib.dll を開けません");
80- }
81- if (pasori_init(pasorip) != 0)
82- {
83- throw new Exception("PaSoRi に接続できません");
84- }
85- }
74+ public Felica()
75+ {
76+ pasorip = pasori_open(null);
77+ if (pasorip == IntPtr.Zero)
78+ {
79+ throw new Exception("felicalib.dll を開けません");
80+ }
81+ if (pasori_init(pasorip) != 0)
82+ {
83+ throw new Exception("PaSoRi に接続できません");
84+ }
85+ }
8686
87- public void Dispose()
88- {
89- if (pasorip != IntPtr.Zero)
90- {
91- pasori_close(pasorip);
92- pasorip = IntPtr.Zero;
93- }
94- }
87+ public void Dispose()
88+ {
89+ if (pasorip != IntPtr.Zero)
90+ {
91+ pasori_close(pasorip);
92+ pasorip = IntPtr.Zero;
93+ }
94+ }
9595
96- ~Felica()
97- {
98- Dispose();
99- }
96+ ~Felica()
97+ {
98+ Dispose();
99+ }
100100
101- public void Polling(int systemcode)
102- {
103- felica_free(felicap);
101+ public void Polling(int systemcode)
102+ {
103+ felica_free(felicap);
104104
105- felicap = felica_polling(pasorip, (ushort)systemcode, 0, 0);
106- if (felicap == IntPtr.Zero)
107- {
108- throw new Exception("カード読み取り失敗");
109- }
110- }
105+ felicap = felica_polling(pasorip, (ushort)systemcode, 0, 0);
106+ if (felicap == IntPtr.Zero)
107+ {
108+ throw new Exception("カード読み取り失敗");
109+ }
110+ }
111111
112- public byte[] IDm()
113- {
114- if (felicap == IntPtr.Zero)
115- {
116- throw new Exception("no polling executed.");
117- }
112+ public byte[] IDm()
113+ {
114+ if (felicap == IntPtr.Zero)
115+ {
116+ throw new Exception("no polling executed.");
117+ }
118118
119- byte[] buf = new byte[8];
120- felica_getidm(felicap, buf);
121- return buf;
122- }
119+ byte[] buf = new byte[8];
120+ felica_getidm(felicap, buf);
121+ return buf;
122+ }
123123
124- public byte[] PMm()
125- {
126- if (felicap == IntPtr.Zero)
127- {
128- throw new Exception("no polling executed.");
129- }
124+ public byte[] PMm()
125+ {
126+ if (felicap == IntPtr.Zero)
127+ {
128+ throw new Exception("no polling executed.");
129+ }
130130
131- byte[] buf = new byte[8];
132- felica_getpmm(felicap, buf);
133- return buf;
134- }
131+ byte[] buf = new byte[8];
132+ felica_getpmm(felicap, buf);
133+ return buf;
134+ }
135135
136- public byte[] ReadWithoutEncryption(int servicecode, int addr)
137- {
138- if (felicap == IntPtr.Zero)
139- {
140- throw new Exception("no polling executed.");
141- }
136+ public byte[] ReadWithoutEncryption(int servicecode, int addr)
137+ {
138+ if (felicap == IntPtr.Zero)
139+ {
140+ throw new Exception("no polling executed.");
141+ }
142142
143- byte[] data = new byte[16];
144- int ret = felica_read_without_encryption02(felicap, servicecode, 0, (byte)addr, data);
145- if (ret != 0)
146- {
147- return null;
148- }
149- return data;
150- }
143+ byte[] data = new byte[16];
144+ int ret = felica_read_without_encryption02(felicap, servicecode, 0, (byte)addr, data);
145+ if (ret != 0)
146+ {
147+ return null;
148+ }
149+ return data;
150+ }
151151 }
152152 }
--- trunk/src/testap/testap.c (revision 84)
+++ trunk/src/testap/testap.c (revision 85)
@@ -51,31 +51,31 @@
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, 0x80cd, 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
6565 for (i = 0; i < 16; i++) {
66- data[i] = i;
66+ data[i] = i;
6767 }
6868
6969 if (felica_write_without_encryption(f, 0x1009, 0, data)) {
70- fprintf(stderr, "write failed.\n");
71- exit(1);
70+ fprintf(stderr, "write failed.\n");
71+ exit(1);
7272 }
7373 if (felica_read_without_encryption02(f, 0x1009, 0, 0, data)) {
74- fprintf(stderr, "Can't read.\n");
75- exit(1);
74+ fprintf(stderr, "Can't read.\n");
75+ exit(1);
7676 }
7777 for (i = 0; i < 16; i++) {
78- printf("%02x", data[i]);
78+ printf("%02x", data[i]);
7979 }
8080 printf("\n");
8181 return 0;
--- trunk/src/edy/edy.c (revision 84)
+++ trunk/src/edy/edy.c (revision 85)
@@ -74,7 +74,7 @@
7474 for (i = 0; i < 8; i++) {
7575 printf("%02x", f->IDm[i]);
7676 }
77- printf("\n");
77+ printf("\n");
7878
7979 for (i = 0; ; i++) {
8080 if (felica_read_without_encryption02(f, SERVICE_EDY, 0, (uint8)i, data)) {
--- trunk/src/ChangeLog.txt (revision 84)
+++ trunk/src/ChangeLog.txt (revision 85)
@@ -1,5 +1,7 @@
11 2008-04-19 : Takuya Murakami
2- * indentation を修正
2+ * ver 0.4
3+ * バージョンリソース追加
4+ * 一部ソースのインデント修正
35
46 2008-04-15 : Takuya Murakami
57 * x64 環境で動作しない問題に対処
--- trunk/src/dump/dump.c (revision 84)
+++ trunk/src/dump/dump.c (revision 85)
@@ -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 dump.c
34+ @file dump.c
3535
36- FeliCa ダンプ
36+ FeliCa ダンプ
3737 */
3838
3939 #include <stdio.h>
@@ -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,40 +71,40 @@
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++) {
78- printf("# System code: %04X\n", N2HS(f->system_code[i]));
79- f2 = felica_enum_service(p, N2HS(f->system_code[i]));
80- if (!f2) {
81- fprintf(stderr, "Enum service failed.\n");
82- exit(1);
83- }
84-
85- printf("# Number of area = %d\n", f2->num_area_code);
86- for (j = 0; j < f2->num_area_code; j++) {
87- printf("# Area: %04X - %04X\n", f2->area_code[j], f2->end_service_code[j]);
88- }
78+ printf("# System code: %04X\n", N2HS(f->system_code[i]));
79+ f2 = felica_enum_service(p, N2HS(f->system_code[i]));
80+ if (!f2) {
81+ fprintf(stderr, "Enum service failed.\n");
82+ exit(1);
83+ }
84+
85+ printf("# Number of area = %d\n", f2->num_area_code);
86+ for (j = 0; j < f2->num_area_code; j++) {
87+ printf("# Area: %04X - %04X\n", f2->area_code[j], f2->end_service_code[j]);
88+ }
8989
90- printf("# Number of service code = %d\n", f2->num_service_code);
91- for (j = 0; j < f2->num_service_code; j++) {
92- uint16 service = f2->service_code[j];
93- printserviceinfo(service);
90+ printf("# Number of service code = %d\n", f2->num_service_code);
91+ for (j = 0; j < f2->num_service_code; j++) {
92+ uint16 service = f2->service_code[j];
93+ printserviceinfo(service);
9494
95- for (k = 0; k < 255; k++) {
96- uint8 data[16];
95+ for (k = 0; k < 255; k++) {
96+ uint8 data[16];
9797
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");
105- }
106- }
107- printf("\n");
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");
105+ }
106+ }
107+ printf("\n");
108108 }
109109
110110 return 0;
@@ -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/resource.h (nonexistent)
+++ trunk/src/lib/resource.h (revision 85)
@@ -0,0 +1,14 @@
1+//{{NO_DEPENDENCIES}}
2+// Microsoft Visual C++ generated include file.
3+// Used by felicalib.rc
4+
5+// 新しいオブジェクトの次の既定値
6+//
7+#ifdef APSTUDIO_INVOKED
8+#ifndef APSTUDIO_READONLY_SYMBOLS
9+#define _APS_NEXT_RESOURCE_VALUE 101
10+#define _APS_NEXT_COMMAND_VALUE 40001
11+#define _APS_NEXT_CONTROL_VALUE 1001
12+#define _APS_NEXT_SYMED_VALUE 101
13+#endif
14+#endif
Show on old repository browser