Back to index

php5  5.3.10
Defines | Typedefs | Functions | Variables
php_xmlwriter.c File Reference
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_xmlwriter.h"
#include "ext/standard/php_string.h"

Go to the source code of this file.

Defines

#define XMLW_NAME_CHK(__err)

Typedefs

typedef int(* xmlwriter_read_one_char_t )(xmlTextWriterPtr writer, const xmlChar *content)
typedef int(* xmlwriter_read_int_t )(xmlTextWriterPtr writer)

Functions

static PHP_FUNCTION (xmlwriter_start_attribute)
static PHP_FUNCTION (xmlwriter_end_attribute)
static PHP_FUNCTION (xmlwriter_write_attribute)
static PHP_FUNCTION (xmlwriter_start_element)
static PHP_FUNCTION (xmlwriter_end_element)
static PHP_FUNCTION (xmlwriter_full_end_element)
static PHP_FUNCTION (xmlwriter_start_element_ns)
static PHP_FUNCTION (xmlwriter_write_element)
static PHP_FUNCTION (xmlwriter_write_element_ns)
static PHP_FUNCTION (xmlwriter_start_pi)
static PHP_FUNCTION (xmlwriter_end_pi)
static PHP_FUNCTION (xmlwriter_write_pi)
static PHP_FUNCTION (xmlwriter_start_cdata)
static PHP_FUNCTION (xmlwriter_end_cdata)
static PHP_FUNCTION (xmlwriter_write_cdata)
static PHP_FUNCTION (xmlwriter_text)
static PHP_FUNCTION (xmlwriter_write_raw)
static PHP_FUNCTION (xmlwriter_start_document)
static PHP_FUNCTION (xmlwriter_end_document)
static PHP_FUNCTION (xmlwriter_write_comment)
static PHP_FUNCTION (xmlwriter_start_dtd)
static PHP_FUNCTION (xmlwriter_end_dtd)
static PHP_FUNCTION (xmlwriter_write_dtd)
static PHP_FUNCTION (xmlwriter_start_dtd_element)
static PHP_FUNCTION (xmlwriter_end_dtd_element)
static PHP_FUNCTION (xmlwriter_write_dtd_element)
static PHP_FUNCTION (xmlwriter_open_uri)
static PHP_FUNCTION (xmlwriter_open_memory)
static PHP_FUNCTION (xmlwriter_output_memory)
static PHP_FUNCTION (xmlwriter_flush)
static void xmlwriter_free_resource_ptr (xmlwriter_object *intern TSRMLS_DC)
static void xmlwriter_dtor (zend_rsrc_list_entry *rsrc TSRMLS_DC)
static PHP_MINIT_FUNCTION (xmlwriter)
static PHP_MSHUTDOWN_FUNCTION (xmlwriter)
static PHP_MINFO_FUNCTION (xmlwriter)
static char * _xmlwriter_get_valid_file_path (char *source, char *resolved_path, int resolved_path_len TSRMLS_DC)
static void * php_xmlwriter_streams_IO_open_write_wrapper (const char *filename TSRMLS_DC)
static int php_xmlwriter_streams_IO_write (void *context, const char *buffer, int len)
static int php_xmlwriter_streams_IO_close (void *context)
static void php_xmlwriter_string_arg (INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_one_char_t internal_function, char *err_string)
static void php_xmlwriter_end (INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t internal_function)
static void php_xmlwriter_flush (INTERNAL_FUNCTION_PARAMETERS, int force_string)

Variables

static zend_class_entry * xmlwriter_class_entry_ce
static const zend_function_entry xmlwriter_functions []
static int le_xmlwriter
zend_module_entry xmlwriter_module_entry

Define Documentation

#define XMLW_NAME_CHK (   __err)
Value:
if (xmlValidateName((xmlChar *) name, 0) != 0) { \
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", __err);      \
              RETURN_FALSE; \
       }      \

Definition at line 169 of file php_xmlwriter.c.


Typedef Documentation

typedef int(* xmlwriter_read_int_t)(xmlTextWriterPtr writer)

Definition at line 90 of file php_xmlwriter.c.

typedef int(* xmlwriter_read_one_char_t)(xmlTextWriterPtr writer, const xmlChar *content)

Definition at line 89 of file php_xmlwriter.c.


Function Documentation

static char* _xmlwriter_get_valid_file_path ( char *  source,
char *  resolved_path,
int resolved_path_len  TSRMLS_DC 
) [static]

Definition at line 604 of file php_xmlwriter.c.

                                                                                                                 {
       xmlURI *uri;
       xmlChar *escsource;
       char *file_dest;
       int isFileUri = 0;

       uri = xmlCreateURI();
       escsource = xmlURIEscapeStr((xmlChar *)source, (xmlChar *) ":");
       xmlParseURIReference(uri, (char *)escsource);
       xmlFree(escsource);

       if (uri->scheme != NULL) {
              /* absolute file uris - libxml only supports localhost or empty host */
              if (strncasecmp(source, "file:///", 8) == 0) {
                     if (source[sizeof("file:///") - 1] == '\0') {
                            return NULL;
                     }
                     isFileUri = 1;
#ifdef PHP_WIN32
                     source += 8;
#else
                     source += 7;
#endif
              } else if (strncasecmp(source, "file://localhost/",17) == 0) {
                     if (source[sizeof("file://localhost/") - 1] == '\0') {
                            return NULL;
                     }

                     isFileUri = 1;
#ifdef PHP_WIN32
                     source += 17;
#else
                     source += 16;
#endif
              }
       }

       if ((uri->scheme == NULL || isFileUri)) {
              char file_dirname[MAXPATHLEN];
              size_t dir_len;

              if (!VCWD_REALPATH(source, resolved_path) && !expand_filepath(source, resolved_path TSRMLS_CC)) {
                     xmlFreeURI(uri);
                     return NULL;
              }

              memcpy(file_dirname, source, strlen(source));
              dir_len = php_dirname(file_dirname, strlen(source));

              if (dir_len > 0) {
                     struct stat buf;
                     if (php_sys_stat(file_dirname, &buf) != 0) {
                            xmlFreeURI(uri);
                            return NULL;
                     }
              }

              file_dest = resolved_path;
       } else {
              file_dest = source;
       }

       xmlFreeURI(uri);

       return file_dest;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PHP_FUNCTION ( xmlwriter_start_attribute  ) [static]

Definition at line 870 of file php_xmlwriter.c.

{
       php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartAttribute, "Invalid Attribute Name");
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_attribute  ) [static]

Definition at line 878 of file php_xmlwriter.c.

{
       php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndAttribute);
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_attribute  ) [static]

Definition at line 931 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *content;
       int name_len, content_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind, 
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid Attribute Name");

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterWriteAttribute(ptr, (xmlChar *)name, (xmlChar *)content);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_element  ) [static]

Definition at line 1021 of file php_xmlwriter.c.

{
       php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartElement, "Invalid Element Name");
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_element  ) [static]

Definition at line 1073 of file php_xmlwriter.c.

{
       php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndElement);
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_full_end_element  ) [static]

Definition at line 1081 of file php_xmlwriter.c.

{
       php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterFullEndElement);
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_element_ns  ) [static]

Definition at line 1029 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *prefix, *uri;
       int name_len, prefix_len, uri_len, retval;
#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!",
                     &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!", &pind, 
                     &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid Element Name");

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterStartElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
              if (retval != -1) {
                     RETURN_TRUE;
              }
              
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_element  ) [static]

Definition at line 1089 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *content = NULL;
       int name_len, content_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind, 
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid Element Name");

       ptr = intern->ptr;

       if (ptr) {
              if (!content) {
                     retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
            if (retval == -1) {
                RETURN_FALSE;
            }
                     xmlTextWriterEndElement(ptr);
            if (retval == -1) {
                RETURN_FALSE;
            }
              } else {
                     retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
              }
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_element_ns  ) [static]

Definition at line 1144 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *prefix, *uri, *content = NULL;
       int name_len, prefix_len, uri_len, content_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!|s!", 
                     &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!|s!", &pind, 
                     &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid Element Name");

       ptr = intern->ptr;

       if (ptr) {
              if (!content) {
                     retval = xmlTextWriterStartElementNS(ptr,(xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
            if (retval == -1) {
                RETURN_FALSE;
            }
                     retval = xmlTextWriterEndElement(ptr);
            if (retval == -1) {
                RETURN_FALSE;
            }
              } else {
                     retval = xmlTextWriterWriteElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
              }
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_pi  ) [static]

Definition at line 1199 of file php_xmlwriter.c.

{
       php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartPI, "Invalid PI Target");
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_pi  ) [static]

Definition at line 1207 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_pi  ) [static]

Definition at line 1215 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *content;
       int name_len, content_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind, 
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid PI Target");

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterWritePI(ptr, (xmlChar *)name, (xmlChar *)content);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_cdata  ) [static]

Definition at line 1259 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       int retval;
#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterStartCDATA(ptr);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_cdata  ) [static]

Definition at line 1294 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_cdata  ) [static]

Definition at line 1302 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_text  ) [static]

Definition at line 1318 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_raw  ) [static]

Definition at line 1310 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_document  ) [static]

Definition at line 1380 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *version = NULL, *enc = NULL, *alone = NULL;
       int version_len, enc_len, alone_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();

       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterStartDocument(ptr, version, enc, alone);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_document  ) [static]

Definition at line 1420 of file php_xmlwriter.c.

{
       php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDocument);
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_comment  ) [static]

Definition at line 1372 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_dtd  ) [static]

Definition at line 1428 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *pubid = NULL, *sysid = NULL;
       int name_len, pubid_len, sysid_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();

       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
                     return;
              }

              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
                     return;
              }
       
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }
       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterStartDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_dtd  ) [static]

Definition at line 1469 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_dtd  ) [static]

Definition at line 1477 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *pubid = NULL, *sysid = NULL, *subset = NULL;
       int name_len, pubid_len, sysid_len, subset_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();

       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
                     return;
              }

              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
                     return;
              }
       
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterWriteDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)subset);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_start_dtd_element  ) [static]

Definition at line 1519 of file php_xmlwriter.c.

{
       php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartDTDElement, "Invalid Element Name");
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_end_dtd_element  ) [static]

Definition at line 1527 of file php_xmlwriter.c.

{
       php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDElement);
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_write_dtd_element  ) [static]

Definition at line 1535 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name, *content;
       int name_len, content_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();

       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind, 
                     &name, &name_len, &content, &content_len) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       XMLW_NAME_CHK("Invalid Element Name");

       ptr = intern->ptr;

       if (ptr) {
              retval = xmlTextWriterWriteDTDElement(ptr, (xmlChar *)name, (xmlChar *)content);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_open_uri  ) [static]

Definition at line 1743 of file php_xmlwriter.c.

{
       char *valid_file = NULL;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *source;
       char resolved_path[MAXPATHLEN + 1];
       int source_len;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       ze_xmlwriter_object *ze_obj = NULL;
#endif

#ifndef ZEND_ENGINE_2
       xmlOutputBufferPtr out_buffer;
       void *ioctx;
#endif

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
              return;
       }
       
#ifdef ZEND_ENGINE_2
       if (this) {
              /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
              ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC); 
       }
#endif

       if (source_len == 0) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source");
              RETURN_FALSE;
       }

       valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
       if (!valid_file) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to resolve file path");
              RETURN_FALSE;
       }

       /* TODO: Fix either the PHP stream or libxml APIs: it can then detect when a given 
               path is valid and not report out of memory error. Once it is done, remove the
               directory check in _xmlwriter_get_valid_file_path */
#ifndef ZEND_ENGINE_2
       ioctx = php_xmlwriter_streams_IO_open_write_wrapper(valid_file TSRMLS_CC);
       if (ioctx == NULL) {
              RETURN_FALSE;
       }

       out_buffer = xmlOutputBufferCreateIO(php_xmlwriter_streams_IO_write, 
              php_xmlwriter_streams_IO_close, ioctx, NULL);

       if (out_buffer == NULL) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
              RETURN_FALSE;
       }
       ptr = xmlNewTextWriter(out_buffer);
#else
       ptr = xmlNewTextWriterFilename(valid_file, 0);
#endif

       if (!ptr) {
              RETURN_FALSE;
       }

       intern = emalloc(sizeof(xmlwriter_object));
       intern->ptr = ptr;
       intern->output = NULL;
#ifndef ZEND_ENGINE_2
       intern->uri_output = out_buffer;
#else
       if (this) {
              if (ze_obj->xmlwriter_ptr) {
                     xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
              }
              ze_obj->xmlwriter_ptr = intern;
              RETURN_TRUE;
       } else
#endif
       {
              ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
       }
}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_open_memory  ) [static]

Definition at line 1831 of file php_xmlwriter.c.

{
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       xmlBufferPtr buffer;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       ze_xmlwriter_object *ze_obj = NULL;
#endif

#ifdef ZEND_ENGINE_2
       if (this) {
              /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
              ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC); 
       }
#endif

       buffer = xmlBufferCreate();

       if (buffer == NULL) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
              RETURN_FALSE;
       }

       ptr = xmlNewTextWriterMemory(buffer, 0);
       if (! ptr) {
              xmlBufferFree(buffer);
              RETURN_FALSE;
       }

       intern = emalloc(sizeof(xmlwriter_object));
       intern->ptr = ptr;
       intern->output = buffer;
#ifndef ZEND_ENGINE_2
       intern->uri_output = NULL;
#else
       if (this) {
              if (ze_obj->xmlwriter_ptr) {
                     xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
              }
              ze_obj->xmlwriter_ptr = intern;
              RETURN_TRUE;
       } else
#endif
       {
              ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
       }

}

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_output_memory  ) [static]

Definition at line 1935 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_FUNCTION ( xmlwriter_flush  ) [static]

Definition at line 1943 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_MINFO_FUNCTION ( xmlwriter  ) [static]

Definition at line 1980 of file php_xmlwriter.c.

Here is the call graph for this function:

static PHP_MINIT_FUNCTION ( xmlwriter  ) [static]

Definition at line 1951 of file php_xmlwriter.c.

{
#ifdef ZEND_ENGINE_2
       zend_class_entry ce;
#endif

       le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);

#ifdef ZEND_ENGINE_2
       memcpy(&xmlwriter_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
       xmlwriter_object_handlers.clone_obj      = NULL;
       INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
       ce.create_object = xmlwriter_object_new;
       xmlwriter_class_entry_ce = zend_register_internal_class(&ce TSRMLS_CC);
#endif
       return SUCCESS;
}

Here is the call graph for this function:

static PHP_MSHUTDOWN_FUNCTION ( xmlwriter  ) [static]

Definition at line 1972 of file php_xmlwriter.c.

{
       return SUCCESS;
}
static void php_xmlwriter_end ( INTERNAL_FUNCTION_PARAMETERS  ,
xmlwriter_read_int_t  internal_function 
) [static]

Definition at line 782 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       int retval;
#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              XMLWRITER_FROM_OBJECT(intern, this);
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
       } else 
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
                     return;
              }
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       ptr = intern->ptr;

       if (ptr) {
              retval = internal_function(ptr);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void php_xmlwriter_flush ( INTERNAL_FUNCTION_PARAMETERS  ,
int  force_string 
) [static]

Definition at line 1884 of file php_xmlwriter.c.

                                                                                {
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       xmlBufferPtr buffer;
       zend_bool empty = 1;
       int output_bytes;


#ifdef ZEND_ENGINE_2
       zval *this = getThis();

       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &empty) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &pind, &empty) == FAILURE) {
                     return;
              }

              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }
       ptr = intern->ptr;

       if (ptr) {
              buffer = intern->output;
              if (force_string == 1 && buffer == NULL) {
                     RETURN_EMPTY_STRING();
              }
              output_bytes = xmlTextWriterFlush(ptr);
              if (buffer) {
                     RETVAL_STRING((char *) buffer->content, 1);
                     if (empty) {
                            xmlBufferEmpty(buffer);
                     }
              } else {
                     RETVAL_LONG(output_bytes);
              }
              return;
       }
       
       RETURN_EMPTY_STRING();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int php_xmlwriter_streams_IO_close ( void *  context) [static]

Definition at line 696 of file php_xmlwriter.c.

{
       TSRMLS_FETCH();
       return php_stream_close((php_stream*)context);
}

Here is the caller graph for this function:

static void* php_xmlwriter_streams_IO_open_write_wrapper ( const char *filename  TSRMLS_DC) [static]

Definition at line 677 of file php_xmlwriter.c.

{
       php_stream_wrapper *wrapper = NULL;
       void *ret_val = NULL;

       ret_val = php_stream_open_wrapper_ex((char *)filename, "wb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, NULL);
       return ret_val;
}

Here is the caller graph for this function:

static int php_xmlwriter_streams_IO_write ( void *  context,
const char *  buffer,
int  len 
) [static]

Definition at line 688 of file php_xmlwriter.c.

{
       TSRMLS_FETCH();
       return php_stream_write((php_stream*)context, buffer, len);
}

Here is the caller graph for this function:

static void php_xmlwriter_string_arg ( INTERNAL_FUNCTION_PARAMETERS  ,
xmlwriter_read_one_char_t  internal_function,
char *  err_string 
) [static]

Definition at line 740 of file php_xmlwriter.c.

{
       zval *pind;
       xmlwriter_object *intern;
       xmlTextWriterPtr ptr;
       char *name;
       int name_len, retval;

#ifdef ZEND_ENGINE_2
       zval *this = getThis();
       
       if (this) {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
                     return;
              }
              XMLWRITER_FROM_OBJECT(intern, this);
       } else
#endif
       {
              if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
                     return;
              }
       
              ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
       }

       if (err_string != NULL) {
              XMLW_NAME_CHK(err_string);
       }

       ptr = intern->ptr;

       if (ptr) {
              retval = internal_function(ptr, (xmlChar *) name);
              if (retval != -1) {
                     RETURN_TRUE;
              }
       }
       
       RETURN_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void xmlwriter_dtor ( zend_rsrc_list_entry *rsrc  TSRMLS_DC) [static]

Definition at line 732 of file php_xmlwriter.c.

                                                                 {
       xmlwriter_object *intern;

       intern = (xmlwriter_object *) rsrc->ptr;
       xmlwriter_free_resource_ptr(intern TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void xmlwriter_free_resource_ptr ( xmlwriter_object *intern  TSRMLS_DC) [static]

Definition at line 93 of file php_xmlwriter.c.

{
       if (intern) {
              if (intern->ptr) {
                     xmlFreeTextWriter(intern->ptr);
                     intern->ptr = NULL;
              }
              if (intern->output) {
                     xmlBufferFree(intern->output);
                     intern->output = NULL;
              }
              efree(intern);
       }
}

Here is the caller graph for this function:


Variable Documentation

int le_xmlwriter [static]

Definition at line 598 of file php_xmlwriter.c.

zend_class_entry* xmlwriter_class_entry_ce [static]

Definition at line 84 of file php_xmlwriter.c.

Definition at line 480 of file php_xmlwriter.c.

zend_module_entry xmlwriter_module_entry
Initial value:
 {
       STANDARD_MODULE_HEADER,
       "xmlwriter",
       xmlwriter_functions,
       PHP_MINIT(xmlwriter),
       PHP_MSHUTDOWN(xmlwriter),
       NULL,
       NULL,
       PHP_MINFO(xmlwriter),
       "0.1",
       STANDARD_MODULE_PROPERTIES
}

Definition at line 706 of file php_xmlwriter.c.