mirror of
https://github.com/pcsc-for-php/pcsc.git
synced 2026-08-09 21:39:25 +02:00
Compare commits
28 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b0fab487f | |||
| 37ecbc4eb0 | |||
| 9ab1ae883a | |||
| 1c14647729 | |||
| a722128295 | |||
| 1503e63658 | |||
| aab796c982 | |||
| 4b2df9bae8 | |||
| 62b8e1e6d8 | |||
| 9023e2a831 | |||
| 576a3c6ca0 | |||
| 1226d9ace8 | |||
| aac7782210 | |||
| 87c612789b | |||
| 2e58c9192d | |||
| ac8fa37a53 | |||
| 744c0e7654 | |||
| 41eafbe76f | |||
| 23bc4ea3e4 | |||
| d76a0296ec | |||
| 6508c44984 | |||
| 83de43d9fe | |||
| 4b7273ae39 | |||
| 6a3027b35b | |||
| fc687719c6 | |||
| 2562478bd4 | |||
| 5aad57fa26 | |||
| 851e1dded2 |
13 changed files with 508 additions and 202 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,3 +1,7 @@
|
||||||
|
nbproject/
|
||||||
|
|
||||||
|
*.dep
|
||||||
|
|
||||||
# Object files
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
*.lo
|
*.lo
|
||||||
|
|
@ -28,11 +32,14 @@ config.cache
|
||||||
config.guess
|
config.guess
|
||||||
config.h
|
config.h
|
||||||
config.h.in
|
config.h.in
|
||||||
|
config.h.in~
|
||||||
config.log
|
config.log
|
||||||
config.nice
|
config.nice
|
||||||
config.status
|
config.status
|
||||||
config.sub
|
config.sub
|
||||||
configure
|
configure
|
||||||
|
configure~
|
||||||
|
configure.ac
|
||||||
configure.in
|
configure.in
|
||||||
conftest
|
conftest
|
||||||
conftest.c
|
conftest.c
|
||||||
|
|
|
||||||
11
CREDITS.md
11
CREDITS.md
|
|
@ -1,11 +0,0 @@
|
||||||
# Contributors
|
|
||||||
|
|
||||||
## In alphabetical order:
|
|
||||||
|
|
||||||
* Johann Dantant (Original author)
|
|
||||||
* Anatol Belski (Contributor)
|
|
||||||
* Calvin Buckley (Contributor)
|
|
||||||
* Remi Collet (Contributor)
|
|
||||||
* Johannes Findeisen (Maintainer)
|
|
||||||
* Marco Schuster (Contributor)
|
|
||||||
|
|
||||||
165
README.md
165
README.md
|
|
@ -29,21 +29,92 @@ After that you have all needed files in ./modules/ .
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
The extension currently provides the following API:
|
The extension currently provides the following API (alphabetical order):
|
||||||
|
|
||||||
### scard_establish_context">scard_establish_context();
|
### pcsc_stringify_error($errno);
|
||||||
|
|
||||||
|
Returns $errstr for $errno or NULL.
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Duplicate of scard_errstr() but this should be the default.
|
||||||
|
|
||||||
|
### scard_begin_transaction($connection);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Establishes a temporary exclusive access mode for doing a serie of commands in a transaction.
|
||||||
|
|
||||||
|
You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCARD_SHARE_EXCLUSIVE there will be no action taken.
|
||||||
|
|
||||||
|
### scard_cancel($context);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Maybe not useful because of this extension is for server side usage designed but since we want the API implemented it should be available.
|
||||||
|
|
||||||
|
### scard_connect($context, "OMNIKEY CardMan 5x21 00 00" [, int $protocol]);
|
||||||
|
|
||||||
|
Connects to a card. Returns the $connection to a reader or FALSE.
|
||||||
|
|
||||||
|
Where optional $protocol is:
|
||||||
|
|
||||||
|
* 1 = T=0
|
||||||
|
* 2 = T=1
|
||||||
|
|
||||||
|
Default $protocol is T=1.
|
||||||
|
|
||||||
|
### scard_control($connection);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Sends a command directly to the IFD Handler (reader driver) to be processed by the reader.
|
||||||
|
|
||||||
|
### scard_disconnect($connection);
|
||||||
|
|
||||||
|
Disconnects the $connection to a card. Returns the TRUE if disconnecting was succesful or FALSE.
|
||||||
|
|
||||||
|
### scard_end_transaction($connection);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Ends a previously begun transaction.
|
||||||
|
|
||||||
|
The calling application must be the owner of the previously begun transaction or an error will occur.
|
||||||
|
|
||||||
|
### scard_errstr($errno); - Not PC/SC standard.
|
||||||
|
|
||||||
|
Returns $errstr for $errno or NULL.
|
||||||
|
|
||||||
|
### scard_establish_context();
|
||||||
|
|
||||||
Returns the application $context to the PC/SC resource manager.
|
Returns the application $context to the PC/SC resource manager.
|
||||||
|
|
||||||
### scard_is_valid_context">scard_is_valid_context($context);
|
### scard_get_attrib($connection);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Get an attribute from the IFD Handler (reader driver).
|
||||||
|
|
||||||
|
### scard_get_status_change($context);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Blocks execution until the current availability of the cards in a specific set of readers changes.
|
||||||
|
|
||||||
|
### scard_is_valid_context($context);
|
||||||
|
|
||||||
Returns TRUE if $context is valid or FALSE if $context is not valid.
|
Returns TRUE if $context is valid or FALSE if $context is not valid.
|
||||||
|
|
||||||
### scard_release_context">scard_release_context($context);
|
### scard_last_errno(); - Not PC/SC standard.
|
||||||
|
|
||||||
Releases the application $context.
|
Returns the last $errno or nothing? NULL or FALSE? (TODO)
|
||||||
|
|
||||||
### scard_list_readers">scard_list_readers($context);
|
### scard_list_reader_groups($context);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Returns a list of currently available reader groups on the system.
|
||||||
|
|
||||||
|
### scard_list_readers($context);
|
||||||
|
|
||||||
Returns an array of available readers or FALSE.
|
Returns an array of available readers or FALSE.
|
||||||
|
|
||||||
|
|
@ -60,37 +131,97 @@ array(3) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### scard_connect">scard_connect($context, "OMNIKEY CardMan 5x21 00 00");
|
### scard_reconnect($connection);
|
||||||
|
|
||||||
Connects to a card. Returns the $connection to a reader or FALSE.
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
### scard_reconnect">scard_reconnect($connection);
|
|
||||||
|
|
||||||
Returns the $connection to a reader or FALSE.
|
Returns the $connection to a reader or FALSE.
|
||||||
|
|
||||||
### scard_disconnect">scard_disconnect($connection);
|
### scard_release_context($context);
|
||||||
|
|
||||||
Disconnects the $connection to a card. Returns the TRUE if disconnecting was succesful or FALSE.
|
Releases the application $context.
|
||||||
|
|
||||||
### scard_transmit">scard_transmit($connection, $apdu);
|
### scard_set_attrib($connection);
|
||||||
|
|
||||||
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
|
Set an attribute of the IFD Handler.
|
||||||
|
|
||||||
|
### scard_status($connection);
|
||||||
|
|
||||||
|
Returns the status array or FALSE.
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
array(7) {
|
||||||
|
["state"]=>
|
||||||
|
int(52)
|
||||||
|
["SCARD_PRESENT"]=>
|
||||||
|
int(1)
|
||||||
|
["SCARD_POWERED"]=>
|
||||||
|
int(1)
|
||||||
|
["SCARD_NEGOTIABLE"]=>
|
||||||
|
int(1)
|
||||||
|
["SCARD_PROTOCOL_T1"]=>
|
||||||
|
int(1)
|
||||||
|
["PROTOCOL"]=>
|
||||||
|
string(3) "T=1"
|
||||||
|
["ATR"]=>
|
||||||
|
string(28) "3B8980014A434F5033315632324A"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### scard_transmit($connection, $apdu);
|
||||||
|
|
||||||
Returns the response $apdu as string or FALSE.
|
Returns the response $apdu as string or FALSE.
|
||||||
|
|
||||||
### scard_status">scard_status($connection);
|
## To do:
|
||||||
|
|
||||||
Returns the status or FALSE.
|
There is some stuff to do. Some things are important but some are not.
|
||||||
|
|
||||||
### scard_cancel">scard_cancel($context);
|
### Implement important missing PC/SC functions and write documentation:
|
||||||
|
|
||||||
|
* SCardBeginTransaction()
|
||||||
|
* SCardEndTransaction()
|
||||||
|
* SCardControl()
|
||||||
|
* SCardGetStatusChange()
|
||||||
|
* Write complete API documentation
|
||||||
|
|
||||||
|
### Implement less important missing PC/SC functions:
|
||||||
|
|
||||||
|
* SCardGetAttrib()
|
||||||
|
* SCardSetAttrib()
|
||||||
|
* SCardListReaderGroups()
|
||||||
|
* SCardReconnect()
|
||||||
|
|
||||||
|
### Goal:
|
||||||
|
|
||||||
|
Completely implement the full API from [PC/SC API from PCSC-Lite](https://pcsclite.apdu.fr/api/group__API.html)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This code is licensed under the terms of the PHP License version 3.01. PCSC-Lite is licensed in a way where it is possible to integrate it native in the PHP environment.
|
This code is licensed under the terms of the PHP License version 3.01. PCSC-Lite is licensed in a way where it is possible to integrate it native in the PHP environment.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
This extension was originally written in 2005 by Johann Dantant. In 2011 Johannes Findeisen took his code and updated it to work with the current PHP version. Johannes maintains the code to this day, but there have been some contributions from other people in the past. All people who have worked on extending or porting the "pcsc" extension are listed below in alphabetical order by their last name. Thanks to all!
|
||||||
|
|
||||||
|
* [Anatol Belski](https://github.com/weltling) (Contributor)
|
||||||
|
* [Calvin Buckley](https://github.com/NattyNarwhal) (Contributor)
|
||||||
|
* [Remi Collet](https://github.com/remicollet) (Contributor)
|
||||||
|
* Johann Dantant (Original author)
|
||||||
|
* [Jan Ehrhardt](https://github.com/Jan-E) (Contributor)
|
||||||
|
* [Johannes Findeisen](https://github.com/hanez) (Maintainer)
|
||||||
|
* Marco Schuster (Contributor)
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
* [PECL Project Page](http://pecl.php.net/package/pcsc) - Page for package download at PHP.net
|
* [PECL Project Page](http://pecl.php.net/package/pcsc) - Page for package download at PHP.net
|
||||||
* [PC/SC Worgroup](http://www.pcscworkgroup.com/) - Homepage and definition file downloads
|
* [PC/SC Worgroup](http://www.pcscworkgroup.com/) - Homepage and definition file downloads
|
||||||
* [PC/SC](http://en.wikipedia.org/wiki/PC/SC) - PC/SC at Wikipedia
|
* [PC/SC](http://en.wikipedia.org/wiki/PC/SC) - PC/SC at Wikipedia
|
||||||
* [PC/SC-Lite](https://pcsclite.apdu.fr/) - The free and open implementation of the PC/SC SCard API for UNIX
|
* [PC/SC-Lite](https://pcsclite.apdu.fr/) - The free and open implementation of the PC/SC SCard API for UNIX
|
||||||
* [PCSC sample in PHP5](http://ludovicrousseau.blogspot.de/2015/01/pcsc-sample-in-php5.html) - Ludovic Rousseau about "PC/SC for PHP"
|
* [PC/SC API from PCSC-Lite](https://pcsclite.apdu.fr/api/group__API.html) - Documentation of the PCSC-Lite API
|
||||||
|
* [PCSC sample in PHP5](https://blog.apdu.fr/posts/2015/01/pcsc-sample-in-php5/) - Ludovic Rousseau about "PC/SC for PHP"
|
||||||
|
* [winscard.h header](https://docs.microsoft.com/en-us/windows/win32/api/winscard/) - Microsoft Documentation
|
||||||
|
|
||||||
|
|
|
||||||
17
TODO.md
17
TODO.md
|
|
@ -1,17 +0,0 @@
|
||||||
# TODO
|
|
||||||
|
|
||||||
## Implement important missing PC/SC functions and write documentation:
|
|
||||||
|
|
||||||
* SCardControl()
|
|
||||||
* SCardGetStatusChange()
|
|
||||||
* SCardBeginTransaction()
|
|
||||||
* SCardEndTransaction()
|
|
||||||
* Write complete API documentation
|
|
||||||
|
|
||||||
## Implement less important missing PC/SC functions:
|
|
||||||
|
|
||||||
* SCardGetAttrib()
|
|
||||||
* SCardSetAttrib()
|
|
||||||
* SCardListReaderGroups()
|
|
||||||
* SCardReconnect
|
|
||||||
|
|
||||||
|
|
@ -15,9 +15,9 @@ class PCSC {
|
||||||
$this->context = scard_establish_context();
|
$this->context = scard_establish_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct() {
|
/*function __destruct() {
|
||||||
$this->context = scard_release_context($this->context);
|
$this->context = scard_release_context($this->context);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
function connect($reader) {
|
function connect($reader) {
|
||||||
return $this->connection = scard_connect($this->context, $reader);
|
return $this->connection = scard_connect($this->context, $reader);
|
||||||
|
|
|
||||||
119
docs/examples/simple.php
Normal file
119
docs/examples/simple.php
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!extension_loaded('pcsc')) {
|
||||||
|
dl('pcsc.so');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a PC/SC context
|
||||||
|
echo ">> Create Context\n";
|
||||||
|
$context = scard_establish_context();
|
||||||
|
var_dump($context);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Get the reader list
|
||||||
|
echo ">> Get Readers\n";
|
||||||
|
$readers = scard_list_readers($context);
|
||||||
|
var_dump($readers);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Use the first reader
|
||||||
|
echo ">> Select Reader\n";
|
||||||
|
$reader = $readers[1];
|
||||||
|
echo "Using reader: ", $reader, "\n";
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Connect to the card
|
||||||
|
echo ">> Connect to Card\n";
|
||||||
|
$card = scard_connect($context, $reader, 2);
|
||||||
|
var_dump( $card );
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Begin Transaction
|
||||||
|
echo ">> Begin Transaction\n";
|
||||||
|
$begin= scard_begin_transaction($card);
|
||||||
|
var_dump($begin);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Select Applet APDU
|
||||||
|
echo ">> Select Applet\n";
|
||||||
|
$apdu = "00a4040c0cD2760001354B414E4D30310000";
|
||||||
|
$res = scard_transmit($card , $apdu);
|
||||||
|
var_dump($res);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# test APDU
|
||||||
|
echo ">> Send APDU\n";
|
||||||
|
$apdu = "0084000008";
|
||||||
|
$res = scard_transmit($card, $apdu);
|
||||||
|
var_dump($res);
|
||||||
|
#echo pack("H*", $res), "\n";
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# End Transaction
|
||||||
|
echo ">> End Transaction\n";
|
||||||
|
$begin= scard_end_transaction($card);
|
||||||
|
var_dump( $card );
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Show Status
|
||||||
|
echo ">> Show Status\n";
|
||||||
|
$status = scard_status($card);
|
||||||
|
var_dump($status);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
# Release the PC/SC context
|
||||||
|
echo ">> Release Context\n";
|
||||||
|
scard_release_context($context);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -13,19 +13,22 @@ $foo = new PCSC();
|
||||||
echo "Create Context:\n";
|
echo "Create Context:\n";
|
||||||
var_dump($foo->context);
|
var_dump($foo->context);
|
||||||
|
|
||||||
|
#echo "Last Error String:";
|
||||||
|
#var_dump($foo->scard_errstr($foo->scard_last_errno()));
|
||||||
|
|
||||||
echo "List Readers:\n";
|
echo "List Readers:\n";
|
||||||
var_dump($foo->listreaders());
|
var_dump($foo->listreaders());
|
||||||
|
|
||||||
echo "Connect Card:\n";
|
echo "Connect Card:\n";
|
||||||
var_dump($foo->connect("OMNIKEY CardMan 5x21 00 01"));
|
var_dump($foo->connect("OMNIKEY CardMan (076B:5321) 5321 00 01"));
|
||||||
|
|
||||||
#echo "Reconnect:\n";
|
#echo "Reconnect:\n";
|
||||||
#var_dump($foo->reconnect());
|
#var_dump($foo->reconnect());
|
||||||
|
|
||||||
echo "Some Transmits:\n";
|
echo "Some Transmits:\n";
|
||||||
|
// Select applet
|
||||||
var_dump($foo->transmit("00a4040c0cD2760001354B414E4D30310000"));
|
var_dump($foo->transmit("00a4040c0cD2760001354B414E4D30310000"));
|
||||||
var_dump($foo->transmit("0084000008"));
|
// APDU to execute RNG function on card applet
|
||||||
var_dump($foo->transmit("0084000008"));
|
|
||||||
var_dump($foo->transmit("0084000008"));
|
var_dump($foo->transmit("0084000008"));
|
||||||
|
|
||||||
echo "Is Valid Context?\n";
|
echo "Is Valid Context?\n";
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<date>2021-02-21</date>
|
<date>2021-02-21</date>
|
||||||
<time>01:26:42</time>
|
<time>01:26:42</time>
|
||||||
<version>
|
<version>
|
||||||
<release>0.5.1</release>
|
<release>0.6.0</release>
|
||||||
<api>0.3.1</api>
|
<api>0.3.1</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
|
|
@ -35,7 +35,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<contents>
|
<contents>
|
||||||
<dir name="/">
|
<dir name="/">
|
||||||
<file name="COPYING" role="doc" />
|
<file name="COPYING" role="doc" />
|
||||||
<file name="CREDITS.md" role="doc" />
|
|
||||||
<file name="config.m4" role="src" />
|
<file name="config.m4" role="src" />
|
||||||
<file name="config.w32" role="src" />
|
<file name="config.w32" role="src" />
|
||||||
<file name="pcsc.c" role="src" />
|
<file name="pcsc.c" role="src" />
|
||||||
|
|
@ -44,7 +43,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<file name="pcsc_arginfo.h" role="src" />
|
<file name="pcsc_arginfo.h" role="src" />
|
||||||
<file name="pcsc_legacy_arginfo.h" role="src" />
|
<file name="pcsc_legacy_arginfo.h" role="src" />
|
||||||
<file name="README.md" role="doc" />
|
<file name="README.md" role="doc" />
|
||||||
<file name="TODO.md" role="doc" />
|
|
||||||
</dir> <!-- / -->
|
</dir> <!-- / -->
|
||||||
</contents>
|
</contents>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
45
pcsc.c
45
pcsc.c
|
|
@ -575,7 +575,7 @@ PHP_FUNCTION(scard_list_readers)
|
||||||
Return a handle to the card */
|
Return a handle to the card */
|
||||||
PHP_FUNCTION(scard_connect)
|
PHP_FUNCTION(scard_connect)
|
||||||
{
|
{
|
||||||
DWORD dwPreferredProtocol = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
|
DWORD dwPreferredProtocol = SCARD_PROTOCOL_RAW | SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
|
||||||
DWORD dwCurrentProtocol;
|
DWORD dwCurrentProtocol;
|
||||||
SCARDHANDLE hCard = 0;
|
SCARDHANDLE hCard = 0;
|
||||||
LONG rc = 0;
|
LONG rc = 0;
|
||||||
|
|
@ -636,6 +636,48 @@ PHP_FUNCTION(scard_disconnect)
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto boolean scard_begin_transaction(resource card_handle)
|
||||||
|
Begin transaction on a card connection obtained with scard_connect */
|
||||||
|
PHP_FUNCTION(scard_begin_transaction)
|
||||||
|
{
|
||||||
|
LONG rc;
|
||||||
|
zval* conn_res;
|
||||||
|
SCARDHANDLE hCard;
|
||||||
|
|
||||||
|
ZEND_FETCH_RESOURCE(hCard, SCARDHANDLE, &conn_res, -1, PHP_PCSC_CONN_RES_NAME, le_pcsc_conn_res);
|
||||||
|
|
||||||
|
rc = SCardBeginTransaction(hCard);
|
||||||
|
if (rc != SCARD_S_SUCCESS) {
|
||||||
|
PCSC_G(last_errno) = rc;
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
RETURN_TRUE;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto boolean scard_end_transaction(resource card_handle, [long disposition = SCARD_LEAVE_CARD])
|
||||||
|
End a previously begun transaction invoked by scard_begin_transaction on a card connection obtained with scard_connect; If no transaction began, do nothing. */
|
||||||
|
PHP_FUNCTION(scard_end_transaction)
|
||||||
|
{
|
||||||
|
zend_long dwDisposition = SCARD_LEAVE_CARD;
|
||||||
|
LONG rc;
|
||||||
|
zval* conn_res;
|
||||||
|
SCARDHANDLE hCard;
|
||||||
|
|
||||||
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &conn_res, &dwDisposition) == FAILURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ZEND_FETCH_RESOURCE(hCard, SCARDHANDLE, &conn_res, -1, PHP_PCSC_CONN_RES_NAME, le_pcsc_conn_res);
|
||||||
|
|
||||||
|
rc = SCardEndTransaction(hCard, (DWORD)dwDisposition);
|
||||||
|
if (rc != SCARD_S_SUCCESS) {
|
||||||
|
PCSC_G(last_errno) = rc;
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
RETURN_TRUE;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto string scard_transmit(resource card_handle, string send_command)
|
/* {{{ proto string scard_transmit(resource card_handle, string send_command)
|
||||||
Transmit (and receive) data to (and from) the card */
|
Transmit (and receive) data to (and from) the card */
|
||||||
PHP_FUNCTION(scard_transmit)
|
PHP_FUNCTION(scard_transmit)
|
||||||
|
|
@ -751,7 +793,6 @@ PHP_FUNCTION(scard_status)
|
||||||
add_assoc_long(return_value, "SCARD_SPECIFIC", 1);
|
add_assoc_long(return_value, "SCARD_SPECIFIC", 1);
|
||||||
|
|
||||||
switch (dwProtocol) {
|
switch (dwProtocol) {
|
||||||
/* Maybe change to bool type here instead of add_assoc_long...? */
|
|
||||||
case SCARD_PROTOCOL_RAW : add_assoc_long(return_value, "SCARD_PROTOCOL_RAW", 1);
|
case SCARD_PROTOCOL_RAW : add_assoc_long(return_value, "SCARD_PROTOCOL_RAW", 1);
|
||||||
add_assoc_string(return_value, "PROTOCOL", "RAW");
|
add_assoc_string(return_value, "PROTOCOL", "RAW");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,18 @@ function scard_connect($context, string $reader_name, int $preferred_protocol=SC
|
||||||
*/
|
*/
|
||||||
function scard_disconnect($card, int $disposition=SCARD_EJECT_CARD): bool {}
|
function scard_disconnect($card, int $disposition=SCARD_EJECT_CARD): bool {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $card
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_begin_transaction($card): bool {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $card
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_end_transaction($card, int $disposition=SCARD_LEAVE_CARD): bool {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $card
|
* @param resource $card
|
||||||
* @return resource|false
|
* @return resource|false
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */
|
* Stub hash: 676b86ff0a1ee4d762d86126e8068f4cb6805272 */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
@ -26,6 +26,15 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_disconnect, 0, 1, _IS_BOOL
|
||||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, disposition, IS_LONG, 0, "SCARD_EJECT_CARD")
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, disposition, IS_LONG, 0, "SCARD_EJECT_CARD")
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_begin_transaction, 0, 1, _IS_BOOL, 0)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_end_transaction, 0, 1, _IS_BOOL, 0)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, disposition, IS_LONG, 0, "SCARD_LEAVE_CARD")
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scard_transmit, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scard_transmit, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
|
||||||
ZEND_ARG_INFO(0, card)
|
ZEND_ARG_INFO(0, card)
|
||||||
ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0)
|
ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0)
|
||||||
|
|
@ -49,6 +58,8 @@ ZEND_FUNCTION(scard_is_valid_context);
|
||||||
ZEND_FUNCTION(scard_list_readers);
|
ZEND_FUNCTION(scard_list_readers);
|
||||||
ZEND_FUNCTION(scard_connect);
|
ZEND_FUNCTION(scard_connect);
|
||||||
ZEND_FUNCTION(scard_disconnect);
|
ZEND_FUNCTION(scard_disconnect);
|
||||||
|
ZEND_FUNCTION(scard_begin_transaction);
|
||||||
|
ZEND_FUNCTION(scard_end_transaction);
|
||||||
ZEND_FUNCTION(scard_transmit);
|
ZEND_FUNCTION(scard_transmit);
|
||||||
ZEND_FUNCTION(scard_status);
|
ZEND_FUNCTION(scard_status);
|
||||||
ZEND_FUNCTION(scard_last_errno);
|
ZEND_FUNCTION(scard_last_errno);
|
||||||
|
|
@ -62,6 +73,8 @@ static const zend_function_entry ext_functions[] = {
|
||||||
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
||||||
ZEND_FE(scard_connect, arginfo_scard_connect)
|
ZEND_FE(scard_connect, arginfo_scard_connect)
|
||||||
ZEND_FE(scard_disconnect, arginfo_scard_disconnect)
|
ZEND_FE(scard_disconnect, arginfo_scard_disconnect)
|
||||||
|
ZEND_FE(scard_begin_transaction, arginfo_scard_begin_transaction)
|
||||||
|
ZEND_FE(scard_end_transaction, arginfo_scard_end_transaction)
|
||||||
ZEND_FE(scard_transmit, arginfo_scard_transmit)
|
ZEND_FE(scard_transmit, arginfo_scard_transmit)
|
||||||
ZEND_FE(scard_status, arginfo_scard_status)
|
ZEND_FE(scard_status, arginfo_scard_status)
|
||||||
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */
|
* Stub hash: 676b86ff0a1ee4d762d86126e8068f4cb6805272 */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
@ -24,14 +24,18 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_disconnect, 0, 0, 1)
|
||||||
ZEND_ARG_INFO(0, disposition)
|
ZEND_ARG_INFO(0, disposition)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_begin_transaction, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
#define arginfo_scard_end_transaction arginfo_scard_disconnect
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_transmit, 0, 0, 2)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_transmit, 0, 0, 2)
|
||||||
ZEND_ARG_INFO(0, card)
|
ZEND_ARG_INFO(0, card)
|
||||||
ZEND_ARG_INFO(0, command)
|
ZEND_ARG_INFO(0, command)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_status, 0, 0, 1)
|
#define arginfo_scard_status arginfo_scard_begin_transaction
|
||||||
ZEND_ARG_INFO(0, card)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
#define arginfo_scard_last_errno arginfo_scard_establish_context
|
#define arginfo_scard_last_errno arginfo_scard_establish_context
|
||||||
|
|
||||||
|
|
@ -46,6 +50,8 @@ ZEND_FUNCTION(scard_is_valid_context);
|
||||||
ZEND_FUNCTION(scard_list_readers);
|
ZEND_FUNCTION(scard_list_readers);
|
||||||
ZEND_FUNCTION(scard_connect);
|
ZEND_FUNCTION(scard_connect);
|
||||||
ZEND_FUNCTION(scard_disconnect);
|
ZEND_FUNCTION(scard_disconnect);
|
||||||
|
ZEND_FUNCTION(scard_begin_transaction);
|
||||||
|
ZEND_FUNCTION(scard_end_transaction);
|
||||||
ZEND_FUNCTION(scard_transmit);
|
ZEND_FUNCTION(scard_transmit);
|
||||||
ZEND_FUNCTION(scard_status);
|
ZEND_FUNCTION(scard_status);
|
||||||
ZEND_FUNCTION(scard_last_errno);
|
ZEND_FUNCTION(scard_last_errno);
|
||||||
|
|
@ -59,6 +65,8 @@ static const zend_function_entry ext_functions[] = {
|
||||||
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
||||||
ZEND_FE(scard_connect, arginfo_scard_connect)
|
ZEND_FE(scard_connect, arginfo_scard_connect)
|
||||||
ZEND_FE(scard_disconnect, arginfo_scard_disconnect)
|
ZEND_FE(scard_disconnect, arginfo_scard_disconnect)
|
||||||
|
ZEND_FE(scard_begin_transaction, arginfo_scard_begin_transaction)
|
||||||
|
ZEND_FE(scard_end_transaction, arginfo_scard_end_transaction)
|
||||||
ZEND_FE(scard_transmit, arginfo_scard_transmit)
|
ZEND_FE(scard_transmit, arginfo_scard_transmit)
|
||||||
ZEND_FE(scard_status, arginfo_scard_status)
|
ZEND_FE(scard_status, arginfo_scard_status)
|
||||||
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
extern zend_module_entry pcsc_module_entry;
|
extern zend_module_entry pcsc_module_entry;
|
||||||
#define phpext_pcsc_ptr &pcsc_module_entry
|
#define phpext_pcsc_ptr &pcsc_module_entry
|
||||||
|
|
||||||
#define PHP_PCSC_VERSION "0.5.1"
|
#define PHP_PCSC_VERSION "0.6.0"
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
#define PHP_PCSC_API __declspec(dllexport)
|
#define PHP_PCSC_API __declspec(dllexport)
|
||||||
|
|
@ -32,6 +32,8 @@ PHP_FUNCTION(scard_list_readers);
|
||||||
PHP_FUNCTION(scard_connect);
|
PHP_FUNCTION(scard_connect);
|
||||||
//PHP_FUNCTION(scard_reconnect);
|
//PHP_FUNCTION(scard_reconnect);
|
||||||
PHP_FUNCTION(scard_disconnect);
|
PHP_FUNCTION(scard_disconnect);
|
||||||
|
PHP_FUNCTION(scard_begin_transaction);
|
||||||
|
PHP_FUNCTION(scard_end_transaction);
|
||||||
PHP_FUNCTION(scard_status);
|
PHP_FUNCTION(scard_status);
|
||||||
//PHP_FUNCTION(scard_get_status_change);
|
//PHP_FUNCTION(scard_get_status_change);
|
||||||
PHP_FUNCTION(scard_transmit);
|
PHP_FUNCTION(scard_transmit);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue