- Added basic twig extension structure.

This commit is contained in:
Derick Rethans
2011-03-21 11:42:25 +00:00
commit 430aecfdc0
3 changed files with 164 additions and 0 deletions
+8
View File
@@ -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
+52
View File
@@ -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
+104
View File
@@ -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();
}