mirror of
https://github.com/pcsc-for-php/pcsc.git
synced 2026-08-13 15:11:25 +02:00
Compare commits
37 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 | |||
| 54382009f7 | |||
| f66c5ae0a6 | |||
|
7fb5ca5d41 |
|||
|
|
7086a7e25a | ||
|
|
7849799fe7 | ||
|
|
71ee080987 | ||
|
1c91afe164 |
|||
|
|
1d0a009e02 | ||
|
|
054ec3d5a3 |
13 changed files with 807 additions and 264 deletions
63
.gitignore
vendored
Normal file
63
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
nbproject/
|
||||||
|
|
||||||
|
*.dep
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# archives
|
||||||
|
pcsc-*.tgz
|
||||||
|
|
||||||
|
# autotools
|
||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
config.cache
|
||||||
|
config.guess
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.h.in~
|
||||||
|
config.log
|
||||||
|
config.nice
|
||||||
|
config.status
|
||||||
|
config.sub
|
||||||
|
configure
|
||||||
|
configure~
|
||||||
|
configure.ac
|
||||||
|
configure.in
|
||||||
|
conftest
|
||||||
|
conftest.c
|
||||||
|
Makefile
|
||||||
|
Makefile.fragments
|
||||||
|
Makefile.global
|
||||||
|
Makefile.objects
|
||||||
|
acinclude.m4
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache
|
||||||
|
build
|
||||||
|
install-sh
|
||||||
|
libtool
|
||||||
|
ltmain.sh
|
||||||
|
ltmain.sh.backup
|
||||||
|
missing
|
||||||
|
mkinstalldirs
|
||||||
|
modules
|
||||||
|
run-tests.php
|
||||||
|
run-tests.log
|
||||||
|
tmp-php.ini
|
||||||
2
CREDITS
2
CREDITS
|
|
@ -1,2 +0,0 @@
|
||||||
pcsc
|
|
||||||
Johann Dantant, Johannes Findeisen, Marco Schuster, Calvin Buckley
|
|
||||||
236
README.md
236
README.md
|
|
@ -1,103 +1,227 @@
|
||||||
<h2 id="About">About</h2>
|
# PC/SC for PHP
|
||||||
|
|
||||||
<p>This is the only extension for using <a href="http://www.pcscworkgroup.com/" class="ext">PC/SC</a> based smart cards with <a href="http://www.php.net" class="ext">PHP</a>. It is a wrapper to the wonderful and free project by Ludovic Rousseau, <a href="http://pcsclite.alioth.debian.org/" class="ext">PCSC-Lite</a>, which is the middleware to access a smart card using SCard API (PC/SC). Since PCSC-Lite is compatible to the winscard API it should be possible to compile this extension using a Windows(R) operating system. Currently I only take focus on Linux environments.</p>
|
## About
|
||||||
|
|
||||||
<p>Thanks are going to Johann Dantant! He provides a PC/SC extension for PHP since 2005 and I reused some of his code. He allowed me to relicense these parts under the terms of the PHP license so I could integrate PCSC-Lite natively into PHP.</p>
|
This is the only extension for using [PC/SC](http://www.pcscworkgroup.com/) based smart cards with [PHP](http://www.php.net). It is a wrapper to the wonderful and free project by Ludovic Rousseau, [PCSC-Lite](https://pcsclite.apdu.fr/), which is the middleware to access a smart card using SCard API (PC/SC). Since PCSC-Lite is compatible to the winscard API it should be possible to compile this extension using a Windows or macOS operating system.
|
||||||
|
|
||||||
<h2 id="Installation">Installation</h2>
|
Thanks are going to Johann Dantant! He provided a PC/SC extension for PHP since 2005 and I reused some of his code. He allowed me to relicense these parts under the terms of the PHP license so I could integrate PCSC-Lite native into PHP.
|
||||||
|
|
||||||
<p>I recommend to install the PECL extension the "PHP" way:</p>
|
## Installation
|
||||||
|
|
||||||
<pre>pecl install pcsc-alpha</pre>
|
I recommend to install the PECL extension the "PHP" way:
|
||||||
|
|
||||||
<p>You can install the latest version by downloading the sources and compile yourself too... :)</p>
|
```
|
||||||
|
pecl install pcsc-beta
|
||||||
|
```
|
||||||
|
|
||||||
<pre>wget http://pecl.php.net/get/pcsc-0.3.1.tgz
|
You can install the latest code by downloading the sources and compile yourself too.
|
||||||
tar -xvf pcsc-0.3.1.tgz
|
|
||||||
cd pcsc-0.3.1
|
```
|
||||||
|
git clone https://github.com/pcsc-for-php/pcsc.git
|
||||||
|
cd pcsc
|
||||||
phpize
|
phpize
|
||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
make install</pre>
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
<p>After that you have all needed files in ./modules/</p>
|
After that you have all needed files in ./modules/ .
|
||||||
|
|
||||||
<h2 id="API">API</h2>
|
## API
|
||||||
|
|
||||||
<p>The extension currently provides the following API:</p>
|
The extension currently provides the following API (alphabetical order):
|
||||||
|
|
||||||
<h3 id="scard_establish_context">scard_establish_context();</h3>
|
### pcsc_stringify_error($errno);
|
||||||
|
|
||||||
<p>Returns the application $context to the PC/SC resource manager.</p>
|
Returns $errstr for $errno or NULL.
|
||||||
|
|
||||||
<h3 id="scard_is_valid_context">scard_is_valid_context($context);</h3>
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
<p>Returns TRUE if $context is valid or FALSE if $context is not valid.</p>
|
Duplicate of scard_errstr() but this should be the default.
|
||||||
|
|
||||||
<h3 id="scard_release_context">scard_release_context($context);</h3>
|
### scard_begin_transaction($connection);
|
||||||
|
|
||||||
<p>Releases the application $context.</p>
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
<h3 id="scard_list_readers">scard_list_readers($context);</h3>
|
Establishes a temporary exclusive access mode for doing a serie of commands in a transaction.
|
||||||
|
|
||||||
<p>Returns an array of available readers or FALSE.</p>
|
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.
|
||||||
|
|
||||||
<h5>Example:</h5>
|
### scard_cancel($context);
|
||||||
|
|
||||||
<pre>array(3) {
|
**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.
|
||||||
[0]=>
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
### scard_last_errno(); - Not PC/SC standard.
|
||||||
|
|
||||||
|
Returns the last $errno or nothing? NULL or FALSE? (TODO)
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
string(26) "OMNIKEY CardMan 5x21 00 00"
|
string(26) "OMNIKEY CardMan 5x21 00 00"
|
||||||
[1]=>
|
[1]=>
|
||||||
string(26) "OMNIKEY CardMan 5x21 00 01"
|
string(26) "OMNIKEY CardMan 5x21 00 01"
|
||||||
[2]=>
|
[2]=>
|
||||||
string(76) "SCL01x Contactless Reader [SCL01x Contactless Reader] (21161009200722) 00 00"
|
string(76) "SCL01x Contactless Reader [SCL01x Contactless Reader] (21161009200722) 00 00"
|
||||||
}
|
}
|
||||||
</pre>
|
```
|
||||||
|
|
||||||
<h3 id="scard_connect">scard_connect($context, "OMNIKEY CardMan 5x21 00 00");</h3>
|
### scard_reconnect($connection);
|
||||||
|
|
||||||
<p>Connects to a card. Returns the $connection to a reader or FALSE.</p>
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
<h3 id="scard_reconnect">scard_reconnect($connection);</h3>
|
Returns the $connection to a reader or FALSE.
|
||||||
|
|
||||||
<p>Returns the $connection to a reader or FALSE.</p>
|
### scard_release_context($context);
|
||||||
|
|
||||||
<h3 id="scard_disconnect">scard_disconnect($connection);</h3>
|
Releases the application $context.
|
||||||
|
|
||||||
<p>Disconnects the $connection to a card. Returns the TRUE if disconnecting was succesful or FALSE.</p>
|
### scard_set_attrib($connection);
|
||||||
|
|
||||||
<h3 id="scard_transmit">scard_transmit($connection, $apdu);</h3>
|
**NOT IMPLEMENTED!** - Should be available!
|
||||||
|
|
||||||
<p>Returns the response $apdu as string or FALSE.</p>
|
Set an attribute of the IFD Handler.
|
||||||
|
|
||||||
<h3 id="scard_status">scard_status($connection);</h3>
|
### scard_status($connection);
|
||||||
|
|
||||||
<p>Returns the status or FALSE.</p>
|
Returns the status array or FALSE.
|
||||||
|
|
||||||
<h3 id="scard_cancel">scard_cancel($context);</h3>
|
#### Example:
|
||||||
|
|
||||||
<h2 id="Code">Code</h2>
|
```
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
<p>The code has successful been released to the official code repository <a href="http://pecl.php.net" class="ext">pecl.php.net</a>... ;)
|
### scard_transmit($connection, $apdu);
|
||||||
|
|
||||||
<ul>
|
Returns the response $apdu as string or FALSE.
|
||||||
<li><a href="http://pecl.php.net/package/pcsc" class="ext">PECL Project Page</a></li>
|
|
||||||
<li><a href="http://svn.php.net/viewvc/pecl/pcsc/trunk/" class="ext">PHP SVN Code Browser</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>You could get the code using the following command:</p>
|
## To do:
|
||||||
|
|
||||||
<pre>svn checkout http://svn.php.net/repository/pecl/pcsc/trunk pcsc</pre>
|
There is some stuff to do. Some things are important but some are not.
|
||||||
|
|
||||||
<h2 id="License">License</h2>
|
### Implement important missing PC/SC functions and write documentation:
|
||||||
|
|
||||||
<p>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.</p>
|
* SCardBeginTransaction()
|
||||||
|
* SCardEndTransaction()
|
||||||
|
* SCardControl()
|
||||||
|
* SCardGetStatusChange()
|
||||||
|
* Write complete API documentation
|
||||||
|
|
||||||
<h2 id="Links">Links</h2>
|
### 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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
* [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](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 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
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://www.pcscworkgroup.com/" class="ext">PC/SC Worgroup</a> - Homepage and definition file downloads.</li>
|
|
||||||
<li><a href="http://en.wikipedia.org/wiki/PC/SC" class="ext">PC/SC</a> - PC/SC at Wikipedia.</li>
|
|
||||||
<li><a href="http://pcsclite.alioth.debian.org/" class="ext">PC/SC-Lite</a> - The free and open implementation of the PC/SC SCard API for UNIX</li>
|
|
||||||
<li><a href="http://ludovicrousseau.blogspot.de/2015/01/pcsc-sample-in-php5.html" class="ext">PCSC sample in PHP5</a> - Ludovic Rousseau about "PC/SC for PHP"</li>
|
|
||||||
</ul>
|
|
||||||
|
|
|
||||||
15
TODO
15
TODO
|
|
@ -1,15 +0,0 @@
|
||||||
Implement important missing PC/SC functions:
|
|
||||||
|
|
||||||
- SCardControl(),
|
|
||||||
SCardGetStatusChange(),
|
|
||||||
SCardBeginTransaction(),
|
|
||||||
SCardEndTransaction()
|
|
||||||
|
|
||||||
Implement less important missing PC/SC functions:
|
|
||||||
|
|
||||||
- SCardGetAttrib(),
|
|
||||||
SCardSetAttrib(),
|
|
||||||
SCardListReaderGroups(),
|
|
||||||
SCardReconnect
|
|
||||||
|
|
||||||
Write complete API documentation
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
16
package.xml
16
package.xml
|
|
@ -6,7 +6,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<name>pcsc</name>
|
<name>pcsc</name>
|
||||||
<channel>pecl.php.net</channel>
|
<channel>pecl.php.net</channel>
|
||||||
<summary>winscard PC/SC API support for PHP</summary>
|
<summary>winscard PC/SC API support for PHP</summary>
|
||||||
<description>This is an extension for using PC/SC based smart cards with PHP. It is a wrapper to the winscard API which provides a native interface to smart cards using the PC/SC standard. Both Linux and Windows are supported.
|
<description>This is an extension for using PC/SC based smart cards with PHP. It is a wrapper to the winscard API which provides a native interface to smart cards using the PC/SC standard. Linux/UNIX and Windows are supported.
|
||||||
</description>
|
</description>
|
||||||
<lead>
|
<lead>
|
||||||
<name>Johannes Findeisen</name>
|
<name>Johannes Findeisen</name>
|
||||||
|
|
@ -20,10 +20,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<email>calvin@cmpct.info</email>
|
<email>calvin@cmpct.info</email>
|
||||||
<active>yes</active>
|
<active>yes</active>
|
||||||
</developer>
|
</developer>
|
||||||
<date>2021-02-08</date>
|
<date>2021-02-21</date>
|
||||||
<time>23:22:33</time>
|
<time>01:26:42</time>
|
||||||
<version>
|
<version>
|
||||||
<release>0.4.0</release>
|
<release>0.6.0</release>
|
||||||
<api>0.3.1</api>
|
<api>0.3.1</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
|
|
@ -31,16 +31,18 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||||
<api>stable</api>
|
<api>stable</api>
|
||||||
</stability>
|
</stability>
|
||||||
<license uri="http://www.php.net/license">PHP</license>
|
<license uri="http://www.php.net/license">PHP</license>
|
||||||
<notes>Updated for PHP 7 compatibility.</notes>
|
<notes>Added and updated content like README.md; No bug or feature updates.</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir name="/">
|
<dir name="/">
|
||||||
<file name="COPYING" role="doc" />
|
<file name="COPYING" role="doc" />
|
||||||
<file name="CREDITS" 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" />
|
||||||
<file name="php_pcsc.h" role="src" />
|
<file name="php_pcsc.h" role="src" />
|
||||||
<file name="TODO" role="doc" />
|
<file name="pcsc.stub.php" role="src" />
|
||||||
|
<file name="pcsc_arginfo.h" role="src" />
|
||||||
|
<file name="pcsc_legacy_arginfo.h" role="src" />
|
||||||
|
<file name="README.md" role="doc" />
|
||||||
</dir> <!-- / -->
|
</dir> <!-- / -->
|
||||||
</contents>
|
</contents>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
102
pcsc.c
102
pcsc.c
|
|
@ -1,8 +1,6 @@
|
||||||
/*
|
/*
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
| PHP Version 5 |
|
| Copyright (c) The PHP Group |
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| Copyright (c) 1997-2006 The PHP Group |
|
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
| This source file is subject to version 3.01 of the PHP license, |
|
| This source file is subject to version 3.01 of the PHP license, |
|
||||||
| that is bundled with this package in the file LICENSE, and is |
|
| that is bundled with this package in the file LICENSE, and is |
|
||||||
|
|
@ -38,34 +36,11 @@ ZEND_DECLARE_MODULE_GLOBALS(pcsc);
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* arg info for scard_connect (accepts an optional compile-time reference parameter) */
|
#if PHP_VERSION_ID < 80000
|
||||||
ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_connect_arginfo, 0, 0, 2)
|
#include "pcsc_legacy_arginfo.h"
|
||||||
ZEND_ARG_INFO(0, context)
|
#else
|
||||||
ZEND_ARG_INFO(0, reader_name)
|
#include "pcsc_arginfo.h"
|
||||||
ZEND_ARG_INFO(0, preferred_protocol)
|
#endif
|
||||||
ZEND_ARG_INFO(1, active_protocol)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
/* {{{ pcsc_functions[]
|
|
||||||
*
|
|
||||||
* Every user visible function must have an entry in pcsc_functions[].
|
|
||||||
*/
|
|
||||||
zend_function_entry pcsc_functions[] = {
|
|
||||||
PHP_FE(scard_establish_context, NULL)
|
|
||||||
PHP_FE(scard_release_context, NULL)
|
|
||||||
PHP_FE(scard_is_valid_context, NULL)
|
|
||||||
PHP_FE(scard_list_readers, NULL)
|
|
||||||
PHP_FE(scard_connect, php_pcsc_scard_connect_arginfo)
|
|
||||||
//PHP_FE(scard_reconnect, NULL)
|
|
||||||
PHP_FE(scard_disconnect, NULL)
|
|
||||||
PHP_FE(scard_transmit, NULL)
|
|
||||||
PHP_FE(scard_status, NULL)
|
|
||||||
//PHP_FE(scard_get_status_change, NULL)
|
|
||||||
PHP_FE(scard_last_errno, NULL)
|
|
||||||
PHP_FE(scard_errstr, NULL)
|
|
||||||
{NULL, NULL, NULL}
|
|
||||||
};
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ pcsc_module_entry
|
/* {{{ pcsc_module_entry
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,7 +49,7 @@ zend_module_entry pcsc_module_entry = {
|
||||||
STANDARD_MODULE_HEADER,
|
STANDARD_MODULE_HEADER,
|
||||||
#endif
|
#endif
|
||||||
"PC/SC",
|
"PC/SC",
|
||||||
pcsc_functions,
|
ext_functions,
|
||||||
PHP_MINIT(pcsc),
|
PHP_MINIT(pcsc),
|
||||||
PHP_MSHUTDOWN(pcsc),
|
PHP_MSHUTDOWN(pcsc),
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -102,13 +77,13 @@ static void php_pcsc_ctx_res_dtor(zend_resource *rsrc) {
|
||||||
context=(SCARDCONTEXT)rsrc->ptr;
|
context=(SCARDCONTEXT)rsrc->ptr;
|
||||||
rc = SCardIsValidContext(context);
|
rc = SCardIsValidContext(context);
|
||||||
if (rc != SCARD_S_SUCCESS) {
|
if (rc != SCARD_S_SUCCESS) {
|
||||||
php_error_docref(NULL, E_WARNING, "PC/SC context dtor: SCardIsValidContext returned %s (0x%x)", php_pcsc_error_to_string(rc), rc);
|
php_error_docref(NULL, E_WARNING, "PC/SC context dtor: SCardIsValidContext returned %s (0x%lx)", php_pcsc_error_to_string(rc), rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = SCardReleaseContext(context);
|
rc = SCardReleaseContext(context);
|
||||||
if (rc != SCARD_S_SUCCESS) {
|
if (rc != SCARD_S_SUCCESS) {
|
||||||
php_error_docref(NULL, E_WARNING, "PC/SC context dtor: SCardReleaseContext returned %s (0x%x)", php_pcsc_error_to_string(rc), rc);
|
php_error_docref(NULL, E_WARNING, "PC/SC context dtor: SCardReleaseContext returned %s (0x%lx)", php_pcsc_error_to_string(rc), rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -127,7 +102,7 @@ static void php_pcsc_conn_res_dtor(zend_resource *rsrc) {
|
||||||
|
|
||||||
rc = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
|
rc = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
|
||||||
if (rc != SCARD_S_SUCCESS) {
|
if (rc != SCARD_S_SUCCESS) {
|
||||||
php_error_docref(NULL, E_WARNING, "PC/SC connection dtor: SCardDisconnect returned %s (0x%x)", php_pcsc_error_to_string(rc), rc);
|
php_error_docref(NULL, E_WARNING, "PC/SC connection dtor: SCardDisconnect returned %s (0x%lx)", php_pcsc_error_to_string(rc), rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -502,6 +477,10 @@ PHP_FUNCTION(scard_establish_context)
|
||||||
SCARDCONTEXT scard_context = 0;
|
SCARDCONTEXT scard_context = 0;
|
||||||
LONG rc = 0;
|
LONG rc = 0;
|
||||||
|
|
||||||
|
if (zend_parse_parameters_none() == FAILURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &scard_context);
|
rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &scard_context);
|
||||||
if (rc != SCARD_S_SUCCESS)
|
if (rc != SCARD_S_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
@ -539,7 +518,6 @@ PHP_FUNCTION(scard_is_valid_context)
|
||||||
Invalidate the PC/SC context */
|
Invalidate the PC/SC context */
|
||||||
PHP_FUNCTION(scard_release_context)
|
PHP_FUNCTION(scard_release_context)
|
||||||
{
|
{
|
||||||
LONG rc = 0;
|
|
||||||
zval* ctx_res;
|
zval* ctx_res;
|
||||||
SCARDCONTEXT context;
|
SCARDCONTEXT context;
|
||||||
|
|
||||||
|
|
@ -547,6 +525,7 @@ PHP_FUNCTION(scard_release_context)
|
||||||
RETURN_NULL();
|
RETURN_NULL();
|
||||||
}
|
}
|
||||||
ZEND_FETCH_RESOURCE(context, SCARDCONTEXT, &ctx_res, -1, PHP_PCSC_CTX_RES_NAME, le_pcsc_ctx_res);
|
ZEND_FETCH_RESOURCE(context, SCARDCONTEXT, &ctx_res, -1, PHP_PCSC_CTX_RES_NAME, le_pcsc_ctx_res);
|
||||||
|
(void)context;
|
||||||
|
|
||||||
zend_hash_index_del(&EG(regular_list), Z_RES_HANDLE_P(ctx_res));
|
zend_hash_index_del(&EG(regular_list), Z_RES_HANDLE_P(ctx_res));
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
|
|
@ -596,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;
|
||||||
|
|
@ -657,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)
|
||||||
|
|
@ -669,7 +690,7 @@ PHP_FUNCTION(scard_transmit)
|
||||||
SCARD_IO_REQUEST *recvPci = NULL;
|
SCARD_IO_REQUEST *recvPci = NULL;
|
||||||
BYTE *sendBuffer;
|
BYTE *sendBuffer;
|
||||||
BYTE *recvBuffer;
|
BYTE *recvBuffer;
|
||||||
DWORD sendLen, recvLen;
|
DWORD sendLen = 0, recvLen;
|
||||||
LONG rc;
|
LONG rc;
|
||||||
char *apdu;
|
char *apdu;
|
||||||
size_t apduLen;
|
size_t apduLen;
|
||||||
|
|
@ -734,7 +755,6 @@ PHP_FUNCTION(scard_status)
|
||||||
{
|
{
|
||||||
zval* conn_res;
|
zval* conn_res;
|
||||||
SCARDHANDLE hCard = 0;
|
SCARDHANDLE hCard = 0;
|
||||||
char *strReader = NULL;
|
|
||||||
DWORD dwProtocol, dwState;
|
DWORD dwProtocol, dwState;
|
||||||
BYTE atrBuffer[32];
|
BYTE atrBuffer[32];
|
||||||
DWORD atrLen;
|
DWORD atrLen;
|
||||||
|
|
@ -773,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;
|
||||||
|
|
@ -799,6 +818,9 @@ PHP_FUNCTION(scard_status)
|
||||||
Retrieve last error code */
|
Retrieve last error code */
|
||||||
PHP_FUNCTION(scard_last_errno)
|
PHP_FUNCTION(scard_last_errno)
|
||||||
{
|
{
|
||||||
|
if (zend_parse_parameters_none() == FAILURE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
RETURN_LONG(PCSC_G(last_errno));
|
RETURN_LONG(PCSC_G(last_errno));
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
|
||||||
67
pcsc.stub.php
Normal file
67
pcsc.stub.php
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generate-function-entries
|
||||||
|
* @generate-legacy-arginfo
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_establish_context() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $context
|
||||||
|
*/
|
||||||
|
function scard_release_context($context): bool {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $context
|
||||||
|
*/
|
||||||
|
function scard_is_valid_context($context): bool {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $context
|
||||||
|
*/
|
||||||
|
function scard_list_readers($context): array|false {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $context
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_connect($context, string $reader_name, int $preferred_protocol=SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1, int &$current_protocol=NULL): array|false {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $card
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_transmit($card, string $command): string|false {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $card
|
||||||
|
* @return resource|false
|
||||||
|
*/
|
||||||
|
function scard_status($card): array|false {}
|
||||||
|
|
||||||
|
function scard_last_errno(): int {}
|
||||||
|
|
||||||
|
function scard_errstr(int $errno): string {}
|
||||||
|
|
||||||
83
pcsc_arginfo.h
Normal file
83
pcsc_arginfo.h
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
|
* Stub hash: 676b86ff0a1ee4d762d86126e8068f4cb6805272 */
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_release_context, 0, 1, _IS_BOOL, 0)
|
||||||
|
ZEND_ARG_INFO(0, context)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
#define arginfo_scard_is_valid_context arginfo_scard_release_context
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scard_list_readers, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
|
||||||
|
ZEND_ARG_INFO(0, context)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scard_connect, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
|
||||||
|
ZEND_ARG_INFO(0, context)
|
||||||
|
ZEND_ARG_TYPE_INFO(0, reader_name, IS_STRING, 0)
|
||||||
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preferred_protocol, IS_LONG, 0, "SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1")
|
||||||
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(1, current_protocol, IS_LONG, 0, "NULL")
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_disconnect, 0, 1, _IS_BOOL, 0)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, disposition, IS_LONG, 0, "SCARD_EJECT_CARD")
|
||||||
|
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_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scard_status, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_last_errno, 0, 0, IS_LONG, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_scard_errstr, 0, 1, IS_STRING, 0)
|
||||||
|
ZEND_ARG_TYPE_INFO(0, errno, IS_LONG, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
|
||||||
|
ZEND_FUNCTION(scard_establish_context);
|
||||||
|
ZEND_FUNCTION(scard_release_context);
|
||||||
|
ZEND_FUNCTION(scard_is_valid_context);
|
||||||
|
ZEND_FUNCTION(scard_list_readers);
|
||||||
|
ZEND_FUNCTION(scard_connect);
|
||||||
|
ZEND_FUNCTION(scard_disconnect);
|
||||||
|
ZEND_FUNCTION(scard_begin_transaction);
|
||||||
|
ZEND_FUNCTION(scard_end_transaction);
|
||||||
|
ZEND_FUNCTION(scard_transmit);
|
||||||
|
ZEND_FUNCTION(scard_status);
|
||||||
|
ZEND_FUNCTION(scard_last_errno);
|
||||||
|
ZEND_FUNCTION(scard_errstr);
|
||||||
|
|
||||||
|
|
||||||
|
static const zend_function_entry ext_functions[] = {
|
||||||
|
ZEND_FE(scard_establish_context, arginfo_scard_establish_context)
|
||||||
|
ZEND_FE(scard_release_context, arginfo_scard_release_context)
|
||||||
|
ZEND_FE(scard_is_valid_context, arginfo_scard_is_valid_context)
|
||||||
|
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
||||||
|
ZEND_FE(scard_connect, arginfo_scard_connect)
|
||||||
|
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_status, arginfo_scard_status)
|
||||||
|
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
||||||
|
ZEND_FE(scard_errstr, arginfo_scard_errstr)
|
||||||
|
ZEND_FE_END
|
||||||
|
};
|
||||||
75
pcsc_legacy_arginfo.h
Normal file
75
pcsc_legacy_arginfo.h
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
|
* Stub hash: 676b86ff0a1ee4d762d86126e8068f4cb6805272 */
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_release_context, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, context)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
#define arginfo_scard_is_valid_context arginfo_scard_release_context
|
||||||
|
|
||||||
|
#define arginfo_scard_list_readers arginfo_scard_release_context
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_connect, 0, 0, 2)
|
||||||
|
ZEND_ARG_INFO(0, context)
|
||||||
|
ZEND_ARG_INFO(0, reader_name)
|
||||||
|
ZEND_ARG_INFO(0, preferred_protocol)
|
||||||
|
ZEND_ARG_INFO(1, current_protocol)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_disconnect, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_INFO(0, disposition)
|
||||||
|
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_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_INFO(0, command)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
#define arginfo_scard_status arginfo_scard_begin_transaction
|
||||||
|
|
||||||
|
#define arginfo_scard_last_errno arginfo_scard_establish_context
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_errstr, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, errno)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
|
||||||
|
ZEND_FUNCTION(scard_establish_context);
|
||||||
|
ZEND_FUNCTION(scard_release_context);
|
||||||
|
ZEND_FUNCTION(scard_is_valid_context);
|
||||||
|
ZEND_FUNCTION(scard_list_readers);
|
||||||
|
ZEND_FUNCTION(scard_connect);
|
||||||
|
ZEND_FUNCTION(scard_disconnect);
|
||||||
|
ZEND_FUNCTION(scard_begin_transaction);
|
||||||
|
ZEND_FUNCTION(scard_end_transaction);
|
||||||
|
ZEND_FUNCTION(scard_transmit);
|
||||||
|
ZEND_FUNCTION(scard_status);
|
||||||
|
ZEND_FUNCTION(scard_last_errno);
|
||||||
|
ZEND_FUNCTION(scard_errstr);
|
||||||
|
|
||||||
|
|
||||||
|
static const zend_function_entry ext_functions[] = {
|
||||||
|
ZEND_FE(scard_establish_context, arginfo_scard_establish_context)
|
||||||
|
ZEND_FE(scard_release_context, arginfo_scard_release_context)
|
||||||
|
ZEND_FE(scard_is_valid_context, arginfo_scard_is_valid_context)
|
||||||
|
ZEND_FE(scard_list_readers, arginfo_scard_list_readers)
|
||||||
|
ZEND_FE(scard_connect, arginfo_scard_connect)
|
||||||
|
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_status, arginfo_scard_status)
|
||||||
|
ZEND_FE(scard_last_errno, arginfo_scard_last_errno)
|
||||||
|
ZEND_FE(scard_errstr, arginfo_scard_errstr)
|
||||||
|
ZEND_FE_END
|
||||||
|
};
|
||||||
|
|
@ -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.4.0"
|
#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