forked from arnaudmorin/libgtop11dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Marshaller.h
96 lines (61 loc) · 2.63 KB
/
Marshaller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* PKCS#11 library for .Net smart cards
* Copyright (C) 2007-2009 Gemalto <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GEMALTO_MARSHALLER_H__
#define __GEMALTO_MARSHALLER_H__
#include "MarshallerUtil.h"
#include "PCSC.h"
MARSHALLER_NS_BEGIN
typedef void (*pCommunicationStream)(u1Array& st,u1Array& stM);
class SMARTCARDMARSHALLER_DLLAPI SmartCardMarshaller {
private:
PCSC* m_pPCSC;
u4 m_NameSpaceHivecode;
u2 m_TypeHivecode;
u2 m_PortNumber;
std::string m_stURI;
MarshallerUtil m_MarshallerUtil;
pCommunicationStream m_pProcessInputStream;
pCommunicationStream m_pProcessOutputStream;
public:
// Existing PCSC connection
//SmartCardMarshaller( SCARDHANDLE, u2, std::string, u4, u2 );
// PCSC compatible readers
SmartCardMarshaller( std::string, u2, std::string, u4, u2, u4 );
// destructor
virtual ~SmartCardMarshaller( );
// Remoting marshalling method
void Invoke( s4 nParam, ... );
inline void UpdatePCSCCardHandle( SCARDHANDLE m_hCard ) { if( m_pPCSC ) { m_pPCSC->setCardHandle( m_hCard ); } }
inline void SetInputStream( pCommunicationStream a_inStream ) { m_pProcessInputStream = a_inStream; }
inline void SetOutputStream( pCommunicationStream a_outStream ){ m_pProcessOutputStream = a_outStream; }
inline std::string& GetReaderName( void ) { if( m_pPCSC ) { return m_pPCSC->getReaderName( ); } else throw ("Empty PCSC context"); }
inline SCARDHANDLE GetCardHandle( void ) { if( m_pPCSC ) { return m_pPCSC->getCardHandle( ); }
#ifdef WIN32
return NULL;
#else
return 0;
#endif
}
inline void DoTransact( bool& flag ) { if( m_pPCSC ) { m_pPCSC->doTransact( flag ); } }
inline void beginTransaction( void ) { if( m_pPCSC ) { m_pPCSC->beginTransaction( ); } }
inline void endTransaction( void ) { if( m_pPCSC ) { m_pPCSC->endTransaction( ); } }
};
MARSHALLER_NS_END
#endif // __GEMALTO_MARSHALLER_H__