[cvs-annodex] commit (/annodex): phpannodex/trunk/src/phpannodex.c phpannodex/trunk/src/phpanx_constants.c phpannodex/trunk/src/phpanx_general.c phpannodex/trunk/src/phpanx_read.c phpannodex/trunk/src/phpanx_types.c phpannodex/trunk/src/phpanx_util.h phpannodex/trunk/src/phpanx_write.c

ctford nobody at lists.annodex.net
Thu Dec 15 12:59:15 EST 2005


Update of /annodex (new revision 1707)

Modified files:
   phpannodex/trunk/src/phpannodex.c
   phpannodex/trunk/src/phpanx_constants.c
   phpannodex/trunk/src/phpanx_general.c
   phpannodex/trunk/src/phpanx_read.c
   phpannodex/trunk/src/phpanx_types.c
   phpannodex/trunk/src/phpanx_util.h
   phpannodex/trunk/src/phpanx_write.c

Log Message:
phpanx_util.h is now a convenience header. Files now just include their own header and phpanx_util.h rather than mucking around seperately including php.h etc.

Modified: phpannodex/trunk/src/phpannodex.c
===================================================================
--- phpannodex/trunk/src/phpannodex.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpannodex.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -3,17 +3,11 @@
 #include "config.h"
 #endif
 
-#include "php.h"
-#include "phpannodex.h"
-#include "phpanx_read.h"
-#include "phpanx_general.h"
-#include "phpanx_write.h"
-#include "phpanx_constants.h"
-#include "phpanx_types.h"
 #include "phpanx_util.h"
+#include "phpannodex.h"
 
-#define LE_ANX_HANDLE_NAME "Annodex file handle"
 
+
 static void anx_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC);
 
 /* This array tells php what functions this extension provides. The functions

Modified: phpannodex/trunk/src/phpanx_constants.c
===================================================================
--- phpannodex/trunk/src/phpanx_constants.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_constants.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,7 +1,5 @@
-#include "php.h"
+#include "phpanx_util.h"
 #include "phpanx_constants.h"
-#include "phpannodex.h"
-#include <annodex/annodex.h>
 
 extern void init_constants( int module_number, int tsrm_ls ) {
 

Modified: phpannodex/trunk/src/phpanx_general.c
===================================================================
--- phpannodex/trunk/src/phpanx_general.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_general.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,8 +1,6 @@
 
-#include "php.h"
+#include "phpanx_util.h"
 #include "phpanx_general.h"
-#include "phpanx_util.h"
-#include <annodex/annodex.h>
 
 PHP_FUNCTION(anx_last_error)
 {
@@ -76,13 +74,16 @@
 	}
 
 	/* Call Annodex function */
-	anx = anx_new(mode);
+	anx = anx_new( mode );
 
-	MAKE_STD_ZVAL( anx_resource );
+//	MAKE_STD_ZVAL( anx_resource );
 
-	resource_id = ZEND_REGISTER_RESOURCE( anx_resource, anx, le_anx_handle);
+//	resource_id = ZEND_REGISTER_RESOURCE( anx_resource, anx, le_anx_handle);
 
-php_printf("in anx new <br>");
+	resource_id = anx_to_resource_id( anx );
+
+php_printf("in anx new with address %d<br>", (int) anx);
+php_printf("the resource id is %d<br>", resource_id);
 	
 	RETURN_RESOURCE( resource_id );
 	//RETURN_LONG(ptr_long);
@@ -90,20 +91,41 @@
 
 PHP_FUNCTION(anx_close)
 {
-	long ptr_long;
-	ANNODEX *anx;
+	zval *anx_resource, *returned_anx_resource;
+	ANNODEX *anx = NULL;
+	int returned_resource_id;
 
 	/* Process arguments */
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", 
-			&ptr_long) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", 
+			&anx_resource) == FAILURE) {
 	RETURN_NULL();
 	}
-	anx = (ANNODEX*) ptr_long;
+	//anx = (ANNODEX*) ptr_long;
 
+	ZEND_FETCH_RESOURCE( anx, ANNODEX*, &anx_resource, -1, 
+			LE_ANX_HANDLE_NAME, le_anx_handle);
+php_printf("anx address is %d<br>", (int) anx);	
 	/* Call Annodex function */
-	anx = anx_close( anx );
+//	anx = anx_close( anx );
 
-	RETURN_LONG( (long) anx );
+	if( anx == NULL ) {
+php_printf("anx is NULL?<br>");
+		RETURN_NULL();
+	}  
+
+php_printf("About to return resource <br>");
+php_printf("anx is now %d<br>", (int) anx);
+
+//	anx = NULL;
+//	returned_resource_id = anx_to_resource_id( anx );
+	//MAKE_STD_ZVAL( returned_anx_resource );
+//	returned_resource_id = ZEND_REGISTER_RESOURCE( returned_anx_resource, 
+//			anx, le_anx_handle);
+//		
+
+//	RETURN_RESOURCE( returned_resource_id );
+
+	//RETURN_LONG( (long) anx );
 }
 
 PHP_FUNCTION(anx_ready)

Modified: phpannodex/trunk/src/phpanx_read.c
===================================================================
--- phpannodex/trunk/src/phpanx_read.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_read.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,7 +1,6 @@
 
-#include "php.h"
+#include "phpanx_util.h"
 #include "phpanx_read.h"
-#include <annodex/annodex.h>
 
 PHP_FUNCTION(anx_read)
 {

Modified: phpannodex/trunk/src/phpanx_types.c
===================================================================
--- phpannodex/trunk/src/phpanx_types.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_types.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,7 +1,5 @@
-#include "php.h"
+#include "phpanx_util.h"
 #include "phpanx_types.h"
-#include <annodex/annodex.h>
-#include "phpanx_util.h"
 
 static zval* add_string_attribute( zval* object, char* attribute_name, 
 		char* string, int tsrm_ls );
@@ -230,4 +228,15 @@
 
 }	
 
-       	
+int anx_to_resource_id( ANNODEX* anx ) {
+
+	zval* anx_resource;
+	int resource_id;
+
+	MAKE_STD_ZVAL( anx_resource );
+
+	resource_id = ZEND_REGISTER_RESOURCE( anx_resource, anx, le_anx_handle);
+
+	return( resource_id );
+}
+

Modified: phpannodex/trunk/src/phpanx_util.h
===================================================================
--- phpannodex/trunk/src/phpanx_util.h	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_util.h	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,14 +1,26 @@
 #ifndef PHPANX_UTIL_H
 #define PHPANX_UTIL_H 1
 
+#include <annodex/annodex.h>
+#include "php.h"
+#include "phpannodex.h"
+#include "phpanx_read.h"
+#include "phpanx_general.h"
+#include "phpanx_write.h"
+#include "phpanx_constants.h"
+#include "phpanx_types.h"
+
 #define DUPLICATE	1
 #define DONT_DUPLICATE	0
 
+#define LE_ANX_HANDLE_NAME "Annodex file handle"
+
 #define ANX_RETURN_OBJECT( object ) 	\
 	*return_value = *object;	\
 	zval_copy_ctor( return_value );	\
 
 char* empty_to_null( char* string );
 extern int le_anx_handle;
+int anx_to_resource_id( ANNODEX* anx );
 
 #endif

Modified: phpannodex/trunk/src/phpanx_write.c
===================================================================
--- phpannodex/trunk/src/phpanx_write.c	2005-12-14 23:04:43 UTC (rev 1706)
+++ phpannodex/trunk/src/phpanx_write.c	2005-12-15 01:59:14 UTC (rev 1707)
@@ -1,8 +1,6 @@
 
-#include "php.h"
-#include "phpanx_write.h"
 #include "phpanx_util.h"
-#include <annodex/annodex.h>
+#include "phpanx_write.h"
 
 
 PHP_FUNCTION(anx_init_importers)


-- 
ctford



More information about the cvs-annodex mailing list