[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] =?utf-8?q?svn:_/pecl/yaf/trunk/_configs/yaf=5Fconfig=5Fini.c_configs/yaf=5Fconfig=5Fini.h
From:       Xinchen_Hui <laruence () php ! net>
Date:       2013-01-18 8:35:31
Message-ID: svn-laruence-1358498131-329203-76042802 () svn ! php ! net
[Download RAW message or body]

laruence                                 Fri, 18 Jan 2013 08:35:31 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=329203

Log:
Fix compile fail with VS(name conflicts)

Changed paths:
    A   pecl/yaf/trunk/configs/yaf_config_ini.c
    A   pecl/yaf/trunk/configs/yaf_config_ini.h
    A   pecl/yaf/trunk/configs/yaf_config_simple.c
    A   pecl/yaf/trunk/configs/yaf_config_simple.h
    A   pecl/yaf/trunk/responses/
    A   pecl/yaf/trunk/responses/yaf_response_cli.c
    A   pecl/yaf/trunk/responses/yaf_response_cli.h
    A   pecl/yaf/trunk/responses/yaf_response_http.c
    A   pecl/yaf/trunk/responses/yaf_response_http.h
    A   pecl/yaf/trunk/routes/yaf_route_interface.c
    A   pecl/yaf/trunk/routes/yaf_route_interface.h
    A   pecl/yaf/trunk/routes/yaf_route_map.c
    A   pecl/yaf/trunk/routes/yaf_route_map.h
    A   pecl/yaf/trunk/routes/yaf_route_regex.c
    A   pecl/yaf/trunk/routes/yaf_route_regex.h
    A   pecl/yaf/trunk/routes/yaf_route_rewrite.c
    A   pecl/yaf/trunk/routes/yaf_route_rewrite.h
    A   pecl/yaf/trunk/routes/yaf_route_simple.c
    A   pecl/yaf/trunk/routes/yaf_route_simple.h
    A   pecl/yaf/trunk/routes/yaf_route_static.c
    A   pecl/yaf/trunk/routes/yaf_route_static.h
    A   pecl/yaf/trunk/routes/yaf_route_supervar.c
    A   pecl/yaf/trunk/routes/yaf_route_supervar.h
    A   pecl/yaf/trunk/views/yaf_view_interface.c
    A   pecl/yaf/trunk/views/yaf_view_interface.h
    A   pecl/yaf/trunk/views/yaf_view_simple.c
    A   pecl/yaf/trunk/views/yaf_view_simple.h


["svn-diffs-329203.txt" (text/x-diff)]

Added: pecl/yaf/trunk/configs/yaf_config_ini.c
===================================================================
--- pecl/yaf/trunk/configs/yaf_config_ini.c	                        (rev 0)
+++ pecl/yaf/trunk/configs/yaf_config_ini.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,873 @@
+/*
+   +----------------------------------------------------------------------+
+   | Yet Another Framework                                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+   +----------------------------------------------------------------------+
+*/
+
+/* $Id: ini.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "Zend/zend_interfaces.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_config.h"
+
+#include "configs/yaf_config_ini.h"
+
+zend_class_entry *yaf_config_ini_ce;
+
+#ifdef HAVE_SPL
+extern PHPAPI zend_class_entry *spl_ce_Countable;
+#endif
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_void_arginfo, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_construct_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, config_file)
+	ZEND_ARG_INFO(0, section)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_get_arginfo, 0, 0, 0)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_rget_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_unset_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_set_arginfo, 0, 0, 2)
+	ZEND_ARG_INFO(0, name)
+	ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_isset_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ static void yaf_config_ini_zval_deep_copy(zval **p)
+ */
+static void yaf_config_ini_zval_deep_copy(zval **p) {
+	zval *value;
+	ALLOC_ZVAL(value);
+	*value = **p;
+
+	switch (Z_TYPE_PP(p)) {
+		case IS_ARRAY:
+			{
+				array_init(value);
+				zend_hash_copy(Z_ARRVAL_P(value), Z_ARRVAL_PP(p),
+						(copy_ctor_func_t)yaf_config_ini_zval_deep_copy, NULL, sizeof(zval *));
+			}
+			break;
+		default:
+			zval_copy_ctor(value);
+			Z_TYPE_P(value) = Z_TYPE_PP(p);
+	}
+
+	INIT_PZVAL(value);
+	*p = value;
+}
+/* }}} */
+
+/** {{{ zval * yaf_config_ini_format(yaf_config_t *instance, zval **ppzval \
TSRMLS_DC) +*/
+zval * yaf_config_ini_format(yaf_config_t *instance, zval **ppzval TSRMLS_DC) {
+	zval *readonly, *ret;
+	readonly = zend_read_property(yaf_config_ini_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 1 TSRMLS_CC); +	ret = \
yaf_config_ini_instance(NULL, *ppzval, NULL TSRMLS_CC); +	return ret;
+}
+/* }}} */
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2))
+/** {{{ static void yaf_config_ini_simple_parser_cb(zval *key, zval *value, zval \
*index, int callback_type, zval *arr TSRMLS_DC) +*/
+static void yaf_config_ini_simple_parser_cb(zval *key, zval *value, zval *index, int \
callback_type, zval *arr TSRMLS_DC) { +	zval *element;
+	switch (callback_type) {
+		case ZEND_INI_PARSER_ENTRY:
+			{
+				char *skey, *seg, *ptr;
+				zval **ppzval, *dst;
+
+				if (!value) {
+					break;
+				}
+
+				dst = arr;
+				skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+				if ((seg = php_strtok_r(skey, ".", &ptr))) {
+					do {
+					    char *real_key = seg;
+						seg = php_strtok_r(NULL, ".", &ptr);
+						if (zend_symtable_find(Z_ARRVAL_P(dst), real_key, strlen(real_key) + 1, (void \
**) &ppzval) == FAILURE) { +							if (seg) {
+								zval *tmp;
+							    MAKE_STD_ZVAL(tmp);
+								array_init(tmp);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										real_key, strlen(real_key) + 1, (void **)&tmp, sizeof(zval *), (void \
**)&ppzval); +							} else {
+							    MAKE_STD_ZVAL(element);
+								ZVAL_ZVAL(element, value, 1, 0);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										real_key, strlen(real_key) + 1, (void **)&element, sizeof(zval *), NULL);
+								break;
+							}
+						} else {
+							if (IS_ARRAY != Z_TYPE_PP(ppzval)) {
+								if (seg) {
+									zval *tmp;
+									MAKE_STD_ZVAL(tmp);
+									array_init(tmp);
+									zend_symtable_update(Z_ARRVAL_P(dst),
+											real_key, strlen(real_key) + 1, (void **)&tmp, sizeof(zval *), (void \
**)&ppzval); +								} else {
+									MAKE_STD_ZVAL(element);
+									ZVAL_ZVAL(element, value, 1, 0);
+									zend_symtable_update(Z_ARRVAL_P(dst),
+											real_key, strlen(real_key) + 1, (void **)&element, sizeof(zval *), NULL);
+								}
+							}
+						}
+						dst = *ppzval;
+					} while (seg);
+				}
+				efree(skey);
+			}
+			break;
+
+		case ZEND_INI_PARSER_POP_ENTRY:
+			{
+				zval *hash, **find_hash, *dst;
+
+				if (!value) {
+					break;
+				}
+
+				if (!(Z_STRLEN_P(key) > 1 && Z_STRVAL_P(key)[0] == '0')
+						&& is_numeric_string(Z_STRVAL_P(key), Z_STRLEN_P(key), NULL, NULL, 0) == \
IS_LONG) { +					ulong skey = (ulong)zend_atol(Z_STRVAL_P(key), Z_STRLEN_P(key));
+					if (zend_hash_index_find(Z_ARRVAL_P(arr), skey, (void **) &find_hash) == \
FAILURE) { +						MAKE_STD_ZVAL(hash);
+						array_init(hash);
+						zend_hash_index_update(Z_ARRVAL_P(arr), skey, &hash, sizeof(zval *), NULL);
+					} else {
+						hash = *find_hash;
+					}
+				} else {
+					char *seg, *ptr;
+					char *skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+
+					dst = arr;
+					if ((seg = php_strtok_r(skey, ".", &ptr))) {
+						while (seg) {
+							if (zend_symtable_find(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void **) \
&find_hash) == FAILURE) { +								MAKE_STD_ZVAL(hash);
+								array_init(hash);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										seg, strlen(seg) + 1, (void **)&hash, sizeof(zval *), (void \
**)&find_hash); +							}
+							dst = *find_hash;
+							seg = php_strtok_r(NULL, ".", &ptr);
+						}
+						hash = dst;
+					} else {
+						if (zend_symtable_find(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void \
**)&find_hash) == FAILURE) { +							MAKE_STD_ZVAL(hash);
+							array_init(hash);
+							zend_symtable_update(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void **)&hash, \
sizeof(zval *), NULL); +						} else {
+							hash = *find_hash;
+						}
+					}
+					efree(skey);
+				}
+
+				if (Z_TYPE_P(hash) != IS_ARRAY) {
+					zval_dtor(hash);
+					INIT_PZVAL(hash);
+					array_init(hash);
+				}
+
+				MAKE_STD_ZVAL(element);
+				ZVAL_ZVAL(element, value, 1, 0);
+
+				if (index && Z_STRLEN_P(index) > 0) {
+					add_assoc_zval_ex(hash, Z_STRVAL_P(index), Z_STRLEN_P(index) + 1, element);
+				} else {
+					add_next_index_zval(hash, element);
+				}
+			}
+			break;
+
+		case ZEND_INI_PARSER_SECTION:
+			break;
+	}
+}
+/* }}} */
+
+/** {{{ static void yaf_config_ini_parser_cb(zval *key, zval *value, zval *index, \
int callback_type, zval *arr TSRMLS_DC) +*/
+static void yaf_config_ini_parser_cb(zval *key, zval *value, zval *index, int \
callback_type, zval *arr TSRMLS_DC) { +
+	if (YAF_G(parsing_flag) == YAF_CONFIG_INI_PARSING_END) {
+		return;
+	}
+
+	if (callback_type == ZEND_INI_PARSER_SECTION) {
+		zval **parent;
+		char *seg, *skey;
+		uint skey_len;
+
+		if (YAF_G(parsing_flag) == YAF_CONFIG_INI_PARSING_PROCESS) {
+			YAF_G(parsing_flag) = YAF_CONFIG_INI_PARSING_END;
+			return;
+		}
+
+		skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+
+		MAKE_STD_ZVAL(YAF_G(active_ini_file_section));
+		array_init(YAF_G(active_ini_file_section));
+
+		if ((seg = strchr(skey, ':'))) {
+			char *section;
+
+			while (*(seg) == ' ' || *(seg) == ':') {
+				*(seg++) = '\0';
+			}
+
+			if ((section = strrchr(seg, ':'))) {
+			    /* muilt-inherit */
+				do {
+					while (*(section) == ' ' || *(section) == ':') {
+						*(section++) = '\0';
+					}
+					if (zend_symtable_find(Z_ARRVAL_P(arr), section, strlen(section) + 1, (void \
**)&parent) == SUCCESS) { \
+						zend_hash_copy(Z_ARRVAL_P(YAF_G(active_ini_file_section)), \
Z_ARRVAL_PP(parent), +							   	(copy_ctor_func_t)yaf_config_ini_zval_deep_copy, \
NULL, sizeof(zval *)); +					}
+				} while ((section = strrchr(seg, ':')));
+			}
+
+			/* remove the tail space, thinking of 'foo : bar : test' */
+            section = seg + strlen(seg) - 1;
+			while (*section == ' ' || *section == ':') {
+				*(section--) = '\0';
+			}
+
+			if (zend_symtable_find(Z_ARRVAL_P(arr), seg, strlen(seg) + 1, (void **)&parent) \
== SUCCESS) { +				zend_hash_copy(Z_ARRVAL_P(YAF_G(active_ini_file_section)), \
Z_ARRVAL_PP(parent), +						(copy_ctor_func_t)yaf_config_ini_zval_deep_copy, NULL, \
sizeof(zval *)); +			}
+		}
+	    seg = skey + strlen(skey) - 1;
+        while (*seg == ' ' || *seg == ':') {
+			*(seg--) = '\0';
+		}
+		skey_len = strlen(skey);
+		zend_symtable_update(Z_ARRVAL_P(arr), skey, skey_len + 1, \
&YAF_G(active_ini_file_section), sizeof(zval *), NULL); +		if \
(YAF_G(ini_wanted_section) && Z_STRLEN_P(YAF_G(ini_wanted_section)) == skey_len \
+				&& !strncasecmp(Z_STRVAL_P(YAF_G(ini_wanted_section)), skey, skey_len)) { \
+			YAF_G(parsing_flag) = YAF_CONFIG_INI_PARSING_PROCESS; +		}
+		efree(skey);
+	} else if (value) {
+		zval *active_arr;
+		if (YAF_G(active_ini_file_section)) {
+			active_arr = YAF_G(active_ini_file_section);
+		} else {
+			active_arr = arr;
+		}
+		yaf_config_ini_simple_parser_cb(key, value, index, callback_type, active_arr \
TSRMLS_CC); +	}
+}
+/* }}} */
+#else
+/** {{{ static void yaf_config_ini_simple_parser_cb(zval *key, zval *value, int \
callback_type, zval *arr) +*/
+static void yaf_config_ini_simple_parser_cb(zval *key, zval *value, int \
callback_type, zval *arr) { +	zval *element;
+	switch (callback_type) {
+		case ZEND_INI_PARSER_ENTRY:
+			{
+				char *skey, *seg, *ptr;
+				zval **ppzval, *dst;
+
+				if (!value) {
+					break;
+				}
+
+				dst = arr;
+				skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+				if ((seg = php_strtok_r(skey, ".", &ptr))) {
+					do {
+					    char *real_key = seg;
+						seg = php_strtok_r(NULL, ".", &ptr);
+						if (zend_symtable_find(Z_ARRVAL_P(dst), real_key, strlen(real_key) + 1, (void \
**) &ppzval) == FAILURE) { +							if (seg) {
+								zval *tmp;
+							    MAKE_STD_ZVAL(tmp);
+								array_init(tmp);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										real_key, strlen(real_key) + 1, (void **)&tmp, sizeof(zval *), (void \
**)&ppzval); +							} else {
+							    MAKE_STD_ZVAL(element);
+								ZVAL_ZVAL(element, value, 1, 0);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										real_key, strlen(real_key) + 1, (void **)&element, sizeof(zval *), NULL);
+								break;
+							}
+						} else {
+							if (IS_ARRAY != Z_TYPE_PP(ppzval)) {
+								if (seg) {
+									zval *tmp;
+									MAKE_STD_ZVAL(tmp);
+									array_init(tmp);
+									zend_symtable_update(Z_ARRVAL_P(dst),
+											real_key, strlen(real_key) + 1, (void **)&tmp, sizeof(zval *), (void \
**)&ppzval); +								} else {
+									MAKE_STD_ZVAL(element);
+									ZVAL_ZVAL(element, value, 1, 0);
+									zend_symtable_update(Z_ARRVAL_P(dst),
+											real_key, strlen(real_key) + 1, (void **)&element, sizeof(zval *), NULL);
+								}
+							}
+						}
+						dst = *ppzval;
+					} while (seg);
+				}
+				efree(skey);
+			}
+			break;
+
+		case ZEND_INI_PARSER_POP_ENTRY:
+			{
+				zval *hash, **find_hash, *dst;
+
+				if (!value) {
+					break;
+				}
+
+				if (!(Z_STRLEN_P(key) > 1 && Z_STRVAL_P(key)[0] == '0')
+						&& is_numeric_string(Z_STRVAL_P(key), Z_STRLEN_P(key), NULL, NULL, 0) == \
IS_LONG) { +					ulong skey = (ulong)zend_atol(Z_STRVAL_P(key), Z_STRLEN_P(key));
+					if (zend_hash_index_find(Z_ARRVAL_P(arr), skey, (void **) &find_hash) == \
FAILURE) { +						MAKE_STD_ZVAL(hash);
+						array_init(hash);
+						zend_hash_index_update(Z_ARRVAL_P(arr), skey, &hash, sizeof(zval *), NULL);
+					} else {
+						hash = *find_hash;
+					}
+				} else {
+					char *seg, *ptr;
+					char *skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+
+					dst = arr;
+					if ((seg = php_strtok_r(skey, ".", &ptr))) {
+						while (seg) {
+							if (zend_symtable_find(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void **) \
&find_hash) == FAILURE) { +								MAKE_STD_ZVAL(hash);
+								array_init(hash);
+								zend_symtable_update(Z_ARRVAL_P(dst),
+										seg, strlen(seg) + 1, (void **)&hash, sizeof(zval *), (void \
**)&find_hash); +							}
+							dst = *find_hash;
+							seg = php_strtok_r(NULL, ".", &ptr);
+						}
+						hash = dst;
+					} else {
+						if (zend_symtable_find(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void \
**)&find_hash) == FAILURE) { +							MAKE_STD_ZVAL(hash);
+							array_init(hash);
+							zend_symtable_update(Z_ARRVAL_P(dst), seg, strlen(seg) + 1, (void **)&hash, \
sizeof(zval *), NULL); +						} else {
+							hash = *find_hash;
+						}
+					}
+					efree(skey);
+				}
+
+				if (Z_TYPE_P(hash) != IS_ARRAY) {
+					zval_dtor(hash);
+					INIT_PZVAL(hash);
+					array_init(hash);
+				}
+
+				MAKE_STD_ZVAL(element);
+				ZVAL_ZVAL(element, value, 1, 0);
+				add_next_index_zval(hash, element);
+			}
+			break;
+
+		case ZEND_INI_PARSER_SECTION:
+			break;
+	}
+}
+/* }}} */
+
+/** {{{ static void yaf_config_ini_parser_cb(zval *key, zval *value, int \
callback_type, zval *arr) +*/
+static void yaf_config_ini_parser_cb(zval *key, zval *value, int callback_type, zval \
*arr) { +	TSRMLS_FETCH();
+
+	if (YAF_G(parsing_flag) == YAF_CONFIG_INI_PARSING_END) {
+		return;
+	}
+
+	if (callback_type == ZEND_INI_PARSER_SECTION) {
+		zval **parent;
+		char *seg, *skey;
+		uint skey_len;
+
+		if (YAF_G(parsing_flag) == YAF_CONFIG_INI_PARSING_PROCESS) {
+			YAF_G(parsing_flag) = YAF_CONFIG_INI_PARSING_END;
+			return;
+		}
+
+		skey = estrndup(Z_STRVAL_P(key), Z_STRLEN_P(key));
+
+		MAKE_STD_ZVAL(YAF_G(active_ini_file_section));
+		array_init(YAF_G(active_ini_file_section));
+
+		if ((seg = strchr(skey, ':'))) {
+			char *section;
+
+			while (*(seg) == ' ' || *(seg) == ':') {
+				*(seg++) = '\0';
+			}
+
+			if ((section = strrchr(seg, ':'))) {
+			    /* muilt-inherit */
+				do {
+					while (*(section) == ' ' || *(section) == ':') {
+						*(section++) = '\0';
+					}
+					if (zend_symtable_find(Z_ARRVAL_P(arr), section, strlen(section) + 1, (void \
**)&parent) == SUCCESS) { \
+						zend_hash_copy(Z_ARRVAL_P(YAF_G(active_ini_file_section)), \
Z_ARRVAL_PP(parent), +							   	(copy_ctor_func_t)yaf_config_ini_zval_deep_copy, \
NULL, sizeof(zval *)); +					}
+				} while ((section = strrchr(seg, ':')));
+			}
+
+			/* remove the tail space, thinking of 'foo : bar : test' */
+            section = seg + strlen(seg) - 1;
+			while (*section == ' ' || *section == ':') {
+				*(section--) = '\0';
+			}
+
+			if (zend_symtable_find(Z_ARRVAL_P(arr), seg, strlen(seg) + 1, (void **)&parent) \
== SUCCESS) { +				zend_hash_copy(Z_ARRVAL_P(YAF_G(active_ini_file_section)), \
Z_ARRVAL_PP(parent), +						(copy_ctor_func_t)yaf_config_ini_zval_deep_copy, NULL, \
sizeof(zval *)); +			}
+		}
+	    seg = skey + strlen(skey) - 1;
+        while (*seg == ' ' || *seg == ':') {
+			*(seg--) = '\0';
+		}
+		skey_len = strlen(skey);
+		zend_symtable_update(Z_ARRVAL_P(arr), skey, skey_len + 1, \
&YAF_G(active_ini_file_section), sizeof(zval *), NULL); +		if \
(YAF_G(ini_wanted_section) && Z_STRLEN_P(YAF_G(ini_wanted_section)) == skey_len \
+				&& !strncasecmp(Z_STRVAL_P(YAF_G(ini_wanted_section)), skey, \
Z_STRLEN_P(YAF_G(ini_wanted_section)))) { +			YAF_G(parsing_flag) = \
YAF_CONFIG_INI_PARSING_PROCESS; +		}
+		efree(skey);
+	} else if (value) {
+		zval *active_arr;
+		if (YAF_G(active_ini_file_section)) {
+			active_arr = YAF_G(active_ini_file_section);
+		} else {
+			active_arr = arr;
+		}
+		yaf_config_ini_simple_parser_cb(key, value, callback_type, active_arr);
+	}
+}
+/* }}} */
+#endif
+
+/** {{{ yaf_config_t * yaf_config_ini_instance(yaf_config_t *this_ptr, zval \
*filename, zval *section_name TSRMLS_DC) +*/
+yaf_config_t * yaf_config_ini_instance(yaf_config_t *this_ptr, zval *filename, zval \
*section_name TSRMLS_DC) { +	yaf_config_t *instance;
+	zval *configs = NULL;
+
+	if (filename && Z_TYPE_P(filename) == IS_ARRAY) {
+		if (this_ptr) {
+			instance = this_ptr;
+		} else {
+			MAKE_STD_ZVAL(instance);
+			object_init_ex(instance, yaf_config_ini_ce);
+		}
+
+		zend_update_property(yaf_config_ini_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), filename TSRMLS_CC); +
+		return instance;
+	} else if (filename && Z_TYPE_P(filename) == IS_STRING) {
+	    struct stat sb;
+	    zend_file_handle fh = {0};
+		char *ini_file = Z_STRVAL_P(filename);
+
+		MAKE_STD_ZVAL(configs);
+		ZVAL_NULL(configs);
+
+		if (VCWD_STAT(ini_file, &sb) == 0) {
+			if (S_ISREG(sb.st_mode)) {
+				if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
+					fh.filename = ini_file;
+					fh.type = ZEND_HANDLE_FP;
+					YAF_G(active_ini_file_section) = NULL;
+
+					YAF_G(parsing_flag) = YAF_CONFIG_INI_PARSING_START;
+					if (section_name && Z_STRLEN_P(section_name)) {
+						YAF_G(ini_wanted_section) = section_name;
+					} else {
+						YAF_G(ini_wanted_section) = NULL;
+					}
+
+	 				array_init(configs);
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2))
+					if (zend_parse_ini_file(&fh, 0, 0 /* ZEND_INI_SCANNER_NORMAL */,
+						   	(zend_ini_parser_cb_t)yaf_config_ini_parser_cb, configs TSRMLS_CC) == \
FAILURE +							|| Z_TYPE_P(configs) != IS_ARRAY)
+#else
+					if (zend_parse_ini_file(&fh, 0, (zend_ini_parser_cb_t)yaf_config_ini_parser_cb, \
configs) == FAILURE +							|| Z_TYPE_P(configs) != IS_ARRAY)
+#endif
+					{
+						zval_ptr_dtor(&configs);
+						yaf_trigger_error(E_ERROR TSRMLS_CC, "Parsing ini file '%s' failed", \
ini_file); +						return NULL;
+					}
+				}
+			} else {
+				zval_ptr_dtor(&configs);
+				yaf_trigger_error(E_ERROR TSRMLS_CC, "Argument is not a valid ini file '%s'", \
ini_file); +				return NULL;
+			}
+		} else {
+			zval_ptr_dtor(&configs);
+			yaf_trigger_error(E_ERROR TSRMLS_CC, "Unable to find config file '%s'", \
ini_file); +			return NULL;
+		}
+
+		if (section_name && Z_STRLEN_P(section_name)) {
+			zval **section;
+			zval tmp;
+			if (zend_symtable_find(Z_ARRVAL_P(configs),
+						Z_STRVAL_P(section_name), Z_STRLEN_P(section_name) + 1, (void **)&section) == \
FAILURE) { +				zval_ptr_dtor(&configs);
+				yaf_trigger_error(E_ERROR TSRMLS_CC, "There is no section '%s' in '%s'", \
Z_STRVAL_P(section_name), ini_file); +				return NULL;
+			}
+			INIT_PZVAL(&tmp);
+			array_init(&tmp);
+			zend_hash_copy(Z_ARRVAL(tmp), Z_ARRVAL_PP(section), (copy_ctor_func_t) \
zval_add_ref, NULL, sizeof(zval *)); +			zval_dtor(configs);
+
+			*configs = tmp;
+		}
+
+		if (this_ptr) {
+			instance = this_ptr;
+		} else {
+			MAKE_STD_ZVAL(instance);
+			object_init_ex(instance, yaf_config_ini_ce);
+		}
+
+		zend_update_property(yaf_config_ini_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), configs TSRMLS_CC); +		zval_ptr_dtor(&configs);
+
+		return instance;
+	} else {
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Invalid parameters provided, must \
be path of ini file"); +		return NULL;
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::__construct(mixed $config_path, string \
$section_name) +*/
+PHP_METHOD(yaf_config_ini, __construct) {
+	zval *filename, *section = NULL;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &filename, &section) == \
FAILURE) { +		zval *prop;
+		MAKE_STD_ZVAL(prop);
+		array_init(prop);
+		zend_update_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), prop TSRMLS_CC); +		zval_ptr_dtor(&prop);
+		return;
+	}
+
+	(void)yaf_config_ini_instance(getThis(), filename, section TSRMLS_CC);
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Config_Ini::get(string $name = NULL)
+*/
+PHP_METHOD(yaf_config_ini, get) {
+	zval *ret, **ppzval;
+	char *name;
+	uint len = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &len) == FAILURE) \
{ +		return;
+	}
+
+	if (!len) {
+		RETURN_ZVAL(getThis(), 1, 0);
+	} else {
+		zval *properties;
+		char *entry, *seg, *pptr;
+
+		properties = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +
+		if (Z_TYPE_P(properties) != IS_ARRAY) {
+			RETURN_NULL();
+		}
+
+		entry = estrndup(name, len);
+		if ((seg = php_strtok_r(entry, ".", &pptr))) {
+			while (seg) {
+				if (zend_hash_find(Z_ARRVAL_P(properties), seg, strlen(seg) + 1, (void **) \
&ppzval) == FAILURE) { +					efree(entry);
+					RETURN_NULL();
+				}
+
+				properties = *ppzval;
+				seg = php_strtok_r(NULL, ".", &pptr);
+			}
+		} else {
+			if (zend_hash_find(Z_ARRVAL_P(properties), name, len + 1, (void **)&ppzval) == \
FAILURE) { +				efree(entry);
+				RETURN_NULL();
+			}
+		}
+
+		efree(entry);
+
+		if (Z_TYPE_PP(ppzval) == IS_ARRAY) {
+			if ((ret = yaf_config_ini_format(getThis(), ppzval TSRMLS_CC))) {
+				RETURN_ZVAL(ret, 1, 1);
+			} else {
+				RETURN_NULL();
+			}
+		} else {
+			RETURN_ZVAL(*ppzval, 1, 0);
+		}
+	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::toArray(void)
+*/
+PHP_METHOD(yaf_config_ini, toArray) {
+	zval *properties = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +	RETURN_ZVAL(properties, 1, 0);
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::set($name, $value)
+*/
+PHP_METHOD(yaf_config_ini, set) {
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::__isset($name)
+*/
+PHP_METHOD(yaf_config_ini, __isset) {
+	char * name;
+	int len;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &len) == FAILURE) \
{ +		return;
+	} else {
+		zval *prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+		RETURN_BOOL(zend_hash_exists(Z_ARRVAL_P(prop), name, len + 1)); +	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::count($name)
+*/
+PHP_METHOD(yaf_config_ini, count) {
+	zval *prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	RETURN_LONG(zend_hash_num_elements(Z_ARRVAL_P(prop))); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::offsetUnset($index)
+*/
+PHP_METHOD(yaf_config_ini, offsetUnset) {
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::rewind(void)
+*/
+PHP_METHOD(yaf_config_ini, rewind) {
+	zval *prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	zend_hash_internal_pointer_reset(Z_ARRVAL_P(prop)); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::current(void)
+*/
+PHP_METHOD(yaf_config_ini, current) {
+	zval *prop, **ppzval, *ret;
+
+	prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +	if \
(zend_hash_get_current_data(Z_ARRVAL_P(prop), (void **)&ppzval) == FAILURE) { \
+		RETURN_FALSE; +	}
+
+	if (Z_TYPE_PP(ppzval) == IS_ARRAY) {
+		if ((ret = yaf_config_ini_format(getThis(),  ppzval TSRMLS_CC))) {
+			RETURN_ZVAL(ret, 1, 1);
+		} else {
+			RETURN_NULL();
+		}
+	} else {
+		RETURN_ZVAL(*ppzval, 1, 0);
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::key(void)
+*/
+PHP_METHOD(yaf_config_ini, key) {
+	zval *prop;
+	char *string;
+	ulong index;
+
+	prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 0 TSRMLS_CC); +	switch \
(zend_hash_get_current_key(Z_ARRVAL_P(prop), &string, &index, 0)) { +		case \
HASH_KEY_IS_LONG: +			RETURN_LONG(index);
+			break;
+		case HASH_KEY_IS_STRING:
+			RETURN_STRING(string, 1);
+			break;
+		default:
+			RETURN_FALSE;
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::next(void)
+*/
+PHP_METHOD(yaf_config_ini, next) {
+	zval *prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	zend_hash_move_forward(Z_ARRVAL_P(prop)); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::valid(void)
+*/
+PHP_METHOD(yaf_config_ini, valid) {
+	zval *prop = zend_read_property(yaf_config_ini_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	RETURN_LONG(zend_hash_has_more_elements(Z_ARRVAL_P(prop)) == SUCCESS); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::readonly(void)
+*/
+PHP_METHOD(yaf_config_ini, readonly) {
+	RETURN_TRUE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Ini::__destruct
+*/
+PHP_METHOD(yaf_config_ini, __destruct) {
+}
+/* }}} */
+
+/** {{{ proto private Yaf_Config_Ini::__clone
+*/
+PHP_METHOD(yaf_config_ini, __clone) {
+}
+/* }}} */
+
+/** {{{ yaf_config_ini_methods
+*/
+zend_function_entry yaf_config_ini_methods[] = {
+	PHP_ME(yaf_config_ini, __construct,	yaf_config_ini_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	/* PHP_ME(yaf_config_ini, __destruct,	NULL, \
ZEND_ACC_PUBLIC|ZEND_ACC_DTOR) */ +	PHP_ME(yaf_config_ini, __isset, \
yaf_config_ini_isset_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, \
get,	yaf_config_ini_get_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, set, \
yaf_config_ini_set_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, count, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, rewind, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, current, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, next, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, valid, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, key, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, toArray, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, readonly, \
yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_ini, offsetUnset, \
yaf_config_ini_unset_arginfo, ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_ini, \
offsetGet, get, yaf_config_ini_rget_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_MALIAS(yaf_config_ini, offsetExists, __isset, yaf_config_ini_isset_arginfo, \
ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_ini, offsetSet, set, \
yaf_config_ini_set_arginfo, ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_ini, __get, get, \
yaf_config_ini_get_arginfo, ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_ini, __set, set, \
yaf_config_ini_set_arginfo, ZEND_ACC_PUBLIC) +	{NULL, NULL, NULL}
+};
+
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(config_ini) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Config_Ini", "Yaf\\Config\\Ini", \
yaf_config_ini_methods); +	yaf_config_ini_ce = zend_register_internal_class_ex(&ce, \
yaf_config_ce, NULL TSRMLS_CC); +
+#ifdef HAVE_SPL
+	zend_class_implements(yaf_config_ini_ce TSRMLS_CC, 3, zend_ce_iterator, \
zend_ce_arrayaccess, spl_ce_Countable); +#else
+	zend_class_implements(yaf_config_ini_ce TSRMLS_CC, 2, zend_ce_iterator, \
zend_ce_arrayaccess); +#endif
+
+	yaf_config_ini_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/configs/yaf_config_ini.h
===================================================================
--- pecl/yaf/trunk/configs/yaf_config_ini.h	                        (rev 0)
+++ pecl/yaf/trunk/configs/yaf_config_ini.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,40 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_config.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_CONFIG_INI_H
+#define YAF_CONFIG_INI_H
+
+#define YAF_CONFIG_INI_PARSING_START   0
+#define YAF_CONFIG_INI_PARSING_PROCESS 1
+#define YAF_CONFIG_INI_PARSING_END     2
+
+extern zend_class_entry *yaf_config_ini_ce;
+
+yaf_config_t * yaf_config_ini_instance(yaf_config_t *this_ptr, zval *filename, zval \
*section TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(config_ini);
+
+#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
+ */

Added: pecl/yaf/trunk/configs/yaf_config_simple.c
===================================================================
--- pecl/yaf/trunk/configs/yaf_config_simple.c	                        (rev 0)
+++ pecl/yaf/trunk/configs/yaf_config_simple.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,395 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: simple.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "Zend/zend_interfaces.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_config.h"
+
+#include "configs/yaf_config_simple.h"
+
+zend_class_entry *yaf_config_simple_ce;
+
+#ifdef HAVE_SPL
+extern PHPAPI zend_class_entry *spl_ce_Countable;
+#endif
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_void_arginfo, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_construct_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, config_file)
+	ZEND_ARG_INFO(0, section)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_get_arginfo, 0, 0, 0)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_rget_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_set_arginfo, 0, 0, 2)
+	ZEND_ARG_INFO(0, name)
+	ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_isset_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_unset_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/** {{{ yaf_config_t * yaf_config_simple_instance(yaf_config_t *this_ptr, zval \
*values, zval *readonly TSRMLS_DC) +*/
+yaf_config_t * yaf_config_simple_instance(yaf_config_t *this_ptr, zval *values, zval \
*readonly TSRMLS_DC) { +	yaf_config_t *instance;
+
+	switch (Z_TYPE_P(values)) {
+		case IS_ARRAY:
+			if (this_ptr) {
+				instance = this_ptr;
+			} else {
+				MAKE_STD_ZVAL(instance);
+				object_init_ex(instance, yaf_config_simple_ce);
+			}
+			zend_update_property(yaf_config_simple_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), values TSRMLS_CC); +			if (readonly) {
+				convert_to_boolean(readonly);
+				zend_update_property_bool(yaf_config_simple_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), Z_BVAL_P(readonly) TSRMLS_CC); +			}
+			return instance;
+		break;
+		default:
+			yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Invalid parameters provided, \
must be an array"); +			return NULL;
+	}
+}
+/* }}} */
+
+/** {{{ zval * yaf_config_simple_format(yaf_config_t *instance, zval **ppzval \
TSRMLS_DC) + */
+zval * yaf_config_simple_format(yaf_config_t *instance, zval **ppzval TSRMLS_DC) {
+	zval *readonly, *ret;
+	readonly = zend_read_property(yaf_config_simple_ce, instance, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 1 TSRMLS_CC); +	ret = \
yaf_config_simple_instance(NULL, *ppzval, readonly TSRMLS_CC); +	return ret;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::__construct(mixed $array, string $readonly)
+*/
+PHP_METHOD(yaf_config_simple, __construct) {
+	zval *values, *readonly = NULL;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &values, &readonly) == \
FAILURE) { +		zval *prop;
+
+		MAKE_STD_ZVAL(prop);
+		array_init(prop);
+		zend_update_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), prop TSRMLS_CC); +		zval_ptr_dtor(&prop);
+
+		return;
+	}
+
+	(void)yaf_config_simple_instance(getThis(), values, readonly TSRMLS_CC);
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Config_Simple::get(string $name = NULL)
+*/
+PHP_METHOD(yaf_config_simple, get) {
+	zval *ret, **ppzval;
+	char *name;
+	uint len = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &len) == FAILURE) \
{ +		return;
+	}
+
+	if (!len) {
+		RETURN_ZVAL(getThis(), 1, 0);
+	} else {
+		zval *properties;
+		HashTable *hash;
+
+		properties = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +		hash  = Z_ARRVAL_P(properties);
+
+		if (zend_hash_find(hash, name, len + 1, (void **) &ppzval) == FAILURE) {
+			RETURN_FALSE;
+		}
+
+		if (Z_TYPE_PP(ppzval) == IS_ARRAY) {
+			if ((ret = yaf_config_simple_format(getThis(), ppzval TSRMLS_CC))) {
+				RETURN_ZVAL(ret, 1, 1);
+			} else {
+				RETURN_NULL();
+			}
+		} else {
+			RETURN_ZVAL(*ppzval, 1, 0);
+		}
+	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::toArray(void)
+*/
+PHP_METHOD(yaf_config_simple, toArray) {
+	zval *properties = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +	RETURN_ZVAL(properties, 1, 0);
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::set($name, $value)
+*/
+PHP_METHOD(yaf_config_simple, set) {
+	zval *readonly = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 1 TSRMLS_CC); +
+	if (!Z_BVAL_P(readonly)) {
+		zval *name, *value, *props;
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &name, &value) == \
FAILURE) { +			return;
+		}
+
+		if (Z_TYPE_P(name) != IS_STRING || Z_TYPE_P(name) != IS_STRING) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expect a string key name");
+			RETURN_FALSE;
+		}
+
+		Z_ADDREF_P(value);
+		props = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +		if \
(zend_hash_update(Z_ARRVAL_P(props), Z_STRVAL_P(name), Z_STRLEN_P(name) + 1, (void \
**)&value, sizeof(zval*), NULL) == SUCCESS) { +			RETURN_TRUE;
+		} else {
+			Z_DELREF_P(value);
+		}
+	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::__isset($name)
+*/
+PHP_METHOD(yaf_config_simple, __isset) {
+	char *name;
+	uint len;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &len) == FAILURE) \
{ +		return;
+	} else {
+		zval *prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+		RETURN_BOOL(zend_hash_exists(Z_ARRVAL_P(prop), name, len + 1)); +	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::offsetUnset($index)
+*/
+PHP_METHOD(yaf_config_simple, offsetUnset) {
+	zval *readonly = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 1 TSRMLS_CC); +
+	if (!Z_BVAL_P(readonly)) {
+		zval *name, *props;
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
+			return;
+		}
+
+		if (Z_TYPE_P(name) != IS_STRING || Z_TYPE_P(name) != IS_STRING) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expect a string key name");
+			RETURN_FALSE;
+		}
+
+		props = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +		if \
(zend_hash_del(Z_ARRVAL_P(props), Z_STRVAL_P(name), Z_STRLEN_P(name) + 1) == SUCCESS) \
{ +			RETURN_TRUE;
+		}
+	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::count($name)
+*/
+PHP_METHOD(yaf_config_simple, count) {
+	zval *prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	RETURN_LONG(zend_hash_num_elements(Z_ARRVAL_P(prop))); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::rewind(void)
+*/
+PHP_METHOD(yaf_config_simple, rewind) {
+	zval *prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	zend_hash_internal_pointer_reset(Z_ARRVAL_P(prop)); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::current(void)
+*/
+PHP_METHOD(yaf_config_simple, current) {
+	zval *prop, **ppzval, *ret;
+
+	prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); +	if \
(zend_hash_get_current_data(Z_ARRVAL_P(prop), (void **)&ppzval) == FAILURE) { \
+		RETURN_FALSE; +	}
+
+	if (Z_TYPE_PP(ppzval) == IS_ARRAY) {
+		if ((ret = yaf_config_simple_format(getThis(), ppzval TSRMLS_CC))) {
+			RETURN_ZVAL(ret, 1, 1);
+		} else {
+			RETURN_NULL();
+		}
+	} else {
+		RETURN_ZVAL(*ppzval, 1, 0);
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::key(void)
+*/
+PHP_METHOD(yaf_config_simple, key) {
+	zval *prop;
+	char *string;
+	ulong index;
+
+	prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	zend_hash_get_current_key(Z_ARRVAL_P(prop), &string, &index, 0); \
+	switch(zend_hash_get_current_key_type(Z_ARRVAL_P(prop))) { +		case \
HASH_KEY_IS_LONG: +			RETURN_LONG(index);
+			break;
+		case HASH_KEY_IS_STRING:
+			RETURN_STRING(string, 1);
+			break;
+		default:
+			RETURN_FALSE;
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::next(void)
+*/
+PHP_METHOD(yaf_config_simple, next) {
+	zval *prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	zend_hash_move_forward(Z_ARRVAL_P(prop)); +	RETURN_TRUE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::valid(void)
+*/
+PHP_METHOD(yaf_config_simple, valid) {
+	zval *prop = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC); \
+	RETURN_LONG(zend_hash_has_more_elements(Z_ARRVAL_P(prop)) == SUCCESS); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::readonly(void)
+*/
+PHP_METHOD(yaf_config_simple, readonly) {
+	zval *readonly = zend_read_property(yaf_config_simple_ce, getThis(), \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 1 TSRMLS_CC); \
+	RETURN_BOOL(Z_LVAL_P(readonly)); +}
+/* }}} */
+
+/** {{{ proto public Yaf_Config_Simple::__destruct
+*/
+PHP_METHOD(yaf_config_simple, __destruct) {
+}
+/* }}} */
+
+/** {{{ proto private Yaf_Config_Simple::__clone
+*/
+PHP_METHOD(yaf_config_simple, __clone) {
+}
+/* }}} */
+
+/** {{{ yaf_config_simple_methods
+*/
+zend_function_entry yaf_config_simple_methods[] = {
+	PHP_ME(yaf_config_simple, __construct, yaf_config_simple_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	/* PHP_ME(yaf_config_simple, __destruct,	NULL, \
ZEND_ACC_PUBLIC|ZEND_ACC_DTOR) */ +	PHP_ME(yaf_config_simple, __isset, \
yaf_config_simple_isset_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_simple, get, \
yaf_config_simple_get_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_simple, set, \
yaf_config_simple_set_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_simple, count, \
yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_simple, \
offsetUnset,	yaf_config_simple_unset_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, rewind, yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, current, yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, next,	yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, valid, yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, key, yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_ME(yaf_config_simple, readonly,	yaf_config_simple_void_arginfo, \
ZEND_ACC_PUBLIC) +	PHP_ME(yaf_config_simple, toArray, yaf_config_simple_void_arginfo, \
ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_simple, __set, set, \
yaf_config_simple_set_arginfo, ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_simple, \
__get, get, yaf_config_simple_get_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_MALIAS(yaf_config_simple, offsetGet, get, yaf_config_simple_rget_arginfo, \
ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_simple, offsetExists, __isset, \
yaf_config_simple_isset_arginfo, ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_config_simple, \
offsetSet, set, yaf_config_simple_set_arginfo, ZEND_ACC_PUBLIC) +	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(config_simple) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Config_Simple", "Yaf\\Config\\Simple", \
yaf_config_simple_methods); +	yaf_config_simple_ce = \
zend_register_internal_class_ex(&ce, yaf_config_ce, NULL TSRMLS_CC); +
+#ifdef HAVE_SPL
+	zend_class_implements(yaf_config_simple_ce TSRMLS_CC, 3, zend_ce_iterator, \
zend_ce_arrayaccess, spl_ce_Countable); +#else
+	zend_class_implements(yaf_config_simple_ce TSRMLS_CC, 2, zend_ce_iterator, \
zend_ce_arrayaccess); +#endif
+	zend_declare_property_bool(yaf_config_simple_ce, \
ZEND_STRL(YAF_CONFIG_PROPERT_NAME_READONLY), 0, ZEND_ACC_PROTECTED TSRMLS_CC); +
+	yaf_config_simple_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/configs/yaf_config_simple.h
===================================================================
--- pecl/yaf/trunk/configs/yaf_config_simple.h	                        (rev 0)
+++ pecl/yaf/trunk/configs/yaf_config_simple.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,36 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_config.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_CONFIG_SIMPLE_H
+#define YAF_CONFIG_SIMPLE_H
+
+extern zend_class_entry *yaf_config_simple_ce;
+
+yaf_config_t * yaf_config_simple_instance(yaf_config_t *this_ptr, zval *values, zval \
*readonly TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(config_simple);
+
+#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
+ */

Added: pecl/yaf/trunk/responses/yaf_response_cli.c
===================================================================
--- pecl/yaf/trunk/responses/yaf_response_cli.c	                        (rev 0)
+++ pecl/yaf/trunk/responses/yaf_response_cli.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,61 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: cli.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_response.h"
+#include "yaf_exception.h"
+
+#include "responses/yaf_response_cli.h"
+
+zend_class_entry * yaf_response_cli_ce;
+
+/** {{{ yaf_response_methods
+*/
+zend_function_entry yaf_response_cli_methods[] = {
+	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(response_cli) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Response_Cli", "Yaf\\Response\\Cli", \
yaf_response_cli_methods); +
+	yaf_response_cli_ce = zend_register_internal_class_ex(&ce, yaf_response_ce, NULL \
TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/responses/yaf_response_cli.h
===================================================================
--- pecl/yaf/trunk/responses/yaf_response_cli.h	                        (rev 0)
+++ pecl/yaf/trunk/responses/yaf_response_cli.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,35 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_response.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef PHP_YAF_RESPONSE_CLI_H
+#define PHP_YAF_RESPONSE_CLI_H
+
+extern zend_class_entry *yaf_response_cli_ce;
+
+YAF_STARTUP_FUNCTION(response_cli);
+
+#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
+ */

Added: pecl/yaf/trunk/responses/yaf_response_http.c
===================================================================
--- pecl/yaf/trunk/responses/yaf_response_http.c	                        (rev 0)
+++ pecl/yaf/trunk/responses/yaf_response_http.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,64 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+ */
+
+/* $Id: http.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_response.h"
+#include "yaf_exception.h"
+
+#include "responses/yaf_response_http.h"
+
+zend_class_entry *yaf_response_http_ce;
+
+/** {{{ yaf_response_methods
+*/
+zend_function_entry yaf_response_http_methods[] = {
+	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(response_http) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Response_Http", "Yaf\\Response\\Http", \
yaf_response_http_methods); +
+	yaf_response_http_ce = zend_register_internal_class_ex(&ce, yaf_response_ce, NULL \
TSRMLS_CC); +
+	zend_declare_property_bool(yaf_response_http_ce, \
ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_HEADEREXCEPTION), 1, ZEND_ACC_PROTECTED \
TSRMLS_CC); +	zend_declare_property_long(yaf_response_http_ce, \
ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE),	200, ZEND_ACC_PROTECTED \
TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/responses/yaf_response_http.h
===================================================================
--- pecl/yaf/trunk/responses/yaf_response_http.h	                        (rev 0)
+++ pecl/yaf/trunk/responses/yaf_response_http.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,35 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_response.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef PHP_YAF_RESPONSE_HTTP_H
+#define PHP_YAF_RESPONSE_HTTP_H
+
+extern zend_class_entry *yaf_response_http_ce;
+
+YAF_STARTUP_FUNCTION(response_http);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_interface.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_interface.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_interface.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,160 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: interface.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_router.h"
+
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_static.h"
+#include "routes/yaf_route_simple.h"
+#include "routes/yaf_route_supervar.h"
+#include "routes/yaf_route_regex.h"
+#include "routes/yaf_route_rewrite.h"
+#include "routes/yaf_route_map.h"
+
+zend_class_entry *yaf_route_ce;
+
+/* {{{ yaf_route_t * yaf_route_instance(yaf_route_t *this_ptr,  zval *config \
TSRMLS_DC) + */
+yaf_route_t * yaf_route_instance(yaf_route_t *this_ptr, zval *config TSRMLS_DC) {
+	zval **match, **def, **map, **ppzval;
+	yaf_route_t *instance = NULL;
+
+	if (!config || IS_ARRAY != Z_TYPE_P(config)) {
+		return NULL;
+	}
+
+	if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("type"), (void **)&ppzval) == \
FAILURE +			|| IS_STRING != Z_TYPE_PP(ppzval)) {
+		return NULL;
+	}
+
+	if (Z_STRLEN_PP(ppzval) == (sizeof("rewrite") - 1)
+			&& strncasecmp(Z_STRVAL_PP(ppzval), "rewrite", sizeof("rewrite") - 1) == 0) {
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("match"), (void **)&match) == \
FAILURE +				|| Z_TYPE_PP(match) != IS_STRING) {
+			return NULL;
+		}
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("route"), (void **)&def) == \
FAILURE +				|| Z_TYPE_PP(def) != IS_ARRAY) {
+			return NULL;
+		}
+
+		instance = yaf_route_rewrite_instance(NULL, *match, *def, NULL TSRMLS_CC);
+	} else if (Z_STRLEN_PP(ppzval) == (sizeof("regex") - 1)
+			&& strncasecmp(Z_STRVAL_PP(ppzval), "regex", sizeof("regex") - 1) == 0) {
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("match"), (void **)&match) == \
FAILURE || Z_TYPE_PP(match) != IS_STRING) { +			return NULL;
+		}
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("route"), (void **)&def) == \
FAILURE +				|| Z_TYPE_PP(def) != IS_ARRAY) {
+			return NULL;
+		}
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("map"), (void **)&map) == FAILURE \
|| Z_TYPE_PP(map) != IS_ARRAY) { +			map = NULL;
+		}
+
+		instance = yaf_route_regex_instance(NULL, *match, *def, map? *map : NULL, NULL \
TSRMLS_CC); +	} else if (Z_STRLEN_PP(ppzval) == (sizeof("map") - 1)
+			&& strncasecmp(Z_STRVAL_PP(ppzval), "map", sizeof("map") - 1) == 0) {
+		char *delimiter = NULL;
+		uint delim_len  = 0;
+		zend_bool controller_prefer = 0;
+
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("controllerPrefer"), (void \
**)&ppzval) == SUCCESS) { +			zval *tmp = *ppzval;
+			Z_ADDREF_P(tmp);
+			convert_to_boolean_ex(&tmp);
+			controller_prefer = Z_BVAL_P(tmp);
+			zval_ptr_dtor(&tmp);
+		}
+
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("delimiter"), (void **)&ppzval) \
== SUCCESS +				&& Z_TYPE_PP(ppzval) == IS_STRING) {
+			delimiter = Z_STRVAL_PP(ppzval);
+			delim_len = Z_STRLEN_PP(ppzval);
+		}
+
+		instance = yaf_route_map_instance(NULL, controller_prefer, delimiter, delim_len \
TSRMLS_CC); +	} else if (Z_STRLEN_PP(ppzval) == (sizeof("simple") - 1)
+			&& strncasecmp(Z_STRVAL_PP(ppzval), "simple", sizeof("simple") - 1) == 0) {
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("module"), (void **)&match) == \
FAILURE +				|| Z_TYPE_PP(match) != IS_STRING) {
+			return NULL;
+		}
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("controller"), (void **)&def) == \
FAILURE +				|| Z_TYPE_PP(def) != IS_STRING) {
+			return NULL;
+		}
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("action"), (void **)&map) == \
FAILURE +				|| Z_TYPE_PP(map) != IS_STRING) {
+			return NULL;
+		}
+
+		instance = yaf_route_simple_instance(NULL, *match, *def, *map TSRMLS_CC);
+	} else if (Z_STRLEN_PP(ppzval) == (sizeof("supervar") - 1)
+			&& strncasecmp(Z_STRVAL_PP(ppzval), "supervar", sizeof("supervar") - 1) == 0) {
+		if (zend_hash_find(Z_ARRVAL_P(config), ZEND_STRS("varname"), (void **)&match) == \
FAILURE +				|| Z_TYPE_PP(match) != IS_STRING) {
+			return NULL;
+		}
+
+		instance = yaf_route_supervar_instance(NULL, *match TSRMLS_CC);
+	}
+
+	return instance;
+}
+/* }}} */
+
+/** {{{ yaf_route_methods
+ */
+zend_function_entry yaf_route_methods[] = {
+	PHP_ABSTRACT_ME(yaf_route, route, yaf_route_route_arginfo)
+    {NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Interface", "Yaf\\Route_Interface", \
yaf_route_methods); +	yaf_route_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_interface.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_interface.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_interface.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,48 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_INTERFACE_H
+#define YAF_ROUTER_INTERFACE_H
+
+#define YAF_ROUTE_PROPETY_NAME_MATCH  	"_route"
+#define YAF_ROUTE_PROPETY_NAME_ROUTE  	"_default"
+#define YAF_ROUTE_PROPETY_NAME_MAP	 	"_maps"
+#define YAF_ROUTE_PROPETY_NAME_VERIFY 	"_verify"
+
+#define YAF_ROUTER_URL_DELIMIETER  	 "/"
+#define YAF_ROUTE_REGEX_DILIMITER  	 '#'
+
+YAF_BEGIN_ARG_INFO_EX(yaf_route_route_arginfo, 0, 0, 1)
+	YAF_ARG_INFO(0, request)
+YAF_END_ARG_INFO()
+
+extern zend_class_entry *yaf_route_ce;
+
+yaf_route_t * yaf_route_instance(yaf_route_t *this_ptr,  zval *config TSRMLS_DC);
+
+YAF_STARTUP_FUNCTION(route);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_map.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_map.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_map.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,210 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: map.c 329197 2013-01-18 05:55:37Z laruence $*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "ext/standard/php_smart_str.h" /* for smart_str */
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_request.h"
+
+#include "yaf_router.h"
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_map.h"
+
+zend_class_entry *yaf_route_map_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_map_construct_arginfo, 0, 0, 0)
+    ZEND_ARG_INFO(0, controller_prefer)
+	ZEND_ARG_INFO(0, delimiter)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ yaf_route_t * yaf_route_map_instance(yaf_route_t *this_ptr, zend_bool \
controller_prefer, char *delim, uint len TSRMLS_DC) + */
+yaf_route_t * yaf_route_map_instance(yaf_route_t *this_ptr, zend_bool \
controller_prefer, char *delim, uint len TSRMLS_DC) { +	yaf_route_t *instance;
+
+	if (this_ptr) {
+		instance  = this_ptr;
+	} else {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_route_map_ce);
+	}
+
+	if (controller_prefer) {
+		zend_update_property_bool(yaf_route_map_ce, instance,
+				ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_CTL_PREFER), 1 TSRMLS_CC);
+	}
+
+	if (delim && len) {
+		zend_update_property_stringl(yaf_route_map_ce, instance,
+				ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_DELIMETER), delim, len TSRMLS_CC);
+	}
+
+	return instance;
+}
+/* }}} */
+
+/** {{{ int yaf_route_map_route(yaf_route_t *route, yaf_request_t *request \
TSRMLS_DC) +*/
+int yaf_route_map_route(yaf_route_t *route, yaf_request_t *request TSRMLS_DC) {
+	zval *ctl_prefer, *delimer, *zuri, *base_uri, *params;
+	char *req_uri, *tmp, *rest, *ptrptr, *seg;
+	char *query_str = NULL;
+	uint seg_len = 0;
+
+	smart_str route_result = {0};
+
+	zuri 	 = zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_URI), 1 TSRMLS_CC); +	base_uri = \
zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_BASE), 1 TSRMLS_CC); +
+	ctl_prefer = zend_read_property(yaf_route_map_ce, route, \
ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_CTL_PREFER), 1 TSRMLS_CC); +	delimer	   = \
zend_read_property(yaf_route_map_ce, route, \
ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_DELIMETER), 1 TSRMLS_CC); +
+	if (base_uri && IS_STRING == Z_TYPE_P(base_uri)
+			&& !strncasecmp(Z_STRVAL_P(zuri), Z_STRVAL_P(base_uri), Z_STRLEN_P(base_uri))) {
+		req_uri  = estrdup(Z_STRVAL_P(zuri) + Z_STRLEN_P(base_uri));
+	} else {
+		req_uri  = estrdup(Z_STRVAL_P(zuri));
+	}
+
+	if (Z_TYPE_P(delimer) == IS_STRING
+			&& Z_STRLEN_P(delimer)) {
+		if ((query_str = strstr(req_uri, Z_STRVAL_P(delimer))) != NULL
+			&& *(query_str - 1) == '/') {
+			tmp  = req_uri;
+			rest = query_str + Z_STRLEN_P(delimer);
+			if (*rest == '\0') {
+				req_uri 	= estrndup(req_uri, query_str - req_uri);
+				query_str 	= NULL;
+				efree(tmp);
+			} else if (*rest == '/') {
+				req_uri 	= estrndup(req_uri, query_str - req_uri);
+				query_str   = estrdup(rest);
+				efree(tmp);
+			} else {
+				query_str = NULL;
+			}
+		}
+	}
+
+	seg = php_strtok_r(req_uri, YAF_ROUTER_URL_DELIMIETER, &ptrptr);
+	while (seg) {
+		seg_len = strlen(seg);
+		if (seg_len) {
+			smart_str_appendl(&route_result, seg, seg_len);
+		}
+		smart_str_appendc(&route_result, '_');
+		seg = php_strtok_r(NULL, YAF_ROUTER_URL_DELIMIETER, &ptrptr);
+	}
+
+	if (route_result.len) {
+		if (Z_BVAL_P(ctl_prefer)) {
+			zend_update_property_stringl(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), route_result.c, route_result.len - 1 \
TSRMLS_CC); +		} else {
+			zend_update_property_stringl(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), route_result.c, route_result.len - 1 \
TSRMLS_CC); +		}
+		efree(route_result.c);
+	}
+
+	if (query_str) {
+		params = yaf_router_parse_parameters(query_str TSRMLS_CC);
+		(void)yaf_request_set_params_multi(request, params TSRMLS_CC);
+		zval_ptr_dtor(&params);
+		efree(query_str);
+	}
+
+	efree(req_uri);
+
+	return 1;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Simple::route(Yaf_Request $req)
+*/
+PHP_METHOD(yaf_route_map, route) {
+	yaf_request_t *request;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	} else {
+		RETURN_BOOL(yaf_route_map_route(getThis(), request TSRMLS_CC));
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Simple::__construct(bool $controller_prefer=FALSE, \
string $delimer = '#!') +*/
+PHP_METHOD(yaf_route_map, __construct) {
+	char *delim	= NULL;
+	uint delim_len = 0;
+	zend_bool controller_prefer = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bs",
+			   	&controller_prefer, &delim, &delim_len) == FAILURE) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	(void)yaf_route_map_instance(getThis(), controller_prefer, delim, delim_len \
TSRMLS_CC); +}
+/* }}} */
+
+/** {{{ yaf_route_map_methods
+*/
+zend_function_entry yaf_route_map_methods[] = {
+	PHP_ME(yaf_route_map, __construct, yaf_route_map_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	PHP_ME(yaf_route_map, route, \
yaf_route_route_arginfo, ZEND_ACC_PUBLIC) +	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(route_map) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Map", "Yaf\\Route\\Map", \
yaf_route_map_methods); +	yaf_route_map_ce = zend_register_internal_class_ex(&ce, \
NULL, NULL TSRMLS_CC); +	zend_class_implements(yaf_route_map_ce TSRMLS_CC, 1, \
yaf_route_ce); +
+	yaf_route_map_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+	zend_declare_property_bool(yaf_route_map_ce, \
ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_CTL_PREFER), 0, ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_map_ce, \
ZEND_STRL(YAF_ROUTE_MAP_VAR_NAME_DELIMETER),  ZEND_ACC_PROTECTED TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_map.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_map.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_map.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,39 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_MAP_H
+#define YAF_ROUTER_MAP_H
+
+#define YAF_ROUTE_MAP_VAR_NAME_DELIMETER	"_delimeter"
+#define YAF_ROUTE_MAP_VAR_NAME_CTL_PREFER	"_ctl_router"
+
+extern zend_class_entry *yaf_route_map_ce;
+
+yaf_route_t * yaf_route_map_instance(yaf_route_t *this_ptr, zend_bool \
controller_prefer, char *delim, uint len TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_map);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_regex.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_regex.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_regex.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,305 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+ */
+
+/* $Id: regex.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "ext/pcre/php_pcre.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_request.h"
+
+#include "yaf_router.h"
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_regex.h"
+
+zend_class_entry *yaf_route_regex_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_regex_construct_arginfo, 0, 0, 2)
+	ZEND_ARG_INFO(0, match)
+    ZEND_ARG_ARRAY_INFO(0, route, 0)
+    ZEND_ARG_ARRAY_INFO(0, map, 1)
+    ZEND_ARG_ARRAY_INFO(0, verify, 1)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/** {{{ yaf_route_t * yaf_route_regex_instance(yaf_route_t *this_ptr, zval *route, \
zval *def, zval *map, zval *verify TSRMLS_DC) + */
+yaf_route_t * yaf_route_regex_instance(yaf_route_t *this_ptr, zval *route, zval \
*def, zval *map, zval *verify TSRMLS_DC) { +	yaf_route_t	*instance;
+
+	if (this_ptr) {
+		instance = this_ptr;
+	} else {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_route_regex_ce);
+	}
+
+	zend_update_property(yaf_route_regex_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH), route TSRMLS_CC); \
+	zend_update_property(yaf_route_regex_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE), def TSRMLS_CC); +
+	if (map) {
+		zend_update_property(yaf_route_regex_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MAP), map TSRMLS_CC); +	}
+
+	if (!verify) {
+		zend_update_property_null(yaf_route_regex_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY) TSRMLS_CC); +	} else {
+		zend_update_property(yaf_route_regex_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY), verify TSRMLS_CC); +	}
+
+	return instance;
+}
+/* }}} */
+
+/** {{{ static zval * yaf_route_regex_match(yaf_route_t *router, char *uir, int len \
TSRMLS_DC) + */
+static zval * yaf_route_regex_match(yaf_route_t *route, char *uir, int len \
TSRMLS_DC) { +	zval *match;
+	pcre_cache_entry *pce_regexp;
+
+	if (!len) {
+		return NULL;
+	}
+
+	match = zend_read_property(yaf_route_regex_ce, route, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH), 1 TSRMLS_CC); +
+	if ((pce_regexp = pcre_get_compiled_regex_cache(Z_STRVAL_P(match), \
Z_STRLEN_P(match) TSRMLS_CC)) == NULL) { +		return NULL;
+	} else {
+		zval *matches, *subparts, *map;
+
+		MAKE_STD_ZVAL(matches);
+		MAKE_STD_ZVAL(subparts);
+		ZVAL_NULL(subparts);
+
+		map = zend_read_property(yaf_route_regex_ce, route, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MAP), 1 TSRMLS_CC); +		if (IS_ARRAY != \
Z_TYPE_P(map)) { +			map = NULL;
+		}
+
+		php_pcre_match_impl(pce_regexp, uir, len, matches, subparts /* subpats */,
+				0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* \
start_offset */ TSRMLS_CC); +
+		if (!Z_LVAL_P(matches)) {
+			zval_ptr_dtor(&matches);
+			zval_ptr_dtor(&subparts);
+			return NULL;
+		} else {
+			zval  *ret, **name, **ppzval;
+			char	*key = NULL;
+			uint	len  = 0;
+			ulong	idx	 = 0;
+			HashTable 	*ht;
+
+			MAKE_STD_ZVAL(ret);
+			array_init(ret);
+
+			ht = Z_ARRVAL_P(subparts);
+			for(zend_hash_internal_pointer_reset(ht);
+					zend_hash_has_more_elements(ht) == SUCCESS;
+					zend_hash_move_forward(ht)) {
+
+				if (zend_hash_get_current_data(ht, (void**)&ppzval) == FAILURE) {
+					continue;
+				}
+
+				if (zend_hash_get_current_key_ex(ht, &key, &len, &idx, 0, NULL) == \
HASH_KEY_IS_LONG) { +					if (map && zend_hash_index_find(Z_ARRVAL_P(map), idx, (void \
**)&name) == SUCCESS) { +						Z_ADDREF_P(*ppzval);
+						zend_hash_update(Z_ARRVAL_P(ret), Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, \
(void **)ppzval, sizeof(zval *), NULL); +					}
+				} else {
+					Z_ADDREF_P(*ppzval);
+					zend_hash_update(Z_ARRVAL_P(ret), key, len, (void **)ppzval, sizeof(zval *), \
NULL); +				}
+			}
+
+			zval_ptr_dtor(&matches);
+			zval_ptr_dtor(&subparts);
+			return ret;
+		}
+	}
+
+	return NULL;
+}
+/* }}} */
+
+/** {{{ int yaf_route_regex_route(yaf_route_t *router, yaf_request_t *request \
TSRMLS_DC) + */
+int yaf_route_regex_route(yaf_route_t *router, yaf_request_t *request TSRMLS_DC) {
+	char *request_uri;
+	zval *args, *base_uri, *zuri;
+
+	zuri 	 = zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_URI), 1 TSRMLS_CC); +	base_uri = \
zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_BASE), 1 TSRMLS_CC); +
+	if (base_uri && IS_STRING == Z_TYPE_P(base_uri)
+			&& !strncasecmp(Z_STRVAL_P(zuri), Z_STRVAL_P(base_uri), Z_STRLEN_P(base_uri))) {
+		request_uri = estrdup(Z_STRVAL_P(zuri) + Z_STRLEN_P(base_uri));
+	} else {
+		request_uri = estrdup(Z_STRVAL_P(zuri));
+	}
+
+	if (!(args = yaf_route_regex_match(router, request_uri, strlen(request_uri) \
TSRMLS_CC))) { +		efree(request_uri);
+		return 0;
+	} else {
+		zval **module, **controller, **action, *routes;
+
+		routes = zend_read_property(yaf_route_regex_ce, router, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE), 1 TSRMLS_CC); +		if \
(zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("module"), (void **)&module) == SUCCESS \
&& IS_STRING == Z_TYPE_PP(module)) { +			if (Z_STRVAL_PP(module)[0] != ':') {
+				zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), *module TSRMLS_CC); +			} else {
+				zval **m;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(module) + 1, \
Z_STRLEN_PP(module), (void **)&m) == SUCCESS && IS_STRING == Z_TYPE_PP(m)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), *m TSRMLS_CC); +				}
+			}
+		}
+
+		if (zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("controller"), (void \
**)&controller) == SUCCESS && IS_STRING == Z_TYPE_PP(controller)) { +			if \
(Z_STRVAL_PP(controller)[0] != ':') { +				zend_update_property(yaf_request_ce, \
request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), *controller TSRMLS_CC); \
+			} else { +				zval **c;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(controller) + 1, \
Z_STRLEN_PP(controller), (void **)&c) == SUCCESS && IS_STRING == Z_TYPE_PP(c)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), *c TSRMLS_CC); +				}
+			}
+		}
+
+		if (zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("action"), (void **)&action) == \
SUCCESS && IS_STRING == Z_TYPE_PP(action)) { +			if (Z_STRVAL_PP(action)[0] != ':') {
+				zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), *action TSRMLS_CC); +			} else {
+				zval **a;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(action) + 1, \
Z_STRLEN_PP(action), (void **)&a) == SUCCESS && IS_STRING == Z_TYPE_PP(a)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), *a TSRMLS_CC); +				}
+			}
+		}
+
+		(void)yaf_request_set_params_multi(request, args TSRMLS_CC);
+		zval_ptr_dtor(&args);
+		efree(request_uri);
+	}
+
+	return 1;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Regex::route(string $uri)
+ */
+PHP_METHOD(yaf_route_regex, route) {
+	yaf_route_t	*route;
+	yaf_request_t *request;
+
+	route = getThis();
+
+	RETVAL_FALSE;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	}
+
+	if (!request || IS_OBJECT != Z_TYPE_P(request)
+			|| !instanceof_function(Z_OBJCE_P(request), yaf_request_ce TSRMLS_CC)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expects a %s instance",  \
yaf_request_ce->name); +		RETURN_FALSE;
+	}
+
+	RETURN_BOOL(yaf_route_regex_route(route, request TSRMLS_CC));
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Route_Regex::__construct(string $match, array $route, array \
$map = NULL, array $verify = NULL) + */
+PHP_METHOD(yaf_route_regex, __construct) {
+	zval 		*match, *route, *map = NULL, *verify = NULL;
+	yaf_route_t	*self = getThis();
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za|aa", &match, &route, &map, \
&verify) ==  FAILURE) { +		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	if (IS_STRING != Z_TYPE_P(match) || !Z_STRLEN_P(match)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects a valid string as the \
first parameter", yaf_route_regex_ce->name); +		RETURN_FALSE;
+	}
+
+	if (verify && IS_ARRAY != Z_TYPE_P(verify)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects an array as verify \
parmater",  yaf_route_regex_ce->name); +		RETURN_FALSE;
+	}
+
+	(void)yaf_route_regex_instance(self, match, route, map, verify TSRMLS_CC);
+
+	if (self) {
+		RETURN_ZVAL(self, 1, 0);
+	}
+
+	RETURN_FALSE;
+}
+/** }}} */
+
+/** {{{ yaf_route_regex_methods
+ */
+zend_function_entry yaf_route_regex_methods[] = {
+	PHP_ME(yaf_route_regex, __construct, yaf_route_regex_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	PHP_ME(yaf_route_regex, route, \
yaf_route_route_arginfo, ZEND_ACC_PUBLIC) +    {NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route_regex) {
+	zend_class_entry ce;
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Regex", "Yaf\\Route\\Regex", \
yaf_route_regex_methods); +	yaf_route_regex_ce = zend_register_internal_class_ex(&ce, \
yaf_route_ce, NULL TSRMLS_CC); +	zend_class_implements(yaf_route_regex_ce TSRMLS_CC, \
1, yaf_route_ce); +	yaf_route_regex_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+	zend_declare_property_null(yaf_route_regex_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH),  ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_regex_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE),  ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_regex_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MAP),    ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_regex_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY), ZEND_ACC_PROTECTED TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/routes/yaf_route_regex.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_regex.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_regex.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,36 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_REGEX_H
+#define YAF_ROUTER_REGEX_H
+
+extern zend_class_entry *yaf_route_regex_ce;
+
+yaf_route_t * yaf_route_regex_instance(yaf_route_t *this_ptr, zval *route, zval \
*def, zval *map, zval *verify TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_regex);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_rewrite.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_rewrite.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_rewrite.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,360 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: rewrite.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "ext/standard/php_smart_str.h" /* for smart_str */
+#include "ext/pcre/php_pcre.h" /* for pcre */
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_request.h"
+
+#include "yaf_router.h"
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_rewrite.h"
+
+zend_class_entry *yaf_route_rewrite_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_rewrite_construct_arginfo, 0, 0, 2)
+	ZEND_ARG_INFO(0, match)
+    ZEND_ARG_ARRAY_INFO(0, route, 0)
+    ZEND_ARG_ARRAY_INFO(0, verify, 1)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/** {{{ yaf_route_t * yaf_route_rewrite_instance(yaf_route_t *this_ptr, zval *match, \
zval *router, zval *verify TSRMLS_DC) + */
+yaf_route_t * yaf_route_rewrite_instance(yaf_route_t *this_ptr, zval *match, zval \
*route, zval *verify TSRMLS_DC) { +	yaf_route_t	*instance;
+
+	if (this_ptr) {
+		instance = this_ptr;
+	} else {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_route_rewrite_ce);
+	}
+
+	zend_update_property(yaf_route_rewrite_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH), match TSRMLS_CC); \
+	zend_update_property(yaf_route_rewrite_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE), route TSRMLS_CC); +
+	if (!verify) {
+		zend_update_property_null(yaf_route_rewrite_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY) TSRMLS_CC); +	} else {
+		zend_update_property(yaf_route_rewrite_ce, instance, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY), verify TSRMLS_CC); +	}
+
+	return instance;
+}
+/* }}} */
+
+/** {{{ static zval * yaf_route_rewrite_match(yaf_route_t *router, char *uir, int \
len TSRMLS_DC) + */
+static zval * yaf_route_rewrite_match(yaf_route_t *router, char *uir, int len \
TSRMLS_DC) { +	char *seg, *pmatch, *ptrptr;
+	int  seg_len;
+	zval *match;
+	pcre_cache_entry *pce_regexp;
+	smart_str pattern = {0};
+
+	if (!len) {
+		return NULL;
+	}
+
+	match  = zend_read_property(yaf_route_rewrite_ce, router, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH), 1 TSRMLS_CC); +	pmatch = \
estrndup(Z_STRVAL_P(match), Z_STRLEN_P(match)); +
+	smart_str_appendc(&pattern, YAF_ROUTE_REGEX_DILIMITER);
+	smart_str_appendc(&pattern, '^');
+
+	seg = php_strtok_r(pmatch, YAF_ROUTER_URL_DELIMIETER, &ptrptr);
+	while (seg) {
+		seg_len = strlen(seg);
+		if (seg_len) {
+			smart_str_appendl(&pattern, YAF_ROUTER_URL_DELIMIETER, 1);
+
+			if(*(seg) == '*') {
+				smart_str_appendl(&pattern, "(?P<__yaf_route_rest>.*)", \
sizeof("(?P<__yaf_route_rest>.*)") -1); +				break;
+			}
+
+			if(*(seg) == ':') {
+				smart_str_appendl(&pattern, "(?P<", sizeof("(?P<") -1 );
+				smart_str_appendl(&pattern, seg + 1, seg_len - 1);
+				smart_str_appendl(&pattern, ">[^"YAF_ROUTER_URL_DELIMIETER"]+)", \
sizeof(">[^"YAF_ROUTER_URL_DELIMIETER"]+)") - 1); +			} else {
+				smart_str_appendl(&pattern, seg, seg_len);
+			}
+
+		}
+		seg = php_strtok_r(NULL, YAF_ROUTER_URL_DELIMIETER, &ptrptr);
+	}
+
+	efree(pmatch);
+	smart_str_appendc(&pattern, YAF_ROUTE_REGEX_DILIMITER);
+	smart_str_appendc(&pattern, 'i');
+	smart_str_0(&pattern);
+
+	if ((pce_regexp = pcre_get_compiled_regex_cache(pattern.c, pattern.len TSRMLS_CC)) \
== NULL) { +		smart_str_free(&pattern);
+		return NULL;
+	} else {
+		zval *matches, *subparts;
+
+		smart_str_free(&pattern);
+
+		MAKE_STD_ZVAL(matches);
+		MAKE_STD_ZVAL(subparts);
+		ZVAL_LONG(matches, 0);
+		ZVAL_NULL(subparts);
+
+		php_pcre_match_impl(pce_regexp, uir, len, matches, subparts /* subpats */,
+				0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* \
start_offset */ TSRMLS_CC); +
+		if (!Z_LVAL_P(matches)) {
+			zval_ptr_dtor(&matches);
+			zval_ptr_dtor(&subparts);
+			return NULL;
+		} else {
+			zval *ret, **ppzval;
+			char *key;
+			uint len = 0;
+			ulong idx = 0;
+			HashTable *ht;
+
+			MAKE_STD_ZVAL(ret);
+			array_init(ret);
+
+			ht = Z_ARRVAL_P(subparts);
+			for(zend_hash_internal_pointer_reset(ht);
+					zend_hash_has_more_elements(ht) == SUCCESS;
+					zend_hash_move_forward(ht)) {
+
+				if (zend_hash_get_current_key_type(ht) != HASH_KEY_IS_STRING) {
+					continue;
+				}
+
+				zend_hash_get_current_key_ex(ht, &key, &len, &idx, 0, NULL);
+				if (zend_hash_get_current_data(ht, (void**)&ppzval) == FAILURE) {
+					continue;
+				}
+
+				if (!strncmp(key, "__yaf_route_rest", len)) {
+					zval *args = yaf_router_parse_parameters(Z_STRVAL_PP(ppzval) TSRMLS_CC);
+					if (args) {
+						zend_hash_copy(Z_ARRVAL_P(ret), Z_ARRVAL_P(args), (copy_ctor_func_t) \
zval_add_ref, NULL, sizeof(zval *)); +						zval_ptr_dtor(&args);
+					}
+				} else {
+					Z_ADDREF_P(*ppzval);
+					zend_hash_update(Z_ARRVAL_P(ret), key, len, (void **)ppzval, sizeof(zval *), \
NULL); +				}
+			}
+
+			zval_ptr_dtor(&matches);
+			zval_ptr_dtor(&subparts);
+			return ret;
+		}
+	}
+
+	return NULL;
+}
+/* }}} */
+
+/** {{{ int yaf_route_rewrite_route(yaf_route_t *router, yaf_request_t *request \
TSRMLS_DC) + */
+int yaf_route_rewrite_route(yaf_route_t *router, yaf_request_t *request TSRMLS_DC) {
+	char *request_uri;
+	zval *args, *base_uri, *zuri;
+
+	zuri 	 = zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_URI), 1 TSRMLS_CC); +	base_uri = \
zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_BASE), 1 TSRMLS_CC); +
+	if (base_uri && IS_STRING == Z_TYPE_P(base_uri)
+			&& !strncasecmp(Z_STRVAL_P(zuri), Z_STRVAL_P(base_uri), Z_STRLEN_P(base_uri))) {
+		request_uri  = estrdup(Z_STRVAL_P(zuri) + Z_STRLEN_P(base_uri));
+	} else {
+		request_uri  = estrdup(Z_STRVAL_P(zuri));
+	}
+
+	if (!(args = yaf_route_rewrite_match(router, request_uri, strlen(request_uri) \
TSRMLS_CC))) { +		efree(request_uri);
+		return 0;
+	} else {
+		zval **module, **controller, **action, *routes;
+
+		routes = zend_read_property(yaf_route_rewrite_ce, router, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE), 1 TSRMLS_CC); +		if \
(zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("module"), (void **)&module) == SUCCESS \
&& IS_STRING == Z_TYPE_PP(module)) { +			if (Z_STRVAL_PP(module)[0] != ':') {
+				zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), *module TSRMLS_CC); +			} else {
+				zval **m;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(module) + 1, \
Z_STRLEN_PP(module), (void **)&m) == SUCCESS && IS_STRING == Z_TYPE_PP(m)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), *m TSRMLS_CC); +				}
+			}
+		}
+
+		if (zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("controller"), (void \
**)&controller) == SUCCESS && IS_STRING == Z_TYPE_PP(controller)) { +			if \
(Z_STRVAL_PP(controller)[0] != ':') { +				zend_update_property(yaf_request_ce, \
request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), *controller TSRMLS_CC); \
+			} else { +				zval **c;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(controller) + 1, \
Z_STRLEN_PP(controller), (void **)&c) == SUCCESS && IS_STRING == Z_TYPE_PP(c)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), *c TSRMLS_CC); +				}
+			}
+		}
+
+		if (zend_hash_find(Z_ARRVAL_P(routes), ZEND_STRS("action"), (void **)&action) == \
SUCCESS && IS_STRING == Z_TYPE_PP(action)) { +			if (Z_STRVAL_PP(action)[0] != ':') {
+				zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), *action TSRMLS_CC); +			} else {
+				zval **a;
+				if (zend_hash_find(Z_ARRVAL_P(args), Z_STRVAL_PP(action) + 1, \
Z_STRLEN_PP(action), (void **)&a) == SUCCESS && IS_STRING == Z_TYPE_PP(a)) { \
+					zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), *a TSRMLS_CC); +				}
+			}
+		}
+
+		(void)yaf_request_set_params_multi(request, args TSRMLS_CC);
+		zval_ptr_dtor(&args);
+		efree(request_uri);
+		return 1;
+	}
+
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Rewrite::route(Yaf_Request_Abstarct $request)
+ */
+PHP_METHOD(yaf_route_rewrite, route) {
+	yaf_route_t 	*route;
+	yaf_request_t 	*request;
+
+	route = getThis();
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	}
+
+	if (!request || IS_OBJECT != Z_TYPE_P(request)
+			|| !instanceof_function(Z_OBJCE_P(request), yaf_request_ce TSRMLS_CC)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expect a %s instance", \
yaf_request_ce->name); +		RETURN_FALSE;
+	}
+
+	RETURN_BOOL(yaf_route_rewrite_route(route, request TSRMLS_CC));
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Route_Rewrite::match(string $uri)
+ */
+PHP_METHOD(yaf_route_rewrite, match) {
+	char *uri;
+	uint len;
+	zval *matches;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &len) == FAILURE) {
+		WRONG_PARAM_COUNT;
+	}
+
+	if (!len) RETURN_FALSE;
+
+	if ((matches = yaf_route_rewrite_match(getThis(), uri, len TSRMLS_CC))) {
+		RETURN_ZVAL(matches, 0, 0);
+	}
+
+	RETURN_FALSE;
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Route_Rewrite::__construct(string $match, array $route, \
array $verify = NULL) + */
+PHP_METHOD(yaf_route_rewrite, __construct) {
+	zval 		*match, *route, *verify = NULL;
+	yaf_route_t	*self = getThis();
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za|a", &match, &route, \
&verify) ==  FAILURE) { +		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	if (IS_STRING != Z_TYPE_P(match) || !Z_STRLEN_P(match)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects a valid string as the \
first parameter", yaf_route_rewrite_ce->name); +		RETURN_FALSE;
+	}
+
+	if (verify && IS_ARRAY != Z_TYPE_P(verify)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects an array as third \
parameter",  yaf_route_rewrite_ce->name); +		RETURN_FALSE;
+	}
+
+	(void)yaf_route_rewrite_instance(self, match, route, verify TSRMLS_CC);
+
+	if (self) {
+		RETURN_ZVAL(self, 1, 0);
+	}
+
+	RETURN_FALSE;
+}
+/** }}} */
+
+/** {{{ yaf_route_rewrite_methods
+ */
+zend_function_entry yaf_route_rewrite_methods[] = {
+	PHP_ME(yaf_route_rewrite, __construct, yaf_route_rewrite_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	PHP_ME(yaf_route_rewrite, route, \
yaf_route_route_arginfo, ZEND_ACC_PUBLIC) +    {NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route_rewrite) {
+	zend_class_entry ce;
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Rewrite", "Yaf\\Route\\Rewrite", \
yaf_route_rewrite_methods); +	yaf_route_rewrite_ce = \
zend_register_internal_class_ex(&ce, yaf_route_ce, NULL TSRMLS_CC); \
+	zend_class_implements(yaf_route_rewrite_ce TSRMLS_CC, 1, yaf_route_ce); \
+	yaf_route_rewrite_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; +
+	zend_declare_property_null(yaf_route_rewrite_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_MATCH),  ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_rewrite_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_ROUTE),  ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_rewrite_ce, \
ZEND_STRL(YAF_ROUTE_PROPETY_NAME_VERIFY), ZEND_ACC_PROTECTED TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/routes/yaf_route_rewrite.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_rewrite.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_rewrite.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,36 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_REWRITE_H
+#define YAF_ROUTER_REWRITE_H
+
+extern zend_class_entry *yaf_route_rewrite_ce;
+
+yaf_route_t * yaf_route_rewrite_instance(yaf_route_t *this_ptr, zval *match, zval \
*router, zval *verify TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_rewrite);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_simple.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_simple.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_simple.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,166 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: simple.c 329200 2013-01-18 06:26:40Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_application.h" /* for yaf_application_is_module_name */
+#include "yaf_request.h"
+#include "yaf_router.h"
+
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_simple.h"
+
+zend_class_entry *yaf_route_simple_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_simple_construct_arginfo, 0, 0, 3)
+	ZEND_ARG_INFO(0, module_name)
+    ZEND_ARG_INFO(0, controller_name)
+    ZEND_ARG_INFO(0, action_name)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/** {{{ int yaf_route_simple_route(yaf_route_t *route, yaf_request_t *request \
TSRMLS_DC) + */
+int yaf_route_simple_route(yaf_route_t *route, yaf_request_t *request TSRMLS_DC) {
+	zval *module, *controller, *action;
+	zval *nmodule, *ncontroller, *naction;
+
+	nmodule 	= zend_read_property(yaf_route_simple_ce, route, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), 1 TSRMLS_CC); +	ncontroller = \
zend_read_property(yaf_route_simple_ce, route, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), 1 TSRMLS_CC); +	naction 	= \
zend_read_property(yaf_route_simple_ce, route, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), 1 TSRMLS_CC); +
+	/* if there is no expect parameter in supervars, then null will be return */
+	module 		= yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STRVAL_P(nmodule), \
Z_STRLEN_P(nmodule) TSRMLS_CC); +	controller 	= \
yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STRVAL_P(ncontroller), \
Z_STRLEN_P(ncontroller) TSRMLS_CC); +	action 		= \
yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STRVAL_P(naction), Z_STRLEN_P(naction) \
TSRMLS_CC); +
+	if (ZVAL_IS_NULL(module) && ZVAL_IS_NULL(controller) && ZVAL_IS_NULL(action)) {
+		return 0;
+	}
+
+	if (Z_TYPE_P(module) == IS_STRING && \
yaf_application_is_module_name(Z_STRVAL_P(module), Z_STRLEN_P(module) TSRMLS_CC)) { \
+		zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), module TSRMLS_CC); +	}
+
+	zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), controller TSRMLS_CC); \
+	zend_update_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), action TSRMLS_CC); +
+	return 1;
+}
+/* }}} */
+
+/** {{{ yaf_route_t * yaf_route_simple_instance(yaf_route_t *this_ptr, zval *module, \
zval *controller, zval *action TSRMLS_DC) + */
+yaf_route_t * yaf_route_simple_instance(yaf_route_t *this_ptr, zval *module, zval \
*controller, zval *action TSRMLS_DC) { +	yaf_route_t *instance;
+
+	if (this_ptr) {
+		instance  = this_ptr;
+	} else {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_route_simple_ce);
+	}
+
+	zend_update_property(yaf_route_simple_ce, instance, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), module TSRMLS_CC); \
+	zend_update_property(yaf_route_simple_ce, instance, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), controller TSRMLS_CC); \
+	zend_update_property(yaf_route_simple_ce, instance, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), action TSRMLS_CC); +
+	return instance;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Simple::route(Yaf_Request $req)
+*/
+PHP_METHOD(yaf_route_simple, route) {
+	yaf_request_t *request;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	} else {
+		RETURN_BOOL(yaf_route_simple_route(getThis(), request TSRMLS_CC));
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Simple::__construct(string $module, string \
$controller, string $action) + */
+PHP_METHOD(yaf_route_simple, __construct) {
+	zval *module, *controller, *action;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &module, &controller, \
&action) == FAILURE) { +		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	if (IS_STRING != Z_TYPE_P(module)
+			|| IS_STRING != Z_TYPE_P(controller)
+			|| IS_STRING != Z_TYPE_P(action)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expect 3 string paramsters", \
yaf_route_simple_ce->name); +		RETURN_FALSE;
+	} else {
+		(void)yaf_route_simple_instance(getThis(), module, controller, action TSRMLS_CC);
+	}
+}
+/* }}} */
+
+/** {{{ yaf_route_simple_methods
+ */
+zend_function_entry yaf_route_simple_methods[] = {
+	PHP_ME(yaf_route_simple, __construct, yaf_route_simple_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	PHP_ME(yaf_route_simple, route, \
yaf_route_route_arginfo, ZEND_ACC_PUBLIC) +	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route_simple) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Simple", "Yaf\\Route\\Simple", \
yaf_route_simple_methods); +	yaf_route_simple_ce = \
zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); \
+	zend_class_implements(yaf_route_simple_ce TSRMLS_CC, 1, yaf_route_ce); +
+	yaf_route_simple_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+	zend_declare_property_null(yaf_route_simple_ce, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_simple_ce, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_route_simple_ce, \
ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), ZEND_ACC_PROTECTED TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_simple.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_simple.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_simple.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,40 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_SIMPLE_H
+#define YAF_ROUTER_SIMPLE_H
+
+#define YAF_ROUTE_SIMPLE_VAR_NAME_MODULE		"module"
+#define	YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER 	"controller"
+#define YAF_ROUTE_SIMPLE_VAR_NAME_ACTION		"action"
+
+extern zend_class_entry *yaf_route_simple_ce;
+
+yaf_route_t * yaf_route_simple_instance(yaf_route_t *this_ptr, zval *module, zval \
*controller, zval *action TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_simple);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_static.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_static.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_static.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,231 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+ */
+
+/* $Id: static.c 329200 2013-01-18 06:26:40Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_application.h" /* for yaf_application_is_module_name */
+#include "yaf_request.h"
+
+#include "yaf_router.h"
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_static.h"
+
+zend_class_entry * yaf_route_static_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_static_match_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, uri)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+int yaf_route_pathinfo_route(yaf_request_t *request, char *req_uri, int req_uri_len \
TSRMLS_DC) /* {{{ */ { +	zval *params;
+	char *module = NULL, *controller = NULL, *action = NULL, *rest = NULL;
+
+	do {
+#define strip_slashs(p) while (*p == ' ' || *p == '/') { ++p; }
+		char *s, *p;
+		char *uri;
+
+		if (req_uri_len == 0
+				|| (req_uri_len == 1 && *req_uri == '/')) {
+			break;
+		}
+
+		uri = req_uri;
+		s = p = uri;
+
+		if (req_uri_len) {
+			char *q = req_uri + req_uri_len - 1;
+			while (q > req_uri && (*q == ' ' || *q == '/')) {
+				*q-- = '\0';
+			}
+		}
+
+		strip_slashs(p);
+
+		if ((s = strstr(p, "/")) != NULL) {
+			if (yaf_application_is_module_name(p, s-p TSRMLS_CC)) {
+				module = estrndup(p, s - p);
+				p  = s + 1;
+		        strip_slashs(p);
+				if ((s = strstr(p, "/")) != NULL) {
+					controller = estrndup(p, s - p);
+					p  = s + 1;
+				}
+			} else {
+				controller = estrndup(p, s - p);
+				p  = s + 1;
+			}
+		}
+
+		strip_slashs(p);
+		if ((s = strstr(p, "/")) != NULL) {
+			action = estrndup(p, s - p);
+			p  = s + 1;
+		}
+
+		strip_slashs(p);
+		if (*p != '\0') {
+			do {
+				if (!module && !controller && !action) {
+					if (yaf_application_is_module_name(p, strlen(p) TSRMLS_CC)) {
+						module = estrdup(p);
+						break;
+					}
+				}
+
+				if (!controller) {
+					controller = estrdup(p);
+					break;
+				}
+
+				if (!action) {
+					action = estrdup(p);
+					break;
+				}
+
+				rest = estrdup(p);
+			} while (0);
+		}
+
+		if (module && controller == NULL) {
+			controller = module;
+			module = NULL;
+		} else if (module && action == NULL) {
+			action = controller;
+			controller = module;
+			module = NULL;
+	    } else if (controller && action == NULL ) {
+			/* /controller */
+			if (YAF_G(action_prefer)) {
+				action = controller;
+				controller = NULL;
+			}
+		}
+	} while (0);
+
+	if (module != NULL) {
+		zend_update_property_string(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), module TSRMLS_CC); +		efree(module);
+	}
+	if (controller != NULL) {
+		zend_update_property_string(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), controller TSRMLS_CC); \
+		efree(controller); +	}
+
+	if (action != NULL) {
+		zend_update_property_string(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), action TSRMLS_CC); +		efree(action);
+	}
+
+	if (rest) {
+		params = yaf_router_parse_parameters(rest TSRMLS_CC);
+		(void)yaf_request_set_params_multi(request, params TSRMLS_CC);
+		zval_ptr_dtor(&params);
+		efree(rest);
+	}
+
+	return 1;
+}
+/* }}} */
+
+/** {{{ int yaf_route_static_route(yaf_route_t *route, yaf_request_t *request \
TSRMLS_DC) + */
+int yaf_route_static_route(yaf_route_t *route, yaf_request_t *request TSRMLS_DC) {
+	zval *zuri, *base_uri;
+	char *req_uri;
+	int  req_uri_len;
+
+	zuri 	 = zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_URI), 1 TSRMLS_CC); +	base_uri = \
zend_read_property(yaf_request_ce, request, \
ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_BASE), 1 TSRMLS_CC); +
+	if (base_uri && IS_STRING == Z_TYPE_P(base_uri)
+			&& !strncasecmp(Z_STRVAL_P(zuri), Z_STRVAL_P(base_uri), Z_STRLEN_P(base_uri))) {
+		req_uri  = estrdup(Z_STRVAL_P(zuri) + Z_STRLEN_P(base_uri));
+		req_uri_len = Z_STRLEN_P(zuri) - Z_STRLEN_P(base_uri);
+	} else {
+		req_uri  = estrdup(Z_STRVAL_P(zuri));
+		req_uri_len = Z_STRLEN_P(zuri);
+	}
+
+	yaf_route_pathinfo_route(request, req_uri, req_uri_len TSRMLS_CC);
+	efree(req_uri);
+	return 1;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Router_Static::route(Yaf_Request $req)
+*/
+PHP_METHOD(yaf_route_static, route) {
+	yaf_request_t *request;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	} else {
+		RETURN_BOOL(yaf_route_static_route(getThis(), request TSRMLS_CC));
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Router_Static::match(string $uri)
+*/
+PHP_METHOD(yaf_route_static, match) {
+	RETURN_TRUE;
+}
+/* }}} */
+
+/** {{{ yaf_route_static_methods
+ */
+zend_function_entry yaf_route_static_methods[] = {
+	PHP_ME(yaf_route_static, match, yaf_route_static_match_arginfo, ZEND_ACC_PUBLIC)
+	PHP_ME(yaf_route_static, route, yaf_route_route_arginfo, 		ZEND_ACC_PUBLIC)
+	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route_static) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Static", "Yaf\\Route_Static", \
yaf_route_static_methods); +	yaf_route_static_ce = \
zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); \
+	zend_class_implements(yaf_route_static_ce TSRMLS_CC, 1, yaf_route_ce); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/routes/yaf_route_static.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_static.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_static.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,36 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_STATIC_H
+#define YAF_ROUTER_STATIC_H
+
+extern zend_class_entry *yaf_route_static_ce;
+
+int yaf_route_pathinfo_route(yaf_request_t *request, char *req_uri, int req_uri_len \
TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_static);
+
+#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
+ */

Added: pecl/yaf/trunk/routes/yaf_route_supervar.c
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_supervar.c	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_supervar.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,152 @@
+ /*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: supervar.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_request.h"
+
+#include "yaf_router.h"
+#include "routes/yaf_route_interface.h"
+#include "routes/yaf_route_static.h" /* for yaf_route_pathinfo_route */
+#include "routes/yaf_route_supervar.h"
+
+zend_class_entry *yaf_route_supervar_ce;
+
+/** {{{ ARG_INFO
+ */
+ZEND_BEGIN_ARG_INFO_EX(yaf_route_supervar_construct_arginfo, 0, 0, 1)
+    ZEND_ARG_INFO(0, supervar_name)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/** {{{ int yaf_route_supervar_route(yaf_route_t *route, yaf_request_t *request \
TSRMLS_DC) + */
+int yaf_route_supervar_route(yaf_route_t *route, yaf_request_t *request TSRMLS_DC) {
+	zval *varname, *zuri;
+	char *req_uri;
+
+	varname = zend_read_property(yaf_route_supervar_ce, route, \
ZEND_STRL(YAF_ROUTE_SUPERVAR_PROPETY_NAME_VAR), 1 TSRMLS_CC); +
+	zuri = yaf_request_query(YAF_GLOBAL_VARS_GET, Z_STRVAL_P(varname), \
Z_STRLEN_P(varname) TSRMLS_CC); +
+	if (!zuri || ZVAL_IS_NULL(zuri)) {
+		return 0;
+	}
+
+	req_uri = estrndup(Z_STRVAL_P(zuri), Z_STRLEN_P(zuri));
+    yaf_route_pathinfo_route(request, req_uri, Z_STRLEN_P(zuri) TSRMLS_CC);
+	efree(req_uri);
+	return 1;
+}
+/* }}} */
+
+/** {{{ yaf_route_t * yaf_route_supervar_instance(yaf_route_t *this_ptr, zval *name \
TSRMLS_DC) + */
+yaf_route_t * yaf_route_supervar_instance(yaf_route_t *this_ptr, zval *name \
TSRMLS_DC) { +	yaf_route_t *instance;
+
+	if (!name || IS_STRING != Z_TYPE_P(name) || !Z_STRLEN_P(name)) {
+		return NULL;
+	}
+
+	if (this_ptr) {
+		instance  = this_ptr;
+	} else {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_route_supervar_ce);
+	}
+
+	zend_update_property(yaf_route_supervar_ce, instance, \
ZEND_STRL(YAF_ROUTE_SUPERVAR_PROPETY_NAME_VAR), name TSRMLS_CC); +
+	return instance;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_Route_Supervar::route(Yaf_Request_Abstarct $request)
+ */
+PHP_METHOD(yaf_route_supervar, route) {
+	yaf_request_t *request;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, yaf_request_ce) \
== FAILURE) { +		return;
+	} else {
+		RETURN_BOOL(yaf_route_supervar_route(getThis(), request TSRMLS_CC));
+	}
+}
+/** }}} */
+
+/** {{{ proto public Yaf_Route_Supervar::__construct(string $varname)
+ */
+PHP_METHOD(yaf_route_supervar, __construct) {
+	zval *var;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &var) ==   FAILURE) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	if (Z_TYPE_P(var) != IS_STRING || !Z_STRLEN_P(var)) {
+		YAF_UNINITIALIZED_OBJECT(getThis());
+		yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects a valid string super var \
name", yaf_route_supervar_ce->name); +		RETURN_FALSE;
+	}
+
+	zend_update_property(yaf_route_supervar_ce, getThis(), \
ZEND_STRL(YAF_ROUTE_SUPERVAR_PROPETY_NAME_VAR), var TSRMLS_CC); +}
+/** }}} */
+
+/** {{{ yaf_route_supervar_methods
+ */
+zend_function_entry yaf_route_supervar_methods[] = {
+	PHP_ME(yaf_route_supervar, __construct, yaf_route_supervar_construct_arginfo, \
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) +	PHP_ME(yaf_route_supervar, route, \
yaf_route_route_arginfo, ZEND_ACC_PUBLIC) +    {NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(route_supervar) {
+	zend_class_entry ce;
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_Route_Supervar", "Yaf\\Route\\Supervar", \
yaf_route_supervar_methods); +	yaf_route_supervar_ce = \
zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); \
+	zend_class_implements(yaf_route_supervar_ce TSRMLS_CC, 1, yaf_route_ce); \
+	yaf_route_supervar_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; +
+	zend_declare_property_null(yaf_route_supervar_ce, \
ZEND_STRL(YAF_ROUTE_SUPERVAR_PROPETY_NAME_VAR),  ZEND_ACC_PROTECTED TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/routes/yaf_route_supervar.h
===================================================================
--- pecl/yaf/trunk/routes/yaf_route_supervar.h	                        (rev 0)
+++ pecl/yaf/trunk/routes/yaf_route_supervar.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,38 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_router.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_ROUTER_SUPERVAR_H
+#define YAF_ROUTER_SUPERVAR_H
+
+#define YAF_ROUTE_SUPERVAR_PROPETY_NAME_VAR "_var_name"
+
+extern zend_class_entry *yaf_route_supervar_ce;
+
+yaf_route_t * yaf_route_supervar_instance(yaf_route_t *this_ptr, zval *name \
TSRMLS_DC); +
+YAF_STARTUP_FUNCTION(route_supervar);
+
+#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
+ */

Added: pecl/yaf/trunk/views/yaf_view_interface.c
===================================================================
--- pecl/yaf/trunk/views/yaf_view_interface.c	                        (rev 0)
+++ pecl/yaf/trunk/views/yaf_view_interface.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,66 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: interface.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_loader.h"
+#include "yaf_view.h"
+
+#include "views/yaf_view_interface.h"
+
+zend_class_entry *yaf_view_interface_ce;
+
+/** {{{ yaf_view_interface_methods
+ */
+zend_function_entry yaf_view_interface_methods[] = {
+	ZEND_ABSTRACT_ME(yaf_view, assign,  yaf_view_assign_arginfo)
+	ZEND_ABSTRACT_ME(yaf_view, display, yaf_view_display_arginfo)
+	ZEND_ABSTRACT_ME(yaf_view, render, yaf_view_render_arginfo)
+	ZEND_ABSTRACT_ME(yaf_view, setScriptPath, yaf_view_setpath_arginfo)
+	ZEND_ABSTRACT_ME(yaf_view, getScriptPath, yaf_view_getpath_arginfo)
+	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+ */
+YAF_STARTUP_FUNCTION(view_interface) {
+	zend_class_entry ce;
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_View_Interface", "Yaf\\View_Interface", \
yaf_view_interface_methods); +	yaf_view_interface_ce = \
zend_register_internal_interface(&ce TSRMLS_CC); +
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/views/yaf_view_interface.h
===================================================================
--- pecl/yaf/trunk/views/yaf_view_interface.h	                        (rev 0)
+++ pecl/yaf/trunk/views/yaf_view_interface.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,56 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_view.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_VIEW_INTERFACE_H
+#define YAF_VIEW_INTERFACE_H
+
+YAF_BEGIN_ARG_INFO_EX(yaf_view_assign_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+	ZEND_ARG_INFO(0, value)
+YAF_END_ARG_INFO()
+
+YAF_BEGIN_ARG_INFO_EX(yaf_view_display_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, tpl)
+	ZEND_ARG_INFO(0, tpl_vars)
+YAF_END_ARG_INFO()
+
+YAF_BEGIN_ARG_INFO_EX(yaf_view_render_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, tpl)
+	ZEND_ARG_INFO(0, tpl_vars)
+YAF_END_ARG_INFO()
+
+YAF_BEGIN_ARG_INFO_EX(yaf_view_setpath_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, template_dir)
+YAF_END_ARG_INFO()
+
+YAF_BEGIN_ARG_INFO_EX(yaf_view_getpath_arginfo, 0, 0, 0)
+YAF_END_ARG_INFO()
+
+extern zend_class_entry *yaf_view_interface_ce;
+
+YAF_STARTUP_FUNCTION(view_interface);
+
+#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
+ */

Added: pecl/yaf/trunk/views/yaf_view_simple.c
===================================================================
--- pecl/yaf/trunk/views/yaf_view_simple.c	                        (rev 0)
+++ pecl/yaf/trunk/views/yaf_view_simple.c	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,951 @@
+/*
+   +----------------------------------------------------------------------+
+   | Yet Another Framework                                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+   +----------------------------------------------------------------------+
+*/
+
+/* $Id: simple.c 329197 2013-01-18 05:55:37Z laruence $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "main/php_output.h"
+
+#include "php_yaf.h"
+#include "yaf_namespace.h"
+#include "yaf_exception.h"
+#include "yaf_loader.h"
+#include "yaf_view.h"
+
+#include "views/yaf_view_interface.h"
+#include "views/yaf_view_simple.h"
+
+zend_class_entry *yaf_view_simple_ce;
+
+/** {{{ ARG_INFO */
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_construct_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, tempalte_dir)
+	ZEND_ARG_ARRAY_INFO(0, options, 1)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_get_arginfo, 0, 0, 0)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_isset_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_assign_by_ref_arginfo, 0, 0, 2)
+	ZEND_ARG_INFO(0, name)
+	ZEND_ARG_INFO(1, value)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_eval_arginfo, 0, 0, 1)
+	ZEND_ARG_INFO(0, tpl_str)
+	ZEND_ARG_INFO(0, vars)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(yaf_view_simple_clear_arginfo, 0, 0, 0)
+	ZEND_ARG_INFO(0, name)
+ZEND_END_ARG_INFO();
+/* }}} */
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+/** {{{ static int yaf_view_simple_render_write(const char *str, uint str_length \
TSRMLS_DC) +*/
+static int yaf_view_simple_render_write(const char *str, uint str_length TSRMLS_DC) \
{ +	char *target;
+	yaf_view_simple_buffer *buffer = YAF_G(buffer);
+
+	if (!buffer->size) {
+		buffer->size   = (str_length | VIEW_BUFFER_SIZE_MASK) + 1;
+		buffer->len	   = str_length;
+		buffer->buffer = emalloc(buffer->size);
+		target = buffer->buffer;
+	} else {
+		size_t len = buffer->len + str_length;
+
+		if (buffer->size < len + 1) {
+			buffer->size   = (len | VIEW_BUFFER_SIZE_MASK) + 1;
+			buffer->buffer = erealloc(buffer->buffer, buffer->size);
+			if (!buffer->buffer) {
+				php_error_docref(NULL TSRMLS_CC, E_ERROR, "Yaf output buffer collapsed");
+			}
+		}
+
+		target = buffer->buffer + buffer->len;
+		buffer->len = len;
+	}
+
+	memcpy(target, str, str_length);
+	target[str_length] = '\0';
+
+	return str_length;
+}
+/* }}} */
+#endif
+
+static int yaf_view_simple_valid_var_name(char *var_name, int len) /* {{{ */
+{
+	int i, ch;
+
+	if (!var_name)
+		return 0;
+
+	/* These are allowed as first char: [a-zA-Z_\x7f-\xff] */
+	ch = (int)((unsigned char *)var_name)[0];
+	if (var_name[0] != '_' &&
+			(ch < 65  /* A    */ || /* Z    */ ch > 90)  &&
+			(ch < 97  /* a    */ || /* z    */ ch > 122) &&
+			(ch < 127 /* 0x7f */ || /* 0xff */ ch > 255)
+	   ) {
+		return 0;
+	}
+
+	/* And these as the rest: [a-zA-Z0-9_\x7f-\xff] */
+	if (len > 1) {
+		for (i = 1; i < len; i++) {
+			ch = (int)((unsigned char *)var_name)[i];
+			if (var_name[i] != '_' &&
+					(ch < 48  /* 0    */ || /* 9    */ ch > 57)  &&
+					(ch < 65  /* A    */ || /* Z    */ ch > 90)  &&
+					(ch < 97  /* a    */ || /* z    */ ch > 122) &&
+					(ch < 127 /* 0x7f */ || /* 0xff */ ch > 255)
+			   ) {
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+/* }}} */
+
+/** {{{ static int yaf_view_simple_extract(zval *tpl_vars, zval *vars TSRMLS_DC)
+*/
+static int yaf_view_simple_extract(zval *tpl_vars, zval *vars TSRMLS_DC) {
+	zval **entry;
+	char *var_name;
+	ulong num_key;
+	uint var_name_len;
+	HashPosition pos;
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2)) || (PHP_MAJOR_VERSION > 5)
+	if (!EG(active_symbol_table)) {
+		/*zend_rebuild_symbol_table(TSRMLS_C);*/
+		return 1;
+	}
+#endif
+
+	if (tpl_vars && Z_TYPE_P(tpl_vars) == IS_ARRAY) {
+		for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(tpl_vars), &pos);
+				zend_hash_get_current_data_ex(Z_ARRVAL_P(tpl_vars), (void **)&entry, &pos) == \
SUCCESS; +				zend_hash_move_forward_ex(Z_ARRVAL_P(tpl_vars), &pos)) {
+			if (zend_hash_get_current_key_ex(Z_ARRVAL_P(tpl_vars), &var_name, &var_name_len, \
&num_key, 0, &pos) != HASH_KEY_IS_STRING) { +				continue;
+			}
+
+			/* GLOBALS protection */
+			if (var_name_len == sizeof("GLOBALS") && !strcmp(var_name, "GLOBALS")) {
+				continue;
+			}
+
+			if (var_name_len == sizeof("this")  && !strcmp(var_name, "this") && EG(scope) && \
EG(scope)->name_length != 0) { +				continue;
+			}
+
+
+			if (yaf_view_simple_valid_var_name(var_name, var_name_len - 1)) {
+				ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), var_name, var_name_len,
+						*entry, Z_REFCOUNT_P(*entry) + 1, PZVAL_IS_REF(*entry));
+			}
+		}
+	}
+
+	if (vars && Z_TYPE_P(vars) == IS_ARRAY) {
+		for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(vars), &pos);
+				zend_hash_get_current_data_ex(Z_ARRVAL_P(vars), (void **)&entry, &pos) == \
SUCCESS; +				zend_hash_move_forward_ex(Z_ARRVAL_P(vars), &pos)) {
+			if (zend_hash_get_current_key_ex(Z_ARRVAL_P(vars), &var_name, &var_name_len, \
&num_key, 0, &pos) != HASH_KEY_IS_STRING) { +				continue;
+			}
+
+			/* GLOBALS protection */
+			if (var_name_len == sizeof("GLOBALS") && !strcmp(var_name, "GLOBALS")) {
+				continue;
+			}
+
+			if (var_name_len == sizeof("this")  && !strcmp(var_name, "this") && EG(scope) && \
EG(scope)->name_length != 0) { +				continue;
+			}
+
+			if (yaf_view_simple_valid_var_name(var_name, var_name_len - 1)) {
+				ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), var_name, var_name_len,
+						*entry, Z_REFCOUNT_P(*entry) + 1, 0 /**PZVAL_IS_REF(*entry)*/);
+			}
+		}
+	}
+
+	return 1;
+}
+/* }}} */
+
+/** {{{ yaf_view_t * yaf_view_simple_instance(yaf_view_t *view, zval *tpl_dir, zval \
*options TSRMLS_DC) +*/
+yaf_view_t * yaf_view_simple_instance(yaf_view_t *view, zval *tpl_dir, zval *options \
TSRMLS_DC) { +	zval *instance, *tpl_vars;
+
+	instance = view;
+	if (!instance) {
+		MAKE_STD_ZVAL(instance);
+		object_init_ex(instance, yaf_view_simple_ce);
+	}
+
+	MAKE_STD_ZVAL(tpl_vars);
+	array_init(tpl_vars);
+	zend_update_property(yaf_view_simple_ce, instance, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), tpl_vars TSRMLS_CC); \
+	zval_ptr_dtor(&tpl_vars); +
+	if (tpl_dir && Z_TYPE_P(tpl_dir) == IS_STRING) {
+		if (IS_ABSOLUTE_PATH(Z_STRVAL_P(tpl_dir), Z_STRLEN_P(tpl_dir))) {
+			zend_update_property(yaf_view_simple_ce, instance, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR), tpl_dir TSRMLS_CC); +		} else {
+			if (!view) {
+				zval_ptr_dtor(&instance);
+			}
+			yaf_trigger_error(YAF_ERR_TYPE_ERROR TSRMLS_CC, "Expects an absolute path for \
templates directory"); +			return NULL;
+		}
+	}
+
+	if (options && IS_ARRAY == Z_TYPE_P(options)) {
+		zend_update_property(yaf_view_simple_ce, instance, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_OPTS), options TSRMLS_CC); +	}
+
+	return instance;
+}
+/* }}} */
+
+/** {{{ int yaf_view_simple_render(yaf_view_t *view, zval *tpl, zval * vars, zval \
*ret TSRMLS_DC) +*/
+int yaf_view_simple_render(yaf_view_t *view, zval *tpl, zval * vars, zval *ret \
TSRMLS_DC) { +	zval *tpl_vars;
+	char *script;
+	uint len;
+	HashTable *calling_symbol_table;
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	zend_class_entry *old_scope;
+	yaf_view_simple_buffer *buffer;
+	zend_bool short_open_tag;
+#endif
+
+	if (IS_STRING != Z_TYPE_P(tpl)) {
+		return 0;
+	}
+
+	ZVAL_NULL(ret);
+
+	tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC); +	if \
(EG(active_symbol_table)) { +		calling_symbol_table = EG(active_symbol_table);
+	} else {
+		calling_symbol_table = NULL;
+	}
+
+	ALLOC_HASHTABLE(EG(active_symbol_table));
+	zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+
+	(void)yaf_view_simple_extract(tpl_vars, vars TSRMLS_CC);
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	short_open_tag = CG(short_tags);
+	YAF_REDIRECT_OUTPUT_BUFFER(buffer);
+	{
+		zval **short_tag;
+		zval *options = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_OPTS), 0 TSRMLS_CC); +		if (IS_ARRAY != \
Z_TYPE_P(options) +				|| (zend_hash_find(Z_ARRVAL_P(options), \
ZEND_STRS("short_tag"), (void **)&short_tag) == FAILURE) +				|| \
zend_is_true(*short_tag)) { +			CG(short_tags) = 1;
+		}
+	}
+#else
+	if (php_output_start_user(NULL, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC) == \
FAILURE) { +		php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "failed to \
create buffer"); +		return 0;
+	}
+#endif
+
+	if (IS_ABSOLUTE_PATH(Z_STRVAL_P(tpl), Z_STRLEN_P(tpl))) {
+		script 	= Z_STRVAL_P(tpl);
+		len 	= Z_STRLEN_P(tpl);
+
+		if (yaf_loader_import(script, len + 1, 0 TSRMLS_CC) == 0) {
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+			YAF_RESTORE_OUTPUT_BUFFER(buffer);
+			CG(short_tags) = short_open_tag;
+#else
+			php_output_end(TSRMLS_C);
+#endif
+			if (calling_symbol_table) {
+				zend_hash_destroy(EG(active_symbol_table));
+				FREE_HASHTABLE(EG(active_symbol_table));
+				EG(active_symbol_table) = calling_symbol_table;
+			}
+
+			yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC, "Failed opening template %s: \
%s", script, strerror(errno)); +			return 0;
+		}
+	} else {
+		zval *tpl_dir = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR), 0 TSRMLS_CC); +
+		if (IS_STRING != Z_TYPE_P(tpl_dir)) {
+			if (YAF_G(view_directory)) {
+				len = spprintf(&script, 0, "%s%c%s", YAF_G(view_directory), DEFAULT_SLASH, \
Z_STRVAL_P(tpl)); +			} else {
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+				YAF_RESTORE_OUTPUT_BUFFER(buffer);
+				CG(short_tags) = short_open_tag;
+#else
+				php_output_end(TSRMLS_C);
+#endif
+
+				if (calling_symbol_table) {
+					zend_hash_destroy(EG(active_symbol_table));
+					FREE_HASHTABLE(EG(active_symbol_table));
+					EG(active_symbol_table) = calling_symbol_table;
+				}
+
+				yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC,
+						"Could not determine the view script path, you should call %s::setScriptPath \
to specific it", +						yaf_view_simple_ce->name);
+				return 0;
+			}
+		} else {
+			len = spprintf(&script, 0, "%s%c%s", Z_STRVAL_P(tpl_dir), DEFAULT_SLASH, \
Z_STRVAL_P(tpl)); +		}
+
+		if (yaf_loader_import(script, len + 1, 0 TSRMLS_CC) == 0) {
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+			YAF_RESTORE_OUTPUT_BUFFER(buffer);
+			CG(short_tags) = short_open_tag;
+#else
+			php_output_end(TSRMLS_C);
+#endif
+			if (calling_symbol_table) {
+				zend_hash_destroy(EG(active_symbol_table));
+				FREE_HASHTABLE(EG(active_symbol_table));
+				EG(active_symbol_table) = calling_symbol_table;
+			}
+
+			yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC, "Failed opening template %s: \
%s" , script, strerror(errno)); +			efree(script);
+			return 0;
+		}
+		efree(script);
+	}
+
+	if (calling_symbol_table) {
+		zend_hash_destroy(EG(active_symbol_table));
+		FREE_HASHTABLE(EG(active_symbol_table));
+		EG(active_symbol_table) = calling_symbol_table;
+	}
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	CG(short_tags) = short_open_tag;
+	if (buffer->len) {
+		ZVAL_STRINGL(ret, buffer->buffer, buffer->len, 1);
+	}
+#else
+	if (php_output_get_contents(ret TSRMLS_CC) == FAILURE) {
+		php_output_end(TSRMLS_C);
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to fetch ob content");
+		return 0;
+	}
+
+	if (php_output_discard(TSRMLS_C) != SUCCESS ) {
+		return 0;
+	}
+#endif
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	YAF_RESTORE_OUTPUT_BUFFER(buffer);
+#endif
+	return 1;
+}
+/* }}} */
+
+/** {{{ int yaf_view_simple_display(yaf_view_t *view, zval *tpl, zval * vars, zval \
*ret TSRMLS_DC) +*/
+int yaf_view_simple_display(yaf_view_t *view, zval *tpl, zval *vars, zval *ret \
TSRMLS_DC) { +	zval *tpl_vars;
+	char *script;
+	uint len;
+	zend_class_entry *old_scope;
+	HashTable *calling_symbol_table;
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	zend_bool short_open_tag;
+#endif
+
+	if (IS_STRING != Z_TYPE_P(tpl)) {
+		return 0;
+	}
+
+	tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC); +	if \
(EG(active_symbol_table)) { +		calling_symbol_table = EG(active_symbol_table);
+	} else {
+		calling_symbol_table = NULL;
+	}
+
+	ALLOC_HASHTABLE(EG(active_symbol_table));
+	zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+
+	(void)yaf_view_simple_extract(tpl_vars, vars TSRMLS_CC);
+
+	old_scope = EG(scope);
+	EG(scope) = yaf_view_simple_ce;
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	short_open_tag = CG(short_tags);
+	{
+		zval **short_tag;
+		zval *options = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_OPTS), 0 TSRMLS_CC); +		if (IS_ARRAY != \
Z_TYPE_P(options) +				|| (zend_hash_find(Z_ARRVAL_P(options), \
ZEND_STRS("short_tag"), (void **)&short_tag) == FAILURE) +				|| \
zend_is_true(*short_tag)) { +			CG(short_tags) = 1;
+		}
+	}
+#endif
+
+	if (IS_ABSOLUTE_PATH(Z_STRVAL_P(tpl), Z_STRLEN_P(tpl))) {
+		script 	= Z_STRVAL_P(tpl);
+		len 	= Z_STRLEN_P(tpl);
+		if (yaf_loader_import(script, len + 1, 0 TSRMLS_CC) == 0) {
+			yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC, "Failed opening template %s: \
%s" , script, strerror(errno)); +#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION \
< 4)) +			CG(short_tags) = short_open_tag;
+#endif
+			EG(scope) = old_scope;
+			if (calling_symbol_table) {
+				zend_hash_destroy(EG(active_symbol_table));
+				FREE_HASHTABLE(EG(active_symbol_table));
+				EG(active_symbol_table) = calling_symbol_table;
+			}
+			return 0;
+		}
+	} else {
+		zval *tpl_dir = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR), 0 TSRMLS_CC); +
+		if (IS_STRING != Z_TYPE_P(tpl_dir)) {
+			if (YAF_G(view_directory)) {
+				len = spprintf(&script, 0, "%s%c%s", YAF_G(view_directory), DEFAULT_SLASH, \
Z_STRVAL_P(tpl)); +			} else {
+				yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC,
+						"Could not determine the view script path, you should call %s::setScriptPath \
to specific it", yaf_view_simple_ce->name); +#if ((PHP_MAJOR_VERSION == 5) && \
(PHP_MINOR_VERSION < 4)) +				CG(short_tags) = short_open_tag;
+#endif
+				EG(scope) = old_scope;
+				if (calling_symbol_table) {
+					zend_hash_destroy(EG(active_symbol_table));
+					FREE_HASHTABLE(EG(active_symbol_table));
+					EG(active_symbol_table) = calling_symbol_table;
+				}
+				return 0;
+			}
+		} else {
+			len = spprintf(&script, 0, "%s%c%s", Z_STRVAL_P(tpl_dir), DEFAULT_SLASH, \
Z_STRVAL_P(tpl)); +		}
+
+		if (yaf_loader_import(script, len + 1, 0 TSRMLS_CC) == 0) {
+			yaf_trigger_error(YAF_ERR_NOTFOUND_VIEW TSRMLS_CC, "Failed opening template %s: \
%s", script, strerror(errno)); +#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < \
4)) +			CG(short_tags) = short_open_tag;
+#endif
+			efree(script);
+			EG(scope) = old_scope;
+			if (calling_symbol_table) {
+				zend_hash_destroy(EG(active_symbol_table));
+				FREE_HASHTABLE(EG(active_symbol_table));
+				EG(active_symbol_table) = calling_symbol_table;
+			}
+			return 0;
+		}
+		efree(script);
+	}
+
+	EG(scope) = old_scope;
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	CG(short_tags) = short_open_tag;
+#endif
+	if (calling_symbol_table) {
+		zend_hash_destroy(EG(active_symbol_table));
+		FREE_HASHTABLE(EG(active_symbol_table));
+		EG(active_symbol_table) = calling_symbol_table;
+	}
+
+	return 1;
+}
+/* }}} */
+
+/** {{{ int yaf_view_simple_eval(yaf_view_t *view, zval *tpl, zval * vars, zval *ret \
TSRMLS_DC) +*/
+int yaf_view_simple_eval(yaf_view_t *view, zval *tpl, zval * vars, zval *ret \
TSRMLS_DC) { +	zval *tpl_vars;
+	HashTable *calling_symbol_table;
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	zend_class_entry *old_scope;
+	yaf_view_simple_buffer *buffer;
+	zend_bool short_open_tag;
+#endif
+
+	if (IS_STRING != Z_TYPE_P(tpl)) {
+		return 0;
+	}
+
+	ZVAL_NULL(ret);
+
+	tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC); +	if \
(EG(active_symbol_table)) { +		calling_symbol_table = EG(active_symbol_table);
+	} else {
+		calling_symbol_table = NULL;
+	}
+
+	ALLOC_HASHTABLE(EG(active_symbol_table));
+	zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+
+	(void)yaf_view_simple_extract(tpl_vars, vars TSRMLS_CC);
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	short_open_tag = CG(short_tags);
+	YAF_REDIRECT_OUTPUT_BUFFER(buffer);
+	{
+		zval **short_tag;
+		zval *options = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_OPTS), 0 TSRMLS_CC); +		if (IS_ARRAY != \
Z_TYPE_P(options) +				|| (zend_hash_find(Z_ARRVAL_P(options), \
ZEND_STRS("short_tag"), (void **)&short_tag) == FAILURE) +				|| \
zend_is_true(*short_tag)) { +			CG(short_tags) = 1;
+		}
+	}
+#else
+	if (php_output_start_user(NULL, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC) == \
FAILURE) { +		php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "failed to \
create buffer"); +		return 0;
+	}
+#endif
+
+	if (Z_STRLEN_P(tpl)) {
+		zval phtml;
+		zend_op_array *new_op_array;
+		char *eval_desc = zend_make_compiled_string_description("template code" \
TSRMLS_CC); +
+		/* eval require code mustn't be wrapped in opening and closing PHP tags */
+		INIT_ZVAL(phtml);
+		Z_TYPE(phtml)   = IS_STRING;
+		Z_STRLEN(phtml) = Z_STRLEN_P(tpl) + 2;
+		Z_STRVAL(phtml) = emalloc(Z_STRLEN(phtml) + 1);
+		snprintf(Z_STRVAL(phtml), Z_STRLEN(phtml) + 1, "?>%s", Z_STRVAL_P(tpl));
+
+		new_op_array = zend_compile_string(&phtml, eval_desc TSRMLS_CC);
+
+		zval_dtor(&phtml);
+		efree(eval_desc);
+
+		if (new_op_array) {
+			zval *result = NULL;
+
+			YAF_STORE_EG_ENVIRON();
+
+			EG(return_value_ptr_ptr) 	= &result;
+			EG(active_op_array) 		= new_op_array;
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2)) || (PHP_MAJOR_VERSION > 5)
+			if (!EG(active_symbol_table)) {
+				zend_rebuild_symbol_table(TSRMLS_C);
+			}
+#endif
+			zend_execute(new_op_array TSRMLS_CC);
+
+			destroy_op_array(new_op_array TSRMLS_CC);
+			efree(new_op_array);
+
+			if (!EG(exception)) {
+				if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {
+					zval_ptr_dtor(EG(return_value_ptr_ptr));
+				}
+			}
+
+			YAF_RESTORE_EG_ENVIRON();
+		}
+	}
+
+	if (calling_symbol_table) {
+		zend_hash_destroy(EG(active_symbol_table));
+		FREE_HASHTABLE(EG(active_symbol_table));
+		EG(active_symbol_table) = calling_symbol_table;
+	}
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	CG(short_tags) = short_open_tag;
+	if (buffer->len) {
+		ZVAL_STRINGL(ret, buffer->buffer, buffer->len, 1);
+	}
+#else
+	if (php_output_get_contents(ret TSRMLS_CC) == FAILURE) {
+		php_output_end(TSRMLS_C);
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to fetch ob content");
+		return 0;
+	}
+
+	if (php_output_discard(TSRMLS_C) != SUCCESS ) {
+		return 0;
+	}
+#endif
+
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	YAF_RESTORE_OUTPUT_BUFFER(buffer);
+#endif
+	return 1;
+}
+/* }}} */
+
+/** {{{ int yaf_view_simple_assign_single(yaf_view_t *view, char *name, uint len, \
zval *value TSRMLS_DC) + */
+int yaf_view_simple_assign_single(yaf_view_t *view, char *name, uint len, zval \
*value TSRMLS_DC) { +	zval *tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC); +	Z_ADDREF_P(value);
+	if (zend_hash_update(Z_ARRVAL_P(tpl_vars), name, len + 1, &value, sizeof(zval *), \
NULL) == SUCCESS) { +		return 1;
+	}
+	return 0;
+}
+/* }}} */
+
+/** {{{ int yaf_view_simple_assign_single(yaf_view_t *view, zval *name, zval *value \
TSRMLS_DC) + */
+int yaf_view_simple_assign_multi(yaf_view_t *view, zval *value TSRMLS_DC) {
+	zval *tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC); +	if (Z_TYPE_P(value) == \
IS_ARRAY) { +		zend_hash_copy(Z_ARRVAL_P(tpl_vars), Z_ARRVAL_P(value), \
(copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +		return 1;
+	}
+	return 0;
+}
+/* }}} */
+
+/** {{{ void yaf_view_simple_clear_assign(yaf_view_t *view, char *name, uint len \
TSRMLS_DC) + */
+void yaf_view_simple_clear_assign(yaf_view_t *view, char *name, uint len TSRMLS_DC) \
{ +	zval *tpl_vars = zend_read_property(yaf_view_simple_ce, view, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC); +	if (tpl_vars && \
Z_TYPE_P(tpl_vars) == IS_ARRAY) { +		if (len) {
+			zend_symtable_del(Z_ARRVAL_P(tpl_vars), name, len + 1);
+		} else {
+			zend_hash_clean(Z_ARRVAL_P(tpl_vars));
+		}
+	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::__construct(string $tpl_dir, array $options = \
NULL) +*/
+PHP_METHOD(yaf_view_simple, __construct) {
+	zval *tpl_dir, *options = NULL;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &tpl_dir, &options) == \
FAILURE) { +		YAF_UNINITIALIZED_OBJECT(getThis());
+		return;
+	}
+
+	yaf_view_simple_instance(getThis(), tpl_dir, options TSRMLS_CC);
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::__isset($name)
+*/
+PHP_METHOD(yaf_view_simple, __isset) {
+	char *name;
+	uint len;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &len) == FAILURE) \
{ +		return;
+	} else {
+		zval *tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC); \
+		RETURN_BOOL(zend_hash_exists(Z_ARRVAL_P(tpl_vars), name, len + 1)); +	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::setScriptPath(string $tpl_dir)
+*/
+PHP_METHOD(yaf_view_simple, setScriptPath) {
+	zval *tpl_dir;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &tpl_dir) == FAILURE) {
+		return;
+	}
+
+	if (Z_TYPE_P(tpl_dir) == IS_STRING && IS_ABSOLUTE_PATH(Z_STRVAL_P(tpl_dir), \
Z_STRLEN_P(tpl_dir))) { +		zend_update_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR), tpl_dir TSRMLS_CC); \
+		RETURN_ZVAL(getThis(), 1, 0); +	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::getScriptPath(void)
+*/
+PHP_METHOD(yaf_view_simple, getScriptPath) {
+	zval *tpl_dir = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR), 0 TSRMLS_CC); +	if (IS_STRING != \
Z_TYPE_P(tpl_dir) && YAF_G(view_directory)) { +		RETURN_STRING(YAF_G(view_directory), \
1); +	}
+	RETURN_ZVAL(tpl_dir, 1, 0);
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::compose(string $script, zval *args)
+*/
+PHP_METHOD(yaf_view_simple, compose) {
+	char *script;
+	uint len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &script, &len) == \
FAILURE) { +		return;
+	}
+
+	if (!len) {
+		RETURN_FALSE;
+	}
+
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::assign(mixed $value, mixed $value = null)
+*/
+PHP_METHOD(yaf_view_simple, assign) {
+	uint argc = ZEND_NUM_ARGS();
+	if (argc == 1) {
+		zval *value;
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
+			return;
+		}
+		RETURN_BOOL(yaf_view_simple_assign_multi(getThis(), value TSRMLS_CC));
+	} else if (argc == 2) {
+		zval *value;
+		char *name;
+		uint len;
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &len, &value) == \
FAILURE) { +			return;
+		}
+        RETURN_BOOL(yaf_view_simple_assign_single(getThis(), name, len, value \
TSRMLS_CC)); +	} else {
+		WRONG_PARAM_COUNT;
+	}
+
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::assignRef(mixed $value, mixed $value)
+*/
+PHP_METHOD(yaf_view_simple, assignRef) {
+	char * name; int len;
+	zval * value, * tpl_vars;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &len, &value) == \
FAILURE) { +		WRONG_PARAM_COUNT;
+	}
+
+	tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC); +
+	Z_ADDREF_P(value);
+	if (zend_hash_update(Z_ARRVAL_P(tpl_vars), name, len + 1, &value, sizeof(zval *), \
NULL) == SUCCESS) { +		RETURN_TRUE;
+	}
+	RETURN_FALSE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::get($name)
+*/
+PHP_METHOD(yaf_view_simple, get) {
+	char *name;
+	uint len = 0;
+	zval *tpl_vars, **ret;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &len) == FAILURE) \
{ +		return;
+	}
+
+	tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC); +
+	if (tpl_vars && Z_TYPE_P(tpl_vars) == IS_ARRAY) {
+		if (len) {
+			if (zend_hash_find(Z_ARRVAL_P(tpl_vars), name, len + 1, (void **) &ret) == \
SUCCESS) { +				RETURN_ZVAL(*ret, 1, 0);
+			}
+		} else {
+			RETURN_ZVAL(tpl_vars, 1, 0);
+		}
+	}
+
+	RETURN_NULL();
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::render(string $tpl, array $vars = NULL)
+*/
+PHP_METHOD(yaf_view_simple, render) {
+	zval *tpl, *vars = NULL; /*, *tpl_vars;*/
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &tpl, &vars) == \
FAILURE) { +		return;
+	}
+
+	/*tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC);*/ +#if ((PHP_MAJOR_VERSION \
== 5) && (PHP_MINOR_VERSION < 4)) +	zend_try {
+#endif
+		if (!yaf_view_simple_render(getThis(), tpl, vars, return_value TSRMLS_CC)) {
+			RETVAL_FALSE;
+		}
+#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4))
+	} zend_catch {
+		yaf_view_simple_buffer *buffer;
+
+		if (!(--YAF_G(buf_nesting))) {
+			if (YAF_G(owrite_handler)) {
+				OG(php_body_write) 	= (yaf_body_write_func)YAF_G(owrite_handler);
+				YAF_G(owrite_handler) = NULL;
+			}
+		}
+
+		if (YAF_G(buffer)) {
+			buffer = YAF_G(buffer);
+			YAF_G(buffer) = buffer->prev;
+			if (buffer->len) {
+				PHPWRITE(buffer->buffer, buffer->len);
+				efree(buffer->buffer);
+			}
+			efree(buffer);
+		}
+		zend_bailout();
+	} zend_end_try();
+#endif
+
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::eval(string $tpl_content, array $vars = NULL)
+*/
+PHP_METHOD(yaf_view_simple, eval) {
+	zval *tpl, *vars = NULL; /*, *tpl_vars;*/
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &tpl, &vars) == \
FAILURE) { +		return;
+	}
+
+	/*tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 1 TSRMLS_CC);*/ +	if \
(!yaf_view_simple_eval(getThis(), tpl, vars, return_value TSRMLS_CC)) { \
+		RETURN_FALSE; +	}
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::display(string $tpl, array $vars = NULL)
+*/
+PHP_METHOD(yaf_view_simple, display) {
+	zval *tpl, *vars = NULL; /* , *tpl_vars*/
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &tpl, &vars) == \
FAILURE) { +		return;
+	}
+
+	/*tpl_vars = zend_read_property(yaf_view_simple_ce, getThis(), \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), 0 TSRMLS_CC);*/ +	if \
(!yaf_view_simple_display(getThis(), tpl, vars, return_value TSRMLS_CC)) { \
+		RETURN_FALSE; +	}
+
+	RETURN_TRUE;
+}
+/* }}} */
+
+/** {{{ proto public Yaf_View_Simple::clear(string $name)
+*/
+PHP_METHOD(yaf_view_simple, clear) {
+	char *name;
+	uint len = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &len) == FAILURE) \
{ +		return;
+	}
+
+	yaf_view_simple_clear_assign(getThis(), name, len TSRMLS_CC);
+
+	RETURN_ZVAL(getThis(), 1, 0);
+}
+/* }}} */
+
+/** {{{ yaf_view_simple_methods
+*/
+zend_function_entry yaf_view_simple_methods[] = {
+	PHP_ME(yaf_view_simple, __construct, yaf_view_simple_construct_arginfo, \
ZEND_ACC_CTOR|ZEND_ACC_FINAL|ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, __isset, \
yaf_view_simple_isset_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, get, \
yaf_view_simple_get_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, assign, \
yaf_view_assign_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, render, \
yaf_view_render_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, eval,  \
yaf_view_simple_eval_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, display, \
yaf_view_display_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, assignRef, \
yaf_view_simple_assign_by_ref_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, \
clear, yaf_view_simple_clear_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, \
setScriptPath, yaf_view_setpath_arginfo, ZEND_ACC_PUBLIC) +	PHP_ME(yaf_view_simple, \
getScriptPath, yaf_view_getpath_arginfo, ZEND_ACC_PUBLIC) \
+	PHP_MALIAS(yaf_view_simple, __get, get, yaf_view_simple_get_arginfo, \
ZEND_ACC_PUBLIC) +	PHP_MALIAS(yaf_view_simple, __set, assign, \
yaf_view_assign_arginfo, ZEND_ACC_PUBLIC) +	{NULL, NULL, NULL}
+};
+/* }}} */
+
+/** {{{ YAF_STARTUP_FUNCTION
+*/
+YAF_STARTUP_FUNCTION(view_simple) {
+	zend_class_entry ce;
+
+	YAF_INIT_CLASS_ENTRY(ce, "Yaf_View_Simple", "Yaf\\View\\Simple", \
yaf_view_simple_methods); +	yaf_view_simple_ce = zend_register_internal_class_ex(&ce, \
NULL, NULL TSRMLS_CC); +
+	zend_declare_property_null(yaf_view_simple_ce, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLVARS), ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_view_simple_ce, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_TPLDIR),  ZEND_ACC_PROTECTED TSRMLS_CC); \
+	zend_declare_property_null(yaf_view_simple_ce, \
ZEND_STRL(YAF_VIEW_PROPERTY_NAME_OPTS),  ZEND_ACC_PROTECTED TSRMLS_CC); +
+	zend_class_implements(yaf_view_simple_ce TSRMLS_CC, 1, yaf_view_interface_ce);
+
+	return SUCCESS;
+}
+/* }}} */
+
+/*
+ * 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
+ */
+

Added: pecl/yaf/trunk/views/yaf_view_simple.h
===================================================================
--- pecl/yaf/trunk/views/yaf_view_simple.h	                        (rev 0)
+++ pecl/yaf/trunk/views/yaf_view_simple.h	2013-01-18 08:35:31 UTC (rev 329203)
@@ -0,0 +1,37 @@
+/*
+  +----------------------------------------------------------------------+
+  | Yet Another Framework                                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.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: Xinchen Hui  <laruence@php.net>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id: yaf_view.h 329002 2013-01-07 12:55:53Z laruence $ */
+
+#ifndef YAF_VIEW_SIMPLE_H
+#define YAF_VIEW_SIMPLE_H
+
+#define VIEW_BUFFER_BLOCK_SIZE	4096
+#define VIEW_BUFFER_SIZE_MASK 	4095
+
+extern zend_class_entry *yaf_view_simple_ce;
+
+YAF_STARTUP_FUNCTION(view_simple);
+
+#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
+ */



-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic