mirror of
https://github.com/pcsc-for-php/pcsc.git
synced 2026-08-08 21:09:26 +02:00
Added scard_begin_transaction and scard_end_transaction; SEGFAULTS when using it
This commit is contained in:
parent
9023e2a831
commit
62b8e1e6d8
7 changed files with 151 additions and 53 deletions
|
|
@ -48,6 +48,17 @@ $errstr = scard_errstr($errno);
|
||||||
var_dump($errstr);
|
var_dump($errstr);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
# Begin Transaction
|
||||||
|
echo ">> Begin Transaction\n";
|
||||||
|
$begin= scard_begin_transaction($connection);
|
||||||
|
var_dump($begin);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
# Select Applet APDU
|
# Select Applet APDU
|
||||||
echo ">> Select Applet\n";
|
echo ">> Select Applet\n";
|
||||||
$CMD = "00a4040c0cD2760001354B414E4D30310000";
|
$CMD = "00a4040c0cD2760001354B414E4D30310000";
|
||||||
|
|
@ -73,6 +84,17 @@ $errstr = scard_errstr($errno);
|
||||||
var_dump($errstr);
|
var_dump($errstr);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
# End Transaction
|
||||||
|
echo ">> End Transaction\n";
|
||||||
|
$begin= scard_end_transaction($connection);
|
||||||
|
var_dump($connection);
|
||||||
|
|
||||||
|
$errno = scard_last_errno();
|
||||||
|
var_dump($errno);
|
||||||
|
$errstr = scard_errstr($errno);
|
||||||
|
var_dump($errstr);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
# Show Status
|
# Show Status
|
||||||
echo ">> Show Status\n";
|
echo ">> Show Status\n";
|
||||||
$status = scard_status($connection);
|
$status = scard_status($connection);
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
42
pcsc.c
42
pcsc.c
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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,6 +1,3 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
|
||||||
* Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */
|
|
||||||
|
|
||||||
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 +23,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_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_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 +55,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 +70,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,6 +1,3 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
|
||||||
* Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */
|
|
||||||
|
|
||||||
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,6 +21,15 @@ 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()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_end_transaction, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, card)
|
||||||
|
ZEND_ARG_INFO(0, disposition)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -46,6 +52,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 +67,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