Skip to content

Commit d64ee72

Browse files
committed
Feat: helper function
1 parent c1d4318 commit d64ee72

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

php_xlswriter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern zend_module_entry xlswriter_module_entry;
1919
#define phpext_xlswriter_ptr &xlswriter_module_entry
2020

2121
#define PHP_XLSWRITER_VERSION "1.3.7"
22+
#define PHP_XLSWRITER_AUTHOR "Jiexing.Wang ([email protected])"
2223

2324
#ifdef PHP_WIN32
2425
# define PHP_VTIFUL_API __declspec(dllexport)

tests/version.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
var_dump(is_string(xlswriter_get_version()));
8+
var_dump(is_string(xlswriter_get_author()));
9+
?>
10+
--EXPECT--
11+
bool(true)
12+
bool(true)

xlswriter.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@
2525

2626
int le_xls_writer;
2727

28+
ZEND_BEGIN_ARG_INFO_EX(xlswriter_get_version_arginfo, 0, 0, 0)
29+
ZEND_END_ARG_INFO()
30+
31+
ZEND_BEGIN_ARG_INFO_EX(xlswriter_get_auther_arginfo, 0, 0, 0)
32+
ZEND_END_ARG_INFO()
33+
34+
/* {{{ xlswriter_get_version
35+
*/
36+
PHP_FUNCTION(xlswriter_get_version)
37+
{
38+
RETURN_STRINGL(PHP_XLSWRITER_VERSION, strlen(PHP_XLSWRITER_VERSION));
39+
}
40+
/* }}} */
41+
42+
/* {{{ xlswriter_get_author
43+
*/
44+
PHP_FUNCTION(xlswriter_get_author)
45+
{
46+
RETURN_STRINGL(PHP_XLSWRITER_AUTHOR, strlen(PHP_XLSWRITER_AUTHOR));
47+
}
48+
/* }}} */
49+
2850
/* {{{ PHP_MINIT_FUNCTION
2951
*/
3052
PHP_MINIT_FUNCTION(xlswriter)
@@ -40,7 +62,6 @@ PHP_MINIT_FUNCTION(xlswriter)
4062
}
4163
/* }}} */
4264

43-
4465
/* {{{ PHP_MSHUTDOWN_FUNCTION
4566
*/
4667
PHP_MSHUTDOWN_FUNCTION(xlswriter)
@@ -68,7 +89,6 @@ PHP_RSHUTDOWN_FUNCTION(xlswriter)
6889
}
6990
/* }}} */
7091

71-
7292
/* {{{ PHP_MINFO_FUNCTION
7393
*/
7494
PHP_MINFO_FUNCTION(xlswriter)
@@ -109,6 +129,8 @@ PHP_MINFO_FUNCTION(xlswriter)
109129
* Every user visible function must have an entry in xlswriter_functions[].
110130
*/
111131
const zend_function_entry xlswriter_functions[] = {
132+
PHP_FE(xlswriter_get_version, xlswriter_get_version_arginfo)
133+
PHP_FE(xlswriter_get_author, xlswriter_get_auther_arginfo)
112134
PHP_FE_END
113135
};
114136
/* }}} */

0 commit comments

Comments
 (0)