From: Matteo Nastasi (mop) Date: Mon, 11 Jun 2012 16:33:58 +0000 (+0200) Subject: first commit X-Git-Tag: v0.2.0~3 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=5f3d6c49a07662e84b39bc99be7cfc2d5f10b70e;p=php-ancillary.git first commit --- 5f3d6c49a07662e84b39bc99be7cfc2d5f10b70e diff --git a/config.m4 b/config.m4 new file mode 100644 index 0000000..7d18791 --- /dev/null +++ b/config.m4 @@ -0,0 +1,7 @@ +PHP_ARG_ENABLE(ancillary, whether to enable my extension, +[ --enable-my-extension Enable my extension]) + +if test "$PHP_ANCILLARY" = "yes"; then + AC_DEFINE(HAVE_ANCILLARY, 1, [Whether you have my extension]) + PHP_NEW_EXTENSION(ancillary, php-ancillary.c, $ext_shared) +fi \ No newline at end of file diff --git a/php-ancillary.c b/php-ancillary.c new file mode 100644 index 0000000..be249c9 --- /dev/null +++ b/php-ancillary.c @@ -0,0 +1,46 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "php.h" + +#define PHP_ANCILLARY_VERSION "1.0" +#define PHP_ANCILLARY_EXTNAME "ancillary" + +extern zend_module_entry ancillary_module_entry; +#define phpext_ancillary_ptr &ancillary_module_entry + +// declaration of a custom mop_function() +PHP_FUNCTION(mop_function); + +// list of custom PHP functions provided by this extension +// set {NULL, NULL, NULL} as the last record to mark the end of list +static function_entry mop_functions[] = { + PHP_FE(mop_function, NULL) + {NULL, NULL, NULL} +}; + +// the following code creates an entry for the module and registers it with Zend. +zend_module_entry ancillary_module_entry = { +#if ZEND_MODULE_API_NO >= 20010901 + STANDARD_MODULE_HEADER, +#endif + PHP_ANCILLARY_EXTNAME, + mop_functions, + NULL, // name of the MINIT function or NULL if not applicable + NULL, // name of the MSHUTDOWN function or NULL if not applicable + NULL, // name of the RINIT function or NULL if not applicable + NULL, // name of the RSHUTDOWN function or NULL if not applicable + NULL, // name of the MINFO function or NULL if not applicable +#if ZEND_MODULE_API_NO >= 20010901 + PHP_ANCILLARY_VERSION, +#endif + STANDARD_MODULE_PROPERTIES +}; + +ZEND_GET_MODULE(ancillary) + +// implementation of a custom mop_function() +PHP_FUNCTION(mop_function) +{ + RETURN_STRING("This is my function", 1); +}