- Added basic twig extension structure.
authorDerick Rethans <derick@derickrethans.nl>
Mon, 21 Mar 2011 11:42:25 +0000 (11:42 +0000)
committerDerick Rethans <derick@derickrethans.nl>
Mon, 21 Mar 2011 11:42:25 +0000 (11:42 +0000)
config.m4 [new file with mode: 0644]
php_twig.h [new file with mode: 0644]
twig.c [new file with mode: 0644]

diff --git a/config.m4 b/config.m4
new file mode 100644 (file)
index 0000000..83486be
--- /dev/null
+++ b/config.m4
@@ -0,0 +1,8 @@
+dnl config.m4 for extension twig
+
+PHP_ARG_ENABLE(twig, whether to enable twig support,
+[  --enable-twig           Enable twig support])
+
+if test "$PHP_TWIG" != "no"; then
+  PHP_NEW_EXTENSION(twig, twig.c, $ext_shared)
+fi
diff --git a/php_twig.h b/php_twig.h
new file mode 100644 (file)
index 0000000..01d6610
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+   +----------------------------------------------------------------------+
+   | Twig Extension                                                       |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 2011 Derick Rethans                                    |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 2.02 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available at through the world-wide-web at                           |
+   | http://www.php.net/license/2_02.txt.                                 |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Derick Rethans <derick@derickrethans.nl>                     |
+   +----------------------------------------------------------------------+
+ */
+
+#ifndef PHP_TWIG_H
+#define PHP_TWIG_H
+
+#include "php.h"
+
+extern zend_module_entry twig_module_entry;
+#define phpext_twig_ptr &twig_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_TWIG_API __declspec(dllexport)
+#else
+#define PHP_TWIG_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+PHP_MINIT_FUNCTION(twig);
+PHP_MSHUTDOWN_FUNCTION(twig);
+PHP_RINIT_FUNCTION(twig);
+PHP_RSHUTDOWN_FUNCTION(twig);
+PHP_MINFO_FUNCTION(twig);
+
+ZEND_BEGIN_MODULE_GLOBALS(twig)
+ZEND_END_MODULE_GLOBALS(twig) 
+
+#ifdef ZTS
+#define TWIG_G(v) TSRMG(twig_globals_id, zend_twig_globals *, v)
+#else
+#define TWIG_G(v) (twig_globals.v)
+#endif
+
+#endif
diff --git a/twig.c b/twig.c
new file mode 100644 (file)
index 0000000..9dc3dc7
--- /dev/null
+++ b/twig.c
@@ -0,0 +1,104 @@
+/*
+   +----------------------------------------------------------------------+
+   | Twig Extension                                                       |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 2011 Derick Rethans                                    |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 2.02 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available at through the world-wide-web at                           |
+   | http://www.php.net/license/2_02.txt.                                 |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Derick Rethans <derick@derickrethans.nl>                     |
+   +----------------------------------------------------------------------+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_twig.h"
+
+zend_function_entry twig_functions[] = {
+       {NULL, NULL, NULL}
+};
+
+
+zend_module_entry twig_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+       STANDARD_MODULE_HEADER,
+#endif
+       "twig",
+       twig_functions,
+       PHP_MINIT(twig),
+       PHP_MSHUTDOWN(twig),
+       PHP_RINIT(twig),        
+       PHP_RSHUTDOWN(twig),
+       PHP_MINFO(twig),
+#if ZEND_MODULE_API_NO >= 20010901
+       "0.0.1",
+#endif
+       STANDARD_MODULE_PROPERTIES
+};
+
+
+#ifdef COMPILE_DL_TWIG
+ZEND_GET_MODULE(twig)
+#endif
+
+ZEND_DECLARE_MODULE_GLOBALS(twig)
+
+PHP_INI_BEGIN()
+PHP_INI_END()
+static void twig_init_globals(zend_twig_globals *twig_globals)
+{
+}
+
+
+PHP_MINIT_FUNCTION(twig)
+{
+       ZEND_INIT_MODULE_GLOBALS(twig, twig_init_globals, NULL);
+       REGISTER_INI_ENTRIES();
+
+       return SUCCESS;
+}
+
+
+PHP_MSHUTDOWN_FUNCTION(twig)
+{
+       UNREGISTER_INI_ENTRIES();
+
+       return SUCCESS;
+}
+
+
+
+PHP_RINIT_FUNCTION(twig)
+{
+       return SUCCESS;
+}
+
+
+
+PHP_RSHUTDOWN_FUNCTION(twig)
+{
+       return SUCCESS;
+}
+
+
+PHP_MINFO_FUNCTION(twig)
+{
+       php_info_print_table_start();
+       php_info_print_table_header(2, "twig support", "enabled");
+       php_info_print_table_end();
+
+       DISPLAY_INI_ENTRIES();
+
+}