⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ilibparsers.h

📁 解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 * INTEL CONFIDENTIAL
 * Copyright (c) 2002, 2003 Intel Corporation.  All rights reserved.
 * 
 * The source code contained or described herein and all documents
 * related to the source code ("Material") are owned by Intel
 * Corporation or its suppliers or licensors.  Title to the
 * Material remains with Intel Corporation or its suppliers and
 * licensors.  The Material contains trade secrets and proprietary
 * and confidential information of Intel or its suppliers and
 * licensors. The Material is protected by worldwide copyright and
 * trade secret laws and treaty provisions.  No part of the Material
 * may be used, copied, reproduced, modified, published, uploaded,
 * posted, transmitted, distributed, or disclosed in any way without
 * Intel's prior express written permission.
 
 * No license under any patent, copyright, trade secret or other
 * intellectual property right is granted to or conferred upon you
 * by disclosure or delivery of the Materials, either expressly, by
 * implication, inducement, estoppel or otherwise. Any license
 * under such intellectual property rights must be express and
 * approved by Intel in writing.
 * 
 * $Workfile: ILibParsers.h
 * $Revision: #1.0.1868.18043
 * $Author:   Intel Corporation, Intel Device Builder
 * $Date:     Wednesday, April 06, 2005
 *
 *
 *
 */  
  
/*! \file ILibParsers.h 
	\brief MicroStack APIs for various functions and tasks
*/ 
  
#ifndef __ILibParsers__
#define __ILibParsers__
  
/*! \defgroup ILibParsers ILibParser Modules
	\{
	\}
*/ 
  
/*! \def MAX_HEADER_LENGTH
	Specifies the maximum allowed length for an HTTP Header
*/ 
#define MAX_HEADER_LENGTH 800
  
#ifdef MEMORY_CHECK
#include <assert.h>
#define MEMCHECK(x) x
#else /* 
 */#define MEMCHECK(x)
#endif /* 
 */  
#ifdef _WIN32_WCE
#define REQUIRES_MEMORY_ALIGNMENT
#define errno 0
#define ERANGE 1
#define time(x) GetTickCount()
#endif /* 
 */  
#ifndef WIN32
#define REQUIRES_MEMORY_ALIGNMENT
#endif /* 
 */  
#if defined(WIN32) || defined (_WIN32_WCE)
#ifndef MICROSTACK_NO_STDAFX
#include "stdafx.h"
#endif /* 
 */#else /* 
 */#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/utsname.h>
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#include <semaphore.h>
#include <malloc.h>
#include <fcntl.h>
#include <signal.h>
#endif /* 
 */  
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <math.h>
  

#ifdef WIN32
#include <windows.h>
#include <winioctl.h>
#include <winbase.h>
#endif /* 
 */  
#ifndef _WIN32_WCE
#include <time.h>
#endif /* 
 */  
#if defined(WIN32) || defined(_WIN32_WCE)
#define sem_t HANDLE
#define sem_init(x,y,z) *x=CreateSemaphore(NULL,z,FD_SETSIZE,NULL)
#define sem_destroy(x) (CloseHandle(*x)==0?1:0)
#define sem_wait(x) WaitForSingleObject(*x,INFINITE)
#define sem_trywait(x) ((WaitForSingleObject(*x,0)==WAIT_OBJECT_0)?0:1)
#define sem_post(x) ReleaseSemaphore(*x,1,NULL)
  
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
#define strcasecmp(x,y) _stricmp(x,y)
#define gettimeofday(x,y) (x)->tv_sec = GetTickCount()/1000;(x)->tv_usec = 1000*(GetTickCount()%1000)
#endif /* 
 */  
/*! \def UPnPMIN(a,b)
	Returns the minimum of \a a and \a b.
*/ 
#define UPnPMIN(a,b) (((a)<(b))?(a):(b))
/*! \def ILibIsChainBeingDestroyed(Chain)
	Determines if the specified chain is in the process of being disposed.
*/ 
#define ILibIsChainBeingDestroyed(Chain) (*((int*)Chain))

typedef enum 
{ 
ILibServerScope_All = 0, 
ILibServerScope_LocalLoopback = 1, 
ILibServerScope_LocalSegment = 2 
} ILibServerScope;


typedef void (*ILibChain_PreSelect) (void *object, fd_set * readset, fd_set * writeset, fd_set * errorset, int *blocktime);
typedef void (*ILibChain_PostSelect) (void *object, int slct, fd_set * readset, fd_set * writeset, fd_set * errorset);
typedef void (*ILibChain_Destroy) (void *object);


/*! \defgroup DataStructures Data Structures
	\ingroup ILibParsers
	\{
	\}
*/ 
  

/*! \struct parser_result_field ILibParsers.h
	\brief Data Elements of \a parser_result
	\para
	This structure represents individual tokens, resulting from a call to
	\a ILibParseString and \a ILibParseStringAdv
*/ 
struct parser_result_field 
{  
    /*! \var data
       \brief Pointer to string
     */ 
  char *data;  

    /*! \var datalength
       \brief Length of \a data
     */ 
  int datalength;  

    /*! \var NextResult
       \brief Pointer to next token
     */ 
  struct parser_result_field *NextResult; 
};

/*! \struct parser_result ILibParsers.h
	\brief String Parsing Result Index
	\para
	This is returned from a successfull call to either \a ILibParseString or
	\a ILibParseStringAdv.
*/ 
struct parser_result 
{  
    /*! \var FirstResult
       \brief Pointer to the first token
     */ 
  struct parser_result_field *FirstResult;   
    /*! \var LastResult
       \brief Pointer to the last token
     */ 
  struct parser_result_field *LastResult;   
    /*! \var NumResults
       \brief The total number of tokens
     */ 
  int NumResults; 
};

/*! \struct packetheader_field_node ILibParsers.h
	\brief HTTP Headers
	\para
	This structure represents an individual header element. A list of these
	is referenced from a \packetheader_field_node.
*/ 
struct packetheader_field_node 
{  
    /*! \var Field
       \brief Header Name
     */ 
  char *Field;   
    /*! \var FieldLength
       \brief Length of \a Field
     */ 
  int FieldLength;   
    /*! \var FieldData
       \brief Header Value
     */ 
  char *FieldData;   
    /*! \var FieldDataLength
       \brief Length of \a FieldData
     */ 
  int FieldDataLength;   
    /*! \var UserAllocStrings
       \brief Boolean indicating if the above strings are non-static memory
     */ 
  int UserAllocStrings;   
    /*! \var NextField
       \brief Pointer to the Next Header entry. NULL if this is the last one
     */ 
  struct packetheader_field_node *NextField; 
};

/*! \struct packetheader ILibParsers.h
	\brief Structure representing a packet formatted according to HTTP encoding rules
	\para
	This can be created manually by calling \a ILibCreateEmptyPacket(), or automatically via a call to \a ILibParsePacketHeader(...)
*/ 
struct packetheader 
{  
    /*! \var Directive
       \brief HTTP Method
       \para
       eg: \b GET /index.html HTTP/1.1
     */ 
  char *Directive;   
    /*! \var DirectiveLength
       \brief Length of \a Directive
     */ 
  int DirectiveLength;   
    /*! \var DirectiveObj
       \brief HTTP Method Path
       \para
       eg: GET \b /index.html HTTP/1.1
     */ 
  char *DirectiveObj;   
    /*! \var DirectiveObjLength
       \brief Length of \a DirectiveObj
     */ 
   
void *Reserved;  

int DirectiveObjLength;   
    /*! \var StatusCode
       \brief HTTP Response Code
       \para
       eg: HTTP/1.1 \b 200 OK
     */ 
  int StatusCode;   
    /* \var StatusData
       \brief Status Meta Data
       \para
       eg: HTTP/1.1 200 \b OK
     */ 
  char *StatusData;   
    /*! \var StatusDataLength
       \brief Length of \a StatusData
     */ 
  int StatusDataLength;   
    /*! \var Version
       \brief HTTP Version
       \para
       eg: 1.1
     */ 
  char *Version;   
    /*! \var VersionLength
       \brief Length of \a Version
     */ 
  int VersionLength;   
    /*! \var Body
       \brief Pointer to HTTP Body
     */ 
  char *Body;   
    /*! \var BodyLength
       \brief Length of \a Body
     */ 
  int BodyLength;   
    /*! \var UserAllocStrings
       \brief Boolean indicating if Directive/Obj are non-static
       \para
       This only needs to be set, if you manually populate \a Directive and \a DirectiveObj.<br>
       It is \b recommended that you use \a ILibSetDirective
     */ 
  int UserAllocStrings;		// Set flag if you allocate memory pointed to by Directive/Obj
  /*! \var UserAllocVersion
     \brief Boolean indicating if Version string is non-static
     \para
     This only needs to be set, if you manually populate \a Version.<br>
     It is \b recommended that you use \a ILibSetVersion
   */ 
  int UserAllocVersion;		// Set flag if you allocate memory pointed to by Version
  int ClonedPacket;  

    /*! \var FirstField
       \brief Pointer to the first Header field
     */ 
  struct packetheader_field_node *FirstField;   
    /*! \var LastField
       \brief Pointer to the last Header field
     */ 
  struct packetheader_field_node *LastField;  

    /*! \var Source
       \brief The origin of this packet
       \para
       This is only populated if you obtain this structure from either \a ILibWebServer or
       \a ILibWebClient.
     */ 
  struct sockaddr_in *Source;   
    /*! \var ReceivingAddress
       \brief IP address that this packet was received on
       \para
       This is only populated if you obtain this structure from either \a ILibWebServer or
       \a ILibWebClient.
     */ 
  int ReceivingAddress; 
};

/*! \struct ILibXMLNode
	\brief An XML Tree
	\para
	This is obtained via a call to \a ILibParseXML. It is \b highly \b recommended
	that you call \a ILibProcessXMLNodeList, so that the node pointers at the end of this
	structure will be populated. That will greatly simplify node traversal.<br><br>
	In order for namespaces to be resolved, you must call \a ILibXML_BuildNamespaceLookupTable(...)
	with root-most node that you would like to resolve namespaces for. It is recommended that you always use
	the root node, obtained from the initial call to \a ILibParseXML.<br><br>
	For most intents and purposes, you only need to work with the "StartElements"
*/ 
struct ILibXMLNode 
{  
    /*! \var Name
       \brief Local Name of the current element
     */ 
  char *Name;			// Element Name
  /*! \var NameLength
     \brief Length of \a Name
   */ 
  int NameLength;  

    /*! \var NSTag
       \brief Namespace Prefix of the current element
       \para
       This can be resolved using a call to \a ILibXML_LookupNamespace(...)
     */ 
  char *NSTag;			// Element Prefix
  /*! \var NSLength
     \brief Length of \a NSTag
   */ 
  int NSLength;  

    /*! \var StartTag
       \brief boolean indicating if the current element is a start element
     */ 
  int StartTag;			// Non zero if this is a StartElement
  /*! \var EmptyTag
     \brief boolean indicating if this element is an empty element
   */ 
  int EmptyTag;			// Non zero if this is an EmptyElement
   
void *Reserved;		// DO NOT TOUCH
  void *Reserved2;		// DO NOT TOUCH
   
    /*! \var Next
       \brief Pointer to the child of the current node
     */ 
  struct ILibXMLNode *Next;	// Next Node
  /*! \var Parent
     \brief Pointer to the Parent of the current node
   */ 
  struct ILibXMLNode *Parent;	// Parent Node
  /*! \var Peer
     \brief Pointer to the sibling of the current node
   */ 
  struct ILibXMLNode *Peer;	// Sibling Node
  struct ILibXMLNode *ClosingTag;	// Pointer to closing node of this element
  struct ILibXMLNode *StartingTag;	// Pointer to start node of this element
};

/*! \struct ILibXMLAttribute
	\brief A list of XML Attributes for a specified XML node
	\para
	This can be obtained via a call to \a ILibGetXMLAttributes(...)
*/ 
struct ILibXMLAttribute 
{  
    /*! \var Name
       \brief Local name of Attribute
     */ 
  char *Name;			// Attribute Name
  /*! \var NameLength
     \brief Length of \a Name
   */ 
  int NameLength;  

    /*! \var Prefix
       \brief Namespace Prefix of this attribute
       \para
       This can be resolved by calling \a ILibXML_LookupNamespace(...) and passing in \a Parent as the current node
     */ 
  char *Prefix;			// Attribute Namespace Prefix
  /*! \var PrefixLength
     \brief Lenth of \a Prefix
   */ 
  int PrefixLength;  

    /*! \var Parent
       \brief Pointer to the XML Node that contains this attribute
     */ 
  struct ILibXMLNode *Parent;	// The XML Node this attribute belongs to
   
    /*! \var Value
       \brief Attribute Value
     */ 
  char *Value;			// Attribute Value      
  /*! \var ValueLength
     \brief Length of \a Value

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -