nxml.h

Go to the documentation of this file.
00001 /* nXml - Copyright (C) 2005-2007 bakunin - Andrea Marchesini 
00002  *                                    <bakunin@autistici.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  * 
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 #ifndef __N_XML_H__
00020 #define __N_XML_H__
00021 
00022 #include <curl/curl.h>
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #include <fcntl.h>
00026 #include <unistd.h>
00027 #include <stdarg.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <errno.h>
00031 
00032 #define LIBNXML_VERSION_STRING  "0.18.3"
00033 
00034 #define LIBNXML_MAJOR_VERSION   0
00035 #define LIBNXML_MINOR_VERSION   18
00036 #define LIBNXML_MICRO_VERSION   3
00037 
00038 #ifdef  __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 typedef struct nxml_t nxml_t;
00043 typedef struct nxml_data_t nxml_data_t;
00044 typedef struct nxml_attr_t nxml_attr_t;
00045 typedef struct nxml_doctype_t nxml_doctype_t;
00046 typedef struct nxml_namespace_t nxml_namespace_t;
00047 
00048 typedef struct __nxml_private_t __nxml_private_t;
00049 typedef struct __nxml_entity_t __nxml_entity_t;
00050 
00051 /** This enum describes the error type of libnxml */
00052 typedef enum
00053 {
00054   NXML_OK = 0,                  /**< No error */
00055   NXML_ERR_POSIX,               /**< For the correct error, use errno */
00056   NXML_ERR_PARSER,              /**< Parser error */
00057   NXML_ERR_DOWNLOAD,            /**< Download error */
00058   NXML_ERR_DATA                 /**< The parameters are incorrect */
00059 } nxml_error_t;
00060 
00061 /** This enum describes the type of data element of libnxml */
00062 typedef enum
00063 {
00064   NXML_TYPE_TEXT,               /**< Text element */
00065   NXML_TYPE_COMMENT,            /**< Comment element */
00066   NXML_TYPE_ELEMENT,            /**< Data element */
00067   NXML_TYPE_PI,                 /**< PI element */
00068   NXML_TYPE_ELEMENT_CLOSE       /**< Data element - For internal use only */
00069 } nxml_type_t;
00070 
00071 /** This enum describes the supported XML version */
00072 typedef enum
00073 {
00074   NXML_VERSION_1_1,             /**< XML 1.1 */
00075   NXML_VERSION_1_0              /**< XML 1.0 */
00076 } nxml_version_t;
00077 
00078 /** This enum describes the CharSet of XML document */
00079 typedef enum 
00080 {
00081   NXML_CHARSET_UTF8,            /**< UTF8 chatset detected */
00082   NXML_CHARSET_UTF16LE,         /**< UTF 16 Little Endian detected */
00083   NXML_CHARSET_UTF16BE,         /**< UTF 16 Big Endian detected */
00084   NXML_CHARSET_UCS4_1234,       /**< UCS 4byte order 1234 detected */
00085   NXML_CHARSET_UCS4_4321,       /**< UCS 3byte order 4321 detected */
00086   NXML_CHARSET_UCS4_2143,       /**< UCS 3byte order 2143 detected */
00087   NXML_CHARSET_UCS4_3412,       /**< UCS 3byte order 3412 detected */
00088   NXML_CHARSET_UNKNOWN          /**< Unknown format */
00089 } nxml_charset_t;
00090 
00091 /** 
00092  * Data struct for any element of XML stream/files
00093  *
00094  * \brief
00095  * Data struct for any element of XML streams/files
00096  */
00097 struct nxml_data_t
00098 {
00099   nxml_type_t type;             /**< type of this nxml_data_t struct */
00100 
00101   char *value;                  /**< The value of this data struct */
00102 
00103   nxml_attr_t *attributes;      /**< List of attributes of this struct. 
00104                                  This list exists only if 
00105                                  type == NXML_TYPE_ELEMENT */
00106 
00107   nxml_namespace_t *ns;         /**< Pointer to the correct namespace */
00108   nxml_namespace_t *ns_list;    /**< The namespaces in this element */
00109 
00110   nxml_data_t *children;        /**< The children of this data struct */
00111   nxml_data_t *next;            /**< The next element */
00112 
00113   nxml_data_t *parent;          /**< The parent */
00114   nxml_t *doc;                  /**< The nxml_t */
00115 };
00116 
00117 /** 
00118  * Data struct for any element of attribute of xml element 
00119  *
00120  * \brief
00121  * Data struct for any element of attribute of xml element
00122  */
00123 struct nxml_attr_t
00124 {
00125   char *name;
00126   char *value;
00127 
00128   nxml_namespace_t *ns;
00129 
00130   nxml_attr_t *next;
00131 };
00132 
00133 /** 
00134  * Data struct for doctype elements
00135  *
00136  * \brief
00137  * Data struct for doctype elements
00138  */
00139 struct nxml_doctype_t
00140 {
00141   char *value;                  /**< The string no parsers */
00142   char *name;                   /**< The name of current doctype */
00143 
00144   nxml_t *doc;                  /**< The nxml_t */
00145   nxml_doctype_t *next;
00146 };
00147 
00148 /** 
00149  * Data struct for namespace
00150  *
00151  * \brief
00152  * Data struct for namespace
00153  */
00154 struct nxml_namespace_t
00155 {
00156   char *prefix;
00157   char *ns;
00158   nxml_namespace_t *next;
00159 };
00160 
00161 /** Data struct private about entities for internal use only
00162  *
00163  * \brief
00164  * Data struct private about entities for internal use only
00165  */
00166 struct __nxml_entity_t
00167 {
00168   char *name;
00169   char *entity;
00170 
00171   __nxml_entity_t *next;
00172 };
00173 
00174 /** Data struct private for internal use only
00175  *
00176  * \brief
00177  * Data struct private for internal use only
00178  */
00179 struct __nxml_private_t
00180 {
00181   void (*func) (char *, ...);
00182   int line;
00183   int timeout;
00184   char *proxy;
00185   char *proxy_authentication;
00186   char *cacert;
00187   char *certfile;
00188   char *password;
00189   int verifypeer;
00190   char *authentication;
00191   char *user_agent;
00192   char textindent;
00193 
00194   CURLcode curl_error;
00195 
00196   __nxml_entity_t *entities;
00197 };
00198 
00199 /** 
00200  * Principal data struct. It describes a XML document and it contains pointers
00201  * to any other structures.
00202  *
00203  * \brief 
00204  * Principal data struct. It describes a XML document and it contains pointers
00205  * to any other structures */
00206 struct nxml_t
00207 {
00208 
00209   char *file;   /**< XML document filename or url */
00210   size_t size;  /**< Size of XML document in byte */
00211 
00212   nxml_version_t version;       /**< XML document version */
00213   int standalone;               /**< This document is standalone ? */
00214   char *encoding;               /**< Encoding type */
00215 
00216   nxml_charset_t charset_detected;      /**< charset detected when the a
00217                                           XML document is parsed. The document
00218                                           will be convert to UTF-8 */
00219 
00220   nxml_data_t *data;    /**< The data of XML document */
00221   nxml_doctype_t *doctype; /**< The doctype of XML document */
00222 
00223   __nxml_private_t priv;  /**< For internal use only */
00224 };
00225 
00226 /* INIT FUNCTIONS ************************************************************/
00227 
00228 /**
00229  * This function creates a new nxml_t data struct.
00230  *
00231  * \param nxml Pointer to a nxml_t data struct. It will be allocated.
00232  * \return the error code
00233  */
00234 nxml_error_t    nxml_new                (nxml_t ** nxml);
00235 
00236 /** 
00237  * This function creates a new nxml_data_t child of a parent in the data 
00238  * struct. If parent is NULL the child will be created in the root level
00239  * of XML document.
00240  *
00241  * \param nxml Pointer to a nxml_t data struct.
00242  * \param parent The parent of new data struct child. If it is NULL, the
00243  * child is in the root level.
00244  * \param child It is the pointer to the new data struct. If *child is NULL,
00245  * it will be allocated, else it will be insert as it is.
00246  * \return the error code
00247  *
00248  * \code
00249  * nxml_data_t *data1, *data2;
00250  * data1=NULL;
00251  * nxml_add(nxml, NULL, &data1);
00252  *
00253  * data2=(nxml_data_t *)malloc(sizeof(nxml_data_t));
00254  * nxml_add(nxml, NULL, &data2);
00255  * \endcode
00256  */
00257 nxml_error_t    nxml_add                (nxml_t * nxml,
00258                                          nxml_data_t *parent,
00259                                          nxml_data_t **child);
00260 
00261 /** 
00262  * This function removes a nxml_data_t child from a parent in the data 
00263  * struct. If parent is NULL the child will be removed in the root level of
00264  * XML document. This function doesn't free the child. If you want you can
00265  * reinsert the child in another parent tree or use the nxml_free_data 
00266  * function.
00267  *
00268  * \param nxml Pointer to a nxml_t data struct.
00269  * \param parent The parent of data struct child. If it is NULL, the
00270  * child will be searched in the root level.
00271  * \param child It is the pointer to the child that you want remove
00272  * \return the error code
00273  */
00274 nxml_error_t    nxml_remove             (nxml_t * nxml,
00275                                          nxml_data_t *parent,
00276                                          nxml_data_t *child);
00277 
00278 /** 
00279  * This function creates a new nxml_attr_t data of a element in the data 
00280  * struct.
00281  *
00282  * \param nxml Pointer to a nxml_t data struct.
00283  * \param element The element of the new data struct attribute.
00284  * \param attribute The pointer to the your data struct. If it is NULL it will
00285  * be allocated, else no.
00286  * \return the error code
00287  */
00288 nxml_error_t    nxml_add_attribute      (nxml_t *nxml,
00289                                          nxml_data_t *element,
00290                                          nxml_attr_t **attribute);
00291 
00292 /**
00293  * This function removes a nxml_attr_t data of a element. It does not free it
00294  * so you can reinsert o free it with nxml_free_attribute.
00295  *
00296  * \param nxml Pointer to a nxml_t data struct.
00297  * \param element The element that contains the attribute
00298  * \param attribute The attribute that you want remove.
00299  * \return the error code
00300  */
00301 nxml_error_t    nxml_remove_attribute   (nxml_t *nxml,
00302                                          nxml_data_t *element,
00303                                          nxml_attr_t *attribute);
00304 
00305 /**
00306  * This function adds a nxml_namespace_t data in a nxml document.
00307  *
00308  * \param nxml Pointer to a nxml_t data struct.
00309  * \param element The element of the new data struct namespace.
00310  * \param ns The namespace that you want add
00311  * \return the error code
00312  */
00313 nxml_error_t    nxml_add_namespace      (nxml_t *nxml,
00314                                          nxml_data_t *element,
00315                                          nxml_namespace_t **ns);
00316 
00317 /**
00318  * This function removes a nxml_namespace_t data from a nxml document.
00319  *
00320  * \param nxml Pointer to a nxml_t data struct.
00321  * \param element The element of the new data struct namespace.
00322  * \param ns The namespace that you want remove
00323  * \return the error code
00324  */
00325 nxml_error_t    nxml_remove_namespace   (nxml_t *nxml,
00326                                          nxml_data_t *element,
00327                                          nxml_namespace_t *ns);
00328 
00329 /**
00330  * This function sets the output function. If you set your function, the
00331  * parser'll write the error by this function. As default there is not a
00332  * function. If you want tou can set 'nxml_print_general' function that
00333  * print to stderr.
00334  *
00335  * \param nxml The struct create with nxml_new.
00336  * \param func Your function. If you don't want the function, set it to NULL.
00337  * As default a nxml_t element has not a output function.
00338  * \return the error code
00339  */
00340 nxml_error_t    nxml_set_func           (nxml_t * nxml,
00341                                          void (*func) (char *, ...));
00342 
00343 void            nxml_print_generic      (char *, ...);
00344 
00345 /**
00346  * This function sets the timeout in seconds for the download of a remote
00347  *  XML document. Default is 0 and 0 is no timeout.
00348  *  
00349  * \param nxml The struct create with nxml_new.
00350  * \param seconds the timeout in seconds
00351  * \return the error code
00352  */
00353 nxml_error_t    nxml_set_timeout        (nxml_t * nxml,
00354                                          int seconds);
00355 
00356 /**
00357  * This functions sets a proxy server for the downloading procedure.
00358  *  
00359  * \param nxml The struct create with nxml_new.
00360  * \param proxy the proxy as a string
00361  * \param userpwd the user and password in this format user:password
00362  * \return the error code
00363  */
00364 nxml_error_t    nxml_set_proxy          (nxml_t * nxml,
00365                                          char *proxy,
00366                                          char *userpwd);
00367 
00368 /**
00369  * This functions sets a user/password for a for the download procedure.
00370  *  
00371  * \param nxml The struct create with nxml_new.
00372  * \param userpwd the user and password in this format user:password
00373  * \return the error code
00374  */
00375 nxml_error_t    nxml_set_authentication (nxml_t * nxml,
00376                                          char *userpwd);
00377 
00378 /**
00379  * This functions sets an user agent for a for the download procedure.
00380  *  
00381  * \param nxml The struct create with nxml_new.
00382  * \param user_agent The agent
00383  * \return the error code
00384  */
00385 nxml_error_t    nxml_set_user_agent     (nxml_t * nxml,
00386                                          char *user_agent);
00387 
00388 /**
00389  * This functions sets a certificate in the http request. You can set a
00390  * certificate file and a password.
00391  *  
00392  * \param nxml The struct create with nxml_new.
00393  * \param certfile the certfile for the ssl connection (can be NULL)
00394  * \param password the password of your certifcate (can be NULL)
00395  * \param cacert the CA certificate to verify peer against (can be NULL)
00396  * \param verifypeer active/deactive the peer validation
00397  * \return the error code
00398  */
00399 nxml_error_t    nxml_set_certificate    (nxml_t * nxml,
00400                                          char *certfile,
00401                                          char *password,
00402                                          char *cacert,
00403                                          int verifypeer);
00404 
00405 
00406 /**
00407  * This function (de)actives the indent of the TEXT elements. Default it is
00408  * activated.
00409  *
00410  * \param nxml The struct create with nxml_new
00411  * \param textindent If it is != 0, the indent will be activated
00412  * \return the error code
00413  */
00414 nxml_error_t    nxml_set_textindent     (nxml_t *nxml,
00415                                          char textindent);
00416 
00417 /* DOWNLOAD *****************************************************************/
00418 
00419 /**
00420  * This function downloads a stream from a http/https/ftp server.
00421  *  
00422  * \param nxml The struct create with nxml_new.
00423  * \param url the http file
00424  * \param buffer a string for the buffer
00425  * \param size The function sets here the length of the file if it's not NULL.
00426  * \return a buffer or NULL
00427  */
00428 nxml_error_t    nxml_download_file      (nxml_t *nxml,
00429                                          char *url,
00430                                          char ** buffer,
00431                                          size_t *size);
00432 
00433 /* PARSER FUNCTIONS *********************************************************/
00434 
00435 /**
00436  * This function parses a url. It downloads a url with curl library and
00437  * parses it.
00438  *
00439  * \param nxml the struct create with nxml_new.
00440  * \param url the url that you want parse.
00441  * \return the error code
00442  */
00443 nxml_error_t    nxml_parse_url          (nxml_t * nxml,
00444                                          char *url);
00445 
00446 /** 
00447  * This function parses a file.
00448  *
00449  * \param nxml the struct create with nxml_new.
00450  * \param file the file that you want parse.
00451  * \return the error code
00452  */
00453 nxml_error_t    nxml_parse_file         (nxml_t * nxml,
00454                                          char *file);
00455 
00456 /** 
00457  * This function parses a buffer in memory.
00458  *
00459  * \param nxml the struct create with nxml_new.
00460  * \param buffer the buffer that you want parse.
00461  * \param size the size of buffer. If size is 0, the function checks the 
00462  * length of your buffer searching a '\\0'.
00463  * \return the error code
00464  */
00465 nxml_error_t    nxml_parse_buffer       (nxml_t * nxml,
00466                                          char *buffer,
00467                                          size_t size);
00468 
00469 /* WRITE FUNCTIONS **********************************************************/
00470 
00471 /**
00472  * This function writes the data struct in a local file.
00473  *
00474  * \param nxml the nxml data strut
00475  * \param file the local file
00476  * \return the error code
00477  */
00478 nxml_error_t    nxml_write_file         (nxml_t *nxml,
00479                                          char *file);
00480 
00481 /**
00482  * This function writes the data struct in a buffer.
00483  *
00484  * \code
00485  * char *buffer;
00486  * buffer=NULL; // This is important!
00487  * nxml_write_buffer(nxml, &buffer);
00488  * \endcode
00489  *
00490  * The buffer must be NULL.
00491  *
00492  * \param nxml
00493  * \param buffer the memory buffer
00494  * \return the error code
00495  */
00496 nxml_error_t    nxml_write_buffer       (nxml_t *nxml,
00497                                          char **buffer);
00498 
00499 /* FREE FUNCTIONS ************************************************************/
00500 
00501 /**
00502  * This function removes the data in a structure nxml_t and makes it clean for
00503  * another usage.
00504  *
00505  * \param nxml the pointer to you data struct.
00506  * \return the error code.
00507  */
00508 nxml_error_t    nxml_empty              (nxml_t * nxml);
00509 
00510 /** 
00511  * This function frees the memory of a nxml_t *element. After the free,
00512  * your data struct is not useful. If you want erase the internal data, use
00513  * nxml_empty function
00514  *
00515  * \param nxml the pointer to your data struct.
00516  * \return the error code.
00517  */
00518 nxml_error_t    nxml_free               (nxml_t * nxml);
00519 
00520 /**
00521  * This function frees the memory of a nxml_data_t *element and any its
00522  * children and its attributes.
00523  *
00524  * \param data the pointer to you data struct.
00525  * \return the error code
00526  */
00527 nxml_error_t    nxml_free_data          (nxml_data_t *data);
00528 
00529 /**
00530  * This function frees the memory of a nxml_attr_t *element.
00531  *
00532  * \param data the pointer to you data struct.
00533  * \return the error code
00534  */
00535 nxml_error_t    nxml_free_attribute     (nxml_attr_t *data);
00536 
00537 /**
00538  * This function frees the memory of a nxml_namespace_t *element.
00539  *
00540  * \param data the pointer to you data struct.
00541  * \return the error code
00542  */
00543 nxml_error_t    nxml_free_namespace     (nxml_namespace_t *data);
00544 
00545 /* EDIT FUNCTIONS ***********************************************************/
00546 
00547 /**
00548  * This function returns the root element of xml data struct.
00549  *
00550  * \code
00551  * nxml_t *nxml;
00552  * nxml_data_t *root;
00553  *
00554  * nxml_new(&nxml);
00555  * nxml_parser_file(nxml, "file.xml");
00556  * nxml_root_element(nxml, &root);
00557  * printf("%p\n",root);
00558  * nxml_free(nxml);
00559  * \endcode
00560  *
00561  * \param nxml the data struct
00562  * \param element the pointer to your nxml_data_t struct
00563  * \return the error code
00564  */
00565 nxml_error_t    nxml_root_element       (nxml_t *nxml,
00566                                          nxml_data_t **element);
00567 
00568 /**
00569  * This function searchs the request element in the children of the data struct.
00570  *
00571  * \code
00572  * nxml_t *nxml;
00573  * nxml_data_t *root;
00574  *
00575  * nxml_new(&nxml);
00576  * nxml_parser_file(nxml, "file.xml");
00577  * nxml_find_element(nxml, NULL, "hello_world", &root);
00578  * printf("%p\n",root);
00579  * nxml_free(nxml);
00580  * \endcode
00581  *
00582  * \param nxml the data struct
00583  * \param parent the data struct nxml_data_t of parent. If it is NULL, this 
00584  * function searchs in the root element level.
00585  * \param name the name of the node that you want.
00586  * \param element the pointer to your nxml_data_t struct. If element will be
00587  * NULL, the item that you want does not exist.
00588  * \return the error code
00589  */
00590 nxml_error_t    nxml_find_element       (nxml_t *nxml,
00591                                          nxml_data_t *parent,
00592                                          char *name, 
00593                                          nxml_data_t **element);
00594 
00595 /**
00596  * This function searchs the first doctype element in the nxml_t document.
00597  *
00598  * \param nxml the data struct
00599  * \param doctype the pointer to your nxml_doctype_t struct. If element will be
00600  * NULL, the item that you want does not exist.
00601  * \return the error code
00602  */
00603 nxml_error_t    nxml_doctype_element    (nxml_t *nxml,
00604                                          nxml_doctype_t **doctype);
00605 
00606 /**
00607  * This function searchs the request attribute and returns its values.
00608  *
00609  * \code
00610  * nxml_t *nxml;
00611  * nxml_data_t *root;
00612  *
00613  * nxml_new(&nxml);
00614  * nxml_parser_file(nxml, "file.xml");
00615  * nxml_find_element(nxml, NULL, "hello_world", &root);
00616  * if(root) {
00617  *   nxml_attr_t *attribute=NULL;
00618  *   nxml_find_attribute(root, "attribute", &attribute);
00619  *
00620  *   if(attribute)
00621  *     printf("%s\n",attribute->value);
00622  * }
00623  * nxml_free(nxml);
00624  * \endcode
00625  *
00626  * \param data the data struct
00627  * \param name the attribute that you want search
00628  * \param attribute the pointer to your nxml_attr_t struct. If attribute will
00629  * be NULL, the attribute that you want does not exist.
00630  * does not exist.
00631  * \return the error code
00632  */
00633 nxml_error_t    nxml_find_attribute     (nxml_data_t *data,
00634                                          char *name, 
00635                                          nxml_attr_t **attribute);
00636 
00637 /**
00638  * This function searchs the request namespaceibute and returns its values.
00639  *
00640  * \param data the data struct
00641  * \param name the namespace that you want search
00642  * \param ns the pointer to your nxml_attr_t struct. If namespace will
00643  * be NULL, the namespace that you want does not exist.
00644  * does not exist.
00645  * \return the error code
00646  */
00647 nxml_error_t    nxml_find_namespace     (nxml_data_t *data,
00648                                          char *name, 
00649                                          nxml_namespace_t **ns);
00650 
00651 /**
00652  * This function returns the string of a XML element.
00653  * \code
00654  * nxml_t *nxml;
00655  * nxml_data_t *root;
00656  * char *str;
00657  *
00658  * nxml_new(&nxml);
00659  * nxml_parser_file(nxml, "file.xml");
00660  * nxml_find_element(nxml, NULL, "hello_world", &root);
00661  * if(root) {
00662  *   nxml_get_string(root, &str);
00663  *   if(str) {
00664  *     printf("Hello_world item contains: %s\n",str);
00665  *     free(str);
00666  *   }
00667  * }
00668  * nxml_free(nxml);
00669  * \endcode
00670  *
00671  * \param element the xnml_data_t pointer
00672  * \param string the pointer to you char *. You must free it after usage.
00673  * \return the error code
00674  */
00675 nxml_error_t    nxml_get_string         (nxml_data_t *element,
00676                                          char **string);
00677 
00678 /* ERROR FUNCTIONS **********************************************************/
00679 
00680 /**
00681  * This function returns a static string with the description of error code
00682  *
00683  * \param nxml the pointer to data struct
00684  * \param err the error code that you need as string
00685  * \return a string. Don't free this string!
00686  */
00687 char *          nxml_strerror           (nxml_t * nxml,
00688                                          nxml_error_t err);
00689 
00690 /**
00691  * This function returns the CURLcode error if there was a problem about the
00692  * downloading procedure:
00693  *
00694  * \param nxml the pointer to data struct
00695  * \param err the error code that you need as string
00696  * \return the CURLcode
00697  */
00698 CURLcode        nxml_curl_error         (nxml_t * nxml,
00699                                          nxml_error_t err);
00700 
00701 /**
00702  * This function return the line of a error of parse.
00703  *
00704  * \param nxml the pointer to data struct
00705  * \param line pointer to your integer. In this pointer will be set the line.
00706  * \return the error code
00707  */
00708 nxml_error_t    nxml_line_error         (nxml_t * nxml,
00709                                          int *line);
00710 
00711 /* EASY FUNCTIONS ***********************************************************/
00712 
00713 /**
00714  * This function returns a new nxml_t data.
00715  *
00716  * \param err If err is not NULL, err will be set to the error flag.
00717  * \return the pointer to a new nxml_t data. If it returns NULL, read the err
00718  * code. This function use nxml_set_func with nxml_print_generic so the
00719  * error will be write in the standard output.
00720  */
00721 nxml_t *        nxmle_new_data          (nxml_error_t *err);
00722 
00723 /**
00724  * This function returns a new nxml_t data and parses a remote url document
00725  * from http or ftp protocol. This function use nxml_set_func with 
00726  * nxml_print_generic so the error will be write in the standard output.
00727  *
00728  * \param url the url that you want parse.
00729  * \param err If err is not NULL, err will be set to the error flag.
00730  * \return the pointer to a new nxml_t data.
00731  */
00732 nxml_t *        nxmle_new_data_from_url (char *url,
00733                                          nxml_error_t *err);
00734 
00735 /**
00736  * This function returns a new nxml_t data and parses a local file. This 
00737  * function use nxml_set_func with nxml_print_generic so the error will be
00738  * write in the standard output.
00739  *
00740  * \param file the file that you want parse.
00741  * \param err If err is not NULL, err will be set to the error flag.
00742  * \return the pointer to a new nxml_t data.
00743  */
00744 nxml_t *        nxmle_new_data_from_file
00745                                         (char *file,
00746                                          nxml_error_t *err);
00747 
00748 /**
00749  * This function returns a new nxml_t data and parses a buffer. This
00750  * function use nxml_set_func with nxml_print_generic so the error will be
00751  * write in the standard output.
00752  *
00753  * \param buffer the buffer that you want parse.
00754  * \param size the size of buffer. If size is 0, the function checks the 
00755  * \param err If err is not NULL, err will be set to the error flag.
00756  * \return the pointer to a new nxml_t data.
00757  */
00758 nxml_t *        nxmle_new_data_from_buffer
00759                                         (char *buffer,
00760                                          size_t size,
00761                                          nxml_error_t *err);
00762 
00763 /**
00764  * This function creates and adds a child nxml_data_t to a parent in your 
00765  * nxml data struct.
00766  *
00767  * \param nxml Pointer to your nxml data.
00768  * \param parent The parent of new data struct child. If it is NULL, the
00769  * child is in the root level.
00770  * \param err If err is not NULL, err will be set to the error flag.
00771  * \return the pointer to a new nxml_data_t data child.
00772  */
00773 nxml_data_t *   nxmle_add_new           (nxml_t * nxml,
00774                                          nxml_data_t *parent,
00775                                          nxml_error_t *err);
00776 
00777 /**
00778  * This function adds a your nxml_data_t to a parent in your nxml
00779  * data struct.
00780  *
00781  * \param nxml Pointer to your nxml data.
00782  * \param parent The parent of new data struct child. If it is NULL, the
00783  * child is in the root level.
00784  * \param child The you child nxml_data_t struct that you want insert.
00785  * \param err If err is not NULL, err will be set to the error flag.
00786  * \return the pointer to a new nxml_data_t data child.
00787  */
00788 nxml_data_t *   nxmle_add_data          (nxml_t * nxml,
00789                                          nxml_data_t *parent,
00790                                          nxml_data_t *child,
00791                                          nxml_error_t *err);
00792 
00793 /**
00794  * This function creates and adds an attribute nxml_attr_t data to a
00795  * nxml_data_t struct in your nxml data struct.
00796  *
00797  * \param nxml Pointer to your nxml data.
00798  * \param element The parent of new nxml_attr_t struct.
00799  * \param err If err is not NULL, err will be set to the error flag.
00800  * \return the pointer to a new nxml_data_t data child.
00801  */
00802 nxml_attr_t *   nxmle_add_attribute_new (nxml_t *nxml,
00803                                          nxml_data_t *element,
00804                                          nxml_error_t *err);
00805 
00806 /**
00807  * This function adds an attribute nxml_attr_t data to a
00808  * nxml_data_t struct in your nxml data struct.
00809  *
00810  * \param nxml Pointer to your nxml data.
00811  * \param element The parent of your nxml_attr_t struct.
00812  * \param attribute Your attribute element.
00813  * \param err If err is not NULL, err will be set to the error flag.
00814  * \return the pointer to a new nxml_data_t data child.
00815  */
00816 nxml_attr_t *   nxmle_add_attribute_data
00817                                         (nxml_t *nxml,
00818                                          nxml_data_t *element,
00819                                          nxml_attr_t *attribute,
00820                                          nxml_error_t *err);
00821 
00822 /**
00823  * This function creates and adds a namespace nxml_namespace_t data to a
00824  * nxml data struct.
00825  *
00826  * \param nxml Pointer to your nxml data.
00827  * \param element The element of in witch you want add the namespace.
00828  * \param err If err is not NULL, err will be set to the error flag.
00829  * \return the pointer to a new nxml_data_t data child.
00830  */
00831 nxml_namespace_t * nxmle_add_namespace_new
00832                                         (nxml_t *nxml,
00833                                          nxml_data_t *element,
00834                                          nxml_error_t *err);
00835 
00836 /**
00837  * This function adds an namespace nxml_namespace-t data to a nxml data struct.
00838  *
00839  * \param nxml Pointer to your nxml data.
00840  * \param element The element of in witch you want add the namespace.
00841  * \param ns Your namespace element.
00842  * \param err If err is not NULL, err will be set to the error flag.
00843  * \return the pointer to a new nxml_data_t data child.
00844  */
00845 nxml_namespace_t * nxmle_add_namespace_data
00846                                         (nxml_t *nxml,
00847                                          nxml_data_t *element,
00848                                          nxml_namespace_t *ns,
00849                                          nxml_error_t *err);
00850 
00851 /**
00852  * This function returns the root element of a nxml_t.
00853  *
00854  * \param nxml Pointer to your nxml data.
00855  * \param err If err is not NULL, err will be set to the error flag.
00856  * \return the pointer to the root element. If NULL the element does not
00857  * exist.
00858  */
00859 nxml_data_t *   nxmle_root_element      (nxml_t *nxml,
00860                                          nxml_error_t *err);
00861 
00862 /**
00863  * This function returns the first doctype element of a nxml_t.
00864  *
00865  * \param nxml Pointer to your nxml data.
00866  * \param err If err is not NULL, err will be set to the error flag.
00867  * \return the pointer to the doctype element. If NULL the element does not
00868  * exist.
00869  */
00870 nxml_doctype_t *nxmle_doctype_element   (nxml_t *nxml,
00871                                          nxml_error_t *err);
00872 
00873 /**
00874  * This function returns the nxml_data_t pointer to a element by
00875  * a name.
00876  *
00877  * \param nxml Pointer to your nxml data.
00878  * \param parent Pointer to your nxml_data_t parent. If it is NULL, this
00879  * function searchs in a root element level.
00880  * \param name The name of element that you want.
00881  * \param err If err is not NULL, err will be set to the error flag.
00882  * \return the pointer to the root element. If NULL the element does not
00883  * exist.
00884  */
00885 nxml_data_t *   nxmle_find_element      (nxml_t *nxml,
00886                                          nxml_data_t *parent,
00887                                          char *name,
00888                                          nxml_error_t *err);
00889 
00890 /**
00891  * This function returns the value of a attribute by a name.
00892  *
00893  * \param element Pointer to your nxml_data_t.
00894  * \param name The name of attribute that you want.
00895  * \param err If err is not NULL, err will be set to the error flag.
00896  * \return a pointer to a char allocated so you must free it after usage. If
00897  * it is NULL, the attribute does not exist.
00898  */
00899 char *          nxmle_find_attribute    (nxml_data_t *element,
00900                                          char *name,
00901                                          nxml_error_t *err);
00902 
00903 /**
00904  * This function returns the value of a namespace by a name.
00905  *
00906  * \param element Pointer to your nxml_data_t.
00907  * \param name The name of namespace that you want.
00908  * \param err If err is not NULL, err will be set to the error flag.
00909  * \return a pointer to a char allocated so you must free it after usage. If
00910  * it is NULL, the namespace does not exist.
00911  */
00912 char *          nxmle_find_namespace    (nxml_data_t *element,
00913                                          char *name,
00914                                          nxml_error_t *err);
00915 
00916 /**
00917  * This function returns the contain of a element.
00918  *
00919  * \param element Pointer to your nxml_data_t.
00920  * \param err If err is not NULL, err will be set to the error flag.
00921  * \return a pointer to a char allocated so you must free it after usage. If
00922  * it is NULL, the attribute does not exist.
00923  */
00924 char *          nxmle_get_string        (nxml_data_t *element,
00925                                          nxml_error_t *err);
00926 
00927 /**
00928  * This function writes the data struct in a buffer.
00929  *
00930  * \param nxml
00931  * \param err If err is not NULL, err will be set to the error flag.
00932  * \return a pointer to a char allocated so you must free it after usage.
00933  */
00934 char *          nxmle_write_buffer      (nxml_t *nxml, nxml_error_t *err);
00935 
00936 /**
00937  * This function return the line of a error of parse.
00938  * \param nxml the pointer to data struct
00939  * \param err If err is not NULL, err will be set to the error flag.
00940  * \return the line with the error.
00941  */
00942 int             nxmle_line_error        (nxml_t * nxml, nxml_error_t *err);
00943 
00944 /* Easy functions defined: */
00945 #define         nxmle_remove            nxml_remove
00946 #define         nxmle_remove_attribute  nxml_remove_attribute
00947 #define         nxmle_remove_namespace  nxml_remove_namespace
00948 #define         nxmle_write_file        nxml_write_file
00949 
00950 #define         nxmle_empty             nxml_empty
00951 #define         nxmle_free              nxml_free
00952 #define         nxmle_free_data         nxml_free_data
00953 #define         nxmle_free_attribute    nxml_free_attribute
00954 
00955 #define         nxmle_strerror          nxml_strerror
00956 
00957 #ifdef NXML_INTERNAL
00958 #  include "nxml_internal.h"
00959 #endif
00960 
00961 #ifdef  __cplusplus
00962 }
00963 #endif
00964 
00965 #endif
00966 
00967 /* EOF */

Generated on Thu Aug 21 23:58:23 2008 for libnxml by  doxygen 1.5.5