[SmartcardServices-Changes] [49] trunk/SmartCardServices/src/PCSC
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 30 06:58:05 PDT 2009
Revision: 49
http://trac.macosforge.org/projects/smartcardservices/changeset/49
Author: ludovic.rousseau at gmail.com
Date: 2009-07-30 06:58:04 -0700 (Thu, 30 Jul 2009)
Log Message:
-----------
rename reader.{cpp,h} in pcscd_reader.{cpp.h} to free the filename reader.h
Added Paths:
-----------
trunk/SmartCardServices/src/PCSC/pcscd_reader.cpp
trunk/SmartCardServices/src/PCSC/pcscd_reader.h
Removed Paths:
-------------
trunk/SmartCardServices/src/PCSC/reader.cpp
trunk/SmartCardServices/src/PCSC/reader.h
Copied: trunk/SmartCardServices/src/PCSC/pcscd_reader.cpp (from rev 25, trunk/SmartCardServices/src/PCSC/reader.cpp)
===================================================================
--- trunk/SmartCardServices/src/PCSC/pcscd_reader.cpp (rev 0)
+++ trunk/SmartCardServices/src/PCSC/pcscd_reader.cpp 2009-07-30 13:58:04 UTC (rev 49)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * reader.cpp
+ * SmartCardServices
+*/
+
+#include "pcscd_reader.h"
+#include "eventhandler.h"
+#include "pcsclite.h"
+#include <security_utilities/debugging.h>
+
+static PCSCD::Readers *mReaders;
+
+namespace PCSCD {
+
+
+Readers::Readers()
+{
+}
+
+Readers::~Readers()
+{
+}
+
+bool Readers::find(const char *name, XReaderContext &rc) const
+{
+ return false;
+}
+
+bool Readers::find(uint32_t port, const char *name, XReaderContext &rc) const
+{
+ return false;
+}
+
+bool Readers::find(uint32_t id, XReaderContext &rc) const
+{
+ return false;
+}
+
+
+} // end namespace PCSCD
+
+#pragma mark ---------- C Interface ----------
+
+LONG XRFAllocateReaderSpace(DWORD dwAllocNum)
+{
+ try
+ {
+ mReaders = new PCSCD::Readers();
+ }
+ catch (...)
+ {
+ secdebug("pcscd", "failed to allocate Readers");
+ return -1;
+ }
+ return EHInitializeEventStructures();
+}
+
+LONG XRFReaderInfo(LPSTR lpcReader, PREADER_CONTEXT *sReader)
+{
+ // Find a reader given a name
+ PCSCD::XReaderContext rc; //>>>> use iterator instead
+ if (!sReader)
+ return SCARD_E_INVALID_PARAMETER;
+
+ if (!mReaders->find(lpcReader, rc))
+ return SCARD_E_UNKNOWN_READER;
+
+ *sReader = &rc; //>>>> WRONG - temporary var
+ return SCARD_S_SUCCESS;
+}
+
+LONG XRFReaderInfoNamePort(DWORD dwPort, LPSTR lpcReader, PREADER_CONTEXT *sReader)
+{
+ // Find a reader given a name
+ PCSCD::XReaderContext rc;
+ if (!sReader)
+ return SCARD_E_INVALID_PARAMETER;
+
+ if (!mReaders->find(dwPort, lpcReader, rc))
+ return SCARD_E_UNKNOWN_READER;
+
+ *sReader = &rc; //>>>> WRONG - temporary var
+ return SCARD_S_SUCCESS;
+}
+
+LONG XRFReaderInfoById(DWORD dwIdentity, PREADER_CONTEXT * sReader)
+{
+ // Find a reader given a handle
+ PCSCD::XReaderContext rc;
+ if (!sReader)
+ return SCARD_E_INVALID_PARAMETER;
+
+ if (!mReaders->find(dwIdentity, rc))
+ return SCARD_E_INVALID_VALUE;
+
+ *sReader = &rc; //>>>> WRONG - temporary var
+ return SCARD_S_SUCCESS;
+}
+
+LONG XRFCheckSharing(DWORD hCard)
+{
+ PCSCD::XReaderContext rc;
+ if (!mReaders->find(hCard, rc))
+ return SCARD_E_INVALID_VALUE;
+
+ return (rc.dwLockId == 0 || rc.dwLockId == hCard)?SCARD_S_SUCCESS:SCARD_E_SHARING_VIOLATION;
+}
+
+LONG XRFLockSharing(DWORD hCard)
+{
+ PCSCD::XReaderContext rc;
+ if (!mReaders->find(hCard, rc))
+ return SCARD_E_INVALID_VALUE;
+
+ if (rc.dwLockId != 0 && rc.dwLockId != hCard)
+ {
+ secdebug("pcscd", "XRFLockSharing: Lock ID invalid: %d", rc.dwLockId);
+ return SCARD_E_SHARING_VIOLATION;
+ }
+
+ EHSetSharingEvent(&rc, 1);
+ rc.dwLockId = hCard;
+ return SCARD_S_SUCCESS;
+}
+
+LONG XRFUnlockSharing(DWORD hCard)
+{
+ PCSCD::XReaderContext rc;
+ if (!mReaders->find(hCard, rc))
+ return SCARD_E_INVALID_VALUE;
+
+ if (rc.dwLockId != 0 && rc.dwLockId != hCard)
+ {
+ secdebug("pcscd", "XRFUnlockSharing: Lock ID invalid: %d", rc.dwLockId);
+ return SCARD_E_SHARING_VIOLATION;
+ }
+
+ EHSetSharingEvent(&rc, 0);
+ rc.dwLockId = 0;
+ return SCARD_S_SUCCESS;
+}
+
Copied: trunk/SmartCardServices/src/PCSC/pcscd_reader.h (from rev 25, trunk/SmartCardServices/src/PCSC/reader.h)
===================================================================
--- trunk/SmartCardServices/src/PCSC/pcscd_reader.h (rev 0)
+++ trunk/SmartCardServices/src/PCSC/pcscd_reader.h 2009-07-30 13:58:04 UTC (rev 49)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * reader.h
+ * SmartCardServices
+ */
+
+#ifndef _H_PCSCD_READER
+#define _H_PCSCD_READER
+
+#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
+#include "wintypes.h"
+#include "pcsclite.h"
+#include "readerfactory.h"
+#include <security_utilities/refcount.h>
+#include <security_cdsa_utilities/handleobject.h>
+#include <map>
+
+#if 0
+ struct ReaderContext
+ {
+ char lpcReader[MAX_READERNAME]; /* Reader Name */
+ char lpcLibrary[MAX_LIBNAME]; /* Library Path */
+ PCSCLITE_THREAD_T pthThread; /* Event polling thread */
+ PCSCLITE_MUTEX_T mMutex; /* Mutex for this connection */
+ RDR_CAPABILITIES psCapabilites; /* Structure of reader
+ capabilities */
+ PROT_OPTIONS psProtOptions; /* Structure of protocol options */
+ RDR_CLIHANDLES psHandles[PCSCLITE_MAX_CONTEXTS];
+ /* Structure of connected handles */
+ FCT_MAP psFunctions; /* Structure of function pointers */
+ UCHAR ucAtr[MAX_ATR_SIZE]; /* Atr for inserted card */
+ DWORD dwAtrLen; /* Size of the ATR */
+ LPVOID vHandle; /* Dlopen handle */
+ DWORD dwVersion; /* IFD Handler version number */
+ DWORD dwPort; /* Port ID */
+ DWORD dwProtocol; /* Currently used protocol */
+ DWORD dwSlot; /* Current Reader Slot */
+ DWORD dwBlockStatus; /* Current blocking status */
+ DWORD dwStatus; /* Current Status Mask */
+ DWORD dwLockId; /* Lock Id */
+ DWORD dwIdentity; /* Shared ID High Nibble */
+ DWORD dwContexts; /* Number of open contexts */
+ DWORD dwPublicID; /* Public id of public state struct */
+ PDWORD dwFeeds; /* Number of shared client to lib */
+ };
+#endif
+
+#if defined(__cplusplus)
+
+namespace PCSCD {
+
+//
+// The server object itself. This is the "go to" object for anyone who wants
+// to access the server's global state. It runs the show.
+// There is only one Server, and its name is Server::active().
+//
+
+//
+// A PODWrapper for the PCSC READER_CONTEXT structure
+//
+class XReaderContext : public PodWrapper<XReaderContext, READER_CONTEXT>
+{
+public:
+ void set(const char *name, unsigned long known = SCARD_STATE_UNAWARE);
+
+ const char *name() const { return lpcReader; }
+// void name(const char *s) { szReader = s; }
+
+// unsigned long lastKnown() const { return dwStatus; }
+ void lastKnown(unsigned long s);
+
+ unsigned long state() const { return 0; } //fix
+ bool state(unsigned long it) const { return state() & it; }
+ bool changed() const { return state(SCARD_STATE_CHANGED); }
+
+// template <class T>
+// T * &userData() { return reinterpret_cast<T * &>(pvUserData); }
+
+ // DataOid access to the ATR data
+// const void *data() const { return ucAtr; }
+// size_t length() const { return dwAtrLen; }
+ void setATR(const void *atr, size_t size);
+
+ IFDUMP(void dump());
+};
+
+
+class Reader : public HandleObject, public RefCount
+{
+public:
+ Reader(const char *bootstrapName);
+ ~Reader();
+private:
+ // mach bootstrap registration name
+ std::string mBootstrapName;
+ mutable Mutex mLock;
+};
+
+class Readers
+{
+public:
+ Readers();
+ ~Readers();
+
+ typedef std::map<uint32_t, RefPointer<PCSCD::Reader> > ReaderMap;
+ ReaderMap mReaders;
+
+ bool find(uint32_t id, XReaderContext &rc) const;
+ bool find(const char *name, XReaderContext &rc) const;
+ bool find(uint32_t port, const char *name, XReaderContext &rc) const;
+
+ mutable Mutex mReaderMapLock;
+
+ void insert(pair<uint32_t, RefPointer<PCSCD::Reader> > readerpair) { StLock<Mutex> _(mReaderMapLock); mReaders.insert(readerpair); }
+ void remove(ReaderMap::iterator it) { StLock<Mutex> _(mReaderMapLock); mReaders.erase(it); }
+
+private:
+ mutable Mutex mLock;
+};
+
+} // end namespace PCSCD
+
+#endif /* __cplusplus__ */
+
+#endif //_H_PCSCD_READER
+
Deleted: trunk/SmartCardServices/src/PCSC/reader.cpp
===================================================================
--- trunk/SmartCardServices/src/PCSC/reader.cpp 2009-07-30 13:29:52 UTC (rev 48)
+++ trunk/SmartCardServices/src/PCSC/reader.cpp 2009-07-30 13:58:04 UTC (rev 49)
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-
-/*
- * reader.cpp
- * SmartCardServices
-*/
-
-#include "reader.h"
-#include "eventhandler.h"
-#include "pcsclite.h"
-#include <security_utilities/debugging.h>
-
-static PCSCD::Readers *mReaders;
-
-namespace PCSCD {
-
-
-Readers::Readers()
-{
-}
-
-Readers::~Readers()
-{
-}
-
-bool Readers::find(const char *name, XReaderContext &rc) const
-{
- return false;
-}
-
-bool Readers::find(uint32_t port, const char *name, XReaderContext &rc) const
-{
- return false;
-}
-
-bool Readers::find(uint32_t id, XReaderContext &rc) const
-{
- return false;
-}
-
-
-} // end namespace PCSCD
-
-#pragma mark ---------- C Interface ----------
-
-LONG XRFAllocateReaderSpace(DWORD dwAllocNum)
-{
- try
- {
- mReaders = new PCSCD::Readers();
- }
- catch (...)
- {
- secdebug("pcscd", "failed to allocate Readers");
- return -1;
- }
- return EHInitializeEventStructures();
-}
-
-LONG XRFReaderInfo(LPSTR lpcReader, PREADER_CONTEXT *sReader)
-{
- // Find a reader given a name
- PCSCD::XReaderContext rc; //>>>> use iterator instead
- if (!sReader)
- return SCARD_E_INVALID_PARAMETER;
-
- if (!mReaders->find(lpcReader, rc))
- return SCARD_E_UNKNOWN_READER;
-
- *sReader = &rc; //>>>> WRONG - temporary var
- return SCARD_S_SUCCESS;
-}
-
-LONG XRFReaderInfoNamePort(DWORD dwPort, LPSTR lpcReader, PREADER_CONTEXT *sReader)
-{
- // Find a reader given a name
- PCSCD::XReaderContext rc;
- if (!sReader)
- return SCARD_E_INVALID_PARAMETER;
-
- if (!mReaders->find(dwPort, lpcReader, rc))
- return SCARD_E_UNKNOWN_READER;
-
- *sReader = &rc; //>>>> WRONG - temporary var
- return SCARD_S_SUCCESS;
-}
-
-LONG XRFReaderInfoById(DWORD dwIdentity, PREADER_CONTEXT * sReader)
-{
- // Find a reader given a handle
- PCSCD::XReaderContext rc;
- if (!sReader)
- return SCARD_E_INVALID_PARAMETER;
-
- if (!mReaders->find(dwIdentity, rc))
- return SCARD_E_INVALID_VALUE;
-
- *sReader = &rc; //>>>> WRONG - temporary var
- return SCARD_S_SUCCESS;
-}
-
-LONG XRFCheckSharing(DWORD hCard)
-{
- PCSCD::XReaderContext rc;
- if (!mReaders->find(hCard, rc))
- return SCARD_E_INVALID_VALUE;
-
- return (rc.dwLockId == 0 || rc.dwLockId == hCard)?SCARD_S_SUCCESS:SCARD_E_SHARING_VIOLATION;
-}
-
-LONG XRFLockSharing(DWORD hCard)
-{
- PCSCD::XReaderContext rc;
- if (!mReaders->find(hCard, rc))
- return SCARD_E_INVALID_VALUE;
-
- if (rc.dwLockId != 0 && rc.dwLockId != hCard)
- {
- secdebug("pcscd", "XRFLockSharing: Lock ID invalid: %d", rc.dwLockId);
- return SCARD_E_SHARING_VIOLATION;
- }
-
- EHSetSharingEvent(&rc, 1);
- rc.dwLockId = hCard;
- return SCARD_S_SUCCESS;
-}
-
-LONG XRFUnlockSharing(DWORD hCard)
-{
- PCSCD::XReaderContext rc;
- if (!mReaders->find(hCard, rc))
- return SCARD_E_INVALID_VALUE;
-
- if (rc.dwLockId != 0 && rc.dwLockId != hCard)
- {
- secdebug("pcscd", "XRFUnlockSharing: Lock ID invalid: %d", rc.dwLockId);
- return SCARD_E_SHARING_VIOLATION;
- }
-
- EHSetSharingEvent(&rc, 0);
- rc.dwLockId = 0;
- return SCARD_S_SUCCESS;
-}
-
Deleted: trunk/SmartCardServices/src/PCSC/reader.h
===================================================================
--- trunk/SmartCardServices/src/PCSC/reader.h 2009-07-30 13:29:52 UTC (rev 48)
+++ trunk/SmartCardServices/src/PCSC/reader.h 2009-07-30 13:58:04 UTC (rev 49)
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-
-/*
- * reader.h
- * SmartCardServices
- */
-
-#ifndef _H_PCSCD_READER
-#define _H_PCSCD_READER
-
-#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
-#include "wintypes.h"
-#include "pcsclite.h"
-#include "readerfactory.h"
-#include <security_utilities/refcount.h>
-#include <security_cdsa_utilities/handleobject.h>
-#include <map>
-
-#if 0
- struct ReaderContext
- {
- char lpcReader[MAX_READERNAME]; /* Reader Name */
- char lpcLibrary[MAX_LIBNAME]; /* Library Path */
- PCSCLITE_THREAD_T pthThread; /* Event polling thread */
- PCSCLITE_MUTEX_T mMutex; /* Mutex for this connection */
- RDR_CAPABILITIES psCapabilites; /* Structure of reader
- capabilities */
- PROT_OPTIONS psProtOptions; /* Structure of protocol options */
- RDR_CLIHANDLES psHandles[PCSCLITE_MAX_CONTEXTS];
- /* Structure of connected handles */
- FCT_MAP psFunctions; /* Structure of function pointers */
- UCHAR ucAtr[MAX_ATR_SIZE]; /* Atr for inserted card */
- DWORD dwAtrLen; /* Size of the ATR */
- LPVOID vHandle; /* Dlopen handle */
- DWORD dwVersion; /* IFD Handler version number */
- DWORD dwPort; /* Port ID */
- DWORD dwProtocol; /* Currently used protocol */
- DWORD dwSlot; /* Current Reader Slot */
- DWORD dwBlockStatus; /* Current blocking status */
- DWORD dwStatus; /* Current Status Mask */
- DWORD dwLockId; /* Lock Id */
- DWORD dwIdentity; /* Shared ID High Nibble */
- DWORD dwContexts; /* Number of open contexts */
- DWORD dwPublicID; /* Public id of public state struct */
- PDWORD dwFeeds; /* Number of shared client to lib */
- };
-#endif
-
-#if defined(__cplusplus)
-
-namespace PCSCD {
-
-//
-// The server object itself. This is the "go to" object for anyone who wants
-// to access the server's global state. It runs the show.
-// There is only one Server, and its name is Server::active().
-//
-
-//
-// A PODWrapper for the PCSC READER_CONTEXT structure
-//
-class XReaderContext : public PodWrapper<XReaderContext, READER_CONTEXT>
-{
-public:
- void set(const char *name, unsigned long known = SCARD_STATE_UNAWARE);
-
- const char *name() const { return lpcReader; }
-// void name(const char *s) { szReader = s; }
-
-// unsigned long lastKnown() const { return dwStatus; }
- void lastKnown(unsigned long s);
-
- unsigned long state() const { return 0; } //fix
- bool state(unsigned long it) const { return state() & it; }
- bool changed() const { return state(SCARD_STATE_CHANGED); }
-
-// template <class T>
-// T * &userData() { return reinterpret_cast<T * &>(pvUserData); }
-
- // DataOid access to the ATR data
-// const void *data() const { return ucAtr; }
-// size_t length() const { return dwAtrLen; }
- void setATR(const void *atr, size_t size);
-
- IFDUMP(void dump());
-};
-
-
-class Reader : public HandleObject, public RefCount
-{
-public:
- Reader(const char *bootstrapName);
- ~Reader();
-private:
- // mach bootstrap registration name
- std::string mBootstrapName;
- mutable Mutex mLock;
-};
-
-class Readers
-{
-public:
- Readers();
- ~Readers();
-
- typedef std::map<uint32_t, RefPointer<PCSCD::Reader> > ReaderMap;
- ReaderMap mReaders;
-
- bool find(uint32_t id, XReaderContext &rc) const;
- bool find(const char *name, XReaderContext &rc) const;
- bool find(uint32_t port, const char *name, XReaderContext &rc) const;
-
- mutable Mutex mReaderMapLock;
-
- void insert(pair<uint32_t, RefPointer<PCSCD::Reader> > readerpair) { StLock<Mutex> _(mReaderMapLock); mReaders.insert(readerpair); }
- void remove(ReaderMap::iterator it) { StLock<Mutex> _(mReaderMapLock); mReaders.erase(it); }
-
-private:
- mutable Mutex mLock;
-};
-
-} // end namespace PCSCD
-
-#endif /* __cplusplus__ */
-
-#endif //_H_PCSCD_READER
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/smartcardservices-changes/attachments/20090730/a617c62b/attachment-0001.html>
More information about the SmartcardServices-Changes
mailing list