Annotation of embedaddon/php/ext/xmlrpc/libxmlrpc/xml_element.h, revision 1.1
1.1 ! misho 1: /*
! 2: This file is part of libXMLRPC - a C library for xml-encoded function calls.
! 3:
! 4: Author: Dan Libby (dan@libby.com)
! 5: Epinions.com may be contacted at feedback@epinions-inc.com
! 6: */
! 7:
! 8: /*
! 9: Copyright 2000 Epinions, Inc.
! 10:
! 11: Subject to the following 3 conditions, Epinions, Inc. permits you, free
! 12: of charge, to (a) use, copy, distribute, modify, perform and display this
! 13: software and associated documentation files (the "Software"), and (b)
! 14: permit others to whom the Software is furnished to do so as well.
! 15:
! 16: 1) The above copyright notice and this permission notice shall be included
! 17: without modification in all copies or substantial portions of the
! 18: Software.
! 19:
! 20: 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF
! 21: ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY
! 22: IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR
! 23: PURPOSE OR NONINFRINGEMENT.
! 24:
! 25: 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
! 26: SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
! 27: OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING
! 28: NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH
! 29: DAMAGES.
! 30:
! 31: */
! 32:
! 33: #ifndef __XML_ELEMENT_H__
! 34: #define __XML_ELEMENT_H__
! 35:
! 36: /* includes */
! 37: #include <stdio.h>
! 38: #include "queue.h"
! 39: #include "simplestring.h"
! 40: #include "encodings.h"
! 41:
! 42: #ifdef __cplusplus
! 43: extern "C" {
! 44: #endif
! 45:
! 46: /****d* enum/XML_ELEM_VERBOSITY
! 47: * NAME
! 48: * XML_ELEM_VERBOSITY
! 49: * NOTES
! 50: * verbosity/readability options for generated xml
! 51: * SEE ALSO
! 52: * XML_ELEM_OUTPUT_OPTIONS
! 53: * SOURCE
! 54: */
! 55: typedef enum _xml_elem_verbosity {
! 56: xml_elem_no_white_space, /* compact xml with no white space */
! 57: xml_elem_newlines_only, /* add newlines for enhanced readability */
! 58: xml_elem_pretty /* add newlines and indent accordint to depth */
! 59: } XML_ELEM_VERBOSITY;
! 60: /******/
! 61:
! 62:
! 63: /****d* enum/XML_ELEM_ESCAPING
! 64: * NAME
! 65: * XML_ELEM_ESCAPING
! 66: * NOTES
! 67: * xml escaping options for generated xml
! 68: * SEE ALSO
! 69: * XML_ELEM_OUTPUT_OPTIONS
! 70: * SOURCE
! 71: */
! 72: typedef enum _xml_elem_escaping {
! 73: xml_elem_no_escaping = 0x000,
! 74: xml_elem_markup_escaping = 0x002, /* entity escape xml special chars */
! 75: xml_elem_non_ascii_escaping = 0x008, /* entity escape chars above 127 */
! 76: xml_elem_non_print_escaping = 0x010, /* entity escape non print (illegal) chars */
! 77: xml_elem_cdata_escaping = 0x020, /* wrap in cdata section */
! 78: } XML_ELEM_ESCAPING;
! 79: /******/
! 80:
! 81:
! 82: /****s* struct/XML_ELEM_OUTPUT_OPTIONS
! 83: * NAME
! 84: * XML_ELEM_OUTPUT_OPTIONS
! 85: * NOTES
! 86: * defines various output options
! 87: * SOURCE
! 88: */
! 89: typedef struct _xml_output_options {
! 90: XML_ELEM_VERBOSITY verbosity; /* length/verbosity of xml */
! 91: XML_ELEM_ESCAPING escaping; /* how to escape special chars */
! 92: const char* encoding; /* <?xml encoding="<encoding>" ?> */
! 93: } STRUCT_XML_ELEM_OUTPUT_OPTIONS, *XML_ELEM_OUTPUT_OPTIONS;
! 94: /******/
! 95:
! 96: /****s* struct/XML_ELEM_INPUT_OPTIONS
! 97: * NAME
! 98: * XML_ELEM_INPUT_OPTIONS
! 99: * NOTES
! 100: * defines various input options
! 101: * SOURCE
! 102: */
! 103: typedef struct _xml_input_options {
! 104: ENCODING_ID encoding; /* which encoding to use. */
! 105: } STRUCT_XML_ELEM_INPUT_OPTIONS, *XML_ELEM_INPUT_OPTIONS;
! 106: /******/
! 107:
! 108: /****s* struct/XML_ELEM_ERROR
! 109: * NAME
! 110: * XML_ELEM_ERROR
! 111: * NOTES
! 112: * defines an xml parser error
! 113: * SOURCE
! 114: */
! 115: typedef struct _xml_elem_error {
! 116: int parser_code;
! 117: const char* parser_error;
! 118: long line;
! 119: long column;
! 120: long byte_index;
! 121: } STRUCT_XML_ELEM_ERROR, *XML_ELEM_ERROR;
! 122: /******/
! 123:
! 124:
! 125: /*-************************
! 126: * begin xml element stuff *
! 127: **************************/
! 128:
! 129: /****s* struct/xml_elem_attr
! 130: * NAME
! 131: * xml_elem_attr
! 132: * NOTES
! 133: * representation of an xml attribute, foo="bar"
! 134: * SOURCE
! 135: */
! 136: typedef struct _xml_element_attr {
! 137: char* key; /* attribute key */
! 138: char* val; /* attribute value */
! 139: } xml_element_attr;
! 140: /******/
! 141:
! 142: /****s* struct/xml_elem_attr
! 143: * NAME
! 144: * xml_elem_attr
! 145: * NOTES
! 146: * representation of an xml element, eg <candidate name="Harry Browne" party="Libertarian"/>
! 147: * SOURCE
! 148: */
! 149: typedef struct _xml_element {
! 150: const char* name; /* element identifier */
! 151: simplestring text; /* text contained between element begin/end pairs */
! 152: struct _xml_element* parent; /* element's parent */
! 153:
! 154: queue attrs; /* attribute list */
! 155: queue children; /* child element list */
! 156: } xml_element;
! 157: /******/
! 158:
! 159: void xml_elem_free(xml_element* root);
! 160: void xml_elem_free_non_recurse(xml_element* root);
! 161: xml_element* xml_elem_new(void);
! 162: char* xml_elem_serialize_to_string(xml_element *el, XML_ELEM_OUTPUT_OPTIONS options, int *buf_len);
! 163: void xml_elem_serialize_to_stream(xml_element *el, FILE *output, XML_ELEM_OUTPUT_OPTIONS options);
! 164: xml_element* xml_elem_parse_buf(const char* in_buf, int len, XML_ELEM_INPUT_OPTIONS options, XML_ELEM_ERROR error);
! 165:
! 166: /*-**********************
! 167: * end xml element stuff *
! 168: ************************/
! 169:
! 170: /*-**********************
! 171: * Begin xml_element API *
! 172: ************************/
! 173:
! 174: /****d* VALUE/XMLRPC_MACROS
! 175: * NAME
! 176: * Some Helpful Macros
! 177: * NOTES
! 178: * Some macros for making life easier. Should be self-explanatory.
! 179: * SEE ALSO
! 180: * XMLRPC_AddValueToVector ()
! 181: * XMLRPC_VectorGetValueWithID_Case ()
! 182: * XMLRPC_VALUE
! 183: * SOURCE
! 184: */
! 185: #define xml_elem_next_element(el) ((el) ? (xml_element *)Q_Next(&el->children) : NULL)
! 186: #define xml_elem_head_element(el) ((el) ? (xml_element *)Q_Head(&el->children) : NULL)
! 187: #define xml_elem_next_attr(el) ((el) ? (xml_element_attr *)Q_Next(&el->attrs) : NULL)
! 188: #define xml_elem_head_attr(el) ((el) ? (xml_element_attr *)Q_Head(&el->attrs) : NULL)
! 189: #define xml_elem_get_name(el) (char *)((el) ? el->name : NULL)
! 190: #define xml_elem_get_val(el) (char *)((el) ? el->text.str : NULL)
! 191: /******/
! 192:
! 193:
! 194: /*-********************
! 195: * End xml_element API *
! 196: **********************/
! 197:
! 198: #ifdef __cplusplus
! 199: }
! 200: #endif
! 201:
! 202: #endif /* __XML_ELEMENT_H__ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>