[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_util.c

ctford nobody at lists.annodex.net
Thu Dec 15 13:37:18 EST 2005


Update of /annodex (new revision 1708)

Modified files:
   phpannodex/trunk/src/phpannodex.c
   phpannodex/trunk/src/phpanx_constants.c
   phpannodex/trunk/src/phpanx_general.c
   phpannodex/trunk/src/phpanx_util.c

Log Message:
anx_close() now accepts an Annodex file handle resource as an argument (without seg faulting!). The problem seems to have been PHP auto-closing the file through the destruction handler. I have commented out the anx_close() line in the destruction handler, though this is an interim solution, as I still have to make sure the file closes if the script crashes. 

Modified: phpannodex/trunk/src/phpannodex.c
===================================================================
--- phpannodex/trunk/src/phpannodex.c	2005-12-15 01:59:14 UTC (rev 1707)
+++ phpannodex/trunk/src/phpannodex.c	2005-12-15 02:37:18 UTC (rev 1708)
@@ -6,8 +6,6 @@
 #include "phpanx_util.h"
 #include "phpannodex.h"
 
-
-
 static void anx_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC);
 
 /* This array tells php what functions this extension provides. The functions
@@ -88,6 +86,6 @@
 void anx_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
 
 	ANNODEX* anx = (ANNODEX*) rsrc->ptr;
-	anx_close( anx );
+//	anx_close( anx );
 	return;
 }

Modified: phpannodex/trunk/src/phpanx_constants.c
===================================================================
--- phpannodex/trunk/src/phpanx_constants.c	2005-12-15 01:59:14 UTC (rev 1707)
+++ phpannodex/trunk/src/phpanx_constants.c	2005-12-15 02:37:18 UTC (rev 1708)
@@ -1,6 +1,9 @@
 #include "phpanx_util.h"
 #include "phpanx_constants.h"
 
+/* This function will be called when phpannodex is loaded, making these 
+ * constants visible in PHP.
+ */
 extern void init_constants( int module_number, int tsrm_ls ) {
 
 	/* #defines from anx_constants.h */ 

Modified: phpannodex/trunk/src/phpanx_general.c
===================================================================
--- phpannodex/trunk/src/phpanx_general.c	2005-12-15 01:59:14 UTC (rev 1707)
+++ phpannodex/trunk/src/phpanx_general.c	2005-12-15 02:37:18 UTC (rev 1708)
@@ -98,12 +98,13 @@
 	/* Process arguments */
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", 
 			&anx_resource) == FAILURE) {
-	RETURN_NULL();
+		RETURN_NULL();
 	}
 	//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 );
@@ -117,13 +118,13 @@
 php_printf("anx is now %d<br>", (int) anx);
 
 //	anx = NULL;
-//	returned_resource_id = anx_to_resource_id( anx );
+	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_RESOURCE( returned_resource_id );
 
 	//RETURN_LONG( (long) anx );
 }

Modified: phpannodex/trunk/src/phpanx_util.c
===================================================================
--- phpannodex/trunk/src/phpanx_util.c	2005-12-15 01:59:14 UTC (rev 1707)
+++ phpannodex/trunk/src/phpanx_util.c	2005-12-15 02:37:18 UTC (rev 1708)
@@ -2,8 +2,15 @@
 #include "phpanx_util.h"
 #include <string.h>
 
+/* A global holding the code PHP assigns to the "Annodex file handle" resource
+ * when phpannodex is loaded.
+ */
 int le_anx_handle;
 
+/* This function is designed to handle the case where PHP tries to pass C a
+ * NULL, but it gets converted to "". This function is used to convert it back
+ * again.
+ */
 char* empty_to_null( char* string ) {
 	
 	if( strlen(string) == 0 ) {


-- 
ctford



More information about the cvs-annodex mailing list