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

📄 ilibparsers.h

📁 解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。解析xml格式的文件的好源码。
💻 H
📖 第 1 页 / 共 2 页
字号:
   */ 
  int ValueLength;   
    /*! \var Next
       \brief Pointer to the next attribute
     */ 
  struct ILibXMLAttribute *Next;	// Next Attribute
};


/*! \fn ILibFindEntryInTable(char *Entry, char **Table)
	\brief Find the index in \a Table that contains \a Entry.
*/ 
int ILibFindEntryInTable (char *Entry, char **Table);


char *ILibReadFileFromDisk (char *FileName);
int ILibReadFileFromDiskEx (char **Target, char *FileName);
void ILibWriteStringToDisk (char *FileName, char *data);

/*! \defgroup StackGroup Stack
	\ingroup DataStructures
	Stack Methods
	\{
*/ 
void ILibCreateStack (void **TheStack);
void ILibPushStack (void **TheStack, void *data);
void *ILibPopStack (void **TheStack);
void *ILibPeekStack (void **TheStack);
void ILibClearStack (void **TheStack);
/*! \} */ 
  
/*! \defgroup QueueGroup Queue
	\ingroup DataStructures
	Queue Methods
	\{
*/ 
void *ILibQueue_Create ();
void ILibQueue_Destroy (void *q);
int ILibQueue_IsEmpty (void *q);
void ILibQueue_EnQueue (void *q, void *data);
void *ILibQueue_DeQueue (void *q);
void *ILibQueue_PeekQueue (void *q);
void ILibQueue_Lock (void *q);
void ILibQueue_UnLock (void *q);
/* \} */ 
  

/*! \defgroup XML XML Parsing Methods
	\ingroup ILibParsers
MicroStack supplied XML Parsing Methods
	\par
\b Note: None of the XML Parsing Methods copy or allocate memory
The lifetime of any/all strings is bound to the underlying string that was
parsed using ILibParseXML. If you wish to keep any of these strings for longer
then the lifetime of the underlying string, you must copy the string.
	\{
*/ 
  

//
// Parses an XML string. Returns a tree of ILibXMLNode elements.
//
struct ILibXMLNode *ILibParseXML (char *buffer, int offset, int length);

//
// Preprocesses the tree of ILibXMLNode elements returned by ILibParseXML.
// This method populates all the node pointers in each node for easy traversal.
// In addition, this method will also determine if the given XML document was well formed.
// Returns 0 if processing succeeded. Specific Error Codes are returned otherwise.
//
int ILibProcessXMLNodeList (struct ILibXMLNode *nodeList);

//
// Initalizes a namespace lookup table for a given parent node. 
// If you want to resolve namespaces, you must call this method exactly once
//
void ILibXML_BuildNamespaceLookupTable (struct ILibXMLNode *node);

//
// Resolves a namespace prefix.
//
char *ILibXML_LookupNamespace (struct ILibXMLNode *currentLocation, char *prefix, int prefixLength);

//
// Fetches all the data for an element. Returns the length of the populated data
//
int ILibReadInnerXML (struct ILibXMLNode *node, char **RetVal);

//
// Returns the attributes of an XML element. Returned as a linked list of ILibXMLAttribute.
//
struct ILibXMLAttribute *ILibGetXMLAttributes (struct ILibXMLNode *node);

void ILibDestructXMLNodeList (struct ILibXMLNode *node);
void ILibDestructXMLAttributeList (struct ILibXMLAttribute *attribute);

//
// Escapes an XML string.
// indata must be pre-allocated. 
//
int ILibXmlEscape (char *outdata, const char *indata);

//
// Returns the required size string necessary to escape this XML string
//
int ILibXmlEscapeLength (const char *data);

//
// Unescapes an XML string.
// Since Unescaped strings are always shorter than escaped strings,
// the resultant string will overwrite the supplied string, to save memory
//
int ILibInPlaceXmlUnEscape (char *data);

/*! \} */ 
  
/*! \defgroup ChainGroup Chain Methods
	\ingroup ILibParsers
	\brief Chaining Methods
	\{
*/ 
void *ILibCreateChain ();
void ILibAddToChain (void *chain, void *object);
void ILibStartChain (void *chain);
void ILibStopChain (void *chain);
void ILibForceUnBlockChain (void *Chain);
/* \} */ 
  


/*! \defgroup LinkedListGroup Linked List
	\ingroup DataStructures
	\{
*/ 
  
//
// Initializes a new Linked List data structre
//
void *ILibLinkedList_Create ();

//
// Returns the Head node of a linked list data structure
//
void *ILibLinkedList_GetNode_Head (void *LinkedList);	// Returns Node

//
// Returns the Tail node of a linked list data structure
//
void *ILibLinkedList_GetNode_Tail (void *LinkedList);	// Returns Node

//
// Returns the Next node of a linked list data structure
//
void *ILibLinkedList_GetNextNode (void *LinkedList_Node);	// Returns Node

//
// Returns the Previous node of a linked list data structure
//
void *ILibLinkedList_GetPreviousNode (void *LinkedList_Node);	// Returns Node

//
// Returns the number of nodes contained in a linked list data structure
//
long ILibLinkedList_GetCount (void *LinkedList);

//
// Returns a shallow copy of a linked list data structure. That is, the structure
// is copied, but none of the data contents are copied. The pointer values are just copied.
//
void *ILibLinkedList_ShallowCopy (void *LinkedList);

//
// Returns the data pointer of a linked list element
//
void *ILibLinkedList_GetDataFromNode (void *LinkedList_Node);

//
// Creates a new element, and inserts it before the given node
//
void ILibLinkedList_InsertBefore (void *LinkedList_Node, void *data);

//
// Creates a new element, and inserts it after the given node
//
void ILibLinkedList_InsertAfter (void *LinkedList_Node, void *data);

//
// Removes the given node from a linked list data structure
//
void ILibLinkedList_Remove (void *LinkedList_Node);

//
// Given a data pointer, will traverse the linked list data structure, deleting
// elements that point to this data pointer.
//
void ILibLinkedList_Remove_ByData (void *LinkedList, void *data);

//
// Creates a new element, and inserts it at the top of the linked list.
//
void ILibLinkedList_AddHead (void *LinkedList, void *data);

//
// Creates a new element, and appends it to the end of the linked list
//
void ILibLinkedList_AddTail (void *LinkedList, void *data);

void ILibLinkedList_Lock (void *LinkedList);
void ILibLinkedList_UnLock (void *LinkedList);
void ILibLinkedList_Destroy (void *LinkedList);
/*! \} */ 
  


/*! \defgroup HashTreeGroup Hash Table
	\ingroup DataStructures
	\b Note: Duplicate key entries will be overwritten.
	\{
*/ 
  
//
// Initialises a new Hash Table (tree) data structure
//
void *ILibInitHashTree ();
void ILibDestroyHashTree (void *tree);

//
// Returns non-zero if the key entry is found in the table
//
int ILibHasEntry (void *hashtree, char *key, int keylength);

//
// Add a new entry into the hashtable. If the key is already used, it will be overwriten.
//
void ILibAddEntry (void *hashtree, char *key, int keylength, void *value, int valueLen);
void *ILibGetEntry (void *hashtree, char *key, int keylength);
void ILibDeleteEntry (void *hashtree, char *key, int keylength);

//
// Returns an Enumerator to browse all the entries of the Hashtable
//
void *ILibHashTree_GetEnumerator (void *tree);
void ILibHashTree_DestroyEnumerator (void *tree_enumerator);

//
// Advance the Enumerator to the next element.
// Returns non-zero if there are no more entries to enumerate
//
int ILibHashTree_MoveNext (void *tree_enumerator);

//
// Obtains the value of a Hashtable Entry.
//
void ILibHashTree_GetValue (void *tree_enumerator, char **key, int *keyLength, void **data);
void ILibHashTree_Lock (void *hashtree);
void ILibHashTree_UnLock (void *hashtree);

/*! \} */ 
  
/*! \defgroup LifeTimeMonitor LifeTimeMonitor
	\ingroup ILibParsers
	\brief Timed Callback Service
	\para
	These callbacks will always be triggered on the thread that calls ILibStartChain().
	\{
*/ 
  
//
// Adds an event trigger to be called after the specified time elapses, with the
// specified data object
//
#define ILibLifeTime_Add(LifetimeMonitorObject, data, seconds, Callback, Destroy) ILibLifeTime_AddEx(LifetimeMonitorObject, data, seconds*1000, Callback, Destroy)
void ILibLifeTime_AddEx (void *LifetimeMonitorObject, void *data, int milliseconds, void *Callback, void *Destroy);

//
// Removes all event triggers that contain the specified data object.
//
void ILibLifeTime_Remove (void *LifeTimeToken, void *data);

//
// Removes all events triggers
//
void ILibLifeTime_Flush (void *LifeTimeToken);
void *ILibCreateLifeTime (void *Chain);

/* \} */ 
  

/*! \defgroup StringParsing String Parsing
	\ingroup ILibParsers
	\{
*/ 
  
//
// Trims preceding and proceding whitespaces from a string
//
int ILibTrimString (char **theString, int length);

//
// Parses the given string using the specified multichar delimiter.
// Returns a parser_result object, which points to a linked list
// of parser_result_field objects.
//
struct parser_result *ILibParseString (char *buffer, int offset, int length, char *Delimiter, int DelimiterLength);

//
// Same as ILibParseString, except this method ignore all delimiters that are contains within
// quotation marks
//
struct parser_result *ILibParseStringAdv (char *buffer, int offset, int length, char *Delimiter, int DelimiterLength);

//
// Releases resources used by string parser
//
void ILibDestructParserResults (struct parser_result *result);

//
// Parses a URI into IP Address, Port Number, and Path components
// Note: IP and Path must be freed.
//
void ILibParseUri (char *URI, char **IP, unsigned short *Port, char **Path);

//
// Parses a string into a Long or unsigned Long. 
// Returns non-zero on error condition
//
int ILibGetLong (char *TestValue, int TestValueLength, long *NumericValue);
int ILibGetULong (const char *TestValue, const int TestValueLength, unsigned long *NumericValue);
int ILibFragmentText (char *text, int textLength, char *delimiter, int delimiterLength, int tokenLength, char **RetVal);
int ILibFragmentTextLength (char *text, int textLength, char *delimiter, int delimiterLength, int tokenLength);


/* Base64 handling methods */ 
int ILibBase64Encode (unsigned char *input, const int inputlen, unsigned char **output);
int ILibBase64Decode (unsigned char *input, const int inputlen, unsigned char **output);

/* Compression Handling Methods */ 
char *ILibDecompressString (unsigned char *CurrentCompressed, const int bufferLength, const int DecompressedLength);

/* \} */ 
  

/*! \defgroup PacketParsing Packet Parsing
	\ingroup ILibParsers
	\{
*/ 
  
/* Packet Methods */ 
  
//
// Allocates an empty HTTP Packet
//
struct packetheader *ILibCreateEmptyPacket ();

//
// Add a header into the packet. (String is copied)
//
void ILibAddHeaderLine (struct packetheader *packet, char *FieldName, int FieldNameLength, char *FieldData, int FieldDataLength);

//
// Fetches the header value from the packet. (String is NOT copied)
// Returns NULL if the header field does not exist
//
char *ILibGetHeaderLine (struct packetheader *packet, char *FieldName, int FieldNameLength);

//
// Sets the HTTP version: 1.0, 1.1, etc. (string is copied)
//
void ILibSetVersion (struct packetheader *packet, char *Version, int VersionLength);

//
// Set the status code and data line. The status data is copied.
//
void ILibSetStatusCode (struct packetheader *packet, int StatusCode, char *StatusData, int StatusDataLength);

//
// Sets the method and path. (strings are copied)
//
void ILibSetDirective (struct packetheader *packet, char *Directive, int DirectiveLength, char *DirectiveObj, int DirectiveObjLength);

//
// Releases all resources consumed by this packet structure
//
void ILibDestructPacket (struct packetheader *packet);

//
// Parses a string into an packet structure.
// None of the strings are copied, so the lifetime of all the values are bound
// to the lifetime of the underlying string that is parsed.
//
struct packetheader *ILibParsePacketHeader (char *buffer, int offset, int length);

//
// Returns the packetized string and it's length. (must be freed)
//
int ILibGetRawPacket (struct packetheader *packet, char **buffer);

//
// Performs a deep copy of a packet structure
//
struct packetheader *ILibClonePacket (struct packetheader *packet);

//
// Escapes a string according to HTTP escaping rules.
// indata must be pre-allocated
//
int ILibHTTPEscape (char *outdata, const char *indata);

//
// Returns the size of string required to escape this string,
// according to HTTP escaping rules
//
int ILibHTTPEscapeLength (const char *data);

//
// Unescapes the escaped string sequence
// Since escaped string sequences are always longer than unescaped
// string sequences, the resultant string is overwritten onto the supplied string
//
int ILibInPlaceHTTPUnEscape (char *data);
/* \} */ 
  
/*! \defgroup NetworkHelper Network Helper
	\ingroup ILibParsers
	\{
*/ 
  
//
// Obtain an array of IP Addresses available on the local machine.
//
int ILibGetLocalIPAddressList (int **pp_int);
#if defined(WINSOCK2)
int ILibGetLocalIPAddressNetMask (int address);
unsigned short ILibGetDGramSocket (int local, HANDLE * TheSocket);
unsigned short ILibGetStreamSocket (int local, unsigned short PortNumber, HANDLE * TheSocket);
#elif defined(WINSOCK1) || defined(_WIN32_WCE)
unsigned short ILibGetDGramSocket (int local, SOCKET * TheSocket);
unsigned short ILibGetStreamSocket (int local, unsigned short PortNumber, SOCKET * TheSocket);
#else /* 
 */unsigned short ILibGetDGramSocket (int local, int *TheSocket);
unsigned short ILibGetStreamSocket (int local, unsigned short PortNumber, int *TheSocket);
#endif /* 
 */  
/* \} */ 

void *dbg_malloc (int sz);
void dbg_free (void *ptr);
int dbg_GetCount ();

  /* \} */// End of ILibParser Group
#endif /* 
 */

⌨️ 快捷键说明

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