functions to scan specific cards; refs #28

master
Marc Wäckerlin 11 years ago
parent 7b594f13c6
commit d9d0f2875f
  1. 8
      src/cryptoki.cxx
  2. 3
      src/cryptoki.hxx
  3. 13
      src/pcsc.hxx

@ -200,7 +200,7 @@ namespace cryptoki {
}
@endcode */
SlotList Init::slotList(bool tokenPresent) {
SlotList Init::slotList(bool tokenPresent, std::string name) {
CRYPTOKI_LOG("log");
SlotList res;
CK_ULONG count(0);
@ -217,7 +217,11 @@ namespace cryptoki {
} while (_res==CKR_BUFFER_TOO_SMALL);
check(_res, CRYPTOKI_FN_LOG("C_GetSlotList"));
if (!*this) return res;
for (CK_ULONG i(0); i<count; ++i) res.push_back(Slot(*this, slots[i]));
for (CK_ULONG i(0); i<count; ++i) {
Slot s(*this, slots[i]);
if (!name.size() || name==s.slotInfo().slotDescription)
res.push_back(s);
}
} catch (...) {
delete[] slots;
throw;

@ -706,8 +706,9 @@ namespace cryptoki {
//! Get a list of available slots
/*! @param tokenPresent whether a token must be inserted into the reader
@param name if given, only return slots with a given name
@return list of matching slots */
SlotList slotList(bool tokenPresent=true);
SlotList slotList(bool tokenPresent=true, std::string name=std::string());
};

@ -548,6 +548,19 @@ namespace pcsc {
}
//! Find all readers with a given ATR.
/*! @param atr full or partial ATR to match to the reader's ATR
@returns list of readers that contain @c atr in their ATR */
Strings getReadersWithAtr(const std::string& atr) {
Strings res;
pcsc::Connection::Strings readers(scan());
for (pcsc::Connection::Strings::const_iterator it(readers.begin());
it!=readers.end(); ++it)
if (_reader[*it].status().atr.find(atr)!=string::npos)
res.push_back(*it);
return res;
}
//! @c false if last operation was not successful
operator bool() const {
#ifdef WIN32

Loading…
Cancel
Save