nandika jayawardana wrote:

Hi all,

I have started writing a php extension for axis2c starting with om.

For that I have added axis2_xml_reader api in this extension.
Lot has to be done before everything in axis2 is supported.

Pls commit this code.
I think we can put it in a folder named c/bindings/php .

I would like to propose that we place this OM integration code in c/bindings/php/axiom. This way this extention can live inside ext/axiom folder once it is integrated to the php source tree. Once we have the engine implemented in C, the php binding should go in ext/axis2 IMHO.

Thanks,
Samisa...


Thanks
nandika

------------------------------------------------------------------------

#ifndef AXIS2_CE_H
#define AXIS2_CE_H

zend_class_entry *axis2_xml_reader_class_entry;
zend_class_entry *axis2_xml_writer_class_entry;
zend_class_entry *axis2_om_element_class_entry;
zend_class_entry *axis2_om_comment_class_entry;
zend_class_entry *axis2_om_text_class_entry;
zend_class_entry *axis2_om_pi_entry;
zend_class_entry *axis2_om_stax_builder_class_entry;
zend_class_entry *axis2_om_document_class_entry;
zend_class_entry *axis2_om_attribute_class_entry;
zend_class_entry *axis2_om_namespace_class_entry;


#endif /* AXIS2_CE_H */

------------------------------------------------------------------------

#ifndef AXIS2_PROPERTIES_H
#define AXIS2_PROPERTIES_H

#endif /* AXIS2_PROPERTIES_H */

------------------------------------------------------------------------

/*
 +----------------------------------------------------------------------+
 | PHP Version 5                                                        |
 +----------------------------------------------------------------------+
 | Copyright (c) 1997-2004 The PHP Group                                |
 +----------------------------------------------------------------------+
 | This source file is subject to version 3.0 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_0.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          |
 | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
 +----------------------------------------------------------------------+
 | Author:                                                              |
 +----------------------------------------------------------------------+
*/

/* $Id: header,v 1.15 2004/01/08 16:46:52 sniper Exp $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_axis2.h"
#include "axis2_env.h"
#include "axis2_error_default.h"
#include "axis2_stream_default.h"
#include "axis2_log_default.h"


zend_object_value axis2_objects_new(zend_class_entry *class_type TSRMLS_DC );



/* If you declare any globals in php_axis2.h uncomment this:
*/
ZEND_DECLARE_MODULE_GLOBALS(axis2)


/* True global resources - no need for thread safety here */
static int le_axis2;

static zend_object_handlers axis2_object_handlers;

/* {{{ axis2_functions[]
*
* Every user visible function must have an entry in axis2_functions[].
*/
function_entry axis2_functions[] = {
        PHP_FE(axis2_helloworld,        NULL)           
        {NULL, NULL, NULL}      /* Must be the last line in axis2_functions[] */
};
/* }}} */

/* {{{ axis2_module_entry
*/
zend_module_entry axis2_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
        STANDARD_MODULE_HEADER,
#endif
        "axis2",
        axis2_functions,
        PHP_MINIT(axis2),
        PHP_MSHUTDOWN(axis2),
        PHP_RINIT(axis2),               /* Replace with NULL if there's nothing 
to do at request start */
        PHP_RSHUTDOWN(axis2),   /* Replace with NULL if there's nothing to do 
at request end */
        PHP_MINFO(axis2),
#if ZEND_MODULE_API_NO >= 20010901
        "0.1", /* Replace with version number for your extension */
#endif
        STANDARD_MODULE_PROPERTIES
};
/* }}} */

#ifdef COMPILE_DL_AXIS2
ZEND_GET_MODULE(axis2)
#endif

/* {{{ PHP_INI
*/
/* Remove comments and fill if you need to have entries in php.ini
PHP_INI_BEGIN()
   STD_PHP_INI_ENTRY("axis2.global_value",      "42", PHP_INI_ALL, 
OnUpdateLong, global_value, zend_axis2_globals, axis2_globals)
   STD_PHP_INI_ENTRY("axis2.global_string", "foobar", PHP_INI_ALL, 
OnUpdateString, global_string, zend_axis2_globals, axis2_globals)
PHP_INI_END()
*/
/* }}} */

/* {{{ php_axis2_init_globals
*/

static void php_axis2_init_globals(zend_axis2_globals *axis2_globals)
{
   axis2_allocator_t *allocator = NULL;
   axis2_error_t *err = NULL;
   axis2_log_t *log = NULL;
   axis2_stream_t *stream = NULL;
   axis2_env_t *environment = NULL;
   allocator = axis2_allocator_init (NULL);
   log = axis2_log_create(allocator, NULL);
   stream = axis2_stream_create(allocator, NULL);
   err = axis2_error_create(allocator);
environment= axis2_env_create_with_error_stream_log(allocator, err,stream, log); axis2_globals->global_value = 0;
        axis2_globals->global_string = NULL;
        axis2_globals->env = environment;
        axis2_globals->allocator = allocator;
}

/* }}} */

/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(axis2)
{
   zend_class_entry ce;
        
        ZEND_INIT_MODULE_GLOBALS(axis2, php_axis2_init_globals, NULL);
/* If you have INI entries, uncomment these lines REGISTER_INI_ENTRIES();
        */
        
        
        memcpy(&axis2_object_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
        axis2_object_handlers.clone_obj = NULL;
        
        REGISTER_AXIS2_CLASS(ce,"Axis2XMLReader",NULL, 
php_axis2_xml_reader_class_functions, axis2_xml_reader_class_entry);
REGISTER_LONG_CONSTANT("AXIS2_XML_READER_START_DOCUMENT", AXIS2_XML_READER_START_DOCUMENT, CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_START_ELEMENT",   
AXIS2_XML_READER_START_ELEMENT ,                CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_END_ELEMENT",         
AXIS2_XML_READER_END_ELEMENT,                   CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_SPACE",           
AXIS2_XML_READER_SPACE,                     CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_EMPTY_ELEMENT",   
AXIS2_XML_READER_EMPTY_ELEMENT,         CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_CHARACTER",           
AXIS2_XML_READER_CHARACTER,                 CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_ENTITY_REFERANCE",        
AXIS2_XML_READER_ENTITY_REFERANCE,              CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_COMMENT",         
AXIS2_XML_READER_COMMENT,                       CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_PROCESSING_INSTRUCTION",  
AXIS2_XML_READER_PROCESSING_INSTRUCTION,                CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_CDATA",           
AXIS2_XML_READER_CDATA,         CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT("AXIS2_XML_READER_DOCUMENT_TYPE",   
AXIS2_XML_READER_DOCUMENT_TYPE,         CONST_CS | CONST_PERSISTENT);
        
        return SUCCESS;
}
/* }}} */

/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(axis2)
{
        /* uncomment this line if you have INI entries
        UNREGISTER_INI_ENTRIES();
        */
        php_axis2_destroy_env();
        return SUCCESS;
}
/* }}} */



void php_axis2_objects_free_storage(void *object TSRMLS_DC)
{
   axis2_object *intern = (axis2_object_ptr)object;
   zend_hash_destroy(intern->std.properties);
   FREE_HASHTABLE(intern->std.properties);
if(intern->node_list)
   {
       zend_hash_destroy(intern->node_list);
       FREE_HASHTABLE(intern->node_list);
}
   /*TODO individaul objects must be freed */
   if(intern->ptr)
   {
}
}


static zend_object_value axis2_objects_new(zend_class_entry *class_type 
TSRMLS_DC )
{
   zend_object_value retval;
   axis2_object *intern = NULL;
   zval *tmp = NULL;
intern = emalloc(sizeof(axis2_object));
   intern->std.ce = class_type;
   intern->std.in_get = 0;
   intern->std.in_set = 0;
intern->ptr = NULL;
   intern->prop_handler = NULL;
   ALLOC_HASHTABLE(intern->std.properties);
   zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
   zend_hash_copy(intern->std.properties, &class_type->default_properties,
            (copy_ctor_func_t)zval_add_ref, (void*)tmp, sizeof(zval *));
   retval.handle = zend_objects_store_put(intern, NULL,
           ( 
zend_objects_free_object_storage_t)php_axis2_objects_free_storage,NULL 
TSRMLS_CC);
intern->handle = retval.handle; retval.handlers = &axis2_object_handlers; return retval;
}













/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(axis2)
{
        return SUCCESS;
}
/* }}} */

/* Remove if there's nothing to do at request end */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(axis2)
{
        return SUCCESS;
}
/* }}} */

/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(axis2)
{
        php_info_print_table_start();
        php_info_print_table_header(2, "axis2 support", "enabled");
        php_info_print_table_end();

        /* Remove comments if you have entries in php.ini
        DISPLAY_INI_ENTRIES();
        */
}
/* }}} */





/* {{{ proto string axis2_helloworld()
 say welcome note */
PHP_FUNCTION(axis2_helloworld)
{
   php_printf(" welcome axis2");
}
/* }}} */



void php_axis2_destroy_env()
{
   TSRMLS_FETCH();
   axis2_env_free(AXIS2_G(env));
   AXIS2_G(env) = NULL;
   AXIS2_G(allocator) = NULL;
}

axis2_env_t *php_axis2_get_env()
{
   TSRMLS_FETCH();
   return AXIS2_G(env);
}

/*
* 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
*/
------------------------------------------------------------------------

#ifndef AXIS2_FE_H
#define AXIS2_FE_H

extern zend_function_entry php_axis2_xml_reader_class_functions[];
extern zend_function_entry php_axis2_xml_writer_class_functions[];
extern zend_function_entry php_axis2_om_element_class_functions[];
extern zend_function_entry php_axis2_om_comment_class_functions[];
extern zend_function_entry php_axis2_om_text_class_functions[];
extern zend_function_entry php_axis2_om_pi_class_functions[];
extern zend_function_entry php_axis2_om_stax_builder_class_functions[];
extern zend_function_entry php_axis2_om_document_class_functions[];
extern zend_function_entry php_axis2_om_attribute_class_functions[];
extern zend_function_entry php_axis2_om_namespace_class_functions[];

/** axis2_xml_reader functions */
PHP_METHOD(xml_reader, __construct);
PHP_FUNCTION(axis2_xml_reader_next);
PHP_FUNCTION(axis2_xml_reader_get_attribute_count);
PHP_FUNCTION(axis2_xml_reader_get_attribute_name_by_number);
PHP_FUNCTION(axis2_xml_reader_get_attribute_prefix_by_number);
PHP_FUNCTION(axis2_xml_reader_get_attribute_namespace_by_number);
PHP_FUNCTION(axis2_xml_reader_get_attribute_value_by_number);
PHP_FUNCTION(axis2_xml_reader_get_name);
PHP_FUNCTION(axis2_xml_reader_get_value);
PHP_FUNCTION(axis2_xml_reader_get_prefix);
PHP_FUNCTION(axis2_xml_reader_get_namespace_count);
PHP_FUNCTION(axis2_xml_reader_get_namespace_uri_by_number);
PHP_FUNCTION(axis2_xml_reader_get_namespace_prefix_by_number);
PHP_FUNCTION(axis2_xml_reader_get_pi_target);
PHP_FUNCTION(axis2_xml_reader_get_pi_data);


typedef enum {

   OM_ELEMENT = 0,
   OM_NODE,
   OM_PI,
   OM_COMMENT,
   OM_TEXT,
   OM_DOCTYPE,
   AXIS2_XML_READER,
   AXIS2_XML_WRITER,
   OM_DOCUMENT,
   OM_STAX_BUILDER
}om_obj_types;


#endif /* AXIS2_FE_H */

------------------------------------------------------------------------

/*
 +----------------------------------------------------------------------+
 | PHP Version 5                                                        |
 +----------------------------------------------------------------------+
 | Copyright (c) 1997-2004 The PHP Group                                |
 +----------------------------------------------------------------------+
 | This source file is subject to version 3.0 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_0.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          |
 | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
 +----------------------------------------------------------------------+
 | Author:                                                              |
 +----------------------------------------------------------------------+
*/

/* $Id: header,v 1.15 2004/01/08 16:46:52 sniper Exp $ */

#ifndef PHP_AXIS2_H
#define PHP_AXIS2_H

extern zend_module_entry axis2_module_entry;
#define phpext_axis2_ptr &axis2_module_entry

#ifdef PHP_WIN32
#define PHP_AXIS2_API __declspec(dllexport)
#else
#define PHP_AXIS2_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

#include "axis2_ce.h"
#include "axis2_fe.h"
#include "axis2_common.h"

#include <axis2.h>
#include <axis2_env.h>





PHP_MINIT_FUNCTION(axis2);
PHP_MSHUTDOWN_FUNCTION(axis2);
PHP_RINIT_FUNCTION(axis2);
PHP_RSHUTDOWN_FUNCTION(axis2);
PHP_MINFO_FUNCTION(axis2);

PHP_FUNCTION(axis2_helloworld); /* For testing, remove later. */



typedef struct axis2_object{
   zend_object std;
   void *ptr;
   int obj_type;
   HashTable *prop_handler;
   zend_object_handle handle;
   HashTable *node_list;
}axis2_object;

typedef axis2_object *axis2_object_ptr;

void php_axis2_objects_free_storage(void *object TSRMLS_DC);
void php_axis2_destroy_env();
axis2_env_t *php_axis2_get_env();

/* Declare any global variables you may need between the BEGIN
        and END macros here:     */

ZEND_BEGIN_MODULE_GLOBALS(axis2)
        long  global_value;
        char *global_string;
        axis2_env_t *env;
        axis2_allocator_t *allocator;
ZEND_END_MODULE_GLOBALS(axis2)


/* In every utility function you add that needs to use variables in php_axis2_globals, call TSRMLS_FETCH(); after declaring other variables used by that function, or better yet, pass in TSRMLS_CC
  after the last function argument and declare your utility function
  with TSRMLS_DC after the last declared argument.  Always refer to
the globals in your function as AXIS2_G(variable). You are encouraged to rename these macros something shorter, see
  examples in any other php module directory.
*/

#ifdef ZTS
#define AXIS2_G(v) TSRMG(axis2_globals_id, zend_axis2_globals *, v)
#else
#define AXIS2_G(v) (axis2_globals.v)
#endif

#endif  /* PHP_AXIS2_H */


/*
* 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
*/
------------------------------------------------------------------------


#include "php.h"
#include "php_axis2.h"
#include "axis2_xml_reader.h"

zend_function_entry php_axis2_xml_reader_class_functions[]=
{
   PHP_FALIAS(next, axis2_xml_reader_next, NULL)
   PHP_FALIAS(getAttributeCount, axis2_xml_reader_get_attribute_count, NULL)
   PHP_FALIAS(getAttributeName , axis2_xml_reader_get_attribute_name_by_number, 
NULL)
   PHP_FALIAS(getAttributePrefix, 
axis2_xml_reader_get_attribute_prefix_by_number, NULL)
   PHP_FALIAS(getAttributeNamespace, 
axis2_xml_reader_get_attribute_namespace_by_number, NULL)
   PHP_FALIAS(getAttributeValue, 
axis2_xml_reader_get_attribute_value_by_number, NULL)
   PHP_FALIAS(getName, axis2_xml_reader_get_name, NULL)
   PHP_FALIAS(getValue, axis2_xml_reader_get_value, NULL)
   PHP_FALIAS(getPrefix, axis2_xml_reader_get_prefix, NULL)
   PHP_FALIAS(getNamespaceCount, axis2_xml_reader_get_namespace_count, NULL)
   PHP_FALIAS(getNamespaceUri, axis2_xml_reader_get_namespace_uri_by_number, 
NULL)
   PHP_FALIAS(getNamespacePrefix, 
axis2_xml_reader_get_namespace_prefix_by_number, NULL)
   PHP_FALIAS(getPITarget , axis2_xml_reader_get_pi_target, NULL)
   PHP_FALIAS(getPIData, axis2_xml_reader_get_pi_data, NULL)
   PHP_ME(xml_reader, __construct, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL} };

PHP_METHOD(xml_reader , __construct)
{
   zval *object = NULL;
   axis2_object_ptr axis2_obj = NULL;
   om_object_ptr om_obj = NULL;
   char *path;
   int length;
   axis2_env_t *env;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, axis2_xml_reader_class_entry, &path, &length) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
om_obj = emalloc(sizeof(om_object));
   om_obj->ptr = NULL;
   om_obj->obj_type = AXIS2_XML_READER;
   om_obj->ptr = axis2_xml_reader_create_for_file(&env, path, NULL);
   om_obj->ref_count = 1;
   if(om_obj->ptr == NULL)
   {
       php_printf("reader null");
} axis2_obj = (axis2_object_ptr)zend_object_store_get_object(object TSRMLS_CC); axis2_obj->ptr = om_obj; }

PHP_FUNCTION(axis2_xml_reader_next)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   long i = 0;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   i = AXIS2_XML_READER_NEXT(reader, &env);
   RETURN_LONG(i);
}
PHP_FUNCTION(axis2_xml_reader_get_attribute_count)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   int i = 0;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   i = AXIS2_XML_READER_GET_ATTRIBUTE_COUNT(reader, &env);
   RETURN_LONG(i);
}
PHP_FUNCTION(axis2_xml_reader_get_attribute_name_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *attr_name = NULL;
   char *name;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   attr_name = AXIS2_XML_READER_GET_ATTRIBUTE_NAME_BY_NUMBER(reader, &env, i);
   if(!attr_name)
   {
       RETURN_NULL();
   }
   else
   {
   name = estrdup(attr_name);
   AXIS2_XML_READER_XML_FREE(reader, &env, attr_name);
   }
   RETURN_STRING(name, 0);
}
PHP_FUNCTION(axis2_xml_reader_get_attribute_prefix_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *attr_prefix = NULL;
   char *prefix;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   attr_prefix = AXIS2_XML_READER_GET_ATTRIBUTE_PREFIX_BY_NUMBER(reader, &env, 
i);
   if(!attr_prefix)
   {
       RETURN_NULL();
   }
   else
   {
   prefix = estrdup(attr_prefix);
   AXIS2_XML_READER_XML_FREE(reader, &env, attr_prefix);
   }
   RETURN_STRING(prefix, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_attribute_namespace_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *attr_ns_uri = NULL;
   char *uri;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   attr_ns_uri = AXIS2_XML_READER_GET_ATTRIBUTE_NAMESPACE_BY_NUMBER(reader, 
&env, i);
   if(!attr_ns_uri)
   {
       RETURN_NULL();
} else
   {
   uri = estrdup(attr_ns_uri);
   AXIS2_XML_READER_XML_FREE(reader, &env, attr_ns_uri);
   }
   RETURN_STRING(uri, 0);
}
PHP_FUNCTION(axis2_xml_reader_get_attribute_value_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *attr_value = NULL;
   char *value;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   attr_value = AXIS2_XML_READER_GET_ATTRIBUTE_VALUE_BY_NUMBER(reader, &env, i);
   if(!attr_value)
   {
       RETURN_NULL();
   }
   else
{ value = estrdup(attr_value);
   AXIS2_XML_READER_XML_FREE(reader, &env, attr_value);
   }
   RETURN_STRING(value, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_name)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *name = NULL;
   char *na = NULL;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   name = AXIS2_XML_READER_GET_NAME(reader, &env);
   if(!name)
   {
       RETURN_NULL();
   }
   else
{ na = estrdup(name);
   if(name)
       AXIS2_XML_READER_XML_FREE(reader, &env, name);
   }
   RETURN_STRING(na, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_value)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *value = NULL;
   char *val = NULL;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   value = AXIS2_XML_READER_GET_VALUE(reader, &env);
   if(!value)
   {
       RETURN_NULL();
   }
   else
   {
   val = estrdup(value);
   if(value)
       AXIS2_XML_READER_XML_FREE(reader, &env, value);
   }
   RETURN_STRING(val, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_prefix)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *prefix = NULL;
   char *pre = NULL;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   prefix = AXIS2_XML_READER_GET_PREFIX(reader, &env);
   if(!prefix)
   {
      RETURN_NULL();
   }
   else
   {
   pre = estrdup(prefix);
   if(prefix)
       AXIS2_XML_READER_XML_FREE(reader, &env, prefix);
   }
   RETURN_STRING(pre, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_namespace_count)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   long i =0;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   i = AXIS2_XML_READER_GET_NAMESPACE_COUNT(reader, &env);
   RETURN_LONG(i);

}
PHP_FUNCTION(axis2_xml_reader_get_namespace_uri_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *ns_uri = NULL;
   char *uri = NULL;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   ns_uri = AXIS2_XML_READER_GET_NAMESPACE_URI_BY_NUMBER(reader, &env, i);
   if(!ns_uri)
   {
       RETURN_NULL();
   }
   else
   {
       uri = estrdup(ns_uri);
       AXIS2_XML_READER_XML_FREE(reader, &env, ns_uri);
   }
   RETURN_STRING(uri, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_namespace_prefix_by_number)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *ns_prefix = NULL;
   char *prefix = NULL;
   long i = 0;
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &obj, axis2_xml_reader_class_entry, &i) == FAILURE)
   {
       php_std_error_handling();
       return;
   }
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   ns_prefix = AXIS2_XML_READER_GET_NAMESPACE_PREFIX_BY_NUMBER(reader, &env, i);
   if(!ns_prefix)
   {
       RETURN_NULL();
   }
   else
   {
   prefix = estrdup(ns_prefix);
   AXIS2_XML_READER_XML_FREE(reader, &env, ns_prefix);
   }
   RETURN_STRING(prefix, 0);
}
PHP_FUNCTION(axis2_xml_reader_get_pi_target)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *pi_target = NULL;
   char *target = NULL;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   pi_target = AXIS2_XML_READER_GET_PI_TARGET(reader, &env);
   if(!pi_target)
   {
       RETURN_NULL();
   }
   else
   {
   target = estrdup(pi_target);
   if(pi_target)
       AXIS2_XML_READER_XML_FREE(reader, &env, pi_target);
   }
   RETURN_STRING(target, 0);

}
PHP_FUNCTION(axis2_xml_reader_get_pi_data)
{
   axis2_object_ptr axis2_obj = NULL;
   zval *obj = NULL;
   axis2_xml_reader_t *reader = NULL;
   axis2_env_t *env = NULL;
   char *pi_data = NULL;
   char *data = NULL;
obj = getThis();
   env = php_axis2_get_env();
   axis2_obj = (axis2_object_ptr)zend_object_store_get_object(obj TSRMLS_CC);
   reader =(axis2_xml_reader_t*) (((om_object_ptr)(axis2_obj->ptr))->ptr);
   pi_data = AXIS2_XML_READER_GET_PI_DATA(reader, &env);
   if(!pi_data)
   {
       RETURN_NULL();
   }
   else
   {
   data = estrdup(pi_data);
   if(pi_data)
       AXIS2_XML_READER_XML_FREE(reader, &env, pi_data);
   }
   RETURN_STRING(data, 0);
}


Reply via email to