santigimeno / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
170 stars 127 forks source link

added javascript implementation of SCARD_CTL_CODE define #67

Closed samo4 closed 7 years ago

samo4 commented 7 years ago

This is an accessory function to SCardControl implementation. I think absolutely all examples on the internet use C implemenation of SCARD_CTL_CODE to get correct dwControlCode and it was missing from current implementation.

I decided to name the function the same as its original C implementation.

santigimeno commented 7 years ago

Another option could be calling the C definition directly by using a wrapper in cardreader.cpp

samo4 commented 7 years ago

The define only exists in pscs-lite implementation ( https://pcsclite.alioth.debian.org/api/reader_8h.html) not in Windows SDK version of winscard.h. The "offical" way to do it in windows is like this, I think: CTL_CODE(FILE_DEVICE_SMARTCARD,(code),METHOD_BUFFERED,FILE_ANY_ACCESS)

That's why did this in javascript. I can move it to cpp if you think it's better.


Windows check was the first one I found in stackoverflow: http://stackoverflow.com/questions/8683895/how-do-i-determine-the-current-operating-system-with-node-js

BR, Samo

On 22 February 2017 at 12:48, Santiago Gimeno notifications@github.com wrote:

Another option could calling the C definition directly by using a wrapper in cardreader.cpp

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/santigimeno/node-pcsclite/pull/67#issuecomment-281647820, or mute the thread https://github.com/notifications/unsubscribe-auth/AE80MzQqS09f33bpvTKNLgSXi1oolgiSks5rfCBzgaJpZM4MIiEi .

santigimeno commented 7 years ago

I would prefer using a js implementation only as it's going to be faster, but I want to be sure the windows implementation is correct :)

samo4 commented 7 years ago

I'm using both windows and linux, tested on both - it works.

On 22 February 2017 at 13:10, Santiago Gimeno notifications@github.com wrote:

I would prefer using a js implementation only as it's going to be faster, but I want to be sure the windows implementation is correct :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/santigimeno/node-pcsclite/pull/67#issuecomment-281652396, or mute the thread https://github.com/notifications/unsubscribe-auth/AE80M1GhVGFJCbPLv2Ms92kZXEoMkDEhks5rfCWvgaJpZM4MIiEi .

santigimeno commented 7 years ago

Landed in https://github.com/santigimeno/node-pcsclite/commit/1a369f0fad0f2e008f6abb7a4b7a7844133c733b and published as 0.5.0. Thanks!