1/* 2 * INTEL CONFIDENTIAL 3 * Copyright (c) 2002 - 2005 Intel Corporation. All rights reserved. 4 * 5 * The source code contained or described herein and all documents 6 * related to the source code ("Material") are owned by Intel 7 * Corporation or its suppliers or licensors. Title to the 8 * Material remains with Intel Corporation or its suppliers and 9 * licensors. The Material contains trade secrets and proprietary 10 * and confidential information of Intel or its suppliers and 11 * licensors. The Material is protected by worldwide copyright and 12 * trade secret laws and treaty provisions. No part of the Material 13 * may be used, copied, reproduced, modified, published, uploaded, 14 * posted, transmitted, distributed, or disclosed in any way without 15 * Intel's prior express written permission. 16 17 * No license under any patent, copyright, trade secret or other 18 * intellectual property right is granted to or conferred upon you 19 * by disclosure or delivery of the Materials, either expressly, by 20 * implication, inducement, estoppel or otherwise. Any license 21 * under such intellectual property rights must be express and 22 * approved by Intel in writing. 23 * 24 * $Workfile: ILibParsers.h 25 * $Revision: #1.0.1922.38347 26 * $Author: Intel Corporation, Intel Device Builder 27 * $Date: Wednesday, April 06, 2005 28 * 29 * 30 * 31 */ 32 33/*! \file ILibParsers.h 34 \brief MicroStack APIs for various functions and tasks 35*/ 36 37#ifndef __ILibParsers__ 38#define __ILibParsers__ 39 40/*! \defgroup ILibParsers ILibParser Modules 41 \{ 42 \} 43*/ 44 45/*! \def MAX_HEADER_LENGTH 46 Specifies the maximum allowed length for an HTTP Header 47*/ 48//#define MAX_HEADER_LENGTH 998+40+256 //800 49 50/* 51#ifdef MEMORY_CHECK 52 #include <assert.h> 53 #define MEMCHECK(x) x 54#else 55 #define MEMCHECK(x) 56#endif 57*/ 58/* 59#ifdef _WIN32_WCE 60 #define REQUIRES_MEMORY_ALIGNMENT 61 #define errno 0 62 #define ERANGE 1 63 #define time(x) GetTickCount() 64#endif 65*/ 66/* 67#ifndef WIN32 68 #define REQUIRES_MEMORY_ALIGNMENT 69#endif 70*/ 71/* 72#if defined(WIN32) || defined (_WIN32_WCE) 73 #ifndef MICROSTACK_NO_STDAFX 74 #include "stdafx.h" 75 #endif 76 77 #ifndef _WIN32_WCE 78 #include <time.h> 79 #endif 80 81 #ifdef WIN32 82 #include <windows.h> 83 #include <winioctl.h> 84 #include <winbase.h> 85 #endif 86 87#else 88*/ 89// #include <sys/types.h> 90// #include <sys/socket.h> 91// #include <netinet/in.h> 92// #include <arpa/inet.h> 93// #include <sys/time.h> 94 #include <netdb.h> 95// #include <sys/ioctl.h> 96// #include <net/if.h> 97// #include <sys/utsname.h> 98// #include <netinet/in.h> 99// #include <unistd.h> 100// #include <errno.h> 101// #include <semaphore.h> 102// #include <malloc.h> 103// #include <fcntl.h> 104/* #include <signal.h> Arthur, remove for Compiler Error */ 105//#endif 106 107#include <stdlib.h> 108#include <stdio.h> 109//#include <stddef.h> 110#include <string.h> 111//#include <math.h> 112 113/* 114#if defined(WIN32) || defined(_WIN32_WCE) 115 #define sem_t HANDLE 116 #define sem_init(x,y,z) *x=CreateSemaphore(NULL,z,FD_SETSIZE,NULL) 117 #define sem_destroy(x) (CloseHandle(*x)==0?1:0) 118 #define sem_wait(x) WaitForSingleObject(*x,INFINITE) 119 #define sem_trywait(x) ((WaitForSingleObject(*x,0)==WAIT_OBJECT_0)?0:1) 120 #define sem_post(x) ReleaseSemaphore(*x,1,NULL) 121 122 #define strncasecmp(x,y,z) _strnicmp(x,y,z) 123 #define strcasecmp(x,y) _stricmp(x,y) 124 #define gettimeofday(x,y) (x)->tv_sec = GetTickCount()/1000;(x)->tv_usec = 1000*(GetTickCount()%1000) 125 126 #ifndef stricmp 127 #define stricmp(x,y) _stricmp(x,y) 128 #endif 129 130 #ifndef strnicmp 131 #define strnicmp(x,y,z) _strnicmp(x,y,z) 132 #endif 133 134 #ifndef strcmpi 135 #define strcmpi(x,y) _stricmp(x,y) 136 #endif 137#endif 138*/ 139/*! \def UPnPMIN(a,b) 140 Returns the minimum of \a a and \a b. 141*/ 142//#define UPnPMIN(a,b) (((a)<(b))?(a):(b)) 143/*! \def ILibIsChainBeingDestroyed(Chain) 144 Determines if the specified chain is in the process of being disposed. 145*/ 146//#define ILibIsChainBeingDestroyed(Chain) (*((int*)Chain)) 147 148/* 149typedef enum 150{ 151 ILibServerScope_All=0, 152 ILibServerScope_LocalLoopback=1, 153 ILibServerScope_LocalSegment=2 154}ILibServerScope; 155*/ 156/* 157typedef void(*ILibChain_PreSelect)(void* object,fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime); 158typedef void(*ILibChain_PostSelect)(void* object,int slct, fd_set *readset, fd_set *writeset, fd_set *errorset); 159typedef void(*ILibChain_Destroy)(void* object); 160*/ 161 162/*! \defgroup DataStructures Data Structures 163 \ingroup ILibParsers 164 \{ 165 \} 166*/ 167 168 169/*! \struct parser_result_field ILibParsers.h 170 \brief Data Elements of \a parser_result 171 \para 172 This structure represents individual tokens, resulting from a call to 173 \a ILibParseString and \a ILibParseStringAdv 174*/ 175struct parser_result_field 176{ 177 /*! \var data 178 \brief Pointer to string 179 */ 180 char* data; 181 182 /*! \var datalength 183 \brief Length of \a data 184 */ 185 int datalength; 186 187 /*! \var NextResult 188 \brief Pointer to next token 189 */ 190 struct parser_result_field *NextResult; 191}; 192 193/*! \struct parser_result ILibParsers.h 194 \brief String Parsing Result Index 195 \para 196 This is returned from a successfull call to either \a ILibParseString or 197 \a ILibParseStringAdv. 198*/ 199struct parser_result 200{ 201 /*! \var FirstResult 202 \brief Pointer to the first token 203 */ 204 struct parser_result_field *FirstResult; 205 /*! \var LastResult 206 \brief Pointer to the last token 207 */ 208 struct parser_result_field *LastResult; 209 /*! \var NumResults 210 \brief The total number of tokens 211 */ 212 int NumResults; 213}; 214 215/*! \struct packetheader_field_node ILibParsers.h 216 \brief HTTP Headers 217 \para 218 This structure represents an individual header element. A list of these 219 is referenced from a \packetheader_field_node. 220*/ 221/* 222struct packetheader_field_node 223{ 224 //! \var Field 225 // \brief Header Name 226 char* Field; 227 //! \var FieldLength 228 // \brief Length of \a Field 229 int FieldLength; 230 //! \var FieldData 231 // \brief Header Value 232 char* FieldData; 233 //! \var FieldDataLength 234 // \brief Length of \a FieldData 235 int FieldDataLength; 236 //! \var UserAllocStrings 237 // \brief Boolean indicating if the above strings are non-static memory 238 int UserAllocStrings; 239 //! \var NextField 240 // \brief Pointer to the Next Header entry. NULL if this is the last one 241 struct packetheader_field_node* NextField; 242}; 243*/ 244/*! \struct packetheader ILibParsers.h 245 \brief Structure representing a packet formatted according to HTTP encoding rules 246 \para 247 This can be created manually by calling \a ILibCreateEmptyPacket(), or automatically via a call to \a ILibParsePacketHeader(...) 248*/ 249/* 250struct packetheader 251{ 252 //! \var Directive 253 // \brief HTTP Method 254 // \para 255 // eg: \b GET /index.html HTTP/1.1 256 char* Directive; 257 //! \var DirectiveLength 258 // \brief Length of \a Directive 259 int DirectiveLength; 260 //! \var DirectiveObj 261 // \brief HTTP Method Path 262 // \para 263 // eg: GET \b /index.html HTTP/1.1 264 char* DirectiveObj; 265 //! \var DirectiveObjLength 266 // \brief Length of \a DirectiveObj 267 268 void *Reserved; 269 270 int DirectiveObjLength; 271 //! \var StatusCode 272 // \brief HTTP Response Code 273 // \para 274 // eg: HTTP/1.1 \b 200 OK 275 int StatusCode; 276 // \var StatusData 277 // \brief Status Meta Data 278 // \para 279 // eg: HTTP/1.1 200 \b OK 280 char* StatusData; 281 //! \var StatusDataLength 282 // \brief Length of \a StatusData 283 int StatusDataLength; 284 //! \var Version 285 // \brief HTTP Version 286 // \para 287 // eg: 1.1 288 char* Version; 289 //! \var VersionLength 290 // \brief Length of \a Version 291 int VersionLength; 292 //! \var Body 293 // \brief Pointer to HTTP Body 294 char* Body; 295 //! \var BodyLength 296 // \brief Length of \a Body 297 int BodyLength; 298 //! \var UserAllocStrings 299 // \brief Boolean indicating if Directive/Obj are non-static 300 // \para 301 // This only needs to be set, if you manually populate \a Directive and \a DirectiveObj.<br> 302 // It is \b recommended that you use \a ILibSetDirective 303 int UserAllocStrings; // Set flag if you allocate memory pointed to by Directive/Obj 304 //! \var UserAllocVersion 305 // \brief Boolean indicating if Version string is non-static 306 // \para 307 // This only needs to be set, if you manually populate \a Version.<br> 308 // It is \b recommended that you use \a ILibSetVersion 309 int UserAllocVersion; // Set flag if you allocate memory pointed to by Version 310 int ClonedPacket; 311 312 //! \var FirstField 313 // \brief Pointer to the first Header field 314 struct packetheader_field_node* FirstField; 315 //! \var LastField 316 // \brief Pointer to the last Header field 317 struct packetheader_field_node* LastField; 318 319 //! \var Source 320 // \brief The origin of this packet 321 // \para 322 // This is only populated if you obtain this structure from either \a ILibWebServer or 323 // \a ILibWebClient. 324 struct sockaddr_in *Source; 325 //! \var ReceivingAddress 326 // \brief IP address that this packet was received on 327 // \para 328 // This is only populated if you obtain this structure from either \a ILibWebServer or 329 // \a ILibWebClient. 330 int ReceivingAddress; 331}; 332*/ 333/*! \struct ILibXMLNode 334 \brief An XML Tree 335 \para 336 This is obtained via a call to \a ILibParseXML. It is \b highly \b recommended 337 that you call \a ILibProcessXMLNodeList, so that the node pointers at the end of this 338 structure will be populated. That will greatly simplify node traversal.<br><br> 339 In order for namespaces to be resolved, you must call \a ILibXML_BuildNamespaceLookupTable(...) 340 with root-most node that you would like to resolve namespaces for. It is recommended that you always use 341 the root node, obtained from the initial call to \a ILibParseXML.<br><br> 342 For most intents and purposes, you only need to work with the "StartElements" 343*/ 344struct ILibXMLNode 345{ 346 /*! \var Name 347 \brief Local Name of the current element 348 */ 349 char* Name; // Element Name 350 /*! \var NameLength 351 \brief Length of \a Name 352 */ 353 int NameLength; 354 355 /*! \var NSTag 356 \brief Namespace Prefix of the current element 357 \para 358 This can be resolved using a call to \a ILibXML_LookupNamespace(...) 359 */ 360 char* NSTag; // Element Prefix 361 /*! \var NSLength 362 \brief Length of \a NSTag 363 */ 364 int NSLength; 365 366 /*! \var StartTag 367 \brief boolean indicating if the current element is a start element 368 */ 369 int StartTag; // Non zero if this is a StartElement 370 /*! \var EmptyTag 371 \brief boolean indicating if this element is an empty element 372 */ 373 int EmptyTag; // Non zero if this is an EmptyElement 374 375 void *Reserved; // DO NOT TOUCH 376 void *Reserved2; // DO NOT TOUCH 377 378 /*! \var Next 379 \brief Pointer to the child of the current node 380 */ 381 struct ILibXMLNode *Next; // Next Node 382 /*! \var Parent 383 \brief Pointer to the Parent of the current node 384 */ 385 struct ILibXMLNode *Parent; // Parent Node 386 /*! \var Peer 387 \brief Pointer to the sibling of the current node 388 */ 389 struct ILibXMLNode *Peer; // Sibling Node 390 struct ILibXMLNode *ClosingTag; // Pointer to closing node of this element 391 struct ILibXMLNode *StartingTag; // Pointer to start node of this element 392}; 393 394/*! \struct ILibXMLAttribute 395 \brief A list of XML Attributes for a specified XML node 396 \para 397 This can be obtained via a call to \a ILibGetXMLAttributes(...) 398*/ 399/* 400struct ILibXMLAttribute 401{ 402 //! \var Name 403 \brief Local name of Attribute 404 char* Name; // Attribute Name 405 //! \var NameLength 406 \brief Length of \a Name 407 int NameLength; 408 409 //! \var Prefix 410 \brief Namespace Prefix of this attribute 411 \para 412 This can be resolved by calling \a ILibXML_LookupNamespace(...) and passing in \a Parent as the current node 413 char* Prefix; // Attribute Namespace Prefix 414 //! \var PrefixLength 415 \brief Lenth of \a Prefix 416 int PrefixLength; 417 418 //! \var Parent 419 \brief Pointer to the XML Node that contains this attribute 420 struct ILibXMLNode *Parent; // The XML Node this attribute belongs to 421 422 //! \var Value 423 \brief Attribute Value 424 char* Value; // Attribute Value 425 //! \var ValueLength 426 \brief Length of \a Value 427 int ValueLength; 428 //! \var Next 429 \brief Pointer to the next attribute 430 struct ILibXMLAttribute *Next; // Next Attribute 431}; 432*/ 433 434/*! \fn ILibFindEntryInTable(char *Entry, char **Table) 435 \brief Find the index in \a Table that contains \a Entry. 436*/ 437//int ILibFindEntryInTable(char *Entry, char **Table); 438 439 440char *ILibReadFileFromDisk(char *FileName, int *FileLen); 441int ILibReadFileFromDiskEx(char **Target, char *FileName); 442//void ILibWriteStringToDisk(char *FileName, char *data); 443 444/*! \defgroup StackGroup Stack 445 \ingroup DataStructures 446 Stack Methods 447 \{ 448*/ 449void ILibCreateStack(void **TheStack); 450void ILibPushStack(void **TheStack, void *data); 451void *ILibPopStack(void **TheStack); 452void *ILibPeekStack(void **TheStack); 453void ILibClearStack(void **TheStack); 454/*! \} */ 455 456/*! \defgroup QueueGroup Queue 457 \ingroup DataStructures 458 Queue Methods 459 \{ 460*/ 461//void *ILibQueue_Create(); 462//void ILibQueue_Destroy(void *q); 463//int ILibQueue_IsEmpty(void *q); 464//void ILibQueue_EnQueue(void *q, void *data); 465//void *ILibQueue_DeQueue(void *q); 466//void *ILibQueue_PeekQueue(void *q); 467//void ILibQueue_Lock(void *q); 468//void ILibQueue_UnLock(void *q); 469/* \} */ 470 471 472/*! \defgroup XML XML Parsing Methods 473 \ingroup ILibParsers 474MicroStack supplied XML Parsing Methods 475 \par 476\b Note: None of the XML Parsing Methods copy or allocate memory 477The lifetime of any/all strings is bound to the underlying string that was 478parsed using ILibParseXML. If you wish to keep any of these strings for longer 479then the lifetime of the underlying string, you must copy the string. 480 \{ 481*/ 482 483 484// 485// Parses an XML string. Returns a tree of ILibXMLNode elements. 486// 487struct ILibXMLNode *ILibParseXML(char *buffer, int offset, int length); 488 489// 490// Preprocesses the tree of ILibXMLNode elements returned by ILibParseXML. 491// This method populates all the node pointers in each node for easy traversal. 492// In addition, this method will also determine if the given XML document was well formed. 493// Returns 0 if processing succeeded. Specific Error Codes are returned otherwise. 494// 495int ILibProcessXMLNodeList(struct ILibXMLNode *nodeList); 496 497// 498// Initalizes a namespace lookup table for a given parent node. 499// If you want to resolve namespaces, you must call this method exactly once 500// 501//void ILibXML_BuildNamespaceLookupTable(struct ILibXMLNode *node); 502 503// 504// Resolves a namespace prefix. 505// 506//char* ILibXML_LookupNamespace(struct ILibXMLNode *currentLocation, char *prefix, int prefixLength); 507 508// 509// Fetches all the data for an element. Returns the length of the populated data 510// 511int ILibReadInnerXML(struct ILibXMLNode *node, char **RetVal); 512 513// 514// Returns the attributes of an XML element. Returned as a linked list of ILibXMLAttribute. 515// 516//struct ILibXMLAttribute *ILibGetXMLAttributes(struct ILibXMLNode *node); 517 518void ILibDestructXMLNodeList(struct ILibXMLNode *node); 519//void ILibDestructXMLAttributeList(struct ILibXMLAttribute *attribute); 520 521// 522// Escapes an XML string. 523// indata must be pre-allocated. 524// 525//int ILibXmlEscape(char* outdata, const char* indata); 526 527// 528// Returns the required size string necessary to escape this XML string 529// 530//int ILibXmlEscapeLength(const char* data); 531 532// 533// Unescapes an XML string. 534// Since Unescaped strings are always shorter than escaped strings, 535// the resultant string will overwrite the supplied string, to save memory 536// 537//int ILibInPlaceXmlUnEscape(char* data); 538 539/*! \} */ 540 541/*! \defgroup ChainGroup Chain Methods 542 \ingroup ILibParsers 543 \brief Chaining Methods 544 \{ 545*/ 546//void *ILibCreateChain(); 547//void ILibAddToChain(void *chain, void *object); 548//void ILibStartChain(void *chain); 549//void ILibStopChain(void *chain); 550//void ILibForceUnBlockChain(void *Chain); 551/* \} */ 552 553 554 555/*! \defgroup LinkedListGroup Linked List 556 \ingroup DataStructures 557 \{ 558*/ 559 560// 561// Initializes a new Linked List data structre 562// 563//void* ILibLinkedList_Create(); 564 565// 566// Returns the Head node of a linked list data structure 567// 568//void* ILibLinkedList_GetNode_Head(void *LinkedList); // Returns Node 569 570// 571// Returns the Tail node of a linked list data structure 572// 573//void* ILibLinkedList_GetNode_Tail(void *LinkedList); // Returns Node 574 575// 576// Returns the Next node of a linked list data structure 577// 578//void* ILibLinkedList_GetNextNode(void *LinkedList_Node); // Returns Node 579 580// 581// Returns the Previous node of a linked list data structure 582// 583//void* ILibLinkedList_GetPreviousNode(void *LinkedList_Node);// Returns Node 584 585// 586// Returns the number of nodes contained in a linked list data structure 587// 588//long ILibLinkedList_GetCount(void *LinkedList); 589 590// 591// Returns a shallow copy of a linked list data structure. That is, the structure 592// is copied, but none of the data contents are copied. The pointer values are just copied. 593// 594//void* ILibLinkedList_ShallowCopy(void *LinkedList); 595 596// 597// Returns the data pointer of a linked list element 598// 599//void *ILibLinkedList_GetDataFromNode(void *LinkedList_Node); 600 601// 602// Creates a new element, and inserts it before the given node 603// 604//void ILibLinkedList_InsertBefore(void *LinkedList_Node, void *data); 605 606// 607// Creates a new element, and inserts it after the given node 608// 609//void ILibLinkedList_InsertAfter(void *LinkedList_Node, void *data); 610 611// 612// Removes the given node from a linked list data structure 613// 614//void ILibLinkedList_Remove(void *LinkedList_Node); 615 616// 617// Given a data pointer, will traverse the linked list data structure, deleting 618// elements that point to this data pointer. 619// 620//void ILibLinkedList_Remove_ByData(void *LinkedList, void *data); 621 622// 623// Creates a new element, and inserts it at the top of the linked list. 624// 625//void ILibLinkedList_AddHead(void *LinkedList, void *data); 626 627// 628// Creates a new element, and appends it to the end of the linked list 629// 630//void ILibLinkedList_AddTail(void *LinkedList, void *data); 631 632//void ILibLinkedList_Lock(void *LinkedList); 633//void ILibLinkedList_UnLock(void *LinkedList); 634//void ILibLinkedList_Destroy(void *LinkedList); 635/*! \} */ 636 637 638 639/*! \defgroup HashTreeGroup Hash Table 640 \ingroup DataStructures 641 \b Note: Duplicate key entries will be overwritten. 642 \{ 643*/ 644 645// 646// Initialises a new Hash Table (tree) data structure 647// 648//void* ILibInitHashTree(); 649//void ILibDestroyHashTree(void *tree); 650 651// 652// Returns non-zero if the key entry is found in the table 653// 654//int ILibHasEntry(void *hashtree, char* key, int keylength); 655 656// 657// Add a new entry into the hashtable. If the key is already used, it will be overwriten. 658// 659//void ILibAddEntry(void* hashtree, char* key, int keylength, void *value); 660//void* ILibGetEntry(void *hashtree, char* key, int keylength); 661//void ILibDeleteEntry(void *hashtree, char* key, int keylength); 662 663// 664// Returns an Enumerator to browse all the entries of the Hashtable 665// 666//void *ILibHashTree_GetEnumerator(void *tree); 667//void ILibHashTree_DestroyEnumerator(void *tree_enumerator); 668 669// 670// Advance the Enumerator to the next element. 671// Returns non-zero if there are no more entries to enumerate 672// 673//int ILibHashTree_MoveNext(void *tree_enumerator); 674 675// 676// Obtains the value of a Hashtable Entry. 677// 678//void ILibHashTree_GetValue(void *tree_enumerator, char **key, int *keyLength, void **data); 679//void ILibHashTree_Lock(void *hashtree); 680//void ILibHashTree_UnLock(void *hashtree); 681 682/*! \} */ 683 684/*! \defgroup LifeTimeMonitor LifeTimeMonitor 685 \ingroup ILibParsers 686 \brief Timed Callback Service 687 \para 688 These callbacks will always be triggered on the thread that calls ILibStartChain(). 689 \{ 690*/ 691 692// 693// Adds an event trigger to be called after the specified time elapses, with the 694// specified data object 695// 696//#define ILibLifeTime_Add(LifetimeMonitorObject, data, seconds, Callback, Destroy) ILibLifeTime_AddEx(LifetimeMonitorObject, data, seconds*1000, Callback, Destroy) 697//void ILibLifeTime_AddEx(void *LifetimeMonitorObject,void *data, int milliseconds, void* Callback, void* Destroy); 698 699// 700// Removes all event triggers that contain the specified data object. 701// 702//void ILibLifeTime_Remove(void *LifeTimeToken, void *data); 703 704// 705// Removes all events triggers 706// 707//void ILibLifeTime_Flush(void *LifeTimeToken); 708//void *ILibCreateLifeTime(void *Chain); 709 710/* \} */ 711 712 713/*! \defgroup StringParsing String Parsing 714 \ingroup ILibParsers 715 \{ 716*/ 717 718// 719// Trims preceding and proceding whitespaces from a string 720// 721//int ILibTrimString(char **theString, int length); 722 723// 724// Parses the given string using the specified multichar delimiter. 725// Returns a parser_result object, which points to a linked list 726// of parser_result_field objects. 727// 728struct parser_result* ILibParseString(char* buffer, int offset, int length, char* Delimiter, int DelimiterLength); 729 730// 731// Same as ILibParseString, except this method ignore all delimiters that are contains within 732// quotation marks 733// 734//struct parser_result* ILibParseStringAdv(char* buffer, int offset, int length, char* Delimiter, int DelimiterLength); 735 736// 737// Releases resources used by string parser 738// 739void ILibDestructParserResults(struct parser_result *result); 740 741// 742// Parses a URI into IP Address, Port Number, and Path components 743// Note: IP and Path must be freed. 744// 745//void ILibParseUri(char* URI, char** IP, unsigned short* Port, char** Path); 746 747// 748// Parses a string into a Long or unsigned Long. 749// Returns non-zero on error condition 750// 751//int ILibGetLong(char *TestValue, int TestValueLength, long* NumericValue); 752//int ILibGetULong(const char *TestValue, const int TestValueLength, unsigned long* NumericValue); 753//int ILibFragmentText(char *text, int textLength, char *delimiter, int delimiterLength, int tokenLength, char **RetVal); 754//int ILibFragmentTextLength(char *text, int textLength, char *delimiter, int delimiterLength, int tokenLength); 755 756 757/* Base64 handling methods */ 758//int ILibBase64Encode(unsigned char* input, const int inputlen, unsigned char** output); 759//int ILibBase64Decode(unsigned char* input, const int inputlen, unsigned char** output); 760 761/* Compression Handling Methods */ 762//char* ILibDecompressString(unsigned char* CurrentCompressed, const int bufferLength, const int DecompressedLength); 763 764/* \} */ 765 766 767/*! \defgroup PacketParsing Packet Parsing 768 \ingroup ILibParsers 769 \{ 770*/ 771 772/* Packet Methods */ 773 774// 775// Allocates an empty HTTP Packet 776// 777//struct packetheader *ILibCreateEmptyPacket(); 778 779// 780// Add a header into the packet. (String is copied) 781// 782//void ILibAddHeaderLine(struct packetheader *packet, char* FieldName, int FieldNameLength, char* FieldData, int FieldDataLength); 783 784// 785// Fetches the header value from the packet. (String is NOT copied) 786// Returns NULL if the header field does not exist 787// 788//char* ILibGetHeaderLine(struct packetheader *packet, char* FieldName, int FieldNameLength); 789 790// 791// Sets the HTTP version: 1.0, 1.1, etc. (string is copied) 792// 793//void ILibSetVersion(struct packetheader *packet, char* Version, int VersionLength); 794 795// 796// Set the status code and data line. The status data is copied. 797// 798//void ILibSetStatusCode(struct packetheader *packet, int StatusCode, char* StatusData, int StatusDataLength); 799 800// 801// Sets the method and path. (strings are copied) 802// 803//void ILibSetDirective(struct packetheader *packet, char* Directive, int DirectiveLength, char* DirectiveObj, int DirectiveObjLength); 804 805// 806// Releases all resources consumed by this packet structure 807// 808//void ILibDestructPacket(struct packetheader *packet); 809 810// 811// Parses a string into an packet structure. 812// None of the strings are copied, so the lifetime of all the values are bound 813// to the lifetime of the underlying string that is parsed. 814// 815//struct packetheader* ILibParsePacketHeader(char* buffer, int offset, int length); 816 817// 818// Returns the packetized string and it's length. (must be freed) 819// 820//int ILibGetRawPacket(struct packetheader *packet,char **buffer); 821 822// 823// Performs a deep copy of a packet structure 824// 825//struct packetheader* ILibClonePacket(struct packetheader *packet); 826 827// 828// Escapes a string according to HTTP escaping rules. 829// indata must be pre-allocated 830// 831//int ILibHTTPEscape(char* outdata, const char* indata); 832 833// 834// Returns the size of string required to escape this string, 835// according to HTTP escaping rules 836// 837//int ILibHTTPEscapeLength(const char* data); 838 839// 840// Unescapes the escaped string sequence 841// Since escaped string sequences are always longer than unescaped 842// string sequences, the resultant string is overwritten onto the supplied string 843// 844//int ILibInPlaceHTTPUnEscape(char* data); 845/* \} */ 846 847/*! \defgroup NetworkHelper Network Helper 848 \ingroup ILibParsers 849 \{ 850*/ 851 852// 853// Obtain an array of IP Addresses available on the local machine. 854// 855//int ILibGetLocalIPAddressList(int** pp_int); 856//#if defined(WINSOCK2) 857// int ILibGetLocalIPAddressNetMask(int address); 858// unsigned short ILibGetDGramSocket(int local, HANDLE *TheSocket); 859// unsigned short ILibGetStreamSocket(int local, unsigned short PortNumber,HANDLE *TheSocket); 860//#elif defined(WINSOCK1) || defined(_WIN32_WCE) 861// unsigned short ILibGetDGramSocket(int local, SOCKET *TheSocket); 862// unsigned short ILibGetStreamSocket(int local, unsigned short PortNumber,SOCKET *TheSocket); 863//#else 864// unsigned short ILibGetDGramSocket(int local, int *TheSocket); 865// unsigned short ILibGetStreamSocket(int local, unsigned short PortNumber,int *TheSocket); 866//#endif 867 868/* \} */ 869/* 870void* dbg_malloc(int sz); 871void dbg_free(void* ptr); 872int dbg_GetCount(); 873*/ 874/* \} */ // End of ILibParser Group 875#endif 876