fusion: Implement IAssemblyNameImpl_GetDisplayName more completely.
[wine] / dlls / winscard / winscard.c
1 /*
2  * Copyright 2007 Mounir IDRASSI  (mounir.idrassi@idrix.fr, for IDRIX)
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 as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wine/debug.h"
24 #include "winscard.h"
25 #include "winternl.h"
26
27 WINE_DEFAULT_DEBUG_CHANNEL(winscard);
28
29 static HMODULE WINSCARD_hModule;
30 static HANDLE g_startedEvent = NULL;
31
32 const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 };
33 const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, 8 };
34 const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 };
35
36
37 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
38 {
39     TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
40
41     switch (fdwReason)
42     {
43         case DLL_PROCESS_ATTACH:
44         {
45             DisableThreadLibraryCalls(hinstDLL);
46             WINSCARD_hModule = hinstDLL;
47             /* FIXME: for now, we act as if the pcsc daemon is always started */
48             g_startedEvent = CreateEventA(NULL,TRUE,TRUE,NULL);
49             break;
50         }
51         case DLL_PROCESS_DETACH:
52         {
53             CloseHandle(g_startedEvent);
54             break;
55         }
56     }
57
58     return TRUE;
59 }
60
61 HANDLE WINAPI SCardAccessStartedEvent(void)
62 {
63     return g_startedEvent;
64 }
65
66 LONG WINAPI SCardAddReaderToGroupA(SCARDCONTEXT context, LPCSTR reader, LPCSTR group)
67 {
68     LONG retval;
69     UNICODE_STRING readerW, groupW;
70
71     if(reader) RtlCreateUnicodeStringFromAsciiz(&readerW,reader);
72     else readerW.Buffer = NULL;
73     if(group) RtlCreateUnicodeStringFromAsciiz(&groupW,group);
74     else groupW.Buffer = NULL;
75
76     retval = SCardAddReaderToGroupW(context, readerW.Buffer, groupW.Buffer);
77
78     RtlFreeUnicodeString(&readerW);
79     RtlFreeUnicodeString(&groupW);
80
81     return retval;
82 }
83
84 LONG WINAPI SCardAddReaderToGroupW(SCARDCONTEXT context, LPCWSTR reader, LPCWSTR group)
85 {
86     FIXME("%x %s %s\n", (unsigned int) context, debugstr_w(reader), debugstr_w(group));
87     return SCARD_S_SUCCESS;
88 }
89
90 LONG WINAPI SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
91     LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
92 {
93     FIXME("(%x,%p,%p,%p) stub\n", dwScope, pvReserved1, pvReserved2, phContext);
94     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
95     return SCARD_F_INTERNAL_ERROR;
96 }
97
98 LONG WINAPI SCardIsValidContext(SCARDCONTEXT context)
99 {
100     FIXME("(%lx) stub\n", context);
101     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
102     return SCARD_F_INTERNAL_ERROR;
103 }
104
105 LONG WINAPI SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr, LPCGUID rgguidInterfaces, DWORD cguidInterfaceCount, LPSTR mszCards, LPDWORD pcchCards)
106 {
107     FIXME(": stub\n");
108     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
109     return SCARD_F_INTERNAL_ERROR;
110 }
111
112 LONG WINAPI SCardReleaseContext(SCARDCONTEXT context)
113 {
114     FIXME("(%lx) stub\n", context);
115     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
116     return SCARD_F_INTERNAL_ERROR;
117 }