functions to scan specific cards; refs #28
This commit is contained in:
@@ -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());
|
||||
|
||||
};
|
||||
|
||||
|
13
src/pcsc.hxx
13
src/pcsc.hxx
@@ -547,6 +547,19 @@ namespace pcsc {
|
||||
void close(const std::string& s) {
|
||||
|
||||
}
|
||||
|
||||
//! 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 {
|
||||
|
Reference in New Issue
Block a user