summaryrefslogtreecommitdiff
path: root/ext/skeleton
diff options
context:
space:
mode:
Diffstat (limited to 'ext/skeleton')
-rw-r--r--ext/skeleton/.gitignore.in35
-rw-r--r--ext/skeleton/CREDITS1
-rw-r--r--ext/skeleton/EXPERIMENTAL0
-rw-r--r--ext/skeleton/config.m4.in82
-rw-r--r--ext/skeleton/config.w32.in7
-rwxr-xr-xext/skeleton/create_stubs289
-rw-r--r--ext/skeleton/php_skeleton.h49
-rw-r--r--ext/skeleton/skeleton.c173
-rw-r--r--ext/skeleton/skeleton.php21
-rw-r--r--ext/skeleton/tests/001.phpt23
-rw-r--r--ext/skeleton/tests/002.phpt17
-rw-r--r--ext/skeleton/tests/003.phpt16
12 files changed, 229 insertions, 484 deletions
diff --git a/ext/skeleton/.gitignore.in b/ext/skeleton/.gitignore.in
new file mode 100644
index 0000000000..91bef25220
--- /dev/null
+++ b/ext/skeleton/.gitignore.in
@@ -0,0 +1,35 @@
+*.lo
+*.la
+.libs
+acinclude.m4
+aclocal.m4
+autom4te.cache
+build
+config.guess
+config.h
+config.h.in
+config.log
+config.nice
+config.status
+config.sub
+configure
+configure.ac
+configure.in
+include
+install-sh
+libtool
+ltmain.sh
+Makefile
+Makefile.fragments
+Makefile.global
+Makefile.objects
+missing
+mkinstalldirs
+modules
+run-tests.php
+tests/*/*.diff
+tests/*/*.out
+tests/*/*.php
+tests/*/*.exp
+tests/*/*.log
+tests/*/*.sh
diff --git a/ext/skeleton/CREDITS b/ext/skeleton/CREDITS
deleted file mode 100644
index 407205f743..0000000000
--- a/ext/skeleton/CREDITS
+++ /dev/null
@@ -1 +0,0 @@
-extname
diff --git a/ext/skeleton/EXPERIMENTAL b/ext/skeleton/EXPERIMENTAL
deleted file mode 100644
index e69de29bb2..0000000000
--- a/ext/skeleton/EXPERIMENTAL
+++ /dev/null
diff --git a/ext/skeleton/config.m4.in b/ext/skeleton/config.m4.in
new file mode 100644
index 0000000000..e6b34a8eeb
--- /dev/null
+++ b/ext/skeleton/config.m4.in
@@ -0,0 +1,82 @@
+dnl config.m4 for extension %EXTNAME%
+
+dnl Comments in this file start with the string 'dnl'.
+dnl Remove where necessary.
+
+dnl If your extension references something external, use with:
+
+dnl PHP_ARG_WITH(%EXTNAME%, for %EXTNAME% support,
+dnl Make sure that the comment is aligned:
+dnl [ --with-%EXTNAME% Include %EXTNAME% support])
+
+dnl Otherwise use enable:
+
+PHP_ARG_ENABLE(%EXTNAME%, whether to enable %EXTNAME% support,
+dnl Make sure that the comment is aligned:
+[ --enable-%EXTNAME% Enable %EXTNAME% support], no)
+
+if test "$PHP_%EXTNAMECAPS%" != "no"; then
+ dnl Write more examples of tests here...
+
+ dnl # get library FOO build options from pkg-config output
+ dnl AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+ dnl AC_MSG_CHECKING(for libfoo)
+ dnl if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists foo; then
+ dnl if $PKG_CONFIG foo --atleast-version 1.2.3; then
+ dnl LIBFOO_CFLAGS=\`$PKG_CONFIG foo --cflags\`
+ dnl LIBFOO_LIBDIR=\`$PKG_CONFIG foo --libs\`
+ dnl LIBFOO_VERSON=\`$PKG_CONFIG foo --modversion\`
+ dnl AC_MSG_RESULT(from pkgconfig: version $LIBFOO_VERSON)
+ dnl else
+ dnl AC_MSG_ERROR(system libfoo is too old: version 1.2.3 required)
+ dnl fi
+ dnl else
+ dnl AC_MSG_ERROR(pkg-config not found)
+ dnl fi
+ dnl PHP_EVAL_LIBLINE($LIBFOO_LIBDIR, %EXTNAMECAPS%_SHARED_LIBADD)
+ dnl PHP_EVAL_INCLINE($LIBFOO_CFLAGS)
+
+ dnl # --with-%EXTNAME% -> check with-path
+ dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
+ dnl SEARCH_FOR="/include/%EXTNAME%.h" # you most likely want to change this
+ dnl if test -r $PHP_%EXTNAMECAPS%/$SEARCH_FOR; then # path given as parameter
+ dnl %EXTNAMECAPS%_DIR=$PHP_%EXTNAMECAPS%
+ dnl else # search default path list
+ dnl AC_MSG_CHECKING([for %EXTNAME% files in default path])
+ dnl for i in $SEARCH_PATH ; do
+ dnl if test -r $i/$SEARCH_FOR; then
+ dnl %EXTNAMECAPS%_DIR=$i
+ dnl AC_MSG_RESULT(found in $i)
+ dnl fi
+ dnl done
+ dnl fi
+ dnl
+ dnl if test -z "$%EXTNAMECAPS%_DIR"; then
+ dnl AC_MSG_RESULT([not found])
+ dnl AC_MSG_ERROR([Please reinstall the %EXTNAME% distribution])
+ dnl fi
+
+ dnl # --with-%EXTNAME% -> add include path
+ dnl PHP_ADD_INCLUDE($%EXTNAMECAPS%_DIR/include)
+
+ dnl # --with-%EXTNAME% -> check for lib and symbol presence
+ dnl LIBNAME=%EXTNAMECAPS% # you may want to change this
+ dnl LIBSYMBOL=%EXTNAMECAPS% # you most likely want to change this
+
+ dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
+ dnl [
+ dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $%EXTNAMECAPS%_DIR/$PHP_LIBDIR, %EXTNAMECAPS%_SHARED_LIBADD)
+ dnl AC_DEFINE(HAVE_%EXTNAMECAPS%LIB,1,[ ])
+ dnl ],[
+ dnl AC_MSG_ERROR([wrong %EXTNAME% lib version or lib not found])
+ dnl ],[
+ dnl -L$%EXTNAMECAPS%_DIR/$PHP_LIBDIR -lm
+ dnl ])
+ dnl
+ dnl PHP_SUBST(%EXTNAMECAPS%_SHARED_LIBADD)
+
+ dnl # In case of no dependencies
+ AC_DEFINE(HAVE_%EXTNAMECAPS%, 1, [ Have %EXTNAME% support ])
+
+ PHP_NEW_EXTENSION(%EXTNAME%, %EXTNAME%.c, $ext_shared)
+fi
diff --git a/ext/skeleton/config.w32.in b/ext/skeleton/config.w32.in
new file mode 100644
index 0000000000..ea5064b7e2
--- /dev/null
+++ b/ext/skeleton/config.w32.in
@@ -0,0 +1,7 @@
+ARG_ENABLE('%EXTNAME%', '%EXTNAME% support', 'no');
+
+if (PHP_%EXTNAMECAPS% != 'no') {
+ AC_DEFINE('HAVE_%EXTNAMECAPS%', 1, '%EXTNAME% support enabled');
+
+ EXTENSION('%EXTNAME%', '%EXTNAME%.c', null, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
+}
diff --git a/ext/skeleton/create_stubs b/ext/skeleton/create_stubs
deleted file mode 100755
index fe79d6a29c..0000000000
--- a/ext/skeleton/create_stubs
+++ /dev/null
@@ -1,289 +0,0 @@
-#!/usr/bin/awk -f
-
-function gobble(s, x)
-{
- sub(/^ /, "", line)
- match(line, "^" "(" s ")")
- x = substr(line, 1, RLENGTH)
- line = substr(line, RLENGTH+1)
- return x
-}
-
-function convert(i, j, t)
-{
- type = argtypes[i,j]
- name = argnames[i,j]
- opt = optionals[i,j]
- tabs = x = ""
-
- for (i = 0; i < t; i++) { tabs = tabs "\t" }
-
- if (type == "int" || type == "long") {
- longs = longs "\tzend_long " name ";\n"
- } else if (type == "bool" || type == "boolean") {
- bools = bools "\tzend_bool " name ";\n"
- } else if (type == "double" || type == "float") {
- doubles = doubles "\tdouble " name ";\n"
- } else if (type == "string") {
- strings = strings "\tchar *" name " = NULL;\n"
- ints = ints "\tsize_t " name "_len;\n"
- } else if (type == "array" || type == "object" || type == "mixed") {
- zvals = zvals "\tzval *" name " = NULL;\n"
- } else if (type == "resource" || type == "handle") {
- zvals = zvals "\tzval *" name " = NULL;\n"
- resources = resources "\tif (" name ") {\n" \
- "\t\tZEND_FETCH_RESOURCE(???, ???, " name ", " name "_id, \"???\", ???_rsrc_id);\n\t}\n"
- ints = ints "\tint " name "_id = -1;\n"
- }
-}
-
-function comment(s)
-{
- if (i_know_what_to_do_shut_up_i_dont_need_your_help_mode) {
- return
- } else {
- return s
- }
-}
-
-BEGIN {
- name = "[_A-Za-z][_A-Za-z0-9]*"
- type = "int|long|double|float|string|bool|boolean|array|object|resource|handle|mixed|void"
- spec = "l|l|d|d|s|b|b|a|o|r|r|z|"
- num_funcs = 0
-
-# create a map from type name to the spec
- split(type, type_array, "\|")
- split(spec, spec_array, "\|")
- for (i in type_array) {
- spec_map[type_array[i]] = spec_array[i]
- }
-
- if (xml && xml != "yes") {
- xmldoc = xml
- } else {
- xmldoc = extname "/" extname ".xml"
- }
-
-
- xmlhead = "<?xml version='1.0' encoding='iso-8859-1'?>\n" \
- "<!-- $Id$ -->\n" \
- " <reference id=\"ref." extname "\">\n" \
- " <title> functions</title>\n" \
- " <titleabbrev></titleabbrev>\n\n" \
- " <partintro>\n" \
- " &warn.experimental;\n" \
- " <para>\n" \
- " </para>\n" \
- " </partintro>\n\n";
-
- xmlfoot = " </reference>\n\n" \
- "<!-- Keep this comment at the end of the file\n" \
- "Local variables:\n" \
- "mode: sgml\n" \
- "sgml-omittag:t\n" \
- "sgml-shorttag:t\n" \
- "sgml-minimize-attributes:nil\n" \
- "sgml-always-quote-attributes:t\n" \
- "sgml-indent-step:1\n" \
- "sgml-indent-data:t\n" \
- "indent-tabs-mode:nil\n" \
- "sgml-parent-document:nil\n" \
- "sgml-default-dtd-file:\"../../manual.ced\"\n" \
- "sgml-exposed-tags:nil\n" \
- "sgml-local-catalogs:nil\n" \
- "sgml-local-ecat-files:nil\n" \
- "End:\n" \
- "vim600: syn=xml fen fdm=syntax fdl=2 si\n" \
- "vim: et tw=78 syn=sgml\n" \
- "vi: ts=1 sw=1\n" \
- "-->\n"
-}
-
-{
- args_max = args_min = optional = i = spec_opt = 0
- line = $0
- spec_str = "\""
-
-## php extension must use lower case function names.
-## this will translate any capitalized letter to lowercase
-## and warn the user
- if (match(func_name,"[A-Z]") != 0) {
- printf("NOTICE: lower casing function name '%s'\n",func_name)
- func_name = tolower(func_name)
- }
- func_type = gobble(type);
- func_name = gobble(name);
-
- if (gobble("\\(")) {
- if (gobble("\\[")) optional = 1
- while (arg_type = gobble(type)) {
- arg_name = gobble(name)
- if(arg_type == "void") {
- args_max = 0;
- args_min = 0;
- break;
- } else {
- argtypes[num_funcs,args_max] = arg_type
- argnames[num_funcs,args_max] = arg_name
-
- args_max++
- if (optional) {
- if (!spec_opt) {
- spec_str = spec_str "|"
- spec_opt = 1
- }
- optionals[num_funcs,i] = optional
- } else {
- args_min++
- }
- spec_str = spec_str spec_map[arg_type]
-
- if (x = gobble("\\[")) {
- optional++
- }
-
- y = gobble(",")
- if (!x && y && optional) {
- grouped_optional_param[num_funcs,i] = 1
- }
- i++
- }
- }
- }
-
-# if (x = gobble("\\)")) {
- gobble("\\]* *\\)")
- sub(/^[ \t]+/, "", line)
- fcomments[num_funcs] = line
-# }
-
- spec_str = spec_str "\""
-
- funcs[num_funcs] = func_name
- types[num_funcs] = func_type
- maxargs[num_funcs] = args_max
- minargs[num_funcs] = args_min
- specs[num_funcs] = spec_str
- spec_opts[num_funcs] = spec_opt
-
- num_funcs++
-}
-
-END {
- if (xml) print xmlhead > xmldoc
- for (i = 0; i < num_funcs; i++) {
- compareargc = maxargs[i] - minargs[i]
- closefetch = fetchargs = zvals = xmlparams = funcvals = resources = handleargs = closeopts = ""
- ints = longs = doubles = strings = bools = zvals = ""
-
- proto = "/* {{{ proto " types[i] " " funcs[i] "("
-
- refid = funcs[i]
- gsub(/_/, "-", refid)
- xmlstr = " <refentry id=\"function." refid "\">\n" \
- " <refnamediv>\n" \
- " <refname>" funcs[i] "</refname>\n" \
- " <refpurpose>" fcomments[i] "</refpurpose>\n" \
- " </refnamediv>\n" \
- " <refsect1>\n" \
- " <title>Description</title>\n" \
- " <funcsynopsis>\n" \
- " <funcprototype>\n" \
- " <funcdef>" types[i] " <function>" funcs[i] "</function></funcdef>\n"
-
- if (maxargs[i]>0) {
- fetchargs = "\tif (zend_parse_parameters("
- ints = ints "\tint argc = ZEND_NUM_ARGS();\n"
- fetchargs = fetchargs "argc, " specs[i]
- } else {
- fetchargs = fetchargs "\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}"
- xmlparams = xmlparams " <void/>\n"
- }
-
- for (j = 0; j < maxargs[i]; j++) {
-
- fetchargs = fetchargs ", "
-
- fetchargs = fetchargs "&" argnames[i,j]
- if (argtypes[i,j] == "string") {
- fetchargs = fetchargs ", &" argnames[i,j] "_len"
- }
-
- xmlparams = xmlparams " <paramdef>" argtypes[i,j]
- if (j > minargs[i]-1) {
- if (!grouped_optional_param[i,j-1]) {
- if (j > 0) proto = proto " "
- proto = proto "["
- closeopts = closeopts "]"
- }
- xmlparams = xmlparams "\n <parameter><optional>" \
- argnames[i,j] \
- "</optional></parameter>\n </paramdef>\n"
- } else {
- xmlparams = xmlparams \
- " <parameter>" \
- argnames[i,j] \
- "</parameter></paramdef>\n"
- }
-
- if (j > 0) proto = proto ", "
- proto = proto argtypes[i,j] " " argnames[i,j]
-
- convert(i, j, 1)
- }
-
- proto = proto closeopts ")\n " fcomments[i] " */\nPHP_FUNCTION(" funcs[i] ")\n{"
- if (maxargs[i]>0) {
- fetchargs = fetchargs ") == FAILURE)" closefetch " \n\t\treturn;\n"
- }
- funcvals = strings ints longs doubles bools zvals
- xmlstr = xmlstr xmlparams \
- " </funcprototype>\n" \
- " </funcsynopsis>\n" \
- " &warn.experimental.func;\n" \
- " <para>\n" \
- " &warn.undocumented.func;\n" \
- " </para>\n" \
- " </refsect1>\n" \
- " </refentry>\n"
-
- print proto > stubfile
- if (funcvals) print funcvals > stubfile
- if (fetchargs) print fetchargs > stubfile
- if (resources) {
- print resources > stubfile
- if (!stubs) print "" > ( extname "/function_warning" )
- }
- if (!i_know_what_to_do_shut_up_i_dont_need_your_help_mode) {
- print "\tphp_error(E_WARNING, \"" funcs[i] ": not yet implemented\");" > stubfile
- }
- print "}\n/* }}} */\n" > stubfile
-
- if (stubs) {
- h_stubs = h_stubs "PHP_FUNCTION(" funcs[i] ");\n"
- c_stubs = c_stubs "\tPHP_FE(" funcs[i] ",\tNULL)\n"
- } else {
- print "PHP_FUNCTION(" funcs[i] ");" > ( extname "/function_declarations" )
- print "\tPHP_FE(" funcs[i] ",\tNULL)" > ( extname "/function_entries" )
- }
-
- if (xml) print xmlstr > xmldoc
- }
-
- if (stubs) {
- print "\n/* ----------------------------------------------------------- */\n" > stubfile
- print c_stubs > stubfile
- print "\n/* ----------------------------------------------------------- */\n" > stubfile
- print h_stubs > stubfile
- }
-
- if (xml) print xmlfoot > xmldoc
-}
-
-#
-# Local variables:
-# tab-width: 2
-# c-basic-offset: 2
-# End:
-
diff --git a/ext/skeleton/php_skeleton.h b/ext/skeleton/php_skeleton.h
index 1514563a70..35e094d661 100644
--- a/ext/skeleton/php_skeleton.h
+++ b/ext/skeleton/php_skeleton.h
@@ -1,45 +1,16 @@
-/* __header_here__ */
+%HEADER%
-#ifndef PHP_EXTNAME_H
-#define PHP_EXTNAME_H
+#ifndef PHP_%EXTNAMECAPS%_H
+# define PHP_%EXTNAMECAPS%_H
-extern zend_module_entry extname_module_entry;
-#define phpext_extname_ptr &extname_module_entry
+extern zend_module_entry %EXTNAME%_module_entry;
+# define phpext_%EXTNAME%_ptr &%EXTNAME%_module_entry
-#define PHP_EXTNAME_VERSION "0.1.0" /* Replace with version number for your extension */
+# define PHP_%EXTNAMECAPS%_VERSION "0.1.0"
-#ifdef PHP_WIN32
-# define PHP_EXTNAME_API __declspec(dllexport)
-#elif defined(__GNUC__) && __GNUC__ >= 4
-# define PHP_EXTNAME_API __attribute__ ((visibility("default")))
-#else
-# define PHP_EXTNAME_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-/*
- Declare any global variables you may need between the BEGIN
- and END macros here:
-
-ZEND_BEGIN_MODULE_GLOBALS(extname)
- zend_long global_value;
- char *global_string;
-ZEND_END_MODULE_GLOBALS(extname)
-*/
-
-/* Always refer to the globals in your function as EXTNAME_G(variable).
- You are encouraged to rename these macros something shorter, see
- examples in any other php module directory.
-*/
-#define EXTNAME_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(extname, v)
-
-#if defined(ZTS) && defined(COMPILE_DL_EXTNAME)
+# if defined(ZTS) && defined(COMPILE_DL_%EXTNAMECAPS%)
ZEND_TSRMLS_CACHE_EXTERN()
-#endif
-
-#endif /* PHP_EXTNAME_H */
+# endif
-/* __footer_here__ */
+#endif /* PHP_%EXTNAMECAPS%_H */
+%FOOTER%
diff --git a/ext/skeleton/skeleton.c b/ext/skeleton/skeleton.c
index 50f3271e20..a93fd57f53 100644
--- a/ext/skeleton/skeleton.c
+++ b/ext/skeleton/skeleton.c
@@ -1,168 +1,103 @@
-/* __header_here__ */
+%HEADER%
#ifdef HAVE_CONFIG_H
-#include "config.h"
+# include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
#include "ext/standard/info.h"
-#include "php_extname.h"
+#include "php_%EXTNAME%.h"
-/* If you declare any globals in php_extname.h uncomment this:
-ZEND_DECLARE_MODULE_GLOBALS(extname)
-*/
-
-/* True global resources - no need for thread safety here */
-static int le_extname;
-
-/* {{{ PHP_INI
+/* {{{ void %EXTNAME%_test1()
*/
-/* Remove comments and fill if you need to have entries in php.ini
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("extname.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_extname_globals, extname_globals)
- STD_PHP_INI_ENTRY("extname.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_extname_globals, extname_globals)
-PHP_INI_END()
-*/
-/* }}} */
-
-/* Remove the following function when you have successfully modified config.m4
- so that your module can be compiled into PHP, it exists only for testing
- purposes. */
-
-/* Every user-visible function in PHP should document itself in the source */
-/* {{{ proto string confirm_extname_compiled(string arg)
- Return a string to confirm that the module is compiled in */
-PHP_FUNCTION(confirm_extname_compiled)
+PHP_FUNCTION(%EXTNAME%_test1)
{
- char *arg = NULL;
- size_t arg_len, len;
- zend_string *strg;
+ ZEND_PARSE_PARAMETERS_NONE();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
- return;
- }
-
- strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg);
-
- RETURN_STR(strg);
+ php_printf("The extension %s is loaded and working!\r\n", "%EXTNAME%");
}
/* }}} */
-/* The previous line is meant for vim and emacs, so it can correctly fold and
- unfold functions in source code. See the corresponding marks just before
- function definition, where the functions purpose is also documented. Please
- follow this convention for the convenience of others editing your code.
-*/
-/* __function_stubs_here__ */
-
-/* {{{ php_extname_init_globals
+/* {{{ string %EXTNAME%_test2( [ string $var ] )
*/
-/* Uncomment this function if you have INI entries
-static void php_extname_init_globals(zend_extname_globals *extname_globals)
+PHP_FUNCTION(%EXTNAME%_test2)
{
- extname_globals->global_value = 0;
- extname_globals->global_string = NULL;
-}
-*/
-/* }}} */
+ char *var = "World";
+ size_t var_len = sizeof("World") - 1;
+ zend_string *retval;
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(extname)
-{
- /* If you have INI entries, uncomment these lines
- REGISTER_INI_ENTRIES();
- */
- return SUCCESS;
-}
-/* }}} */
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(var, var_len)
+ ZEND_PARSE_PARAMETERS_END();
-/* {{{ PHP_MSHUTDOWN_FUNCTION
- */
-PHP_MSHUTDOWN_FUNCTION(extname)
-{
- /* uncomment this line if you have INI entries
- UNREGISTER_INI_ENTRIES();
- */
- return SUCCESS;
+ retval = strpprintf(0, "Hello %s", var);
+
+ RETURN_STR(retval);
}
-/* }}} */
+/* }}}*/
-/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
-PHP_RINIT_FUNCTION(extname)
+PHP_RINIT_FUNCTION(%EXTNAME%)
{
-#if defined(COMPILE_DL_EXTNAME) && defined(ZTS)
+#if defined(ZTS) && defined(COMPILE_DL_%EXTNAMECAPS%)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
- return SUCCESS;
-}
-/* }}} */
-/* Remove if there's nothing to do at request end */
-/* {{{ PHP_RSHUTDOWN_FUNCTION
- */
-PHP_RSHUTDOWN_FUNCTION(extname)
-{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
-PHP_MINFO_FUNCTION(extname)
+PHP_MINFO_FUNCTION(%EXTNAME%)
{
php_info_print_table_start();
- php_info_print_table_header(2, "extname support", "enabled");
+ php_info_print_table_header(2, "%EXTNAME% support", "enabled");
php_info_print_table_end();
-
- /* Remove comments if you have entries in php.ini
- DISPLAY_INI_ENTRIES();
- */
}
/* }}} */
-/* {{{ extname_functions[]
- *
- * Every user visible function must have an entry in extname_functions[].
+/* {{{ arginfo
+ */
+ZEND_BEGIN_ARG_INFO(arginfo_%EXTNAME%_test1, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_%EXTNAME%_test2, 0)
+ ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ %EXTNAME%_functions[]
*/
-const zend_function_entry extname_functions[] = {
- PHP_FE(confirm_extname_compiled, NULL) /* For testing, remove later. */
- /* __function_entries_here__ */
- PHP_FE_END /* Must be the last line in extname_functions[] */
+static const zend_function_entry %EXTNAME%_functions[] = {
+ PHP_FE(%EXTNAME%_test1, arginfo_%EXTNAME%_test1)
+ PHP_FE(%EXTNAME%_test2, arginfo_%EXTNAME%_test2)
+ PHP_FE_END
};
/* }}} */
-/* {{{ extname_module_entry
+/* {{{ %EXTNAME%_module_entry
*/
-zend_module_entry extname_module_entry = {
+zend_module_entry %EXTNAME%_module_entry = {
STANDARD_MODULE_HEADER,
- "extname",
- extname_functions,
- PHP_MINIT(extname),
- PHP_MSHUTDOWN(extname),
- PHP_RINIT(extname), /* Replace with NULL if there's nothing to do at request start */
- PHP_RSHUTDOWN(extname), /* Replace with NULL if there's nothing to do at request end */
- PHP_MINFO(extname),
- PHP_EXTNAME_VERSION,
+ "%EXTNAME%", /* Extension name */
+ %EXTNAME%_functions, /* zend_function_entry */
+ NULL, /* PHP_MINIT - Module initialization */
+ NULL, /* PHP_MSHUTDOWN - Module shutdown */
+ PHP_RINIT(%EXTNAME%), /* PHP_RINIT - Request initialization */
+ NULL, /* PHP_RSHUTDOWN - Request shutdown */
+ PHP_MINFO(%EXTNAME%), /* PHP_MINFO - Module info */
+ PHP_%EXTNAMECAPS%_VERSION, /* Version */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
-#ifdef COMPILE_DL_EXTNAME
-#ifdef ZTS
+#ifdef COMPILE_DL_%EXTNAMECAPS%
+# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
+# endif
+ZEND_GET_MODULE(%EXTNAME%)
#endif
-ZEND_GET_MODULE(extname)
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
+%FOOTER%
diff --git a/ext/skeleton/skeleton.php b/ext/skeleton/skeleton.php
deleted file mode 100644
index 91db9d5408..0000000000
--- a/ext/skeleton/skeleton.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-$br = (php_sapi_name() == "cli")? "":"<br>";
-
-if(!extension_loaded('extname')) {
- dl('extname.' . PHP_SHLIB_SUFFIX);
-}
-$module = 'extname';
-$functions = get_extension_funcs($module);
-echo "Functions available in the test extension:$br\n";
-foreach($functions as $func) {
- echo $func."$br\n";
-}
-echo "$br\n";
-$function = 'confirm_' . $module . '_compiled';
-if (extension_loaded($module)) {
- $str = $function($module);
-} else {
- $str = "Module $module is not compiled into PHP";
-}
-echo "$str\n";
-?>
diff --git a/ext/skeleton/tests/001.phpt b/ext/skeleton/tests/001.phpt
index 74aebb0888..f03f8a01be 100644
--- a/ext/skeleton/tests/001.phpt
+++ b/ext/skeleton/tests/001.phpt
@@ -1,21 +1,14 @@
--TEST--
-Check for extname presence
+Check if %EXTNAME% is loaded
--SKIPIF--
-<?php if (!extension_loaded("extname")) print "skip"; ?>
+<?php
+if (!extension_loaded('%EXTNAME%')) {
+ echo 'skip';
+}
+?>
--FILE--
<?php
-echo "extname extension is available";
-/*
- you can add regression tests for your extension here
-
- the output of your test code has to be equal to the
- text in the --EXPECT-- section below for the tests
- to pass, differences between the output and the
- expected text are interpreted as failure
-
- see php7/README.TESTING for further information on
- writing regression tests
-*/
+echo 'The extension "%EXTNAME%" is available';
?>
--EXPECT--
-extname extension is available
+The extension "%EXTNAME%" is available
diff --git a/ext/skeleton/tests/002.phpt b/ext/skeleton/tests/002.phpt
new file mode 100644
index 0000000000..da550f27f8
--- /dev/null
+++ b/ext/skeleton/tests/002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+%EXTNAME%_test1() Basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('%EXTNAME%')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+$ret = %EXTNAME%_test1();
+
+var_dump($ret);
+?>
+--EXPECT--
+The extension %EXTNAME% is loaded and working!
+NULL
diff --git a/ext/skeleton/tests/003.phpt b/ext/skeleton/tests/003.phpt
new file mode 100644
index 0000000000..84c9fe1602
--- /dev/null
+++ b/ext/skeleton/tests/003.phpt
@@ -0,0 +1,16 @@
+--TEST--
+%EXTNAME%_test2() Basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('%EXTNAME%')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+var_dump(%EXTNAME%_test2());
+var_dump(%EXTNAME%_test2('PHP'));
+?>
+--EXPECT--
+string(11) "Hello World"
+string(9) "Hello PHP"