Changeset 71
- Timestamp:
- May 22, 2001, 7:18:41 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/expat/expat.h
r39 r71 101 101 // one of: 102 102 // -- XML_CQUANT_NONE --> all fields below are NULL 103 // -- XML_CQUANT_OPT, 104 // -- XML_CQUANT_REP, 105 // -- XML_CQUANT_PLUS 103 // -- XML_CQUANT_OPT, question mark 104 // -- XML_CQUANT_REP, asterisk 105 // -- XML_CQUANT_PLUS plus sign 106 106 107 107 const XML_Char *name; … … 626 626 #define ERROR_XML_FIRST 40000 // first error code used 627 627 628 typedef enum _XMLERROR 629 { 630 ERROR_EXPAT_NONE = 0, 631 // ERROR_EXPAT_NONE, // removed to adhere with APIRET V0.9.9 (2001-02-14) [umoeller] 632 ERROR_EXPAT_NO_MEMORY = ERROR_XML_FIRST, 633 ERROR_EXPAT_SYNTAX, 634 ERROR_EXPAT_NO_ELEMENTS, 635 ERROR_EXPAT_INVALID_TOKEN, 636 ERROR_EXPAT_UNCLOSED_TOKEN, 637 ERROR_EXPAT_PARTIAL_CHAR, 638 ERROR_EXPAT_TAG_MISMATCH, 639 ERROR_EXPAT_DUPLICATE_ATTRIBUTE, 640 ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT, 641 ERROR_EXPAT_PARAM_ENTITY_REF, 642 ERROR_EXPAT_UNDEFINED_ENTITY, 643 ERROR_EXPAT_RECURSIVE_ENTITY_REF, 644 ERROR_EXPAT_ASYNC_ENTITY, 645 ERROR_EXPAT_BAD_CHAR_REF, 646 ERROR_EXPAT_BINARY_ENTITY_REF, 647 ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF, 648 ERROR_EXPAT_MISPLACED_XML_PI, 649 ERROR_EXPAT_UNKNOWN_ENCODING, 650 ERROR_EXPAT_INCORRECT_ENCODING, 651 ERROR_EXPAT_UNCLOSED_CDATA_SECTION, 652 ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING, 653 ERROR_EXPAT_NOT_STANDALONE, 654 ERROR_EXPAT_UNEXPECTED_STATE, 655 656 ERROR_EXPAT_AFTER_LAST // added V0.9.9 (2001-02-14) [umoeller]; 657 // xml.h builds on this 658 } XMLERROR; 628 typedef unsigned long XMLERROR; // V0.9.12 (2001-05-20) [umoeller] 629 630 #define ERROR_EXPAT_NONE 0 631 #define ERROR_EXPAT_NO_MEMORY (ERROR_XML_FIRST) 632 #define ERROR_EXPAT_SYNTAX (ERROR_XML_FIRST + 1) 633 #define ERROR_EXPAT_NO_ELEMENTS (ERROR_XML_FIRST + 2) 634 #define ERROR_EXPAT_INVALID_TOKEN (ERROR_XML_FIRST + 3) 635 #define ERROR_EXPAT_UNCLOSED_TOKEN (ERROR_XML_FIRST + 4) 636 #define ERROR_EXPAT_PARTIAL_CHAR (ERROR_XML_FIRST + 5) 637 #define ERROR_EXPAT_TAG_MISMATCH (ERROR_XML_FIRST + 6) 638 #define ERROR_EXPAT_DUPLICATE_ATTRIBUTE (ERROR_XML_FIRST + 7) 639 #define ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT (ERROR_XML_FIRST + 8) 640 #define ERROR_EXPAT_PARAM_ENTITY_REF (ERROR_XML_FIRST + 10) 641 #define ERROR_EXPAT_UNDEFINED_ENTITY (ERROR_XML_FIRST + 11) 642 #define ERROR_EXPAT_RECURSIVE_ENTITY_REF (ERROR_XML_FIRST + 12) 643 #define ERROR_EXPAT_ASYNC_ENTITY (ERROR_XML_FIRST + 13) 644 #define ERROR_EXPAT_BAD_CHAR_REF (ERROR_XML_FIRST + 14) 645 #define ERROR_EXPAT_BINARY_ENTITY_REF (ERROR_XML_FIRST + 15) 646 #define ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF (ERROR_XML_FIRST + 16) 647 #define ERROR_EXPAT_MISPLACED_XML_PI (ERROR_XML_FIRST + 17) 648 #define ERROR_EXPAT_UNKNOWN_ENCODING (ERROR_XML_FIRST + 18) 649 #define ERROR_EXPAT_INCORRECT_ENCODING (ERROR_XML_FIRST + 19) 650 #define ERROR_EXPAT_UNCLOSED_CDATA_SECTION (ERROR_XML_FIRST + 20) 651 #define ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING (ERROR_XML_FIRST + 21) 652 #define ERROR_EXPAT_NOT_STANDALONE (ERROR_XML_FIRST + 22) 653 #define ERROR_EXPAT_UNEXPECTED_STATE (ERROR_XML_FIRST + 23) 659 654 660 655 /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode -
trunk/include/helpers/linklist.h
r53 r71 140 140 typedef LSTINIT *PLSTINIT; 141 141 142 #ifdef __ XWPMEMDEBUG__ // setup.h, helpers\memdebug.c142 #ifdef __DEBUG_MALLOC_ENABLED__ // setup.h, helpers\memdebug.c 143 143 PLINKLIST XWPENTRY lstCreateDebug(BOOL fItemsFreeable, 144 144 const char *file, … … 194 194 typedef LSTINDEXFROMITEM *PLSTINDEXFROMITEM; 195 195 196 #ifdef __ XWPMEMDEBUG__ // setup.h, helpers\memdebug.c196 #ifdef __DEBUG_MALLOC_ENABLED__ // setup.h, helpers\memdebug.c 197 197 PLISTNODE XWPENTRY lstAppendItemDebug(PLINKLIST pList, 198 198 void* pNewItemData, -
trunk/include/helpers/memdebug.h
r14 r71 138 138 #endif 139 139 140 #define __DEBUG_MALLOC_ENABLED__ 141 140 142 #endif 141 143 #endif -
trunk/include/helpers/prfh.h
r68 r71 52 52 PSZ *ppszKeys); 53 53 54 #ifdef __ XWPMEMDEBUG__ // setup.h, helpers\memdebug.c54 #ifdef __DEBUG_MALLOC_ENABLED__ // setup.h, helpers\memdebug.c 55 55 PSZ prfhQueryProfileDataDebug(HINI hIni, 56 56 const char *pcszApp, -
trunk/include/helpers/winh.h
r69 r71 543 543 BOOL fSelectTarget); 544 544 545 ULONG XWPENTRY winhLboxFindItemFromHandle(HWND hwndListBox, 546 ULONG ulHandle); 547 545 548 /* ****************************************************************** 546 549 * -
trunk/include/helpers/xml.h
r64 r71 43 43 ********************************************************************/ 44 44 45 typedef enum _DOMERROR 46 { 47 // validity errors: 45 // ERROR_XML_FIRST is defined in expat\expat.h; 46 // the range up to ERROR_XML_FIRST + 24 is used 47 // by expat 48 48 49 // START MATCHING ERROR MESSAGES (xmlDescribeError) 49 ERROR_DOM_UNDECLARED_ELEMENT = ERROR_EXPAT_AFTER_LAST, 50 // validity errors: 51 #define ERROR_DOM_UNDECLARED_ELEMENT (ERROR_XML_FIRST + 24) 50 52 // invalidity: element is undeclared 51 ERROR_DOM_ROOT_ELEMENT_MISNAMED,52 ERROR_DOM_INVALID_ROOT_ELEMENT,53 ERROR_DOM_INVALID_SUBELEMENT,53 #define ERROR_DOM_ROOT_ELEMENT_MISNAMED (ERROR_XML_FIRST + 25) 54 #define ERROR_DOM_INVALID_ROOT_ELEMENT (ERROR_XML_FIRST + 26) 55 #define ERROR_DOM_INVALID_SUBELEMENT (ERROR_XML_FIRST + 27) 54 56 // subelement may not appear in its parent element 55 ERROR_DOM_DUPLICATE_ELEMENT_DECL,57 #define ERROR_DOM_DUPLICATE_ELEMENT_DECL (ERROR_XML_FIRST + 28) 56 58 // more than one declaration for an element type 57 ERROR_DOM_DUPLICATE_ATTRIBUTE_DECL,59 #define ERROR_DOM_DUPLICATE_ATTRIBUTE_DECL (ERROR_XML_FIRST + 29) 58 60 // more than one declaration for an attribute type 59 ERROR_DOM_UNDECLARED_ATTRIBUTE,60 ERROR_ELEMENT_CANNOT_HAVE_CONTENT,61 #define ERROR_DOM_UNDECLARED_ATTRIBUTE (ERROR_XML_FIRST + 30) 62 #define ERROR_ELEMENT_CANNOT_HAVE_CONTENT (ERROR_XML_FIRST + 31) 61 63 // element was declared "empty" and contains text anyway, 62 64 // or was declared "children" and contains something other 63 65 // than whitespace 64 ERROR_DOM_INVALID_ATTRIB_VALUE,65 ERROR_DOM_REQUIRED_ATTRIBUTE_MISSING,66 ERROR_DOM_SUBELEMENT_IN_EMPTY_ELEMENT,66 #define ERROR_DOM_INVALID_ATTRIB_VALUE (ERROR_XML_FIRST + 32) 67 #define ERROR_DOM_REQUIRED_ATTRIBUTE_MISSING (ERROR_XML_FIRST + 33) 68 #define ERROR_DOM_SUBELEMENT_IN_EMPTY_ELEMENT (ERROR_XML_FIRST + 34) 67 69 // END MATCHING ERROR MESSAGES (xmlDescribeError) 68 70 69 71 // error categories: 70 ERROR_DOM_PARSING,71 ERROR_DOM_VALIDITY,72 #define ERROR_DOM_PARSING (ERROR_XML_FIRST + 35) 73 #define ERROR_DOM_VALIDITY (ERROR_XML_FIRST + 36) 72 74 73 75 // additional DOM errors 74 ERROR_DOM_NODETYPE_NOT_SUPPORTED,76 #define ERROR_DOM_NODETYPE_NOT_SUPPORTED (ERROR_XML_FIRST + 37) 75 77 // invalid node type in xmlCreateDomNode 76 ERROR_DOM_NO_DOCUMENT,78 #define ERROR_DOM_NO_DOCUMENT (ERROR_XML_FIRST + 38) 77 79 // cannot find document node 78 ERROR_DOM_NO_ELEMENT,79 ERROR_DOM_DUPLICATE_DOCTYPE,80 ERROR_DOM_DOCTYPE_ROOT_NAMES_MISMATCH,80 #define ERROR_DOM_NO_ELEMENT (ERROR_XML_FIRST + 39) 81 #define ERROR_DOM_DUPLICATE_DOCTYPE (ERROR_XML_FIRST + 40) 82 #define ERROR_DOM_DOCTYPE_ROOT_NAMES_MISMATCH (ERROR_XML_FIRST + 41) 81 83 // DOCTYPE is given and root element name does not match doctype name 82 ERROR_DOM_INTEGRITY,83 ERROR_DOM_DUPLICATE_ATTRIBUTE,84 #define ERROR_DOM_INTEGRITY (ERROR_XML_FIRST + 42) 85 #define ERROR_DOM_DUPLICATE_ATTRIBUTE (ERROR_XML_FIRST + 43) 84 86 85 87 // @@@todo these 86 ERROR_DOM_VALIDATE_INVALID_ELEMENT, 87 ERROR_DOM_ELEMENT_DECL_OUTSIDE_DOCTYPE, 88 ERROR_DOM_ATTLIST_DECL_OUTSIDE_DOCTYPE 89 } DOMERROR; 88 #define ERROR_DOM_VALIDATE_INVALID_ELEMENT (ERROR_XML_FIRST + 44) 89 #define ERROR_DOM_ELEMENT_DECL_OUTSIDE_DOCTYPE (ERROR_XML_FIRST + 45) 90 #define ERROR_DOM_ATTLIST_DECL_OUTSIDE_DOCTYPE (ERROR_XML_FIRST + 46) 90 91 91 92 const char* xmlDescribeError(int code); … … 130 131 /* 131 132 *@@ NODEBASE: 132 * "content model" node. With the DOM content models, 133 * this represents an entry in a DTD or XML schema. 133 * root class of all nodes used in the 134 * DOM tree. 135 * 136 * The first item is a TREE to make this insertable 137 * into string maps via the functions in tree.c. 138 * 139 * A NODEBASE is also the first member of a DOMNODE 140 * so this is effectively a simulation of inheritance 141 * in plain C... DOMNODE inherits from NODEBASE, 142 * and some other types inherit from DOMNODE. 143 * 144 * This contains the node name, which is also used 145 * by the DOMNODE's (e.g. for element names). 146 * However, only DOMNODE defines the node value 147 * string. 134 148 * 135 149 *@@added V0.9.9 (2001-02-14) [umoeller] … … 138 152 typedef struct _NODEBASE 139 153 { 140 TREE Tree; 141 142 NODEBASETYPE ulNodeType; 154 TREE Tree; // tree.c 155 156 NODEBASETYPE ulNodeType; // class type; this is precious, 157 // all xml* functions make assumptions 158 // from this value 143 159 144 160 XSTRING strNodeName; … … 189 205 * Overview of member fields usage: 190 206 + 191 + ulNodeType | strNodeName | strNodeValue | llChildren | llAttributes 207 + ulNodeType | strNodeName | strNodeValue | llChildren | AttributesMap 208 + (NODEBASE) | (NODEBASE) | (DOMNODE) | (DOMNODE) | (DOMNODE) 192 209 + ======================================================================= 193 210 + | | | | … … 409 426 // one of: 410 427 // -- XML_CQUANT_NONE --> all fields below are NULL 411 // -- XML_CQUANT_OPT, 412 // -- XML_CQUANT_REP, 413 // -- XML_CQUANT_PLUS 428 // -- XML_CQUANT_OPT, question mark 429 // -- XML_CQUANT_REP, asterisk 430 // -- XML_CQUANT_PLUS plus sign 414 431 415 432 struct _CMELEMENTPARTICLE *pParentParticle; // or NULL if this is in the … … 596 613 /* ****************************************************************** 597 614 * 598 * DOM APIs615 * DOM parser APIs 599 616 * 600 617 ********************************************************************/ … … 690 707 const char *pcszAttribName); 691 708 709 /* ****************************************************************** 710 * 711 * DOM build 712 * 713 ********************************************************************/ 714 715 APIRET xmlCreateDocument(const char *pcszRootElementName, 716 PDOMDOCUMENTNODE *ppDocument, 717 PDOMNODE *ppRootElement); 718 719 APIRET xmlWriteDocument(PDOMDOCUMENTNODE pDocument, 720 const char *pcszEncoding, 721 const char *pcszDoctype, 722 PXSTRING pxstr); 692 723 #endif 693 724 -
trunk/src/helpers/configsys.c
r63 r71 159 159 * for analyzing CONFIG.SYS settings. 160 160 * 161 * Remarks: 162 * 163 * -- With pcszKey, you can either specify a CONFIG.SYS 164 * key WITH an equals sign (e.g. search for "LIBPATH=") 165 * or the key name only (e.g. "SET SHELL"). 166 * 167 * Only in the latter case, this function makes sure 168 * that the search key is complete; e.g. it will not 169 * find "SET SHELLHANDLESINC=" then. 170 * 171 * -- If the line found starts with leading spaces, 172 * *ppStartOfLine will still receive the start of 173 * the line. 174 * For example, if you're searching for "SET PATH" 175 * and the PATH line is 176 * 177 + " SET PATH=C:\os2" 178 * 179 * the first space in the line is written into 180 * *ppStartOfLine. 181 * 161 182 *@@changed V0.9.0 [umoeller]: fixed bug in that this would also return something if only the first chars matched 162 183 *@@changed V0.9.0 [umoeller]: fixed bug which could cause character before pszSearchIn to be examined … … 164 185 *@@changed V0.9.7 (2001-01-15) [umoeller]: now checking for tabs too 165 186 *@@changed V0.9.11 (2001-04-25) [umoeller]: this never found lines which had leading spaces, fixed 187 *@@changed V0.9.12 (2001-05-22) [umoeller]: added checks for key termination (SET SHELLHANDLESINC) 166 188 */ 167 189 … … 177 199 ULONG ulKeyLength = strlen(pcszKey); 178 200 201 BOOL fSearchKeyContainsEquals = (strchr(pcszKey, '=') != 0); 202 179 203 do 180 204 { 181 p = strhistr(p, pcszKey);182 183 if ( (p)184 && (p >= pcszSearchIn)185 205 // find the key 206 // (on first loop, p is start of buffer; 207 // on subsequent loops, p is somewhere in bufer, 208 // if we've found the key somewhere else) 209 if (p = strhistr(p, pcszKey)) 186 210 { 187 211 // make sure the key is at the beginning of a line … … 207 231 // OK, we're at the start of a line: 208 232 209 // return address of key 210 pReturn = (PSZ)p; 211 // return start of line 212 if (ppStartOfLine) 213 *ppStartOfLine = (PSZ)pStartOfLine; 214 215 // test for all upper case? 216 if (pfIsAllUpperCase) 233 // check the character AFTER the 234 // key if it's a space or '='; 235 // without this check, we'd find 236 // SET SHELL= if caller is really 237 // looking for SET SHELLHANDLESINC=, 238 // but only do this check if the caller 239 // doesn't have '=' in the search string 240 // already 241 // V0.9.12 (2001-05-22) [umoeller] 242 CHAR c = *(p + ulKeyLength); 243 if ( (fSearchKeyContainsEquals) 244 || (c == ' ') 245 || (c == '=') 246 || (c == '\n') 247 || (c == '\r') 248 || (c == '\t') 249 ) 217 250 { 218 ULONG ul = 0; 219 *pfIsAllUpperCase = TRUE; 220 221 for (ul = 0; 222 ul < ulKeyLength; 223 ul++) 251 // return address of key 252 pReturn = (PSZ)p; 253 // return start of line 254 if (ppStartOfLine) 255 *ppStartOfLine = (PSZ)pStartOfLine; 256 257 // test for all upper case? 258 if (pfIsAllUpperCase) 224 259 { 225 if (islower(*(p + ul))) 260 ULONG ul = 0; 261 *pfIsAllUpperCase = TRUE; 262 263 for (ul = 0; 264 ul < ulKeyLength; 265 ul++) 226 266 { 227 *pfIsAllUpperCase = FALSE; 228 break; // for 267 if (islower(*(p + ul))) 268 { 269 *pfIsAllUpperCase = FALSE; 270 break; // for 271 } 229 272 } 230 273 } 231 } 232 233 break; // do274 275 break; // do 276 } // else search next key 234 277 } // else search next key 235 278 236 p++; // search on after this key 279 p += ulKeyLength; // search on after this key 280 // now skipping ulKeyLength V0.9.12 (2001-05-22) [umoeller] 237 281 } 238 282 else … … 475 519 * 476 520 * If the manipulation succeeded, NO_ERROR is returned 477 * and *ppszChanged receives a new string describing521 * and pstrChanged receives a new string describing 478 522 * what was changed. This can be: 479 523 * … … 502 546 * 503 547 * -- This assumes that the line breaks are represented 504 * by \r\n items ONLY. 548 * by \n ONLY. If *ppszContents has \r\n line breaks, 549 * they must be converted to pure \n first. 505 550 */ 506 551 … … 611 656 &pStartOfLineWithKeyFound, 612 657 &fIsAllUpperCase); 658 // returns beginning of line 613 659 614 660 if (!pKeyFound) -
trunk/src/helpers/dosh2.c
r69 r71 499 499 * 500 500 *@@added V0.9.4 (2000-07-19) [umoeller] 501 *@@changed V0.9.12 (2001-05-21) [umoeller]: fixed memory leak 501 502 */ 502 503 … … 544 545 ppszThis++; 545 546 } 547 548 free(pszSearch); // was missing V0.9.12 (2001-05-21) [umoeller] 546 549 } 547 550 } … … 571 574 *@@added V0.9.4 (2000-07-19) [umoeller] 572 575 *@@changed V0.9.7 (2000-12-17) [umoeller]: added fAddFirst 576 *@@changed V0.9.12 (2001-05-21) [umoeller]: fixed memory leak 573 577 */ 574 578 … … 625 629 else 626 630 { 631 if (pEnv->papszVars) 632 free(pEnv->papszVars); // was missing V0.9.12 (2001-05-21) [umoeller] 633 627 634 pEnv->papszVars = papszNew; 628 635 pEnv->cVars++; -
trunk/src/helpers/linklist.c
r53 r71 235 235 } 236 236 237 #ifdef __ XWPMEMDEBUG__237 #ifdef __DEBUG_MALLOC_ENABLED__ 238 238 239 239 /* … … 263 263 } 264 264 265 #e lse265 #endif // __DEBUG_MALLOC_ENABLED__ 266 266 267 267 /* … … 286 286 */ 287 287 288 PLINKLIST lstCreate(BOOL fItemsFreeable) // in: invoke free() on the data288 PLINKLIST (lstCreate)(BOOL fItemsFreeable) // in: invoke free() on the data 289 289 // item pointers upon destruction? 290 290 { … … 294 294 return (pNewList); 295 295 } 296 297 #endif // __XWPMEMDEBUG__298 296 299 297 /* … … 543 541 } 544 542 545 #ifdef __ XWPMEMDEBUG__543 #ifdef __DEBUG_MALLOC_ENABLED__ 546 544 547 545 /* … … 603 601 } 604 602 605 #e lse603 #endif // __DEBUG_MALLOC_ENABLED__ 606 604 607 605 /* … … 615 613 */ 616 614 617 PLISTNODE lstAppendItem(PLINKLIST pList,615 PLISTNODE (lstAppendItem)(PLINKLIST pList, 618 616 void* pNewItemData) // in: data to store in list node 619 617 { … … 656 654 return (pNewNode); 657 655 } 658 659 #endif // __XWPMEMDEBUG__660 656 661 657 /* -
trunk/src/helpers/memdebug.c
r21 r71 456 456 * 457 457 *@@added V0.9.6 (2000-11-12) [umoeller] 458 *@@changed V0.9.12 (2001-05-21) [umoeller]: this reported errors on realloc(0), which is a valid call, fixed 458 459 */ 459 460 … … 466 467 void *prc = NULL; 467 468 BOOL fFound = FALSE; 469 470 if (!p) 471 // p == NULL: this is valid, use malloc() instead 472 // V0.9.12 (2001-05-21) [umoeller] 473 return (memdMalloc(stSize, pcszSourceFile, ulLine, pcszFunction)); 468 474 469 475 if (memdLock()) -
trunk/src/helpers/memdebug_win.c
r13 r71 479 479 case WM_CREATE: 480 480 { 481 TRY_LOUD(excpt1 , NULL)481 TRY_LOUD(excpt1) 482 482 { 483 483 // PCREATESTRUCT pcs = (PCREATESTRUCT)mp2; -
trunk/src/helpers/prfh.c
r68 r71 122 122 } 123 123 124 #ifdef __ XWPMEMDEBUG__ // setup.h, helpers\memdebug.c124 #ifdef __DEBUG_MALLOC_ENABLED__ // setup.h, helpers\memdebug.c 125 125 126 126 /* -
trunk/src/helpers/winh.c
r69 r71 1492 1492 1493 1493 /* 1494 *@@ winhLboxFindItemFromHandle: 1495 * finds the list box item with the specified 1496 * handle. 1497 * 1498 * Of course this only makes sense if each item 1499 * has a unique handle indeed. 1500 * 1501 * Returns the index of the item found or -1. 1502 * 1503 *@@added V0.9.12 (2001-05-18) [umoeller] 1504 */ 1505 1506 ULONG winhLboxFindItemFromHandle(HWND hwndListBox, 1507 ULONG ulHandle) 1508 { 1509 LONG cItems = WinQueryLboxCount(hwndListBox); 1510 if (cItems) 1511 { 1512 ULONG ul; 1513 for (ul = 0; 1514 ul < cItems; 1515 ul++) 1516 { 1517 if (ulHandle == winhQueryLboxItemHandle(hwndListBox, 1518 ul)) 1519 return (ul); 1520 } 1521 } 1522 1523 return (-1); 1524 } 1525 1526 /* 1494 1527 *@@category: Helpers\PM helpers\Scroll bar helpers 1495 1528 */ … … 3566 3599 * 3567 3600 *@@added V0.9.3 (2000-04-29) [umoeller] 3601 *@@changed V0.9.12 (2001-05-21) [umoeller]: this failed if INI data had root dir, fixed 3568 3602 */ 3569 3603 … … 3580 3614 { 3581 3615 FILEDLG fd; 3616 FILESTATUS3 fs3; 3617 3582 3618 memset(&fd, 0, sizeof(FILEDLG)); 3583 3619 fd.cbSize = sizeof(FILEDLG); … … 3589 3625 fd.fl |= FDS_OPEN_DIALOG; 3590 3626 3591 // default: copy pszFile 3592 strcpy(fd.szFullFile, pszFile); 3593 3594 if ( (hini) && (flFlags & WINH_FOD_INILOADDIR) ) 3595 { 3596 // overwrite with initial directory for FOD from OS2.INI 3597 if (PrfQueryProfileString(hini, 3598 (PSZ)pcszApplication, 3599 (PSZ)pcszKey, 3600 "", // default string V0.9.9 (2001-02-10) [umoeller] 3601 fd.szFullFile, 3602 sizeof(fd.szFullFile)-10) 3603 >= 2) 3604 { 3605 // found: append "\*" 3606 strcat(fd.szFullFile, "\\"); 3607 strcat(fd.szFullFile, pszFile); 3608 } 3609 } 3627 if ( (hini) 3628 && (flFlags & WINH_FOD_INILOADDIR) 3629 && (PrfQueryProfileString(hini, 3630 (PSZ)pcszApplication, 3631 (PSZ)pcszKey, 3632 "", // default string V0.9.9 (2001-02-10) [umoeller] 3633 fd.szFullFile, 3634 sizeof(fd.szFullFile)-10) 3635 > 2) 3636 // added these checks V0.9.12 (2001-05-21) [umoeller] 3637 && (!DosQueryPathInfo(fd.szFullFile, 3638 FIL_STANDARD, 3639 &fs3, 3640 sizeof(fs3))) 3641 && (fs3.attrFile & FILE_DIRECTORY) 3642 ) 3643 { 3644 // found: append "\*" 3645 strcat(fd.szFullFile, "\\"); 3646 strcat(fd.szFullFile, pszFile); 3647 } 3648 else 3649 // default: copy pszFile 3650 strcpy(fd.szFullFile, pszFile); 3651 // fixed V0.9.12 (2001-05-21) [umoeller] 3610 3652 3611 3653 if ( WinFileDlg(HWND_DESKTOP, // parent -
trunk/src/helpers/xml.c
r65 r71 7 7 * layers: 8 8 * 9 * -- The bottom layer is implemented by @expat, which I have10 * ported and hacked to the xwphelpers.9 * -- The bottom layer is implemented by the @expat parser, 10 * which I have ported and hacked to the xwphelpers. 11 11 * 12 12 * See xmlparse.c for an introduction. … … 16 16 * which is vaguely modelled after the Document Object Model 17 17 * (DOM) standardized by the W3C. That's this file. 18 * 19 * This top layer allows you to do two things VERY EASILY: 20 * 21 * 1) Parse an XML document (which uses expat internally) 22 * and build a DOM tree from that. See xmlCreateDOM. 23 * 24 * 2) Create a DOM tree in memory and write an XML 25 * document from that. See xmlCreateDocument. 18 26 * 19 27 * <B>XML</B> … … 43 51 * Most notably, there are the following differences: 44 52 * 53 * -- External entities don't work yet. As a result, DOCTYPE's 54 * only make sense if the entire DTD is in the same document 55 * (internal subset). 56 * 45 57 * -- Not all node types are implemented. See _DOMNODE for 46 58 * the supported types. 47 59 * 48 * -- Only a s mall subset of the standardized methods is implemented,60 * -- Only a subset of the standardized methods is implemented, 49 61 * and they are called differently to adhere to the xwphelpers 50 62 * conventions. … … 349 361 * associated with its members. 350 362 * 351 * NOTE: If you call this for derived types, call352 * this LAST, after you have cleared additional353 * members. After calling this, pNode is no longer354 * valid.363 * After calling this, pNode is no longer valid. 364 * 365 * If you invoke this on a DOCUMENT node, the 366 * entire DOM tree will get deleted recursively. 355 367 * 356 368 *@@added V0.9.9 (2001-02-16) [umoeller] … … 383 395 { 384 396 // call delete recursively 397 PDOMNODE pNext = (PDOMNODE)treeNext((TREE*)pAttrib); 385 398 xmlDeleteNode((PNODEBASE)pAttrib); 386 399 // this will remove pAttrib from pNode's attrib 387 // tree and rebalance the tree; treeNext will 388 // still work #### noooooo 389 pAttrib = (PDOMNODE)treeNext((TREE*)pAttrib); 400 // tree and rebalance the tree 401 pAttrib = pNext; 390 402 } 391 403 break; } … … 395 407 case DOMNODE_PROCESSING_INSTRUCTION: 396 408 case DOMNODE_COMMENT: 409 pDomNode = (PDOMNODE)pNode; 410 break; 411 397 412 case DOMNODE_DOCUMENT: 413 if (((PDOMDOCUMENTNODE)pNode)->pDocType) 414 xmlDeleteNode((PNODEBASE)((PDOMDOCUMENTNODE)pNode)->pDocType); 398 415 pDomNode = (PDOMNODE)pNode; 399 416 break; … … 441 458 pParticle = (PCMELEMENTPARTICLE)pDelNode->pItemData; 442 459 xmlDeleteNode((PNODEBASE)pParticle); 443 // treeDelete(pp-> ###460 // treeDelete(pp-> // @@todo 444 461 pDelNode = pDelNode->pNext; 445 462 } … … 962 979 * _XMLCONTENT content model (which is the @expat structure). 963 980 * This recurses, if necessary. 981 * 982 * NOTE: As opposed to the other "create" functions, 983 * this does not take a parent node as input. If this 984 * returns NO_ERROR, it is the caller's responsibility 985 * to add the produced node to the document's DOCTYPE node. 964 986 * 965 987 *@@added V0.9.9 (2001-02-16) [umoeller] … … 2120 2142 /* ****************************************************************** 2121 2143 * 2122 * DOM rootAPIs2144 * DOM parser APIs 2123 2145 * 2124 2146 ********************************************************************/ … … 2158 2180 + TRUE); // if last, this will clean up the parser 2159 2181 * 2160 * 3) Process the data in the DOM tree. When done, 2161 * call xmlFreeDOM, which will free all memory. 2182 * 3) Process the data in the DOM tree. 2183 * 2184 * Look at the DOMNODE definition to see how you 2185 * can traverse the data. Essentially, everything 2186 * is based on linked lists and string maps. 2187 * 2188 * A few helper functions have been added for 2189 * quick lookup. See xmlGetRootElement, 2190 * xmlGetFirstChild, xmlGetLastChild, xmlGetFirstText, 2191 * xmlGetElementsByTagName, xmlGetAttribute. 2192 * 2193 * 4) When done, call xmlFreeDOM, which will free all memory. 2162 2194 * 2163 2195 *@@added V0.9.9 (2001-02-14) [umoeller] … … 2183 2215 // create the document node 2184 2216 arc = xmlCreateDomNode(NULL, // no parent 2185 DOMNODE_DOCUMENT,2186 NULL,2187 0,2188 &pDocument);2217 DOMNODE_DOCUMENT, 2218 NULL, 2219 0, 2220 &pDocument); 2189 2221 2190 2222 if (arc == NO_ERROR) … … 2263 2295 /* 2264 2296 *@@ xmlParse: 2265 * parses another pieceof XML data.2297 * parses another chunk of XML data. 2266 2298 * 2267 2299 * If (fIsLast == TRUE), the internal @expat parser … … 2375 2407 pDom->pParser = NULL; 2376 2408 } 2409 2410 xmlDeleteNode((PNODEBASE)pDom->pDocumentNode); 2377 2411 2378 2412 free(pDom); … … 2645 2679 return (NULL); 2646 2680 } 2681 2682 /* ****************************************************************** 2683 * 2684 * DOM build 2685 * 2686 ********************************************************************/ 2687 2688 /* 2689 *@@ xmlCreateDocument: 2690 * creates a new XML document. 2691 * 2692 * This is the first step in creating a DOM 2693 * tree in memory. 2694 * 2695 * This function creates a DOCUMENT node 2696 * (which is returned) and a root ELEMENT node 2697 * within the document. For convenience, the 2698 * root ELEMENT node is returned as well. 2699 * 2700 * This does not create a DOCTYPE node in 2701 * the document. 2702 * 2703 * After this, you can add sub-elements and 2704 * attributes to the root element using 2705 * xmlCreateElementNode and xmlCreateAttributeNode. 2706 * 2707 * Use xmlDeleteNode on the DOCUMENT node 2708 * to delete the entire DOM tree. 2709 * 2710 *@@added V0.9.12 (2001-05-21) [umoeller] 2711 */ 2712 2713 APIRET xmlCreateDocument(const char *pcszRootElementName, // in: root element name 2714 PDOMDOCUMENTNODE *ppDocument, // out: DOCUMENT node 2715 PDOMNODE *ppRootElement) // out: root ELEMENT node within DOCUMENT 2716 { 2717 APIRET arc = NO_ERROR; 2718 PDOMDOCUMENTNODE pDocument = NULL; 2719 PDOMNODE pRootElement = NULL; 2720 2721 if ( (!pcszRootElementName) || (!ppDocument) || (!ppRootElement) ) 2722 arc = ERROR_INVALID_PARAMETER; 2723 else 2724 // create the document node 2725 if (!(arc = xmlCreateDomNode(NULL, // no parent 2726 DOMNODE_DOCUMENT, 2727 NULL, 2728 0, 2729 (PDOMNODE*)&pDocument))) 2730 if (!(arc = xmlCreateDomNode((PDOMNODE)pDocument, // parent 2731 DOMNODE_ELEMENT, 2732 pcszRootElementName, 2733 0, 2734 &pRootElement))) 2735 { 2736 *ppDocument = pDocument; 2737 *ppRootElement = pRootElement; 2738 } 2739 2740 return (arc); 2741 } 2742 2743 /* 2744 *@@ WriteNodes: 2745 * internal helper for writing out the nodes. 2746 * 2747 *@@added V0.9.12 (2001-05-21) [umoeller] 2748 */ 2749 2750 VOID WriteNodes(PXSTRING pxstr, 2751 PDOMNODE pDomNode) // in: node whose children are to be written (initially DOCUMENT) 2752 { 2753 PLISTNODE pListNode; 2754 2755 BOOL fMixedContent = (xmlGetFirstText(pDomNode) != NULL); 2756 2757 for (pListNode = lstQueryFirstNode(&pDomNode->llChildren); 2758 (pListNode); 2759 pListNode = pListNode->pNext) 2760 { 2761 PDOMNODE pChildNode = (PDOMNODE)pListNode->pItemData; 2762 2763 switch (pChildNode->NodeBase.ulNodeType) 2764 { 2765 case DOMNODE_ELEMENT: 2766 { 2767 PDOMNODE pAttribNode; 2768 // write out opening ELEMENT tag 2769 // add a line break if this does NOT have mixed 2770 // content 2771 if (!fMixedContent) 2772 xstrcatc(pxstr, '\n'); 2773 2774 xstrcatc(pxstr, '<'); 2775 xstrcats(pxstr, &pChildNode->NodeBase.strNodeName); 2776 2777 // go through attributes 2778 for (pAttribNode = (PDOMNODE)treeFirst(pChildNode->AttributesMap); 2779 (pAttribNode); 2780 pAttribNode = (PDOMNODE)treeNext((TREE*)pAttribNode)) 2781 { 2782 xstrcat(pxstr, "\n ", 0); 2783 xstrcats(pxstr, &pAttribNode->NodeBase.strNodeName); 2784 xstrcat(pxstr, "=\"", 0); 2785 xstrcats(pxstr, pAttribNode->pstrNodeValue); 2786 xstrcatc(pxstr, '\"'); 2787 } 2788 2789 // now check... do we have child nodes? 2790 if (lstCountItems(&pChildNode->llChildren)) 2791 { 2792 // yes: 2793 xstrcatc(pxstr, '>'); 2794 2795 // recurse into this child element 2796 WriteNodes(pxstr, pChildNode); 2797 2798 if (!fMixedContent) 2799 xstrcatc(pxstr, '\n'); 2800 2801 // write closing tag 2802 xstrcat(pxstr, "</", 0); 2803 xstrcats(pxstr, &pChildNode->NodeBase.strNodeName); 2804 xstrcatc(pxstr, '>'); 2805 } 2806 else 2807 { 2808 // no child nodes: 2809 // mark this tag as "empty" 2810 xstrcat(pxstr, "/>", 0); 2811 } 2812 } 2813 break; 2814 2815 case DOMNODE_TEXT: 2816 case DOMNODE_COMMENT: 2817 // that's simple 2818 xstrcats(pxstr, pChildNode->pstrNodeValue); 2819 break; 2820 2821 case DOMNODE_DOCUMENT_TYPE: 2822 // @@todo 2823 break; 2824 2825 } 2826 } 2827 } 2828 2829 /* 2830 *@@ xmlWriteDocument: 2831 * creates a complete XML document in the specified 2832 * string buffer from the specified DOMDOCUMENTNODE. 2833 * 2834 * This creates a full XML document, starting with 2835 * the <?xml...?> header, the DTD (if present), 2836 * and the elements and attributes. 2837 * 2838 * The input XSTRING must be initialized. Its 2839 * contents will be overwritten, if any exists. 2840 * 2841 * Sooo... to write a full XML document to disk, 2842 * do the following: 2843 * 2844 * 1) Call xmlCreateDocument to have an empty 2845 * document with a root element created. 2846 * 2847 * 2) Add elements, subelements, and attributes 2848 * using xmlCreateElementNode and 2849 * xmlCreateAttributeNode. 2850 * 2851 * 3) Call xmlWriteDocument to have the XML 2852 * document written into an XSTRING. 2853 * 2854 * 4) Write the XSTRING to disk, e.g. using 2855 * fwrite(). 2856 * 2857 * Note: You can also use doshWriteTextFile, 2858 * but you should then first convert the 2859 * line format using xstrConvertLineFormat. 2860 * 2861 * Example: 2862 * 2863 + APIRET arc = NO_ERROR; 2864 + PDOMDOCUMENTNODE pDocument = NULL; 2865 + PDOMNODE pRootElement = NULL; 2866 + 2867 + // create a DOM 2868 + if (!(arc = xmlCreateDocument("MYROOTNODE", 2869 + &pDocument, 2870 + &pRootElement))) 2871 + { 2872 + // add subelements to the root element 2873 + PDOMNODE pSubelement; 2874 + if (!(arc = xmlCreateElementNode(pRootElement, 2875 + "MYSUBELEMENT", 2876 + &pSubelement))) 2877 + { 2878 + // add an attribute 2879 + PDOMNODE pAttribute; 2880 + if (!(arc = xmlCreateAttributeNode(pSubElement, 2881 + "MYATTRIB", 2882 + "VALUE", 2883 + &pAttribute))) 2884 + { 2885 + // alright, turn this into a string 2886 + XSTRING str; 2887 + xstrInit(&str, 1000); 2888 + if (!(arc = xmlWriteDocument(pDocument, 2889 + "ISO-8859-1", 2890 + NULL, // or DOCTYPE 2891 + &str))) 2892 + { 2893 + FILE *file = fopen("myfile.xml", "w"); 2894 + fwrite(str.psz, 2895 + 1, 2896 + str.ulLength, 2897 + file); 2898 + fclose(file); 2899 + } 2900 + } 2901 + } 2902 + 2903 + // this kills the entire tree 2904 + xmlDeleteNode((PNODEBASE)pDocument); 2905 + 2906 + } 2907 + 2908 * 2909 * A note about whitespace handling. Presently, this 2910 * adds line breaks after the opening tag of an 2911 * element if the element has element content only. 2912 * However, if the element has mixed content, this 2913 * line break is NOT automatically added because 2914 * white space may then be significant. 2915 * 2916 *@@added V0.9.12 (2001-05-21) [umoeller] 2917 */ 2918 2919 APIRET xmlWriteDocument(PDOMDOCUMENTNODE pDocument, // in: document node 2920 const char *pcszEncoding, // in: encoding string (e.g. "ISO-8859-1") 2921 const char *pcszDoctype, // in: entire DOCTYPE statement or NULL 2922 PXSTRING pxstr) // out: document 2923 { 2924 APIRET arc = NO_ERROR; 2925 2926 if ( (!pDocument) || (!pcszEncoding) || (!pxstr) ) 2927 arc = ERROR_INVALID_PARAMETER; 2928 else 2929 { 2930 // <?xml version="1.0" encoding="ISO-8859-1"?> 2931 xstrcpy(pxstr, "<?xml version=\"1.0\" encoding=\"", 0); 2932 xstrcat(pxstr, pcszEncoding, 0); 2933 xstrcat(pxstr, "\"?>\n", 0); 2934 2935 // write entire DOCTYPE statement 2936 if (pcszDoctype) 2937 { 2938 xstrcatc(pxstr, '\n'); 2939 xstrcat(pxstr, pcszDoctype, 0); 2940 xstrcatc(pxstr, '\n'); 2941 } 2942 2943 // write out children 2944 WriteNodes(pxstr, (PDOMNODE)pDocument); 2945 2946 xstrcatc(pxstr, '\n'); 2947 } 2948 2949 return (arc); 2950 } 2951 2952 -
trunk/src/helpers/xmlparse.c
r39 r71 873 873 XML_Memory_Handling_Suite *mtemp; 874 874 875 parser = malloc(sizeof(Parser));875 parser = (malloc)(sizeof(Parser)); 876 876 mtemp = &(((Parser*)parser)->m_mem); 877 877 878 mtemp->malloc_fcn = malloc; 878 879 mtemp->realloc_fcn = realloc; -
trunk/src/helpers/xstring.c
r65 r71 285 285 *@@added V0.9.7 (2001-01-07) [umoeller] 286 286 *@@changed V0.9.9 (2001-03-09) [umoeller]: now using ulDelta 287 *@@changed V0.9.12 (2001-05-21) [umoeller]: now reporting error on realloc fail 287 288 */ 288 289 … … 318 319 // this gives the C runtime a chance to expand the 319 320 // existing block 320 pxstr->psz = (PSZ)realloc(pxstr->psz, cbAllocate);321 if (pxstr->psz = (PSZ)realloc(pxstr->psz, cbAllocate)) 321 322 // if pxstr->psz is NULL, realloc behaves like malloc 322 pxstr->cbAllocated = cbAllocate;323 pxstr->cbAllocated = cbAllocate; 323 324 // ulLength is unchanged 325 else 326 // error: V0.9.12 (2001-05-21) [umoeller] 327 pxstr->cbAllocated = 0; 324 328 } 325 329 // else: we have enough memory … … 448 452 *@@changed V0.9.9 (2001-02-16) [umoeller]: now supporting non-zero-terminated pcszSource 449 453 *@@changed V0.9.9 (2001-03-09) [umoeller]: now using xstrReserve 454 *@@changed V0.9.12 (2001-05-21) [umoeller]: added xstrReserve error checking 450 455 */ 451 456 … … 470 475 { 471 476 // we do have a source string: 472 xstrReserve(pxstr, 473 // required memory: 474 ulSourceLength + 1); 475 476 memcpy(pxstr->psz, 477 pcszSource, 478 ulSourceLength); 479 *(pxstr->psz + ulSourceLength) = '\0'; 480 // V0.9.9 (2001-02-16) [umoeller] 481 // we must do this or otherwise we require pcszSource 482 // to be zero-terminated... not a good idea 477 if (xstrReserve(pxstr, 478 // required memory: 479 ulSourceLength + 1)) 480 { 481 memcpy(pxstr->psz, 482 pcszSource, 483 ulSourceLength); 484 *(pxstr->psz + ulSourceLength) = '\0'; 485 // V0.9.9 (2001-02-16) [umoeller] 486 // we must do this or otherwise we require pcszSource 487 // to be zero-terminated... not a good idea 488 } 489 else 490 pxstr->ulLength = 0; // error V0.9.12 (2001-05-21) [umoeller] 483 491 } 484 492 else
Note:
See TracChangeset
for help on using the changeset viewer.