added method control; refs #18
This commit is contained in:
18
src/pcsc.hxx
18
src/pcsc.hxx
@@ -325,6 +325,24 @@ namespace pcsc {
|
|||||||
return std::string((char*)buff, len);
|
return std::string((char*)buff, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Transmit control command and data to the reader.
|
||||||
|
/*!
|
||||||
|
* @note Take care: Strings may contain embedded @c 0.
|
||||||
|
*/
|
||||||
|
std::string control(unsigned long controlCode,
|
||||||
|
std::string in) {
|
||||||
|
DWORD len(256); // arbitrary
|
||||||
|
UCHAR dataBuffer[256];
|
||||||
|
PCSC_LOG("SCardControl: "<<"Command: "<<controlCode);
|
||||||
|
PCSC_LOG(" -> "<<crypto::hex(in));
|
||||||
|
check(SCardControl(_id, controlCode,
|
||||||
|
(unsigned char*)in.c_str(), in.size(),
|
||||||
|
dataBuffer, sizeof(dataBuffer), &len),
|
||||||
|
"smartcard control message sent");
|
||||||
|
PCSC_LOG(" -> "<<crypto::hex(std::string((char*)dataBuffer, len)));
|
||||||
|
return std::string((char*)dataBuffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
//! @c false if last operation was not successful
|
//! @c false if last operation was not successful
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
// Values are 32 bit values layed out as follows:
|
// Values are 32 bit values layed out as follows:
|
||||||
|
Reference in New Issue
Block a user