/[openpgpmdrv]/trunk/OpenPGPminidriverTest/PublicDataOperations.cpp
ViewVC logotype

Contents of /trunk/OpenPGPminidriverTest/PublicDataOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Tue Feb 23 19:18:59 2010 UTC (15 years, 2 months ago) by vletoux
File size: 2299 byte(s)


1 /* OpenPGP Smart Card Mini Driver
2 Copyright (C) 2009 Vincent Le Toux
3
4 This library is Free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License version 2.1 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public
14 License along with this library; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 #include <windows.h>
19 #include <tchar.h>
20 #include <stdio.h>
21 #include <cardmod.h>
22 #include "global.h"
23 #include "dialog.h"
24
25 extern HWND hMainWnd;
26
27 DWORD ListFiles(PSTR szDirectory)
28 {
29 DWORD dwReturn = 0, dwSize;
30 LPSTR pszFiles = NULL;
31
32 dwSize = 0;
33 dwReturn = pCardData->pfnCardEnumFiles(pCardData, szDirectory, &pszFiles, &dwSize, 0);
34 if (!dwReturn)
35 {
36 LPSTR szCurrentFile = pszFiles;
37 while (szCurrentFile[0] != 0)
38 {
39 CHAR szText[256];
40 if (szDirectory)
41 {
42 sprintf_s(szText, ARRAYSIZE(szText),"%s\\%s",szDirectory, szCurrentFile);
43 }
44 else
45 {
46 sprintf_s(szText, ARRAYSIZE(szText),"%s",szCurrentFile);
47 }
48 SendDlgItemMessageA(hMainWnd,IDC_FILES,LB_ADDSTRING,0,(LPARAM)szText);
49 if (strcmp(szCurrentFile,"cardapps") == 0)
50 {
51 PBYTE pbData = NULL;
52 dwSize = 0;
53 dwReturn = pCardData->pfnCardReadFile(pCardData, szDirectory, szCurrentFile, 0, &pbData, &dwSize);
54 if (dwReturn == 0)
55 {
56 CHAR szDirectory[9];
57 for (DWORD dwI = 0; dwI < dwSize; dwI+=8)
58 {
59 memcpy(szDirectory, pbData + dwI, 8);
60 szDirectory[8] = 0;
61 ListFiles(szDirectory);
62 }
63
64 pCardData->pfnCspFree(pbData);
65 }
66 }
67
68 szCurrentFile = szCurrentFile + strlen(szCurrentFile)+1;
69 }
70 pCardData->pfnCspFree(pszFiles);
71 }
72 return dwReturn;
73 }
74
75 DWORD ListFiles()
76 {
77 if (!pCardData)
78 {
79 return SCARD_E_COMM_DATA_LOST;
80 }
81 SendMessage(GetDlgItem(hMainWnd, IDC_FILES),LB_RESETCONTENT,0,0);
82 return ListFiles(NULL);
83 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26