(file) Return to xml.h CVS log (file) (dir) Up to [OMI] / omi / xml

Diff for /omi/xml/xml.h between version 1.2 and 1.3

version 1.2, 2015/04/20 18:10:36 version 1.3, 2015/04/20 18:20:37
Line 26 
Line 26 
 #define _omiar_xml_h #define _omiar_xml_h
  
 #include <stddef.h> #include <stddef.h>
   #include "config.h"
   #include <common.h>
   
   #ifdef _MSC_VER
   #pragma prefast (disable: 28252)
   #pragma prefast (disable: 28253)
   #endif
   
   #if defined(CONFIG_ENABLE_WCHAR)
   # include <wchar.h>
   #endif
  
 /* The maximum number of nested XML elements */ /* The maximum number of nested XML elements */
 #define XML_MAX_NESTED 64 #define XML_MAX_NESTED 64
Line 42 
Line 53 
 /* Represents case where tag has no namespace */ /* Represents case where tag has no namespace */
 #define XML_NAMESPACE_NONE 0 #define XML_NAMESPACE_NONE 0
  
   #if defined(CONFIG_ENABLE_WCHAR)
   typedef wchar_t XML_Char;
   typedef wchar_t XML_UChar;
   #else
   typedef char XML_Char;
   typedef unsigned char XML_UChar;
   #endif
   
   typedef _Null_terminated_ XML_Char* XMLCharPtr;
   typedef _Null_terminated_ XML_UChar* XMLUCharPtr;
   
 #if defined(__cplusplus) #if defined(__cplusplus)
 extern "C" { extern "C" {
 #endif #endif
Line 50 
Line 72 
 typedef struct _XML_Name typedef struct _XML_Name
 { {
     /* Pointer to name */     /* Pointer to name */
     char* data;      XML_Char* data;
     /* Size of name (excluding zero-terminator) */     /* Size of name (excluding zero-terminator) */
     size_t size;     size_t size;
   
       /* Full namespace URI */
       const XML_Char* namespaceUri;
       size_t namespaceUriSize;
   
       /* Nonzero if a registered namespace was used */
       XML_Char namespaceId;
 } }
 XML_Name; XML_Name;
  
Line 60 
Line 89 
 typedef struct _XML_RegisteredNameSpace typedef struct _XML_RegisteredNameSpace
 { {
     /* URI for this namespace */     /* URI for this namespace */
     const char* uri;      const XML_Char* uri;
  
     /* Hash code for uri */     /* Hash code for uri */
     unsigned int uriCode;     unsigned int uriCode;
  
     /* Single character namespace name expected by client */     /* Single character namespace name expected by client */
     char id;      XML_Char id;
 } }
 XML_RegisteredNameSpace; XML_RegisteredNameSpace;
  
Line 74 
Line 103 
 typedef struct _XML_NameSpace typedef struct _XML_NameSpace
 { {
     /* Namespace name */     /* Namespace name */
     const char* name;      const XML_Char* name;
  
     /* Hash code for name */     /* Hash code for name */
     unsigned int nameCode;     unsigned int nameCode;
  
     /* URI for this namespace */     /* URI for this namespace */
     const char* uri;      const XML_Char* uri;
       size_t uriSize;
  
     /* Single character namespace name expected by client */     /* Single character namespace name expected by client */
     char id;      XML_Char id;
  
     /* Depth at which this definition was encountered */     /* Depth at which this definition was encountered */
     size_t depth;     size_t depth;
Line 91 
Line 121 
 XML_NameSpace; XML_NameSpace;
  
 void XML_NameSpace_Dump( void XML_NameSpace_Dump(
     XML_NameSpace* self);      _In_ XML_NameSpace* self);
  
 /* Represents an XML attributes */ /* Represents an XML attributes */
 typedef struct _XML_Attr typedef struct _XML_Attr
 { {
     const char* name;      XML_Name name;
     const char* value;      const XML_Char* value;
       size_t valueSize;
 } }
 XML_Attr; XML_Attr;
  
Line 113 
Line 144 
 } }
 XML_Type; XML_Type;
  
 #if 0  
 /* Attribute info (for structure mappings) */  
 typedef struct _XML_AttrDecl  
 {  
     /* Name of this attribute */  
     const char* name;  
   
     /* 'S'=String 'L'=Long 'D'=Double */  
     char type;  
   
     /* Offset of the field in destination structure */  
     size_t offset;  
   
     /* Whether this attribute is required */  
     int required;  
   
     /* Pointer to value (char*, long*, or double*) */  
     void* value;  
 }  
 XML_AttrDecl;  
 #endif  
   
 /* Represents one XML element */ /* Represents one XML element */
 typedef struct _XML_Elem typedef struct _XML_Elem
 { {
     /* Type of this XML object */     /* Type of this XML object */
     XML_Type type;     XML_Type type;
  
     /* Character data or tag name */      /* Tag or character data */
     const char* data;      XML_Name data;
     size_t size;  
  
     /* Attributes */     /* Attributes */
     XML_Attr attrs[XML_MAX_ATTRIBUTES];     XML_Attr attrs[XML_MAX_ATTRIBUTES];
Line 151 
Line 159 
 } }
 XML_Elem; XML_Elem;
  
 const char* XML_Elem_GetAttr(  const XML_Char* XML_Elem_GetAttr(
     XML_Elem* self,      _Inout_ XML_Elem* self,
     const char* name);      XML_Char nsId,
       _In_z_ const XML_Char* name);
  
 void XML_Elem_Dump( void XML_Elem_Dump(
     const XML_Elem* self);      _In_ const XML_Elem* self);
  
 typedef struct _XML typedef struct _XML
 { {
     /* Points to first text character zero-terminated text */     /* Points to first text character zero-terminated text */
     char* text;      XML_Char* text;
  
     /* Pointer to current character */     /* Pointer to current character */
     char* ptr;      XML_Char* ptr;
  
     /* Line number */     /* Line number */
     size_t line;     size_t line;
Line 173 
Line 182 
     int status;     int status;
  
     /* Error message */     /* Error message */
     char message[256];      XML_Char message[256];
  
     /* Stack of open tags (used to match closing tags) */     /* Stack of open tags (used to match closing tags) */
     XML_Name stack[XML_MAX_NESTED];     XML_Name stack[XML_MAX_NESTED];
Line 206 
Line 215 
 XML; XML;
  
 void XML_Init( void XML_Init(
     XML* self);      _Out_ XML* self);
  
 void XML_SetText( void XML_SetText(
     XML* self,      _Inout_ XML* self,
     char* text);      _In_z_ XML_Char* text);
  
 int XML_Next( int XML_Next(
     XML* self,      _Inout_ XML* self,
     XML_Elem* elem);      _Out_ XML_Elem* elem);
  
 int XML_Expect( int XML_Expect(
     XML* self,      _Inout_ XML* self,
     XML_Elem* elem,      _Out_ XML_Elem* elem,
     XML_Type type,     XML_Type type,
     const char* name);      XML_Char nsId,
       _In_z_ const XML_Char* name);
  
 int XML_Skip( int XML_Skip(
     XML* self);      _Inout_ XML* self);
  
 int XML_RegisterNameSpace( int XML_RegisterNameSpace(
     XML* self,      _Inout_ XML* self,
     char id,      XML_Char id,
     const char* uri);      _In_z_ const XML_Char* uri);
  
 int XML_PutBack( int XML_PutBack(
     XML* self,      _Inout_ XML* self,
     const XML_Elem* elem);      _In_ const XML_Elem* elem);
   
   int XML_StripWhitespace(
       _Inout_ XML_Elem* elem);
  
 void XML_Dump( void XML_Dump(
     XML* self);      _In_ XML* self);
   
   void XML_PutError(_Inout_ XML* self);
   
   #if defined(_MSC_VER)
   #include "xml_errors_ids.h"
  
 void XML_PutError(XML* self);  void XML_Raise(_Inout_ XML* self, unsigned formatStringId, ...);
   #else
   
   #define XML_ERROR_BAD_ENTITY_REFERENCE ZT("Failed to parse XML. Bad entity reference. Only these are supported: '&lt;', '&gt;', '&amp;', '&quot;', '&apos;'.")
   #define XML_ERROR_BAD_CHARACTER_REFERENCE ZT("Failed to parse XML. Bad character reference. Only character references in the range of 0 to 255 are supported.")
   #define XML_ERROR_UNDEFINED_NAMESPACE_PREFIX ZT("Failed to parse XML. Undefined namespace prefix found '%T'.")
   #define XML_ERROR_EXPECTED_ATTRIBUTE_NAME ZT("Failed to parse XML. An attribute name was expected.")
   #define XML_ERROR_EXPECTED_ATTRIBUTE_EQUALS ZT("Failed to parse XML. An '=' character was expected while parsing attribute '%T'.")
   #define XML_ERROR_EXPECTED_ATTRIBUTE_OPENING_QUOTES ZT("Failed to parse XML. An opening quote character was expected while parsing attribute '%T'.")
   #define XML_ERROR_EXPECTED_ATTRIBUTE_CLOSING_QUOTES ZT("Failed to parse XML. An closing quote character was expected while parsing attribute '%T'.")
   #define XML_ERROR_TOO_MANY_NAMESPACES ZT("Failed to parse XML. Too many namespaces were detected. A maximum of %u namespaces are allowed.")
   #define XML_ERROR_TOO_MANY_ATTRIBUTES ZT("Failed to parse XML. Too many attributes were detected on element '%T'. A maximum of %u attributes are allowed per element.")
   #define XML_ERROR_END_OF_XML_INSTRUCTION ZT("Failed to parse XML. The end of the XML was detected while processing an XML instruction.")
   #define XML_ERROR_END_OF_INSTRUCTION_MISSING ZT("Failed to parse XML. The end of the XML instruction was not properly terminated with an '?>'.")
   #define XML_ERROR_ELEMENT_NAME_EXPECTED ZT("Failed to parse XML. An element name was expected while decoding an element start tag.")
   #define XML_ERROR_ELEMENT_NAME_PREMATURE_END ZT("Failed to parse XML. The end of the XML was detected while processing an XML element name for a element start tag.")
   #define XML_ERROR_ELEMENT_DEPTH_OVERFLOW ZT("Failed to parse XML. XML element nesting is too deep. A maximum element depth of %u is supported.")
   #define XML_ERROR_ELEMENT_NAME_NOT_CLOSED ZT("Failed to parse XML. The XML element '%T' was not terminated with a '>' while decoding an element start tag.")
   #define XML_ERROR_ELEMENT_NAME_EXPECTED_ELEM_END ZT("Failed to parse XML. An element name was expected while decoding an element end tag.")
   #define XML_ERROR_ELEMENT_NAME_PREMATURE_END_ELEM_END ZT("Failed to parse XML. The end of the XML was detected while processing an XML element name for a element end tag.")
   #define XML_ERROR_ELEMENT_NAME_NOT_CLOSED_ELEM_END ZT("Failed to parse XML. The XML element '%T' was not terminated with a '>' while decoding an element end tag.")
   #define XML_ERROR_ELEMENT_TOO_MANY_ENDS ZT("Failed to parse XML. More element end tags were found than element starting tags. The ending tag found is '%T'.")
   #define XML_ERROR_ELEMENT_END_ELEMENT_TAG_NOT_MATCH_START_TAG ZT("Failed to parse XML. The XML element end tag expected was '%T', but what was found was '%T'.")
   #define XML_ERROR_COMMENT_END_EXPECTED ZT("Failed to parse XML. Double minus signs in comments are not allowed, unless used to terminate comment. '>' was not found.")
   #define XML_ERROR_COMMENT_PREMATURE_END ZT("Failed to parse XML. The end of the XML was detected while processing a comment.")
   #define XML_ERROR_CDATA_PREMATURE_END ZT("Failed to parse XML. The end of the XML was detected while processing a CDATA.")
   #define XML_ERROR_DOCTYPE_PREMATURE_END ZT("Failed to parse XML. The end of the XML was detected while processing a DOCTYPE.")
   #define XML_ERROR_CHARDATA_EXPECTED_ELEMENT_END_TAG ZT("Failed to parse XML. While processing the element data no element end tag was discovered.")
   #define XML_ERROR_OPEN_ANGLE_BRACKET_EXPECTED ZT("Failed to parse XML. An open angle bracket '<' was expected and not found.")
   #define XML_ERROR_COMMENT_CDATA_DOCTYPE_EXPECTED ZT("Failed to parse XML. A comment, CDATA or DOCTYPE element was expected and not found.")
   #define XML_ERROR_ELEMENT_EXPECTED ZT("Failed to parse XML. An XML element was expected and not found.")
   #define XML_ERROR_UNEXPECTED_STATE ZT("Failed to parse XML. The XML parser hit an interal problem that stopped it from progressing.")
   #define XML_ERROR_SPECIFIC_ELEMENT_EXPECTED ZT("Failed to parse XML. The element name %T was expected but %T was found instead.")
   #define XML_ERROR_SPECIFIC_END_ELEMENT_EXPECTED ZT("Failed to parse XML. The element name %T end tag was expected but %T was found instead.")
   #define XML_ERROR_CHARACTER_DATA_EXPECTED ZT("Failed to parse XML. Character data was expected but not found.")
   
   #define WSMAN_ERROR_NO_CLASS_NAME_IN_SELECTOR ZT("Failed to process WS-Management packet. The class name was not found in the selector.")
   #define WSMAN_ERROR_NO_RESOURCE_URI ZT("Failed to process WS-Management packet. The resource URI was not found.")
   #define WSMAN_ERROR_OUTOFMEMORY ZT("Failed to process WS-Management packet. Out of memory.")
   #define WSMAN_ERROR_BAD_SELECTOR ZT("Failed to process WS-Management packet. Character data or the element EndPointReference was expected in the selector but not found.")
   #define WSMAN_ERROR_BAD_EPR_IN_SELECTOR ZT("Failed to process WS-Management packet. The element EndPointReference in the selector could not be parsed.")
  
 void XML_Raise(XML* self, const char* format, ...);  
  
 void XML_FormatError(XML* self, char* format, size_t size);  void XML_Raise(XML* self, _In_z_ const XML_Char* format, ...);
   #endif
   
   void XML_FormatError(_Inout_ XML* self, _Out_writes_z_(size) XML_Char* buffer, size_t size);
  
 #if defined(__cplusplus) #if defined(__cplusplus)
 } /* extern "C" */ } /* extern "C" */


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

ViewCVS 0.9.2