From 71ee0809872b4971ab6afcded66a8bfb60f1390e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 10 Feb 2021 10:22:52 +0100 Subject: [PATCH 1/3] add common .gitignore rules --- .gitignore | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cbbd11 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# 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.log +config.nice +config.status +config.sub +configure +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 From 7849799fe7ac680bcf87d816d0c3967e546c398e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 10 Feb 2021 10:23:42 +0100 Subject: [PATCH 2/3] generate arginfo from stub file --- package.xml | 3 ++ pcsc.c | 60 ++++--------------------------------- pcsc.stub.php | 55 ++++++++++++++++++++++++++++++++++ pcsc_arginfo.h | 70 +++++++++++++++++++++++++++++++++++++++++++ pcsc_legacy_arginfo.h | 67 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 201 insertions(+), 54 deletions(-) create mode 100644 pcsc.stub.php create mode 100644 pcsc_arginfo.h create mode 100644 pcsc_legacy_arginfo.h diff --git a/package.xml b/package.xml index 59a8d10..c258f20 100644 --- a/package.xml +++ b/package.xml @@ -40,6 +40,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + diff --git a/pcsc.c b/pcsc.c index 3b6f788..a0cbb9c 100644 --- a/pcsc.c +++ b/pcsc.c @@ -36,59 +36,11 @@ ZEND_DECLARE_MODULE_GLOBALS(pcsc); #define TRUE 1 #endif -/* arg info for scard_connect (accepts an optional compile-time reference parameter) */ -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_connect_arginfo, 0, 0, 2) - ZEND_ARG_INFO(0, context) - ZEND_ARG_INFO(0, reader_name) - ZEND_ARG_INFO(0, preferred_protocol) - ZEND_ARG_INFO(1, active_protocol) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_void, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_context, 0, 0, 1) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_disconnect, 0, 0, 1) - ZEND_ARG_INFO(0, card) - ZEND_ARG_INFO(0, disposition) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_transmit, 0, 0, 2) - ZEND_ARG_INFO(0, card) - ZEND_ARG_INFO(0, command) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_card, 0, 0, 1) - ZEND_ARG_INFO(0, card) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(php_pcsc_scard_errstr, 0, 0, 1) - ZEND_ARG_INFO(0, errno) -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, php_pcsc_scard_void) - PHP_FE(scard_release_context, php_pcsc_scard_context) - PHP_FE(scard_is_valid_context, php_pcsc_scard_context) - PHP_FE(scard_list_readers, php_pcsc_scard_context) - PHP_FE(scard_connect, php_pcsc_scard_connect_arginfo) - //PHP_FE(scard_reconnect, NULL) - PHP_FE(scard_disconnect, php_pcsc_scard_disconnect) - PHP_FE(scard_transmit, php_pcsc_scard_transmit) - PHP_FE(scard_status, php_pcsc_scard_card) - //PHP_FE(scard_get_status_change, NULL) - PHP_FE(scard_last_errno, php_pcsc_scard_void) - PHP_FE(scard_errstr, php_pcsc_scard_errstr) - PHP_FE_END -}; -/* }}} */ +#if PHP_VERSION_ID < 80000 +#include "pcsc_legacy_arginfo.h" +#else +#include "pcsc_arginfo.h" +#endif /* {{{ pcsc_module_entry */ @@ -97,7 +49,7 @@ zend_module_entry pcsc_module_entry = { STANDARD_MODULE_HEADER, #endif "PC/SC", - pcsc_functions, + ext_functions, PHP_MINIT(pcsc), PHP_MSHUTDOWN(pcsc), NULL, diff --git a/pcsc.stub.php b/pcsc.stub.php new file mode 100644 index 0000000..32753e6 --- /dev/null +++ b/pcsc.stub.php @@ -0,0 +1,55 @@ + Date: Wed, 10 Feb 2021 11:04:17 +0100 Subject: [PATCH 3/3] fix default valur --- pcsc.stub.php | 2 +- pcsc_arginfo.h | 4 ++-- pcsc_legacy_arginfo.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pcsc.stub.php b/pcsc.stub.php index 32753e6..1a973c3 100644 --- a/pcsc.stub.php +++ b/pcsc.stub.php @@ -29,7 +29,7 @@ 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_T0, int &$current_protocol=NULL): array|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 diff --git a/pcsc_arginfo.h b/pcsc_arginfo.h index 886c015..80b4481 100644 --- a/pcsc_arginfo.h +++ b/pcsc_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c92a84c03add0a3e132eb4ce3b787e285148e03e */ + * Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0) ZEND_END_ARG_INFO() @@ -17,7 +17,7 @@ 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_T0") + 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() diff --git a/pcsc_legacy_arginfo.h b/pcsc_legacy_arginfo.h index 1921b3a..c56c076 100644 --- a/pcsc_legacy_arginfo.h +++ b/pcsc_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c92a84c03add0a3e132eb4ce3b787e285148e03e */ + * Stub hash: 3e1df1d509b6416c1eb997f61295c26d9ad0fd03 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_scard_establish_context, 0, 0, 0) ZEND_END_ARG_INFO()