# xml.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  $RCSfile: xml.h,v $
    00003  -------------------
    00004  cvs         : $Id: xml.h,v 1.35 2005/05/18 00:27:11 aquamaniac Exp $
    00005  begin       : Sat Jun 28 2003
    00006  copyright   : (C) 2003 by Martin Preuss
    00007  email       : martin@libchipcard.de
    00008
    00009  ***************************************************************************
    00010  *                                                                         *
    00011  *   This library is free software; you can redistribute it and/or         *
    00012  *   modify it under the terms of the GNU Lesser General Public            *
    00013  *   License as published by the Free Software Foundation; either          *
    00014  *   version 2.1 of the License, or (at your option) any later version.    *
    00015  *                                                                         *
    00016  *   This library is distributed in the hope that it will be useful,       *
    00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
    00019  *   Lesser General Public License for more details.                       *
    00020  *                                                                         *
    00021  *   You should have received a copy of the GNU Lesser General Public      *
    00022  *   License along with this library; if not, write to the Free Software   *
    00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
    00024  *   MA  02111-1307  USA                                                   *
    00025  *                                                                         *
    00026  ***************************************************************************/
    00027
    00028 #ifndef GWENHYWFAR_XML_H
    00029 #define GWENHYWFAR_XML_H
    00030
    00031 #include <gwenhywfar/gwenhywfarapi.h>
    00032 #include <gwenhywfar/bufferedio.h>
    00033 #include <gwenhywfar/stringlist.h>
    00034 #include <gwenhywfar/types.h>
    00035 #include <gwenhywfar/list2.h>
    00036 #include <stdio.h>
    00037
    00038 #ifdef __cplusplus
    00039 extern "C" {
    00040 #endif
    00041
    00047
    00052
    00053
    00057
    00061 #define GWEN_XML_FLAGS_READ_COMMENTS        0x0001
    00062
    00066 #define GWEN_XML_FLAGS_SHARE_TOPLEVEL       0x0002
    00067
    00072 #define GWEN_XML_FLAGS_INCLUDE_TO_TOPLEVEL  0x0004
    00073
    00079 #define GWEN_XML_FLAGS_IGNORE_INCLUDE       0x0008
    00080
    00084 #define GWEN_XML_FLAGS_WRITE_COMMENTS       0x0010
    00085
    00090 #define GWEN_XML_FLAGS_INDENT               0x0020
    00091
    00097 #define GWEN_XML_FLAGS_HANDLE_OPEN_HTMLTAGS 0x0040
    00098
    00103 #define GWEN_XML_FLAGS_NO_CONDENSE          0x0080
    00104
    00109 #define GWEN_XML_FLAGS_KEEP_CNTRL           0x0100
    00110
    00114 #define GWEN_XML_FLAGS_IGNORE_DESCR         0x0200
    00115
    00116 #define GWEN_XML_FLAGS_KEEP_BLANKS          0x0400
    00117
    00118 #define GWEN_XML_FLAGS_SIMPLE               0x0800
    00119
    00123 #define GWEN_XML_FLAGS_HANDLE_HEADERS       0x1000
    00124
    00128 #define GWEN_XML_FLAGS_DEFAULT \
    00129   (\
    00130   GWEN_XML_FLAGS_INDENT | \
    00131   GWEN_XML_FLAGS_WRITE_COMMENTS\
    00132   )
    00133
    00139 typedef enum {
    00142   GWEN_XMLNodeTypeTag=0,
    00144   GWEN_XMLNodeTypeData,
    00146   GWEN_XMLNodeTypeComment
    00147 } GWEN_XMLNODE_TYPE;
    00148
    00152 typedef struct GWEN__XMLNODE GWEN_XMLNODE;
    00153
    00154 GWEN_LIST2_FUNCTION_LIB_DEFS(GWEN_XMLNODE, GWEN_XMLNode, GWENHYWFAR_API);
    00155
    00156
    00157 typedef int
    00158     (*GWEN_XML_INCLUDE_FN)(GWEN_XMLNODE *n,
    00159                            const char *path,
    00160                            const char *file,
    00161                            GWEN_STRINGLIST *sl,
    00162                            GWEN_TYPE_UINT32 flags);
    00163
    00164
    00165
    00170 GWENHYWFAR_API
    00171 GWEN_XMLNODE *GWEN_XMLNode_new(GWEN_XMLNODE_TYPE t, const char *data);
    00172
    00176 GWENHYWFAR_API
    00177 void GWEN_XMLNode_free(GWEN_XMLNODE *n);
    00178
    00184 GWENHYWFAR_API
    00185 void GWEN_XMLNode_freeAll(GWEN_XMLNODE *n);
    00186
    00190 GWENHYWFAR_API
    00191 GWEN_XMLNODE *GWEN_XMLNode_dup(const GWEN_XMLNODE *n);
    00192
    00193 GWENHYWFAR_API
    00194   GWEN_XMLNODE *GWEN_XMLNode_fromString(const char *s,
    00195                                         int len,
    00196                                         GWEN_TYPE_UINT32 flags);
    00197
    00221
    00226 GWENHYWFAR_API
    00227 GWEN_XMLNODE *GWEN_XMLNode_GetHeader(const GWEN_XMLNODE *n);
    00228
    00232 GWENHYWFAR_API
    00233 void GWEN_XMLNode_AddHeader(GWEN_XMLNODE *root, GWEN_XMLNODE *nh);
    00234
    00239 GWENHYWFAR_API
    00240 void GWEN_XMLNode_DelHeader(GWEN_XMLNODE *root, GWEN_XMLNODE *nh);
    00241
    00246 GWENHYWFAR_API
    00247 void GWEN_XMLNode_ClearHeaders(GWEN_XMLNODE *root);
    00248
    00272 GWENHYWFAR_API
    00273   const char *GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n,
    00274                                        const char *name,
    00275                                        const char *defaultValue);
    00276
    00284 GWENHYWFAR_API
    00285   void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n,
    00286                                 const char *name,
    00287                                 const char *value);
    00288
    00298 GWENHYWFAR_API
    00299   void GWEN_XMLNode_CopyProperties(GWEN_XMLNODE *tn,
    00300                                    const GWEN_XMLNODE *sn,
    00301                                    int overwrite);
    00309 GWENHYWFAR_API
    00310 GWEN_XMLNODE_TYPE GWEN_XMLNode_GetType(const GWEN_XMLNODE *n);
    00311
    00313 GWENHYWFAR_API
    00314 const char *GWEN_XMLNode_GetData(const GWEN_XMLNODE *n);
    00315
    00318 GWENHYWFAR_API
    00319   void GWEN_XMLNode_SetData(GWEN_XMLNODE *n, const char *data);
    00337 GWENHYWFAR_API
    00338   void GWEN_XMLNode_IncUsage(GWEN_XMLNODE *n);
    00339
    00340 GWENHYWFAR_API
    00341   void GWEN_XMLNode_DecUsage(GWEN_XMLNODE *n);
    00342
    00343 GWENHYWFAR_API
    00344   GWEN_TYPE_UINT32 GWEN_XMLNode_GetUsage(const GWEN_XMLNODE *n);
    00361 GWENHYWFAR_API
    00362 GWEN_XMLNODE *GWEN_XMLNode_Next(const GWEN_XMLNODE *n);
    00363
    00371 GWENHYWFAR_API
    00372 GWEN_XMLNODE *GWEN_XMLNode_GetChild(const GWEN_XMLNODE *n);
    00373
    00376 GWENHYWFAR_API
    00377   GWEN_XMLNODE *GWEN_XMLNode_GetParent(const GWEN_XMLNODE *n);
    00378
    00387 GWENHYWFAR_API
    00388 GWEN_XMLNODE *GWEN_XMLNode_GetFirstTag(const GWEN_XMLNODE *n);
    00389
    00401 GWENHYWFAR_API
    00402 GWEN_XMLNODE *GWEN_XMLNode_GetNextTag(const GWEN_XMLNODE *n);
    00403
    00411 GWENHYWFAR_API
    00412 GWEN_XMLNODE *GWEN_XMLNode_GetFirstData(const GWEN_XMLNODE *n);
    00413
    00425 GWENHYWFAR_API
    00426 GWEN_XMLNODE *GWEN_XMLNode_GetNextData(const GWEN_XMLNODE *n);
    00427
    00453 GWENHYWFAR_API
    00454 GWEN_XMLNODE *GWEN_XMLNode_FindFirstTag(const GWEN_XMLNODE *n,
    00455                                         const char *tname,
    00456                                         const char *pname,
    00457                                         const char *pvalue);
    00458
    00464 GWENHYWFAR_API
    00465 GWEN_XMLNODE *GWEN_XMLNode_FindNextTag(const GWEN_XMLNODE *n,
    00466                                        const char *tname,
    00467                                        const char *pname,
    00468                                        const char *pvalue);
    00469
    00474 GWENHYWFAR_API
    00475 int GWEN_XMLNode_IsChildOf(const GWEN_XMLNODE *parent,
    00476                            const GWEN_XMLNODE *child);
    00477
    00478 GWENHYWFAR_API
    00479 int GWEN_XMLNode_GetXPath(const GWEN_XMLNODE *n1,
    00480                           const GWEN_XMLNODE *n2,
    00481                           GWEN_BUFFER *nbuf);
    00482
    00495 GWENHYWFAR_API
    00496 GWEN_XMLNODE *GWEN_XMLNode_GetNodeByXPath(GWEN_XMLNODE *n,
    00497                                           const char *path,
    00498                                           GWEN_TYPE_UINT32 flags);
    00499
    00500
    00508
    00517 GWENHYWFAR_API
    00518   void GWEN_XMLNode_AddChild(GWEN_XMLNODE *n, GWEN_XMLNODE *child);
    00519
    00527 GWENHYWFAR_API
    00528   void GWEN_XMLNode_UnlinkChild(GWEN_XMLNODE *n, GWEN_XMLNODE *child);
    00529
    00533 GWENHYWFAR_API
    00534   void GWEN_XMLNode_RemoveChildren(GWEN_XMLNODE *n);
    00535
    00546 GWENHYWFAR_API
    00547   void GWEN_XMLNode_AddChildrenOnly(GWEN_XMLNODE *n, GWEN_XMLNODE *nn,
    00548                                     int copythem);
    00549
    00555 GWENHYWFAR_API
    00556 GWEN_XMLNODE *GWEN_XMLNode_FindNode(const GWEN_XMLNODE *n,
    00557                                     GWEN_XMLNODE_TYPE t,
    00558                                     const char *data);
    00570 GWENHYWFAR_API
    00571 int GWEN_XML_Parse(GWEN_XMLNODE *n, GWEN_BUFFEREDIO *bio,
    00572                    GWEN_TYPE_UINT32 flags);
    00573
    00574
    00579 GWENHYWFAR_API
    00580 int GWEN_XMLNode_NormalizeNameSpaces(GWEN_XMLNODE *n);
    00581
    00582
    00587 GWENHYWFAR_API
    00588 int GWEN_XML_ReadFile(GWEN_XMLNODE *n, const char *filepath,
    00589                       GWEN_TYPE_UINT32 flags);
    00590
    00602 GWENHYWFAR_API
    00603   int GWEN_XML_ReadFileSearch(GWEN_XMLNODE *n, const char *filepath,
    00604                               GWEN_TYPE_UINT32 flags,
    00605                               GWEN_STRINGLIST *searchPath);
    00606
    00607
    00611 GWENHYWFAR_API
    00612 int GWEN_XMLNode_WriteToStream(const GWEN_XMLNODE *n,
    00613                                GWEN_BUFFEREDIO *bio,
    00614                                GWEN_TYPE_UINT32 flags);
    00615
    00619 GWENHYWFAR_API
    00620 int GWEN_XMLNode_WriteFile(const GWEN_XMLNODE *n,
    00621                            const char *fname,
    00622                            GWEN_TYPE_UINT32 flags);
    00623
    00648
    00654 GWENHYWFAR_API
    00655 const char *GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n,
    00656                                       const char *name,
    00657                                       const char *defValue);
    00658
    00659 GWENHYWFAR_API
    00660   void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n,
    00661                                  const char *name,
    00662                                  const char *value);
    00663
    00676 GWENHYWFAR_API
    00677 const char *GWEN_XMLNode_GetLocalizedCharValue(const GWEN_XMLNODE *n,
    00678                                                const char *name,
    00679                                                const char *defValue);
    00680
    00688 GWENHYWFAR_API
    00689 int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n,
    00690                              const char *name,
    00691                              int defValue);
    00692
    00693 GWENHYWFAR_API
    00694 void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n,
    00695                               const char *name,
    00696                               int value);
    00697
    00705
    00709 GWENHYWFAR_API
    00710 void GWEN_XMLNode_Dump(const GWEN_XMLNODE *n, FILE *f, int ind);
    00713  /* defgroup */
    00714
    00715
    00723
    00724 typedef struct GWEN_XMLNODE_PATH GWEN_XMLNODE_PATH;
    00725
    00726
    00727 GWENHYWFAR_API
    00728 GWEN_XMLNODE_PATH *GWEN_XMLNode_Path_new();
    00729 GWENHYWFAR_API
    00730 GWEN_XMLNODE_PATH *GWEN_XMLNode_Path_dup(const GWEN_XMLNODE_PATH *np);
    00731 GWENHYWFAR_API
    00732 void GWEN_XMLNode_Path_free(GWEN_XMLNODE_PATH *np);
    00733
    00737 GWENHYWFAR_API
    00738 int GWEN_XMLNode_Path_Dive(GWEN_XMLNODE_PATH *np,
    00739                            GWEN_XMLNODE *n);
    00740
    00745 GWENHYWFAR_API
    00746   GWEN_XMLNODE *GWEN_XMLNode_Path_Surface(GWEN_XMLNODE_PATH *np);
    00747
    00751 GWENHYWFAR_API
    00752 void GWEN_XMLNode_Path_Dump(GWEN_XMLNODE_PATH *np); /* defgroup */ /* defgroup (all)*/
    00755
    00756
    00757 #ifdef __cplusplus
    00758 }
    00759 #endif
    00760
    00761
    00762
    00763 #endif