cvs: pecl /tidy php_tidy.h tidy.c
| From: | John Coggeshall | Date: | Sun, 14 Sep 2003 00:45:51 +0000 |
| Subject: | cvs: pecl /tidy php_tidy.h tidy.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-440@lists.php.net to get a copy of this message | ||
john Sat Sep 13 20:45:51 2003 EDT
Modified files:
/pecl/tidy php_tidy.h tidy.c
Log:
Moved things around and added some #ifdefs so that the extension can be used
in PHP 4 (without the ZE2 tree parsing).
Index: pecl/tidy/php_tidy.h
diff -u pecl/tidy/php_tidy.h:1.3 pecl/tidy/php_tidy.h:1.4
--- pecl/tidy/php_tidy.h:1.3 Tue Aug 5 20:01:22 2003
+++ pecl/tidy/php_tidy.h Sat Sep 13 20:45:51 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_tidy.h,v 1.3 2003/08/06 00:01:22 john Exp $ */
+/* $Id: php_tidy.h,v 1.4 2003/09/14 00:45:51 john Exp $ */
#ifndef PHP_TIDY_H
#define PHP_TIDY_H
@@ -113,6 +113,8 @@
PHP_FUNCTION(tidy_set_encoding);
PHP_FUNCTION(tidy_save_config);
+#ifdef ZEND_ENGINE_2
+
PHP_FUNCTION(tidy_get_root);
PHP_FUNCTION(tidy_get_html);
PHP_FUNCTION(tidy_get_head);
@@ -154,6 +156,8 @@
zend_bool _php_tidy_attr_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS);
zend_bool _php_tidy_node_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS);
void _php_tidy_init_prop_hashtables();
+
+#endif
/* resource dtor */
void dtor_TidyDoc(zend_rsrc_list_entry * TSRMLS_DC);
Index: pecl/tidy/tidy.c
diff -u pecl/tidy/tidy.c:1.7 pecl/tidy/tidy.c:1.8
--- pecl/tidy/tidy.c:1.7 Thu Aug 7 13:53:48 2003
+++ pecl/tidy/tidy.c Sat Sep 13 20:45:51 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tidy.c,v 1.7 2003/08/07 17:53:48 john Exp $ */
+/* $Id: tidy.c,v 1.8 2003/09/14 00:45:51 john Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -28,16 +28,21 @@
#include "php_tidy.h"
#include "Zend/zend_API.h"
#include "Zend/zend_hash.h"
+#include "safe_mode.h"
+
+#ifdef ZEND_ENGINE_2
#include "zend_objects_API.h"
#include "zend_objects.h"
#include "zend_operators.h"
-#include "safe_mode.h"
+#endif
ZEND_DECLARE_MODULE_GLOBALS(tidy);
static int le_tidydoc;
#define le_tidydoc_name "Tidy Document"
+#ifdef ZEND_ENGINE_2
+
zend_class_entry *php_tidy_ce;
static zend_object_handlers php_tidy_object_handlers = {
@@ -63,17 +68,18 @@
tidy_object_cast
};
+#endif
function_entry tidy_functions[] = {
PHP_FE(tidy_create, NULL)
- PHP_FE(tidy_setopt, NULL)
- PHP_FE(tidy_getopt, NULL)
- PHP_FE(tidy_parse_string, NULL)
- PHP_FE(tidy_parse_file, NULL)
- PHP_FE(tidy_get_output, NULL)
- PHP_FE(tidy_get_error_buffer, NULL)
- PHP_FE(tidy_clean_repair, NULL)
- PHP_FE(tidy_diagnose, NULL)
+ PHP_FE(tidy_setopt, NULL)
+ PHP_FE(tidy_getopt, NULL)
+ PHP_FE(tidy_parse_string, NULL)
+ PHP_FE(tidy_parse_file, NULL)
+ PHP_FE(tidy_get_output, NULL)
+ PHP_FE(tidy_get_error_buffer, NULL)
+ PHP_FE(tidy_clean_repair, NULL)
+ PHP_FE(tidy_diagnose, NULL)
PHP_FE(tidy_get_release, NULL)
PHP_FE(tidy_get_status, NULL)
PHP_FE(tidy_get_html_ver, NULL)
@@ -84,13 +90,17 @@
PHP_FE(tidy_access_count, NULL)
PHP_FE(tidy_config_count, NULL)
PHP_FE(tidy_load_config, NULL)
- PHP_FE(tidy_load_config_enc, NULL)
+ PHP_FE(tidy_load_config_enc, NULL)
PHP_FE(tidy_set_encoding, NULL)
PHP_FE(tidy_save_config, NULL)
+
+#ifdef ZEND_ENGINE_2
PHP_FE(tidy_get_root, NULL)
PHP_FE(tidy_get_head, NULL)
PHP_FE(tidy_get_html, NULL)
PHP_FE(tidy_get_body, NULL)
+#endif
+
{NULL, NULL, NULL}
};
@@ -107,7 +117,7 @@
NULL,
PHP_MINFO(tidy),
#if ZEND_MODULE_API_NO >= 20010901
- "0.5b",
+ "0.6b",
#endif
STANDARD_MODULE_PROPERTIES
};
@@ -117,35 +127,14 @@
ZEND_GET_MODULE(tidy)
#endif
+#ifdef ZEND_ENGINE_2
+
static inline PHPTidyObj *php_tidy_fetch_object(zval *object TSRMLS_DC)
{
return (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);
}
-void * _php_tidy_mem_alloc(size_t size)
-{
- return emalloc(size);
-}
-
-void * _php_tidy_mem_realloc(void *mem, size_t newsize)
-{
- return erealloc(mem, newsize);
-}
-
-void _php_tidy_mem_free(void *mem)
-{
- efree(mem);
-}
-
-void _php_tidy_mem_panic(ctmbstr errmsg)
-{
-
- TSRMLS_FETCH();
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not allocate memory for Tidy: %s",
(char *)errmsg);
-}
-
-
PHPTidyObj *php_tidy_new()
{
@@ -233,24 +222,6 @@
return retval;
}
-
-void dtor_TidyDoc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-
- PHPTidyDoc *tdoc = (PHPTidyDoc *)rsrc->ptr;
-
- if(tdoc->doc) {
- tidyRelease(tdoc->doc);
- }
- if(tdoc->errbuf) {
- tidyBufFree(tdoc->errbuf);
- efree(tdoc->errbuf);
-
- }
-
- efree(tdoc);
-
-}
void php_tidy_obj_dtor(void *object, zend_object_handle handle TSRMLS_DC)
{
@@ -306,6 +277,49 @@
}
+#endif
+
+void * _php_tidy_mem_alloc(size_t size)
+{
+ return emalloc(size);
+}
+
+void * _php_tidy_mem_realloc(void *mem, size_t newsize)
+{
+ return erealloc(mem, newsize);
+}
+
+void _php_tidy_mem_free(void *mem)
+{
+ efree(mem);
+}
+
+void _php_tidy_mem_panic(ctmbstr errmsg)
+{
+
+ TSRMLS_FETCH();
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not allocate memory for Tidy: %s",
(char *)errmsg);
+}
+
+
+void dtor_TidyDoc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+
+ PHPTidyDoc *tdoc = (PHPTidyDoc *)rsrc->ptr;
+
+ if(tdoc->doc) {
+ tidyRelease(tdoc->doc);
+ }
+ if(tdoc->errbuf) {
+ tidyBufFree(tdoc->errbuf);
+ efree(tdoc->errbuf);
+
+ }
+
+ efree(tdoc);
+
+}
+
void php_tidy_init_globals(zend_tidy_globals *tidy_globals)
{
@@ -315,11 +329,15 @@
PHP_MINIT_FUNCTION(tidy)
{
+#ifdef ZEND_ENGINE_2
+
zend_class_entry _tidy_entry;
INIT_CLASS_ENTRY(_tidy_entry, "TidyObject", NULL);
php_tidy_ce = zend_register_internal_class(&_tidy_entry TSRMLS_CC);
-
+
+#endif
+
ZEND_INIT_MODULE_GLOBALS(tidy, php_tidy_init_globals, NULL);
le_tidydoc = zend_register_list_destructors_ex(dtor_TidyDoc, NULL, le_tidydoc_name,
module_number);
@@ -1050,6 +1068,8 @@
}
/* }}} */
+#ifdef ZEND_ENGINE_2
+
/* {{{ proto TidyNode tidy_get_root(resource tidy)
Returns a TidyNode Object representing the root of the tidy parse tree */
PHP_FUNCTION(tidy_get_root)
@@ -1687,6 +1707,7 @@
}
+#endif
void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
{