- Timestamp:
- Nov 24, 2002, 9:45:05 PM (23 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/apps.c
r223 r229 410 410 * representation in OS/2.) 411 411 * 412 *@@added V 0.9.21(2002-09-04) [bird]412 *@@added V1.0.0 (2002-09-04) [bird] 413 413 */ 414 414 … … 834 834 * 835 835 *@@added V0.9.20 (2002-07-03) [umoeller] 836 *@@changed V 0.9.21(2002-08-21) [umoeller]: now allowing for UNC836 *@@changed V1.0.0 (2002-08-21) [umoeller]: now allowing for UNC 837 837 */ 838 838 … … 845 845 // check if the executable is fully qualified; if so, 846 846 // check if the executable file exists 847 if ( // allow UNC V 0.9.21(2002-08-21) [umoeller]847 if ( // allow UNC V1.0.0 (2002-08-21) [umoeller] 848 848 ( (pDetails->pszExecutable[0] == '\\') 849 849 && (pDetails->pszExecutable[1] == '\\') … … 889 889 *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from winh.c to apps.c 890 890 *@@changed V0.9.20 (2002-07-03) [umoeller]: now always qualifying executable to fix broken BAT files 891 *@@changed V 0.9.21(2002-08-12) [umoeller]: this didn't work for batch and cmd files that had "+" characters in their full path, fixed891 *@@changed V1.0.0 (2002-08-12) [umoeller]: this didn't work for batch and cmd files that had "+" characters in their full path, fixed 892 892 */ 893 893 … … 917 917 918 918 // if the path has spaces, or other invalid characters, 919 // include it in quotes V 0.9.21(2002-08-12) [umoeller]919 // include it in quotes V1.0.0 (2002-08-12) [umoeller] 920 920 if (fQuotes = !!strpbrk(pProgDetails->pszExecutable, " +&|=")) 921 921 xstrcatc(pstrParams, '"'); … … 931 931 932 932 if (fQuotes) 933 xstrcatc(pstrParams, '"'); // V 0.9.21(2002-08-12) [umoeller]933 xstrcatc(pstrParams, '"'); // V1.0.0 (2002-08-12) [umoeller] 934 934 935 935 if (pszOldParams) … … 1128 1128 *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed Win-OS/2 full screen breakage 1129 1129 *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed broken bat and cmd files when PROG_DEFAULT was set 1130 *@@changed V 0.9.21(2002-08-18) [umoeller]: fixed cmd and bat files that had "=" in their paths1130 *@@changed V1.0.0 (2002-08-18) [umoeller]: fixed cmd and bat files that had "=" in their paths 1131 1131 */ 1132 1132 … … 1144 1144 ULONG ulIsWinApp; 1145 1145 1146 // parameter checking extended V 0.9.21(2002-08-21) [umoeller]1146 // parameter checking extended V1.0.0 (2002-08-21) [umoeller] 1147 1147 if ( (!pcProgDetails) 1148 1148 || (!pcProgDetails->pszExecutable) … … 1308 1308 } 1309 1309 1310 // V 0.9.21: this define is never set. I have thus completely1310 // V1.0.0: this define is never set. I have thus completely 1311 1311 // disabled the batch hacks that we used to provide, that is 1312 1312 // we no longer change the "c:\path\batch.cmd" to "cmd.exe /c c:\path\batch.cmd" … … 2016 2016 *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed missing destroy window, made wait optional 2017 2017 *@@changed V0.9.20 (2002-08-10) [umoeller]: added pcszWorkingDir 2018 *@@changed V 0.9.21(2002-08-18) [umoeller]: changed prototype to return APIRET2018 *@@changed V1.0.0 (2002-08-18) [umoeller]: changed prototype to return APIRET 2019 2019 */ 2020 2020 … … 2083 2083 * 2084 2084 *@@added V0.9.20 (2002-08-10) [umoeller] 2085 *@@changed V 0.9.21(2002-08-21) [umoeller]: changed prototype to return browser2085 *@@changed V1.0.0 (2002-08-21) [umoeller]: changed prototype to return browser 2086 2086 */ 2087 2087 -
trunk/src/helpers/cctl_checkcnr.c
r224 r229 863 863 *@@ FINDCHECKRECORD: 864 864 * 865 *@@added V 0.9.21(2002-09-09) [umoeller]865 *@@added V1.0.0 (2002-09-09) [umoeller] 866 866 */ 867 867 … … 882 882 * 883 883 *@@added V0.9.0 (99-11-28) [umoeller] 884 *@@changed V 0.9.21(2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates884 *@@changed V1.0.0 (2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates 885 885 */ 886 886 … … 907 907 * 908 908 *@@added V0.9.1 (99-12-03) [umoeller] 909 *@@changed V 0.9.21(2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates909 *@@changed V1.0.0 (2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates 910 910 */ 911 911 -
trunk/src/helpers/cctl_splitwin.c
r222 r229 95 95 * 96 96 *@@added V0.9.1 (2000-02-05) [umoeller] 97 *@@changed V 0.9.21(2002-08-24) [umoeller]: added SBCF_3DEXPLORERSTYLE97 *@@changed V1.0.0 (2002-08-24) [umoeller]: added SBCF_3DEXPLORERSTYLE 98 98 */ 99 99 … … 118 118 if (pData->sbcd.ulCreateFlags & SBCF_3DEXPLORERSTYLE) 119 119 { 120 // this style is new with V 0.9.21(2002-08-24) [umoeller];120 // this style is new with V1.0.0 (2002-08-24) [umoeller]; 121 121 // simulate the Warp 4 entry field margins around the 122 122 // right control only, but leave the left control flat. … … 443 443 444 444 if (!(pData->sbcd.ulCreateFlags & (SBCF_3DSUNK | SBCF_3DEXPLORERSTYLE))) 445 // V 0.9.21(2002-08-31) [umoeller]445 // V1.0.0 (2002-08-31) [umoeller] 446 446 { 447 447 GpiSetColor(hps, pData->lcol3DLight); … … 797 797 pData->hwndLinked2 = NULLHANDLE; 798 798 799 // caching these colors now V 0.9.21(2002-08-21) [umoeller]799 // caching these colors now V1.0.0 (2002-08-21) [umoeller] 800 800 pData->lcol3DDark = WinQuerySysColor(HWND_DESKTOP, SYSCLR_BUTTONDARK, 0); 801 801 pData->lcol3DLight = WinQuerySysColor(HWND_DESKTOP, SYSCLR_BUTTONLIGHT, 0); … … 823 823 * 824 824 *@@added V0.9.0 [umoeller] 825 *@@changed V 0.9.21(2002-08-24) [umoeller]: added support for SBCF_3DEXPLORERSTYLE825 *@@changed V1.0.0 (2002-08-24) [umoeller]: added support for SBCF_3DEXPLORERSTYLE 826 826 */ 827 827 -
trunk/src/helpers/cctl_tooltip.c
r222 r229 224 224 MRESULT mrc = 0; 225 225 226 PFNWP 226 PFNWP pfnwpOrig = NULL; 227 227 228 228 if (LockSubclassedTools()) 229 229 { 230 PSUBCLASSEDTOOL pst = FindSubclassedTool(hwndTool);231 232 if (pst )230 PSUBCLASSEDTOOL pst; 231 232 if (pst = FindSubclassedTool(hwndTool)) 233 233 { 234 234 pfnwpOrig = pst->pfnwpOrig; // call default … … 254 254 (MPARAM)0, 255 255 (MPARAM)&qmsg); 256 break; } 256 } 257 break; 257 258 258 259 case WM_DESTROY: 259 lstRemoveItem(&G_llSubclassedTools, pst); // this frees the item 260 lstRemoveItem(&G_llSubclassedTools, pst); 261 // this frees the item 260 262 break; 261 263 } … … 1466 1468 1467 1469 case WM_PRESPARAMCHANGED: 1468 { 1469 LONG lPPIndex = (LONG)mp1; 1470 switch (lPPIndex) 1470 1471 switch ((LONG)mp1) // pp index 1471 1472 { 1472 1473 case 0: // layout palette thing dropped … … 1478 1479 UpdateTooltipPresColors(hwndTooltip); 1479 1480 } 1480 break; } 1481 1482 break; 1481 1483 1482 1484 /* … … 1900 1902 PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1); 1901 1903 mrc = (MPARAM)lstCountItems(&pttd->llTools); 1902 break; } 1904 } 1905 break; 1903 1906 1904 1907 /* -
trunk/src/helpers/cnrh.c
r224 r229 1579 1579 * 1580 1580 *@@added V0.9.0 [umoeller] 1581 *@@changed V 0.9.21(2002-09-09) [umoeller]: rewritten to support deletion in callback1582 *@@changed V 0.9.21(2002-09-09) [umoeller]: added support for precParent = -11583 *@@changed V 0.9.21(2002-09-09) [umoeller]: changed prototype and callback prototype1581 *@@changed V1.0.0 (2002-09-09) [umoeller]: rewritten to support deletion in callback 1582 *@@changed V1.0.0 (2002-09-09) [umoeller]: added support for precParent = -1 1583 *@@changed V1.0.0 (2002-09-09) [umoeller]: changed prototype and callback prototype 1584 1584 */ 1585 1585 … … 1622 1622 // get the next record BEFORE calling the callback 1623 1623 // in case the callback removes the record 1624 // V 0.9.21(2002-09-09) [umoeller]1624 // V1.0.0 (2002-09-09) [umoeller] 1625 1625 PRECORDCORE precNext = (PRECORDCORE)WinSendMsg(hwndCnr, 1626 1626 CM_QUERYRECORD, … … 1629 1629 CMA_ITEMORDER)); 1630 1630 1631 if (fRecurse) // V 0.9.21(2002-09-09) [umoeller]1631 if (fRecurse) // V1.0.0 (2002-09-09) [umoeller] 1632 1632 // recurse for the record we found 1633 1633 ulrc += cnrhForAllRecords(hwndCnr, -
trunk/src/helpers/comctl.c
r222 r229 182 182 * turns the given static control into a 3D separator line. 183 183 * 184 *@@added V 0.9.21(2002-08-12) [umoeller]184 *@@added V1.0.0 (2002-08-12) [umoeller] 185 185 */ 186 186 -
trunk/src/helpers/debug.c
r222 r229 44 44 */ 45 45 46 //#define DEBUG_SYMDUMP // enable to dump sym file to log V 0.9.21(2002-08-21) [paperino]46 //#define DEBUG_SYMDUMP // enable to dump sym file to log V1.0.0 (2002-08-21) [paperino] 47 47 48 48 #define OS2EMX_PLAIN_CHAR … … 1537 1537 1538 1538 // open .SYM file 1539 #ifdef DEBUG_SYMDUMP // V 0.9.21(2002-08-21) [paperino]1539 #ifdef DEBUG_SYMDUMP // V1.0.0 (2002-08-21) [paperino] 1540 1540 fprintf(LogFile,"Dump of '%s' for object %d\n",SymFileName,Object); 1541 1541 #endif … … 1591 1591 for (SymNum = 0; SymNum < SegDef.cSymbols; SymNum++) 1592 1592 { 1593 // fixed syms > 64 K V 0.9.21(2002-08-21) [paperino]1593 // fixed syms > 64 K V1.0.0 (2002-08-21) [paperino] 1594 1594 if (SegDef.bFlags & 0x01) 1595 1595 { -
trunk/src/helpers/dialog.c
r222 r229 11 11 * 12 12 * See @dlg_algorithm for the gory details of the new 13 * algorithm used since V 0.9.21. Even though much13 * algorithm used since V1.0.0. Even though much 14 14 * of this file was rewritten, the new dialog is 15 15 * backwards-compatible with all the hacks that existing … … 254 254 * 255 255 * We now use the CSS box model for the dialog 256 * formatter (V 0.9.21).256 * formatter (V1.0.0). 257 257 * 258 258 + ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ … … 323 323 * certain controls automatically. See CalcAutoSize. 324 324 * 325 * The algorithm used here has been greatly reworked with V 0.9.21.325 * The algorithm used here has been greatly reworked with V1.0.0. 326 326 * Essentially, the new trick is that we first compute all widths 327 327 * (which requires several iterations since widths may now inherit … … 573 573 * 574 574 * See @dlg_algorithm for the new algorithm 575 * used since V 0.9.21.576 * 577 * With V 0.9.21, we now follow the CSS box model575 * used since V1.0.0. 576 * 577 * With V1.0.0, we now follow the CSS box model 578 578 * to render these things better without all 579 579 * the hacks I am no longer able to understand 580 580 * myself. See @dlg_box_model for details. 581 581 * 582 *@@changed V 0.9.21(2002-08-18) [umoeller]: completely replaced582 *@@changed V1.0.0 (2002-08-18) [umoeller]: completely replaced 583 583 */ 584 584 … … 602 602 603 603 ULONG ulColumnIndex; // zero-based column index in parent row 604 // V 0.9.21(2002-08-18) [umoeller]604 // V1.0.0 (2002-08-18) [umoeller] 605 605 606 606 // b) information for control window to be created: … … 628 628 RECTL rclPadding, // spacing, in pixels, to apply to the four borders of 629 629 rclMargin; // the content to get the box; calculated from CONTROLDEF 630 // V 0.9.21(2002-08-16) [umoeller]630 // V1.0.0 (2002-08-16) [umoeller] 631 631 632 632 LONG cxSpacingTotal; // sum of rclPadding and rclMargin xLeft and … … 684 684 685 685 ULONG cColumns; // no. of columns in this row 686 // V 0.9.21(2002-08-18) [umoeller]686 // V1.0.0 (2002-08-18) [umoeller] 687 687 688 688 // result data after recursion: … … 767 767 * set. 768 768 * 769 *@@added V 0.9.21(2002-08-16) [umoeller]769 *@@added V1.0.0 (2002-08-16) [umoeller] 770 770 */ 771 771 … … 827 827 * set. 828 828 * 829 *@@added V 0.9.21(2002-08-16) [umoeller]829 *@@added V1.0.0 (2002-08-16) [umoeller] 830 830 */ 831 831 … … 949 949 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET 950 950 *@@changed V0.9.16 (2002-02-02) [umoeller]: added ulWidth 951 *@@changed V 0.9.21(2002-08-18) [umoeller]: renamed; moved multi-line processing to CalcAutoSizeTextMulti951 *@@changed V1.0.0 (2002-08-18) [umoeller]: renamed; moved multi-line processing to CalcAutoSizeTextMulti 952 952 */ 953 953 … … 984 984 * static text controls. 985 985 * 986 *@@added V 0.9.21(2002-08-18) [umoeller]986 *@@added V1.0.0 (2002-08-18) [umoeller] 987 987 */ 988 988 … … 1030 1030 * 1031 1031 *@@added V0.9.20 (2002-08-10) [umoeller] 1032 *@@changed V 0.9.21(2002-08-18) [umoeller]: removed temp windows list1032 *@@changed V1.0.0 (2002-08-18) [umoeller]: removed temp windows list 1033 1033 */ 1034 1034 … … 1224 1224 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET 1225 1225 *@@changed V0.9.19 (2002-04-24) [umoeller]: fixed PM groups alignment 1226 *@@changed V 0.9.21(2002-08-16) [umoeller]: adjusted for new algorithm1226 *@@changed V1.0.0 (2002-08-16) [umoeller]: adjusted for new algorithm 1227 1227 */ 1228 1228 … … 1290 1290 *@@changed V0.9.19 (2002-04-17) [umoeller]: fixes for the STUPID drop-down comboboxes 1291 1291 *@@changed V0.9.19 (2002-04-24) [umoeller]: fixed PM groups alignment 1292 *@@changed V 0.9.21(2002-08-16) [umoeller]: adjusted for new algorithm1293 *@@changed V 0.9.21(2002-08-18) [umoeller]: setting entry field length to CCHMAXPATH per default now1292 *@@changed V1.0.0 (2002-08-16) [umoeller]: adjusted for new algorithm 1293 *@@changed V1.0.0 (2002-08-18) [umoeller]: setting entry field length to CCHMAXPATH per default now 1294 1294 */ 1295 1295 … … 1323 1323 flStyle = pColumn->flStyle; 1324 1324 1325 // V 0.9.21(2002-08-16) [umoeller]1325 // V1.0.0 (2002-08-16) [umoeller] 1326 1326 // Removed all the terrible hacks for the PM group 1327 1327 // control. We now use rclPadding and rclMargin … … 1355 1355 } 1356 1356 1357 if ( (!arc) // check error code V 0.9.21(2002-08-16) [umoeller]1357 if ( (!arc) // check error code V1.0.0 (2002-08-16) [umoeller] 1358 1358 && (pcszClass) 1359 1359 ) … … 1365 1365 PCSZ pcszTextEF = NULL; // for entry field 1366 1366 1367 // V 0.9.21(2002-08-16) [umoeller]1367 // V1.0.0 (2002-08-16) [umoeller] 1368 1368 // determine the position where to create the 1369 1369 // control; this is the content box, to which … … 1448 1448 // defer setting the text because we should 1449 1449 // first set the entry field limit 1450 // V 0.9.21(2002-08-18) [umoeller]1450 // V1.0.0 (2002-08-18) [umoeller] 1451 1451 pcszTextEF = pcszText; 1452 1452 pcszText = ""; // for now … … 1532 1532 // set text limit to CCHMAXPATH per default, 1533 1533 // and set the real text now 1534 // V 0.9.21(2002-08-18) [umoeller]1534 // V1.0.0 (2002-08-18) [umoeller] 1535 1535 winhSetEntryFieldLimit(pColumn->hwndControl, CCHMAXPATH); 1536 1536 WinSetWindowText(pColumn->hwndControl, (PSZ)pcszTextEF); … … 1634 1634 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed font problems 1635 1635 *@@changed V0.9.20 (2002-08-08) [umoeller]: added support for aligning columns horizontally 1636 *@@changed V 0.9.21(2002-08-16) [umoeller]: calc size rewritten for new algorithm1636 *@@changed V1.0.0 (2002-08-16) [umoeller]: calc size rewritten for new algorithm 1637 1637 */ 1638 1638 … … 1655 1655 1656 1656 case PROCESS_1_CALC_MIN_WIDTHS: 1657 // rewritten V 0.9.21(2002-08-16) [umoeller]1657 // rewritten V1.0.0 (2002-08-16) [umoeller] 1658 1658 1659 1659 if (!pColumn->pNestedTable) … … 1723 1723 1724 1724 case PROCESS_2_CALC_RELATIVE_WIDTHS: 1725 // rewritten V 0.9.21(2002-08-16) [umoeller]1725 // rewritten V1.0.0 (2002-08-16) [umoeller] 1726 1726 1727 1727 if (!pColumn->pNestedTable) … … 1816 1816 1817 1817 case PROCESS_3_ALIGN_COLUMNS: 1818 // rewritten V 0.9.21(2002-08-16) [umoeller]1818 // rewritten V1.0.0 (2002-08-16) [umoeller] 1819 1819 1820 1820 if (!pColumn->pNestedTable) … … 2101 2101 * in the row. 2102 2102 * 2103 *@@changed V 0.9.21(2002-08-16) [umoeller]: adjusted for new algorithm2103 *@@changed V1.0.0 (2002-08-16) [umoeller]: adjusted for new algorithm 2104 2104 */ 2105 2105 … … 2199 2199 * to which the nested table belongs. 2200 2200 * 2201 *@@changed V 0.9.21(2002-08-16) [umoeller]: adjusted for new algorithm2201 *@@changed V1.0.0 (2002-08-16) [umoeller]: adjusted for new algorithm 2202 2202 */ 2203 2203 … … 2220 2220 // as a separate step (PROCESS_2_INHERIT_TABLE_SIZES), 2221 2221 // but we can save ourselves a loop here 2222 // V 0.9.21(2002-08-16) [umoeller]2222 // V1.0.0 (2002-08-16) [umoeller] 2223 2223 if (pTableDef->flTable & TABLE_INHERIT_SIZE) 2224 2224 { … … 2393 2393 *@@ CreateColumn: 2394 2394 * 2395 *@@changed V 0.9.21(2002-08-18) [umoeller]: mostly rewritten for new algorithm2395 *@@changed V1.0.0 (2002-08-18) [umoeller]: mostly rewritten for new algorithm 2396 2396 */ 2397 2397 … … 2491 2491 + pColumn->rclMargin.xRight; 2492 2492 2493 // set the column index V 0.9.21(2002-08-18) [umoeller]2493 // set the column index V1.0.0 (2002-08-18) [umoeller] 2494 2494 pColumn->ulColumnIndex = (pCurrentRow->cColumns)++; 2495 2495 … … 2745 2745 pCurrentRow, 2746 2746 FALSE, // no nested table 2747 (const CONTROLDEF *)pItemThis->ul1, // pCtlDef, V 0.9.21(2002-08-18) [umoeller]2747 (const CONTROLDEF *)pItemThis->ul1, // pCtlDef, V1.0.0 (2002-08-18) [umoeller] 2748 2748 &pColumn))) 2749 2749 lstAppendItem(&pCurrentRow->llColumns, … … 2804 2804 * 2805 2805 *@@added V0.9.15 (2001-08-26) [umoeller] 2806 *@@changed V 0.9.21(2002-08-16) [umoeller]: adjusted for new algorithm2806 *@@changed V1.0.0 (2002-08-16) [umoeller]: adjusted for new algorithm 2807 2807 */ 2808 2808 … … 2813 2813 // call process mode with the first for "calc size" 2814 2814 // process modes 2815 // changed V 0.9.21(2002-08-16) [umoeller]2815 // changed V1.0.0 (2002-08-16) [umoeller] 2816 2816 if (!(arc = ProcessAll(pDlgData, 2817 2817 PROCESS_1_CALC_MIN_WIDTHS))) … … 2996 2996 * 2997 2997 * See @dlg_algorithm for the gory details of the new 2998 * algorithm used since V 0.9.21.2998 * algorithm used since V1.0.0. 2999 2999 * 3000 3000 * See @dlg_boxmodel for information about how the … … 3069 3069 *@@changed V0.9.16 (2001-12-06) [umoeller]: fixed bad owner if not direct desktop child 3070 3070 *@@changed V0.9.19 (2002-04-24) [umoeller]: added excpt handling 3071 +@@changed V 0.9.21(2002-08-21) [umoeller]: now setting wait pointer3071 +@@changed V1.0.0 (2002-08-21) [umoeller]: now setting wait pointer 3072 3072 */ 3073 3073 … … 3084 3084 APIRET arc = NO_ERROR; 3085 3085 3086 HPOINTER hptrOld = winhSetWaitPointer(); // V 0.9.21(2002-08-21) [umoeller]3086 HPOINTER hptrOld = winhSetWaitPointer(); // V1.0.0 (2002-08-21) [umoeller] 3087 3087 3088 3088 TRY_LOUD(excpt1) … … 3246 3246 } 3247 3247 3248 WinSetPointer(HWND_DESKTOP, hptrOld); // V 0.9.21(2002-08-21) [umoeller]3248 WinSetPointer(HWND_DESKTOP, hptrOld); // V1.0.0 (2002-08-21) [umoeller] 3249 3249 3250 3250 return arc; … … 3626 3626 *@@changed V0.9.20 (2002-07-12) [umoeller]: made icon spacing wider 3627 3627 *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed missing close button 3628 *@@changed V 0.9.21(2002-08-16) [umoeller]: now using table alignment3628 *@@changed V1.0.0 (2002-08-16) [umoeller]: now using table alignment 3629 3629 */ 3630 3630 -
trunk/src/helpers/dosh.c
r226 r229 302 302 * buffer, which should be free()'d afterwards. 303 303 * 304 * The returned string is properly null-terminated but 305 * should not end with a line break (\r or \n) if I see 306 * this correctly. 307 * 304 308 * Returns NULL upon errors. 309 * 310 *@@changed V1.0.0 (2002-09-24) [umoeller]: now supporting NET messages as well 305 311 */ 306 312 307 313 PSZ doshQuerySysErrorMsg(APIRET arc) // in: DOS error code 308 314 { 309 PSZ pszReturn = 0;315 PSZ pszReturn = NULL; 310 316 CHAR szDosError[1000]; 311 317 ULONG cbDosError = 0; 312 DosGetMessage(NULL, 0, // no string replacements 313 szDosError, sizeof(szDosError), 314 arc, 315 "OSO001.MSG", // default OS/2 message file 316 &cbDosError); 317 if (cbDosError > 2) 318 PCSZ pcszMsgFile; 319 320 if ( (arc >= 2100) 321 && (arc <= 8000) 322 ) 323 pcszMsgFile = "NET.MSG"; 324 else 325 pcszMsgFile = "OSO001.MSG"; // default OS/2 message file 326 327 if (!DosGetMessage(NULL, 0, // no string replacements 328 szDosError, sizeof(szDosError), 329 arc, 330 (PSZ)pcszMsgFile, 331 &cbDosError)) 318 332 { 319 333 szDosError[cbDosError - 2] = 0; 320 334 pszReturn = strdup(szDosError); 321 335 } 322 return (pszReturn); 336 337 return pszReturn; 323 338 } 324 339 … … 728 743 * CD-ROM drive. 729 744 * 730 *@@added V 0.9.21(2002-08-31) [umoeller]745 *@@added V1.0.0 (2002-08-31) [umoeller] 731 746 */ 732 747 … … 785 800 * to close the device again. 786 801 * 787 *@@added V 0.9.21(2002-08-31) [umoeller]802 *@@added V1.0.0 (2002-08-31) [umoeller] 788 803 */ 789 804 … … 823 838 * 824 839 *@@added V0.9.14 (2001-08-01) [umoeller] 825 *@@changed V 0.9.21(2002-08-31) [umoeller]: removed ulLogicalDrive which was not needed840 *@@changed V1.0.0 (2002-08-31) [umoeller]: removed ulLogicalDrive which was not needed 826 841 */ 827 842 … … 852 867 else 853 868 { 854 #pragma pack(1) // V 0.9.21(2002-08-31) [umoeller]869 #pragma pack(1) // V1.0.0 (2002-08-31) [umoeller] 855 870 856 871 struct { … … 959 974 * to find out if the door is open with OS/2. 960 975 * 961 *@@added V 0.9.21(2002-08-31) [umoeller]976 *@@added V1.0.0 (2002-08-31) [umoeller] 962 977 */ 963 978 … … 1146 1161 HFILE hf; 1147 1162 1148 // exported this code to doshOpenDrive V 0.9.21(2002-08-31) [umoeller]1163 // exported this code to doshOpenDrive V1.0.0 (2002-08-31) [umoeller] 1149 1164 arc = doshOpenDrive(ulLogicalDrive, 1150 1165 &hf); -
trunk/src/helpers/dosh2.c
r222 r229 412 412 * 413 413 *@@added V0.9.16 (2001-10-08) [umoeller] 414 */ 415 416 APIRET doshSearchPath(const char *pcszPath, // in: path variable name (e.g. "PATH") 414 *@@changed V1.0.0 (2002-11-23) [umoeller]: allowing NULL pcszPath to search for "PATH" 415 */ 416 417 APIRET doshSearchPath(const char *pcszPath, // in: path variable name; if NULL, we use "PATH" 417 418 const char *pcszFile, // in: file to look for (e.g. "LVM.EXE") 418 419 PSZ pszExecutable, // out: full path (e.g. "F:\os2\lvm.exe") … … 423 424 // get the PATH value 424 425 PCSZ pcszPathValue; 426 427 if (!pcszPath) 428 pcszPath = "PATH"; // V1.0.0 (2002-11-23) [umoeller] 429 425 430 if (!(arc = DosScanEnv((PSZ)pcszPath, 426 431 #if __cplusplus -
trunk/src/helpers/encodings.c
r222 r229 13 13 * 14 14 * Be warned, compilation of this file takes a long 15 * file because this includes all the complex codepages15 * time because this includes all the complex codepages 16 16 * from include\encodings. 17 17 * … … 79 79 unsigned long cEntries; // entries in map (array item count) 80 80 unsigned short usCodepageOS2; // corresponding OS/2 codepage or 0 if none 81 // V 0.9.21(2002-08-21) [umoeller]81 // V1.0.0 (2002-08-21) [umoeller] 82 82 unsigned short usLatin; // ISO 8859-X correspondance or 0 83 83 ENCBYTECOUNT bc; … … 234 234 * and reuse it for future conversions. In addition, 235 235 * create codecs only for the codepages that are 236 * actually used. Each codec will take up 236 * actually used. Each codec will take up to 237 237 * n * sizeof(USHORT) bytes, where n is the highest 238 238 * Unicode character used in the codepage. … … 355 355 /* 356 356 *@@ encFreeCodec: 357 * frees a codec created with enc FreeConversion357 * frees a codec created with encCreateCodec 358 358 * and sets the given pointer to NULL. 359 359 * … … 446 446 * pointer is advanced anyway). 447 447 * 448 * This returns 0 if * *ppch points to a448 * This returns 0 if *ppch points to a 449 449 * null character. 450 450 * -
trunk/src/helpers/except.c
r217 r229 451 451 *@@changed V0.9.16 (2001-11-02) [pr]: make object display signed 452 452 *@@changed V0.9.19 (2002-03-28) [umoeller]: added thread ordinal 453 *@@changed V 0.9.21(2002-08-28) [umoeller]: added OS revision to dump453 *@@changed V1.0.0 (2002-08-28) [umoeller]: added OS revision to dump 454 454 */ 455 455 … … 508 508 // generic exception info 509 509 DosQuerySysInfo(QSV_VERSION_MAJOR, // 11 510 QSV_VERSION_REVISION, // 13 V 0.9.21(2002-08-28) [umoeller]510 QSV_VERSION_REVISION, // 13 V1.0.0 (2002-08-28) [umoeller] 511 511 &aulBuf, sizeof(aulBuf)); 512 512 // Warp 3 is reported as 20.30 … … 527 527 aulBuf[0], // major 528 528 aulBuf[1], 529 aulBuf[2], // revision V 0.9.21(2002-08-28) [umoeller]529 aulBuf[2], // revision V1.0.0 (2002-08-28) [umoeller] 530 530 pcszVersion); 531 531 … … 791 791 * 792 792 * -- pfnExcOpenFileNew gets called to open 793 * the trap log file. This must return a FILE* 794 * pointer from fopen(). If this is not defined, 795 * ?:\TRAP.LOG is used. Use this to specify a 796 * different file and have some notes written 797 * into it before the actual exception info. 793 * the trap log file. This can return a FILE* 794 * pointer from fopen() (which will be closed 795 * automatically by the handler). 796 * 797 * If this hook is not defined, ?:\TRAP.LOG is 798 * used. Use this hook to specify a different file 799 * and have some notes written into it before the 800 * actual exception info. 801 * 802 * If the hook returns a null FILE* pointer, 803 * logging is disabled, and the "loud" handler 804 * effectively behaves like the "quiet" handler. 798 805 * 799 806 * -- pfnExcHookNew gets called while the trap log … … 801 808 * the following info has been written into 802 809 * the trap log already: 810 * 803 811 * -- exception type/address block 812 * 804 813 * -- exception explanation 814 * 805 815 * -- process information 806 816 * … … 890 900 { 891 901 /* From the VAC++3 docs: 892 * "The first thing an exception handler should do is check the 893 * exception flags. If EH_EXIT_UNWIND is set, meaning 894 * the thread is ending, the handler tells the operating system 895 * to pass the exception to the next exception handler. It does the 896 * same if the EH_UNWINDING flag is set, the flag that indicates 897 * this exception handler is being removed. 898 * The EH_NESTED_CALL flag indicates whether the exception 899 * occurred within an exception handler. If the handler does 900 * not check this flag, recursive exceptions could occur until 901 * there is no stack remaining." 902 * So for all these conditions, we exit immediately. 902 * "The first thing an exception handler should do is check the 903 * exception flags. If EH_EXIT_UNWIND is set, meaning 904 * the thread is ending, the handler tells the operating system 905 * to pass the exception to the next exception handler. It does the 906 * same if the EH_UNWINDING flag is set, the flag that indicates 907 * this exception handler is being removed. 908 * The EH_NESTED_CALL flag indicates whether the exception 909 * occurred within an exception handler. If the handler does 910 * not check this flag, recursive exceptions could occur until 911 * there is no stack remaining." 912 * 913 * So for all these conditions, we exit immediately. 903 914 */ 904 915 905 916 if (pReportRec->fHandlerFlags & EH_EXIT_UNWIND) 906 return (XCPT_CONTINUE_SEARCH);917 return XCPT_CONTINUE_SEARCH; 907 918 if (pReportRec->fHandlerFlags & EH_UNWINDING) 908 return (XCPT_CONTINUE_SEARCH);919 return XCPT_CONTINUE_SEARCH; 909 920 if (pReportRec->fHandlerFlags & EH_NESTED_CALL) 910 return (XCPT_CONTINUE_SEARCH);921 return XCPT_CONTINUE_SEARCH; 911 922 912 923 switch (pReportRec->ExceptionNum) … … 920 931 { 921 932 // "real" exceptions: 922 FILE *file ;933 FILE *file = NULL; 923 934 924 935 // open traplog file; 925 936 if (G_pfnExcOpenFile) 926 937 // hook defined for this: call it 927 file = (*G_pfnExcOpenFile)();938 file = G_pfnExcOpenFile(); 928 939 else 929 940 { … … 933 944 // boot drive 934 945 sprintf(szFileName, "%c:\\trap.log", doshQueryBootDrive()); 935 file = fopen(szFileName, "a"); 936 937 if (file) 946 947 if (file = fopen(szFileName, "a")) 938 948 { 939 949 DATETIME DT; … … 948 958 } 949 959 950 // write error log 951 excExplainException(file, 952 "excHandlerLoud", 953 pReportRec, 954 pContextRec); 955 fclose(file); 960 if (file) 961 { 962 // write error log 963 excExplainException(file, 964 "excHandlerLoud", 965 pReportRec, 966 pContextRec); 967 fclose(file); 968 } 956 969 957 970 // copy report rec to user buffer … … 963 976 // jump back to failing routine 964 977 longjmp(pRegRec2->jmpThread, pReportRec->ExceptionNum); 965 break; } 978 } 979 break; 966 980 } 967 981 968 982 // not handled 969 return (XCPT_CONTINUE_SEARCH);983 return XCPT_CONTINUE_SEARCH; 970 984 } 971 985 … … 997 1011 { 998 1012 if (pReportRec->fHandlerFlags & EH_EXIT_UNWIND) 999 return (XCPT_CONTINUE_SEARCH);1013 return XCPT_CONTINUE_SEARCH; 1000 1014 if (pReportRec->fHandlerFlags & EH_UNWINDING) 1001 return (XCPT_CONTINUE_SEARCH);1015 return XCPT_CONTINUE_SEARCH; 1002 1016 if (pReportRec->fHandlerFlags & EH_NESTED_CALL) 1003 return (XCPT_CONTINUE_SEARCH);1017 return XCPT_CONTINUE_SEARCH; 1004 1018 1005 1019 switch (pReportRec->ExceptionNum) … … 1033 1047 longjmp(pRegRec2->jmpThread, pReportRec->ExceptionNum); 1034 1048 break; 1035 1036 default:1037 break;1038 1049 } 1039 1050 1040 return (XCPT_CONTINUE_SEARCH);1051 return XCPT_CONTINUE_SEARCH; 1041 1052 } 1042 1053 -
trunk/src/helpers/exeh.c
r222 r229 176 176 *@@changed V0.9.16 (2001-12-08) [umoeller]: speed optimizations, changed some return codes 177 177 *@@changed V0.9.16 (2002-01-04) [umoeller]: added fixes for COM, BAT, CMD extensions 178 *@@changed V 0.9.21(2002-08-18) [umoeller]: this was completely broken for files without extensions (os2krnl)178 *@@changed V1.0.0 (2002-08-18) [umoeller]: this was completely broken for files without extensions (os2krnl) 179 179 */ 180 180 … … 206 206 { 207 207 // has no extension: then open file! 208 // fixed V 0.9.21(2002-08-18) [umoeller]208 // fixed V1.0.0 (2002-08-18) [umoeller] 209 209 fOpenFile = TRUE; 210 210 } … … 561 561 *@@added V0.9.12 (2001-05-18) [umoeller] 562 562 *@@changed V0.9.12 (2001-05-19) [umoeller]: added extended BLDLEVEL support 563 *@@changed V 0.9.21(2002-08-18) [umoeller]: added support for IBM TCP/IP format564 *@@changed V 0.9.21(2002-08-18) [umoeller]: fixed DANIS506 format when an extended field had only one character563 *@@changed V1.0.0 (2002-08-18) [umoeller]: added support for IBM TCP/IP format 564 *@@changed V1.0.0 (2002-08-18) [umoeller]: fixed DANIS506 format when an extended field had only one character 565 565 */ 566 566 … … 599 599 { 600 600 // skip leading and trailing spaces 601 // V 0.9.21(2002-08-18) [umoeller]601 // V1.0.0 (2002-08-18) [umoeller] 602 602 PCSZ pStartOfDT = p, 603 603 pEndOfDT = p + 24; … … 670 670 { 671 671 // if (pNextColon > p + 1) 672 // fixed V 0.9.21(2002-08-18) [umoeller]672 // fixed V1.0.0 (2002-08-18) [umoeller] 673 673 // this failed on fields like "revision" 674 674 // which only had one character … … 694 694 { 695 695 // IBM TCP/IP format: 696 // V 0.9.21(2002-08-18) [umoeller]696 // V1.0.0 (2002-08-18) [umoeller] 697 697 698 698 // ##built 09:16:27 Mon Sep 17 2001 -- On AURORA43;0.1@@ TCP/IP for OS/2: INETD -
trunk/src/helpers/gpih.c
r222 r229 481 481 * the bottom left and top right pixels to be drawn. 482 482 * 483 * Note: With V 0.9.21, this now modifies prcl to be smaller towards483 * Note: With V1.0.0, this now modifies prcl to be smaller towards 484 484 * the center of the rectangle by usWidth so you can call this several 485 485 * times with different colors. … … 487 487 *@@changed V0.9.0 [umoeller]: changed function prototype to have colors specified 488 488 *@@changed V0.9.7 (2000-12-20) [umoeller]: now really using inclusive rectangle... 489 *@@changed V 0.9.21(2002-08-24) [umoeller]: renamed, now modifying prcl on output489 *@@changed V1.0.0 (2002-08-24) [umoeller]: renamed, now modifying prcl on output 490 490 */ 491 491 … … 534 534 * does not modify prcl. 535 535 * 536 *@@added V 0.9.21(2002-08-24) [umoeller]536 *@@added V1.0.0 (2002-08-24) [umoeller] 537 537 */ 538 538 -
trunk/src/helpers/lan.c
r222 r229 39 39 #include <os2.h> 40 40 41 #define PURE_3242 #include <neterr.h>43 #include <netcons.h>44 #include <server.h>41 // #define PURE_32 42 // #include <neterr.h> 43 // #include <netcons.h> 44 // #include <server.h> 45 45 46 46 #include <stdlib.h> … … 67 67 ********************************************************************/ 68 68 69 typedef API32_FUNCTION NET32WKSTAGETINFO(const unsigned char *pszServer, 69 #define API32_FUNCTION APIRET APIENTRY 70 71 typedef API32_FUNCTION NET32WKSTAGETINFO(PCSZ pszServer, 70 72 unsigned long ulLevel, 71 unsigned char *pbBuffer,73 PBYTE pbBuffer, 72 74 unsigned long ulBuffer, 73 75 unsigned long *pulTotalAvail); 74 76 75 typedef API32_FUNCTION NET32SERVERENUM2( const unsigned char *pszServer,77 typedef API32_FUNCTION NET32SERVERENUM2(PCSZ pszServer, 76 78 unsigned long ulLevel, 77 unsigned char *pbBuffer,79 PBYTE pbBuffer, 78 80 unsigned long cbBuffer, 79 81 unsigned long *pcEntriesRead, 80 82 unsigned long *pcTotalAvail, 81 83 unsigned long flServerType, 82 unsigned char *pszDomain); 84 PBYTE pszDomain); 85 86 typedef API32_FUNCTION NET32SERVICESTATUS(PCSZ pbBuffer, 87 unsigned long ulBuffer); 88 89 typedef API32_FUNCTION NET32SERVICEGETINFO(PCSZ pszServer, 90 PCSZ pszService, 91 unsigned long ulLevel, 92 PBYTE pbBuffer, 93 unsigned long ulBuffer, 94 unsigned long *pulTotalAvail); 95 96 typedef API32_FUNCTION NET32SERVICECONTROL(PCSZ pszServer, 97 PCSZ pszService, 98 unsigned short usOpcode, 99 unsigned short usArg, 100 PBYTE pbBuffer, 101 unsigned long ulBuffer); 102 103 typedef API32_FUNCTION NET32SERVICEINSTALL(PCSZ pszServer, 104 PCSZ pszService, 105 PCSZ pszCmdArgs, 106 PBYTE pbBuffer, 107 unsigned long ulBuffer); 83 108 84 109 /* ****************************************************************** … … 92 117 NET32WKSTAGETINFO *pNet32WkstaGetInfo = NULL; 93 118 NET32SERVERENUM2 *pNet32ServerEnum2 = NULL; 119 NET32SERVICESTATUS *pNet32ServiceStatus = NULL; 120 NET32SERVICEGETINFO *pNet32ServiceGetInfo = NULL; 121 NET32SERVICECONTROL *pNet32ServiceControl = NULL; 122 NET32SERVICEINSTALL *pNet32ServiceInstall = NULL; 94 123 95 124 RESOLVEFUNCTION NetResolves[] = 96 125 { 97 126 "Net32WkstaGetInfo", (PFN*)&pNet32WkstaGetInfo, 98 "Net32ServerEnum2", (PFN*)&pNet32ServerEnum2 127 "Net32ServerEnum2", (PFN*)&pNet32ServerEnum2, 128 "Net32ServiceStatus", (PFN*)&pNet32ServiceStatus, 129 "Net32ServiceGetInfo", (PFN*)&pNet32ServiceGetInfo, 130 "Net32ServiceControl", (PFN*)&pNet32ServiceControl, 131 "Net32ServiceInstall", (PFN*)&pNet32ServiceInstall, 99 132 }; 100 133 … … 105 138 /* 106 139 *@@ lanInit: 107 * 140 * initializes the LAN server interface. 141 * 142 * Returns: 143 * 144 * -- NO_ERROR: functions resolved successfully, 145 * engine is ready. 146 * 147 * or the error codes from doshResolveImports. 108 148 */ 109 149 … … 118 158 } 119 159 120 printf(__FUNCTION__ ": arc %d\n", G_ulNetsResolved); 121 122 return (G_ulNetsResolved); 160 return G_ulNetsResolved; 123 161 } 124 162 … … 139 177 { 140 178 APIRET arc; 179 141 180 if (!(arc = lanInit())) 142 181 { … … 150 189 if (!(arc = pNet32ServerEnum2(NULL, 151 190 1, // ulLevel 152 (P UCHAR)pBuf, // pbBuffer191 (PBYTE)pBuf, // pbBuffer 153 192 cb, // cbBuffer, 154 193 &ulEntriesRead, // *pcEntriesRead, … … 170 209 } 171 210 211 /* 212 *@@ lanServiceGetInfo: 213 * queries the given service. 214 * 215 *@@added V1.0.0 (2002-09-24) [umoeller] 216 */ 217 218 APIRET lanServiceGetInfo(PCSZ pcszServiceName, 219 PSERVICEBUF2 pBuf) 220 { 221 APIRET arc; 222 223 if (!(arc = lanInit())) 224 { 225 ULONG ulBytesAvail = 0; 226 arc = pNet32ServiceGetInfo(NULL, 227 pcszServiceName, 228 2, // level 229 (PBYTE)pBuf, 230 sizeof(SERVICEBUF2), 231 &ulBytesAvail); 232 233 } 234 235 return arc; 236 } 237 /* 238 *@@ lanServiceInstall: 239 * starts the given service. The service name 240 * must be fully qualified so you cannot 241 * abbreviate "requester" with "req", for 242 * example (as valid with the net command). 243 * 244 * Returns, among others: 245 * 246 * -- NO_ERROR 247 * 248 * -- NERR_ServiceInstalled (2182): the service 249 * has already been started. 250 * 251 * -- NERR_BadServiceName (2185): invalid service 252 * name. 253 * 254 *@@added V1.0.0 (2002-09-24) [umoeller] 255 */ 256 257 APIRET lanServiceInstall(PCSZ pcszServiceName, 258 PSERVICEBUF2 pBuf2) // out: service data 259 { 260 APIRET arc; 261 262 if (!(arc = lanInit())) 263 { 264 SERVICEBUF2 buf2; 265 266 if (!(arc = pNet32ServiceInstall(NULL, 267 pcszServiceName, 268 NULL, 269 (PBYTE)pBuf2, 270 sizeof(SERVICEBUF2)))) 271 ; 272 } 273 274 return arc; 275 } 276 277 /* 278 *@@ lanServiceControl: 279 * queries, pauses, resumes, or stops the given service. 280 * 281 * opcode must be one of: 282 * 283 * -- SERVICE_CTRL_INTERROGATE (0): interrogate service status. 284 * 285 * -- SERVICE_CTRL_PAUSE (1): pause service. 286 * 287 * -- SERVICE_CTRL_CONTINUE (2): continue service. 288 * 289 * -- SERVICE_CTRL_UNINSTALL (3): stop service. 290 * 291 *@@added V1.0.0 (2002-09-24) [umoeller] 292 */ 293 294 APIRET lanServiceControl(PCSZ pcszServiceName, 295 ULONG opcode, 296 PSERVICEBUF2 pBuf2) // out: service data 297 { 298 APIRET arc; 299 300 if (!(arc = lanInit())) 301 { 302 if (!(arc = pNet32ServiceControl(NULL, 303 pcszServiceName, 304 opcode, 305 0, 306 (PBYTE)pBuf2, 307 sizeof(SERVICEBUF2)))) 308 ; 309 310 } 311 312 return arc; 313 } 314 172 315 #ifdef __LAN_TEST__ 173 316 -
trunk/src/helpers/linklist.c
r193 r229 262 262 263 263 lstInit(pNewList, fItemsFreeable); 264 return (pNewList); 264 265 return pNewList; 265 266 } 266 267 … … 296 297 if (pNewList = (PLINKLIST)malloc(sizeof(LINKLIST))) 297 298 lstInit(pNewList, fItemsFreeable); 298 return (pNewList); 299 300 return pNewList; 299 301 } 300 302 … … 361 363 long lstCountItems(const LINKLIST *pList) 362 364 { 363 long lCount = -1; 364 365 if (pList) 366 if (pList->ulMagic == LINKLISTMAGIC) 367 { 368 lCount = pList->ulCount; 369 } 370 371 return (lCount); 365 if ( (pList) 366 && (pList->ulMagic == LINKLISTMAGIC) 367 ) 368 return pList->ulCount; 369 370 return -1; 372 371 } 373 372 … … 404 403 && (pList->ulMagic == LINKLISTMAGIC) 405 404 ) 406 return (pList->pFirst);407 408 return (0);405 return pList->pFirst; 406 407 return 0; 409 408 } 410 409 … … 422 421 && (pList->ulMagic == LINKLISTMAGIC) 423 422 ) 424 return (pList->pLast);425 426 return (0);423 return pList->pLast; 424 425 return 0; 427 426 } 428 427 … … 463 462 } 464 463 465 return (pNode);464 return pNode; 466 465 } 467 466 … … 500 499 } 501 500 502 return (pNodeFound);501 return pNodeFound; 503 502 } 504 503 … … 558 557 } 559 558 560 return (ulrc);559 return ulrc; 561 560 } 562 561 … … 616 615 } 617 616 618 return (pNewNode);617 return pNewNode; 619 618 } 620 619 … … 670 669 } 671 670 672 return (pNewNode);671 return pNewNode; 673 672 } 674 673 … … 767 766 } 768 767 769 return (pNewNode);768 return pNewNode; 770 769 } 771 770 … … 830 829 } 831 830 832 return (fFound);831 return fFound; 833 832 } 834 833 … … 855 854 856 855 if (pNode = lstNodeFromItem(pList, pRemoveItem)) 857 return (lstRemoveNode(pList, pNode));858 859 return (FALSE);856 return lstRemoveNode(pList, pNode); 857 858 return FALSE; 860 859 } 861 860 … … 879 878 pNode2->pItemData = pTemp; 880 879 881 return (TRUE);880 return TRUE; 882 881 } 883 882 884 return (FALSE);883 return FALSE; 885 884 } 886 885 … … 1085 1084 void* pNewItemData) // in: data to store in list node 1086 1085 { 1087 return (lstAppendItem(pList, pNewItemData));1086 return lstAppendItem(pList, pNewItemData); 1088 1087 } 1089 1088 … … 1115 1114 PLISTNODE lstPop(PLINKLIST pList) 1116 1115 { 1117 return (pList->pLast);1118 } 1119 1120 1116 return pList->pLast; 1117 } 1118 1119 -
trunk/src/helpers/map_vac.c
r226 r229 8 8 * numbering. 9 9 * 10 *@@added V 0.9.21(2002-09-13) [umoeller]10 *@@added V1.0.0 (2002-09-13) [umoeller] 11 11 * 12 12 *@@header "helpers\mapfile.h" -
trunk/src/helpers/prfh2.c
r169 r229 42 42 #define INCL_DOSERRORS 43 43 #define INCL_WINSHELLDATA 44 #define INCL_WINERRORS 44 45 #include <os2.h> 45 46 … … 54 55 55 56 #include "helpers\prfh.h" 57 #include "helpers\xprf.h" 56 58 57 59 #pragma hdrstop … … 641 643 } 642 644 643 645 #ifdef __PRFH2_MAIN__ 646 647 int main(int argc, char* argv[]) 648 { 649 APIRET arc = NO_ERROR; 650 PCSZ pcszSource, 651 pcszTarget, 652 pcszApp; 653 PXINI piniSource; 654 HINI hiniTarget; 655 BOOL fCloseSource = FALSE, 656 fCloseTarget = FALSE; 657 HAB hab = WinInitialize(0); 658 CHAR szFailing[1000]; 659 660 if (argc < 4) 661 { 662 printf("%d\nprfh2 <sourcefile> <targetfile> <appname>\n", argc); 663 exit(2); 664 } 665 666 pcszSource = argv[1]; 667 pcszTarget = argv[2]; 668 pcszApp = argv[3]; 669 670 if (arc = xprfOpenProfile(pcszSource, 671 &piniSource)) 672 { 673 printf("xprfOpenProfile returned %d opening source INI \"%s\"\n", 674 arc, 675 pcszSource); 676 } 677 else 678 fCloseSource = TRUE; 679 680 if (!strcmp(pcszTarget, "USER")) 681 hiniTarget = HINI_USER; 682 else if (!strcmp(pcszTarget, "SYSTEM")) 683 hiniTarget = HINI_SYSTEM; 684 else 685 { 686 if (!(hiniTarget = PrfOpenProfile(hab, (PSZ)pcszTarget))) 687 { 688 printf("Cannot open source INI \"%s\"\n", pcszTarget); 689 arc = -1; 690 } 691 else 692 fCloseTarget = TRUE; 693 } 694 695 if (!arc) 696 { 697 if (arc = xprfCopyApp2(piniSource, 698 pcszApp, 699 hiniTarget, 700 pcszApp, 701 szFailing)) 702 { 703 printf("Error %d copying application \"%s\" from %s to %s\n", 704 arc, 705 pcszApp, 706 pcszSource, 707 pcszTarget); 708 printf("Failing key: \"%s\"\n", 709 szFailing); 710 } 711 else 712 printf("Application \"%s\" successfully copied from %s to %s\n", 713 pcszApp, 714 pcszSource, 715 pcszTarget); 716 } 717 718 if (arc) 719 { 720 ERRORID eid; 721 eid = WinGetLastError(hab); 722 723 printf("WinGetLastError returned 0x%lX\n", 724 eid); 725 } 726 727 728 if (fCloseSource) 729 xprfCloseProfile(piniSource); 730 if (fCloseTarget) 731 PrfCloseProfile(hiniTarget); 732 733 WinTerminate(hab); 734 735 exit(arc); 736 } 737 738 #endif -
trunk/src/helpers/procstat.c
r218 r229 558 558 * 559 559 *@@added V0.9.2 (2000-03-05) [umoeller] 560 *@@changed V 0.9.21(2002-08-16) [pr]: optimized560 *@@changed V1.0.0 (2002-08-16) [pr]: optimized 561 561 */ 562 562 … … 602 602 *@@ prc32FindProcessFromPID: 603 603 * 604 *@@added V 0.9.21(2002-08-12) [umoeller]605 *@@changed V 0.9.21(2002-08-16) [pr]: optimized604 *@@added V1.0.0 (2002-08-12) [umoeller] 605 *@@changed V1.0.0 (2002-08-16) [pr]: optimized 606 606 */ 607 607 -
trunk/src/helpers/textview.c
r222 r229 2319 2319 * implementation for WM_CREATE in fnwpTextView. 2320 2320 * 2321 *@@added V 0.9.21(2002-08-12) [umoeller]2321 *@@added V1.0.0 (2002-08-12) [umoeller] 2322 2322 */ 2323 2323 … … 2465 2465 * implementation for WM_PAINT in fnwpTextView. 2466 2466 * 2467 *@@added V 0.9.21(2002-08-12) [umoeller]2467 *@@added V1.0.0 (2002-08-12) [umoeller] 2468 2468 */ 2469 2469 … … 2559 2559 * implementation for WM_PRESPARAMCHANGED in fnwpTextView. 2560 2560 * 2561 *@@added V 0.9.21(2002-08-12) [umoeller]2561 *@@added V1.0.0 (2002-08-12) [umoeller] 2562 2562 */ 2563 2563 … … 2589 2589 * implementation for WM_SETFOCUS in fnwpTextView. 2590 2590 * 2591 *@@added V 0.9.21(2002-08-12) [umoeller]2591 *@@added V1.0.0 (2002-08-12) [umoeller] 2592 2592 */ 2593 2593 … … 2652 2652 * implementation for WM_BUTTON1DOWN in fnwpTextView. 2653 2653 * 2654 *@@added V 0.9.21(2002-08-12) [umoeller]2654 *@@added V1.0.0 (2002-08-12) [umoeller] 2655 2655 */ 2656 2656 … … 2724 2724 * implementation for WM_BUTTON1UP in fnwpTextView. 2725 2725 * 2726 *@@added V 0.9.21(2002-08-12) [umoeller]2726 *@@added V1.0.0 (2002-08-12) [umoeller] 2727 2727 */ 2728 2728 … … 2766 2766 * implementation for WM_CHAR in fnwpTextView. 2767 2767 * 2768 *@@added V 0.9.21(2002-08-12) [umoeller]2768 *@@added V1.0.0 (2002-08-12) [umoeller] 2769 2769 */ 2770 2770 … … 2889 2889 * implementation for TXM_JUMPTOANCHORNAME in fnwpTextView. 2890 2890 * 2891 *@@added V 0.9.21(2002-08-12) [umoeller]2891 *@@added V1.0.0 (2002-08-12) [umoeller] 2892 2892 */ 2893 2893 … … 2945 2945 * implementation for WM_DESTROY in fnwpTextView. 2946 2946 * 2947 *@@added V 0.9.21(2002-08-12) [umoeller]2947 *@@added V1.0.0 (2002-08-12) [umoeller] 2948 2948 */ 2949 2949 … … 3019 3019 *@@changed V0.9.20 (2002-08-10) [umoeller]: added support for XS_STATIC 3020 3020 *@@changed V0.9.20 (2002-08-10) [umoeller]: added support for formatting HTML and plain text automatically 3021 *@@changed V 0.9.21(2002-08-12) [umoeller]: optimized locality by moving big chunks into subfuncs3021 *@@changed V1.0.0 (2002-08-12) [umoeller]: optimized locality by moving big chunks into subfuncs 3022 3022 */ 3023 3023 … … 3036 3036 case WM_CREATE: 3037 3037 mrc = ProcessCreate(hwndTextView, mp1, mp2); 3038 // extracted V 0.9.21(2002-08-12) [umoeller]3038 // extracted V1.0.0 (2002-08-12) [umoeller] 3039 3039 break; 3040 3040 … … 3090 3090 case WM_PAINT: 3091 3091 ProcessPaint(hwndTextView); 3092 // extracted V 0.9.21(2002-08-12) [umoeller]3092 // extracted V1.0.0 (2002-08-12) [umoeller] 3093 3093 break; 3094 3094 … … 3362 3362 * a ULONG. 3363 3363 * 3364 *@@changed V 0.9.21(2002-08-12) [umoeller]: now returning bytes3364 *@@changed V1.0.0 (2002-08-12) [umoeller]: now returning bytes 3365 3365 */ 3366 3366 -
trunk/src/helpers/threads.c
r222 r229 123 123 *@@added V0.9.2 (2000-03-05) [umoeller] 124 124 *@@changed V0.9.7 (2000-12-18) [lafaix]: THRF_TRANSIENT support added 125 *@@changed V 0.9.21(2002-08-21) [umoeller]: added WinCancelShutdown to avoid shutdown hangs125 *@@changed V1.0.0 (2002-08-21) [umoeller]: added WinCancelShutdown to avoid shutdown hangs 126 126 */ 127 127 … … 151 151 // in XWPDAEMN and causes the default OS/2 152 152 // shutdown to hang 153 // V 0.9.21(2002-08-21) [umoeller]153 // V1.0.0 (2002-08-21) [umoeller] 154 154 WinCancelShutdown(pti->hmq, TRUE); 155 155 -
trunk/src/helpers/winh.c
r219 r229 580 580 * IDs. 581 581 * 582 *@@added V 0.9.21(2002-08-12) [umoeller]582 *@@added V1.0.0 (2002-08-12) [umoeller] 583 583 */ 584 584 … … 909 909 * after calling this function. 910 910 * 911 *@@added V 0.9.21(2002-08-31) [umoeller]911 *@@added V1.0.0 (2002-08-31) [umoeller] 912 912 */ 913 913 … … 2769 2769 * 2770 2770 *@@added V0.9.19 (2002-04-17) [umoeller] 2771 *@@changed V 0.9.21(2002-08-26) [umoeller]: fixed cx and cy confusion2771 *@@changed V1.0.0 (2002-08-26) [umoeller]: fixed cx and cy confusion 2772 2772 */ 2773 2773 … … 2804 2804 2805 2805 // if (xNew + swpThis.cy > WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)) 2806 // not cy, but cx V 0.9.21(2002-08-26) [umoeller]2806 // not cy, but cx V1.0.0 (2002-08-26) [umoeller] 2807 2807 if (xNew + swpThis.cx > WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)) 2808 2808 { … … 4056 4056 * 4057 4057 *@@added V0.9.9 (2001-03-13) [umoeller] 4058 *@@changed V 0.9.21(2002-08-26) [umoeller]: added separate hwndOwner4058 *@@changed V1.0.0 (2002-08-26) [umoeller]: added separate hwndOwner 4059 4059 */ 4060 4060 … … 4758 4758 * replacing the current clipboard contents. 4759 4759 * 4760 *@@added V 0.9.21(2002-08-28) [umoeller]4760 *@@added V1.0.0 (2002-08-28) [umoeller] 4761 4761 */ 4762 4762 … … 4813 4813 * (XWorkplace status bars). 4814 4814 * 4815 *@@added V 0.9.21(2002-08-28) [umoeller]4815 *@@added V1.0.0 (2002-08-28) [umoeller] 4816 4816 */ 4817 4817 -
trunk/src/helpers/xml.c
r222 r229 3103 3103 *@@ ESCAPES: 3104 3104 * 3105 *@@added V 0.9.21(2002-08-21) [umoeller]3105 *@@added V1.0.0 (2002-08-21) [umoeller] 3106 3106 */ 3107 3107 … … 3124 3124 *@@ DoEscapes: 3125 3125 * 3126 *@@added V 0.9.21(2002-08-21) [umoeller]3126 *@@added V1.0.0 (2002-08-21) [umoeller] 3127 3127 */ 3128 3128 … … 3185 3185 * 3186 3186 *@@added V0.9.12 (2001-05-21) [umoeller] 3187 *@@changed V 0.9.21(2002-08-21) [umoeller]: changed prototype, fixed unescaped characters in attributes and content3187 *@@changed V1.0.0 (2002-08-21) [umoeller]: changed prototype, fixed unescaped characters in attributes and content 3188 3188 */ 3189 3189 … … 3227 3227 // copy attribute value to temp buffer first 3228 3228 // so we can escape quotes and ampersands 3229 // V 0.9.21(2002-08-21) [umoeller]3229 // V1.0.0 (2002-08-21) [umoeller] 3230 3230 xstrcpys(&pEscapes->strTemp, pAttribNode->pstrNodeValue); 3231 3231 … … 3270 3270 pChildNode->pstrNodeValue); 3271 3271 3272 DoEscapes(pEscapes, // V 0.9.21(2002-08-21) [umoeller]3272 DoEscapes(pEscapes, // V1.0.0 (2002-08-21) [umoeller] 3273 3273 FALSE); // quotes not 3274 3274 -
trunk/src/helpers/xprf.c
r222 r229 155 155 * 156 156 * Private helper. 157 */ 158 159 STATIC PXINIAPPDATA FindApp(PXINI pXIni, // in: profile opened with xprfOpenProfile 160 const char *pcszApp) 157 * 158 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 159 */ 160 161 STATIC APIRET FindApp(PXINI pXIni, // in: profile opened with xprfOpenProfile 162 const char *pcszApp, 163 PXINIAPPDATA *ppAppData) 161 164 { 162 165 PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps); … … 165 168 PXINIAPPDATA pAppDataThis = (PXINIAPPDATA)pAppNode->pItemData; 166 169 if (!strcmp(pAppDataThis->pszAppName, pcszApp)) 167 return (pAppDataThis); 170 { 171 *ppAppData = pAppDataThis; 172 return NO_ERROR; 173 } 168 174 169 175 pAppNode = pAppNode->pNext; 170 176 } 171 177 172 return NULL;178 return PRFERR_INVALID_APP_NAME; 173 179 } 174 180 … … 181 187 * 182 188 * Private helper. 183 */ 184 185 STATIC PXINIAPPDATA CreateApp(PXINI pXIni, // in: profile opened with xprfOpenProfile 186 const char *pcszApp) 189 * 190 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 191 */ 192 193 STATIC APIRET CreateApp(PXINI pXIni, // in: profile opened with xprfOpenProfile 194 const char *pcszApp, 195 PXINIAPPDATA *ppAppData) 187 196 { 188 197 PXINIAPPDATA pAppData; … … 195 204 // store in INI's apps list 196 205 lstAppendItem(&pXIni->llApps, pAppData); 197 pXIni->cApps++; 198 } 199 200 return (pAppData); 206 207 *ppAppData = pAppData; 208 return NO_ERROR; 209 } 210 211 return ERROR_NOT_ENOUGH_MEMORY; 201 212 } 202 213 … … 208 219 * 209 220 * Private helper. 210 */ 211 212 STATIC PXINIKEYDATA FindKey(PXINIAPPDATA pAppData, 213 const char *pcszKey) 221 * 222 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 223 */ 224 225 STATIC APIRET FindKey(PXINIAPPDATA pAppData, 226 const char *pcszKey, 227 PXINIKEYDATA *ppKeyData) 214 228 { 215 229 PLISTNODE pKeyNode = lstQueryFirstNode(&pAppData->llKeys); … … 218 232 PXINIKEYDATA pKeyDataThis = (PXINIKEYDATA)pKeyNode->pItemData; 219 233 if (!strcmp(pKeyDataThis->pszKeyName, pcszKey)) 220 return (pKeyDataThis); 234 { 235 *ppKeyData = pKeyDataThis; 236 return NO_ERROR; 237 } 221 238 222 239 pKeyNode = pKeyNode->pNext; 223 240 } 224 241 225 return NULL;242 return PRFERR_INVALID_KEY_NAME; 226 243 } 227 244 … … 234 251 * 235 252 * Private helper. 236 */ 237 238 STATIC PXINIKEYDATA CreateKey(PXINIAPPDATA pAppData, 239 const char *pcszKey, // in: key name 240 PBYTE pbData, // in: data for key 241 ULONG cbData) // in: sizeof (*pbData) 253 * 254 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 255 */ 256 257 STATIC APIRET CreateKey(PXINIAPPDATA pAppData, 258 const char *pcszKey, // in: key name 259 PBYTE pbData, // in: data for key 260 ULONG cbData, // in: sizeof (*pbData) 261 PXINIKEYDATA *ppKeyData) // out: new key data 242 262 { 243 263 PXINIKEYDATA pKeyData; … … 253 273 lstAppendItem(&pAppData->llKeys, pKeyData); 254 274 pAppData->cKeys++; 275 276 *ppKeyData = pKeyData; 277 return NO_ERROR; 255 278 } 256 279 else 257 {258 280 // malloc failed: 259 281 free(pKeyData); 260 pKeyData = 0; 261 } 262 } 263 264 return (pKeyData); 282 } 283 284 return ERROR_NOT_ENOUGH_MEMORY; 265 285 } 266 286 … … 284 304 285 305 /* 306 *@@ FreeKeyIfExists: 307 * 308 *@@added V1.0.0 (2002-09-17) [umoeller] 309 */ 310 311 STATIC VOID FreeKeyIfExists(PXINI pXIni, // in: profile opened with xprfOpenProfile 312 PXINIAPPDATA pAppData, 313 PCSZ pcszKey) 314 { 315 // find key 316 PXINIKEYDATA pKeyData; 317 318 if (!FindKey(pAppData, 319 pcszKey, 320 &pKeyData)) 321 { 322 // key exists: kill that 323 FreeKey(pKeyData); 324 // and remove from app's keys list 325 lstRemoveItem(&pAppData->llKeys, pKeyData); 326 pAppData->cKeys--; 327 328 // rewrite profile on close 329 pXIni->fDirty = TRUE; 330 } 331 // else key doesn't exist: 332 // nothing to do 333 } 334 335 /* 286 336 * FreeApp: 287 337 * frees the specified application. Does not remove … … 319 369 */ 320 370 321 STATIC BOOL FreeINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 322 { 323 BOOL brc = FALSE; 324 371 STATIC VOID FreeINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 372 { 325 373 if (pXIni) 326 374 { … … 338 386 free(pXIni); 339 387 } 340 341 return brc;342 388 } 343 389 … … 354 400 * 355 401 * Private helper. 356 */ 357 358 STATIC BOOL ReadINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 359 { 360 BOOL brc = FALSE; 402 * 403 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 404 */ 405 406 STATIC APIRET ReadINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 407 { 408 APIRET arc; 361 409 FILESTATUS3 fs3; 362 410 363 if (DosProtectQueryFileInfo(pXIni->hFile, 364 FIL_STANDARD, 365 &fs3, 366 sizeof(fs3), 367 pXIni->hLock) 368 == NO_ERROR) 411 if (!(arc = DosQueryFileInfo(pXIni->hFile, 412 FIL_STANDARD, 413 &fs3, 414 sizeof(fs3)))) 369 415 { 370 416 PBYTE pbFileData; 371 if (pbFileData = (PBYTE)malloc(fs3.cbFile)) 417 if (!(pbFileData = (PBYTE)malloc(fs3.cbFile))) 418 arc = ERROR_NOT_ENOUGH_MEMORY; 419 else 372 420 { 373 421 ULONG ulSet = 0; 374 APIRET arc = DosProtectSetFilePtr(pXIni->hFile, 375 0, 376 FILE_BEGIN, 377 &ulSet, 378 pXIni->hLock); 379 if ( (arc == NO_ERROR) 380 && (ulSet == 0) 381 ) 422 423 if (!(arc = DosSetFilePtr(pXIni->hFile, 424 0, 425 FILE_BEGIN, 426 &ulSet))) 382 427 { 383 428 ULONG cbRead = 0; 384 arc = DosProtectRead(pXIni->hFile, 385 pbFileData, 386 fs3.cbFile, 387 &cbRead, 388 pXIni->hLock); 389 if ( (arc == NO_ERROR) 390 && (cbRead == fs3.cbFile) 391 ) 429 if (!(arc = DosRead(pXIni->hFile, 430 pbFileData, 431 fs3.cbFile, 432 &cbRead))) 392 433 { 393 PINIFILE_HEADER pHeader = (PINIFILE_HEADER)pbFileData; 394 if (pHeader->magic == 0xFFFFFFFF) 434 if (cbRead != fs3.cbFile) 435 arc = ERROR_NO_DATA; 436 else 395 437 { 396 ULONG ulAppOfs = pHeader->offFirstApp; 397 398 // it was a valid profile, so return TRUE 399 brc = TRUE; 400 401 // create-applications loop 402 while ((ulAppOfs) && (brc)) 438 PINIFILE_HEADER pHeader = (PINIFILE_HEADER)pbFileData; 439 if (pHeader->magic == 0xFFFFFFFF) 403 440 { 404 // application struct 405 PINIFILE_APP pApp = (PINIFILE_APP)(pbFileData + ulAppOfs); 406 ULONG ulKeysOfs = pApp->offFirstKeyInApp; 407 PXINIAPPDATA pIniApp 408 = CreateApp(pXIni, 409 (PBYTE)(pbFileData + pApp->offAppName)); 410 if (!pIniApp) 441 ULONG ulAppOfs = pHeader->offFirstApp; 442 443 // create-applications loop 444 while ((ulAppOfs) && (!arc)) 411 445 { 412 brc = FALSE; 413 break; 446 // application struct 447 PINIFILE_APP pApp = (PINIFILE_APP)(pbFileData + ulAppOfs); 448 ULONG ulKeysOfs = pApp->offFirstKeyInApp; 449 PXINIAPPDATA pIniApp; 450 451 if (arc = CreateApp(pXIni, 452 (PBYTE)(pbFileData + pApp->offAppName), 453 &pIniApp)) 454 break; 455 456 // create-keys loop 457 while ((ulKeysOfs) && (!arc)) 458 { 459 PINIFILE_KEY pKey = (PINIFILE_KEY)(pbFileData + ulKeysOfs); 460 461 PXINIKEYDATA pIniKey; 462 463 if (arc = CreateKey(pIniApp, 464 (PSZ)(pbFileData + pKey->offKeyName), 465 (PBYTE)(pbFileData + pKey->offKeyData), 466 pKey->lenKeyData, 467 &pIniKey)) 468 break; 469 470 // next key; can be null 471 ulKeysOfs = pKey->offNextKeyInApp; 472 } 473 474 // next application; can be null 475 ulAppOfs = pApp->offNextApp; 414 476 } 415 416 // create-keys loop417 while ((ulKeysOfs) && (brc))418 {419 PINIFILE_KEY pKey = (PINIFILE_KEY)(pbFileData + ulKeysOfs);420 421 PXINIKEYDATA pIniKey422 = CreateKey(pIniApp,423 (PSZ)(pbFileData + pKey->offKeyName),424 (PBYTE)(pbFileData + pKey->offKeyData),425 pKey->lenKeyData);426 427 if (!pIniKey)428 {429 brc = FALSE;430 break;431 }432 433 // next key; can be null434 ulKeysOfs = pKey->offNextKeyInApp;435 }436 437 // next application; can be null438 ulAppOfs = pApp->offNextApp;439 477 } 440 478 } … … 446 484 } 447 485 448 return brc;486 return arc; 449 487 } 450 488 … … 455 493 * 456 494 * Private helper. 457 */ 458 459 STATIC BOOL WriteINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 460 { 461 BOOL brc = FALSE; 495 * 496 *@@changed V1.0.0 (2002-09-17) [umoeller]: now returning APIRET 497 */ 498 499 STATIC APIRET WriteINI(PXINI pXIni) // in: profile opened with xprfOpenProfile 500 { 501 APIRET arc = NO_ERROR; 462 502 ULONG ulTotalFileSize = sizeof(INIFILE_HEADER); 463 503 ULONG ulSet = 0; … … 471 511 // go thru all apps 472 512 PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps); 513 473 514 while (pAppNode) 474 515 { … … 501 542 if (pbData2Write = (PBYTE)malloc(ulTotalFileSize)) 502 543 { 503 APIRET arc = NO_ERROR;504 505 544 // set header in buffer 506 545 PINIFILE_HEADER pHeader = (PINIFILE_HEADER)pbData2Write; … … 512 551 513 552 pHeader->magic = 0xFFFFFFFF; 514 if ( pXIni->cApps)553 if (lstCountItems(&pXIni->llApps)) 515 554 // we have any applications: 516 555 pHeader->offFirstApp = sizeof(INIFILE_HEADER); … … 630 669 631 670 // write out everything 632 if (!(arc = DosProtectSetFilePtr(pXIni->hFile, 633 0, 634 FILE_BEGIN, 635 &ulSet, 636 pXIni->hLock))) 671 if (!(arc = DosSetFilePtr(pXIni->hFile, 672 0, 673 FILE_BEGIN, 674 &ulSet))) 637 675 { 638 676 ULONG cbWritten = 0; 639 if ( (!(arc = DosProtectWrite(pXIni->hFile, 640 pbData2Write, 641 ulTotalFileSize, 642 &cbWritten, 643 pXIni->hLock))) 644 && (!(arc = DosProtectSetFileSize(pXIni->hFile, 645 ulTotalFileSize, 646 pXIni->hLock))) 647 ) 648 brc = TRUE; 677 if (!(arc = DosWrite(pXIni->hFile, 678 pbData2Write, 679 ulTotalFileSize, 680 &cbWritten))) 681 { 682 if (!(arc = DosSetFileSize(pXIni->hFile, 683 ulTotalFileSize))) 684 ; 685 } 649 686 } 650 687 … … 652 689 } 653 690 654 return brc;691 return arc; 655 692 } 656 693 … … 688 725 APIRET arc = NO_ERROR; 689 726 PXINI pXIni = NULL; 690 691 if (pcszFilename) 692 if (strlen(pcszFilename) < CCHMAXPATH - 1) 693 { 694 HFILE hFile = NULLHANDLE; 695 ULONG ulAction = 0; 696 FHLOCK hLock = 0; 697 arc = DosProtectOpen((PSZ)pcszFilename, 698 &hFile, 699 &ulAction, 700 1024, // initial size 701 FILE_NORMAL, 702 OPEN_ACTION_CREATE_IF_NEW 703 | OPEN_ACTION_OPEN_IF_EXISTS, 704 OPEN_FLAGS_FAIL_ON_ERROR 705 | OPEN_FLAGS_NO_CACHE 706 | OPEN_FLAGS_SEQUENTIAL 707 | OPEN_SHARE_DENYREADWRITE 708 | OPEN_ACCESS_READWRITE, 709 NULL, // no EAs 710 &hLock); 711 if (arc == NO_ERROR) 727 ULONG ulFilenameLen; 728 729 if ( (!pcszFilename) 730 || (!ppxini) 731 ) 732 arc = ERROR_INVALID_PARAMETER; // V1.0.0 (2002-09-17) [umoeller] 733 else if (!(ulFilenameLen = strlen(pcszFilename))) 734 arc = ERROR_INVALID_PARAMETER; // V1.0.0 (2002-09-17) [umoeller] 735 else if (ulFilenameLen >= CCHMAXPATH - 1) 736 arc = ERROR_FILENAME_EXCED_RANGE; 737 else 738 { 739 HFILE hFile = NULLHANDLE; 740 ULONG ulAction = 0; 741 // FHLOCK hLock = 0; 742 743 if (!(arc = DosOpen((PSZ)pcszFilename, 744 &hFile, 745 &ulAction, 746 1024, // initial size 747 FILE_NORMAL, 748 OPEN_ACTION_CREATE_IF_NEW 749 | OPEN_ACTION_OPEN_IF_EXISTS, 750 OPEN_FLAGS_FAIL_ON_ERROR 751 | OPEN_FLAGS_SEQUENTIAL 752 | OPEN_SHARE_DENYREADWRITE 753 | OPEN_ACCESS_READWRITE, 754 NULL))) 755 { 756 if (!(pXIni = (PXINI)malloc(sizeof(XINI)))) 757 arc = ERROR_NOT_ENOUGH_MEMORY; 758 else 712 759 { 713 pXIni = (PXINI)malloc(sizeof(XINI)); 714 if (!pXIni) 715 arc = ERROR_NOT_ENOUGH_MEMORY; 760 // OK: initialize XINI 761 memset(pXIni, 0, sizeof(XINI)); 762 memcpy(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES)); 763 memcpy(pXIni->szFilename, 764 pcszFilename, 765 ulFilenameLen + 1); 766 pXIni->hFile = hFile; 767 // pXIni->hLock = hLock; 768 769 lstInit(&pXIni->llApps, FALSE); 770 771 if (ulAction == FILE_CREATED) 772 // file newly created: rewrite on close 773 pXIni->fDirty = TRUE; 716 774 else 775 // file existed: read data 776 if (arc = ReadINI(pXIni)) 777 // error: 778 FreeINI(pXIni); 779 } 780 781 if (!arc) 782 *ppxini = pXIni; 783 else 784 DosClose(hFile); 785 } 786 } 787 788 return arc; 789 } 790 791 /* 792 *@@ xprfQueryProfileSize: 793 * returns the size of INI data, similarly to 794 * what PrfQueryProfileSize does. 795 * 796 * If (pszAppName == NULL), this returns the size of 797 * the buffer required to hold the enumerated list 798 * of application names. pszKey is then ignored. 799 * 800 * Otherwise, if (pszKeyName == NULL), this returns 801 * the size of the buffer required to hold the 802 * enumerated list of _key_ names for the given 803 * application. 804 * 805 * If both pszAppName and pszKeyName are not NULL, this 806 * returns the data size of the given key. 807 * 808 * Returns: 809 * 810 * -- NO_ERROR 811 * 812 *@@added V1.0.0 (2002-09-17) [umoeller] 813 */ 814 815 APIRET xprfQueryProfileSize(PXINI pXIni, // in: profile opened with xprfOpenProfile 816 PCSZ pszAppName, // in: application name or NULL 817 PCSZ pszKeyName, // in: key name or NULL 818 PULONG pulDataLen) // out: size of requested data 819 { 820 APIRET arc = NO_ERROR; 821 ULONG ulDataLen = 0; 822 823 if (!pszAppName) 824 { 825 PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps); 826 while (pAppNode) 827 { 828 PXINIAPPDATA pAppDataThis = (PXINIAPPDATA)pAppNode->pItemData; 829 ulDataLen += strlen(pAppDataThis->pszAppName) + 1; 830 pAppNode = pAppNode->pNext; 831 } 832 833 // extra byte for terminating extra null 834 ++ulDataLen; 835 } 836 else 837 { 838 // app specified: 839 PXINIAPPDATA pAppData; 840 841 if (!(arc = FindApp(pXIni, 842 pszAppName, 843 &pAppData))) 844 { 845 // app exists: 846 847 if (!pszKeyName) 848 { 849 // app != NULL, but key == NULL: 850 // return size of keys list 851 PLISTNODE pKeyNode = lstQueryFirstNode(&pAppData->llKeys); 852 while (pKeyNode) 717 853 { 718 // OK: initialize XINI 719 memset(pXIni, 0, sizeof(XINI)); 720 memcpy(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES)); 721 strcpy(pXIni->szFilename, pcszFilename); 722 pXIni->hFile = hFile; 723 pXIni->hLock = hLock; 724 725 lstInit(&pXIni->llApps, FALSE); 726 727 if (ulAction == FILE_CREATED) 728 // file newly created: rewrite on close 729 pXIni->fDirty = TRUE; 854 PXINIKEYDATA pKeyDataThis = (PXINIKEYDATA)pKeyNode->pItemData; 855 ulDataLen += strlen(pKeyDataThis->pszKeyName) + 1; 856 pKeyNode = pKeyNode->pNext; 857 } 858 859 // extra byte for terminating extra null 860 ++ulDataLen; 861 } 862 else 863 { 864 // both app and key specified: 865 PXINIKEYDATA pKeyData; 866 if (!(arc = FindKey(pAppData, 867 pszKeyName, 868 &pKeyData))) 869 ulDataLen = pKeyData->cbData; 870 } 871 } 872 } 873 874 if (pulDataLen) 875 *pulDataLen = ulDataLen; 876 877 return arc; 878 } 879 880 /* 881 *@@ xprfQueryProfileData: 882 * reads data from the given XINI, similarly to 883 * what PrfQueryProfileData does. 884 * 885 * If (pszAppName == NULL), this returns the 886 * enumerated list of application names. 887 * pszKey is then ignored. *pulBufferMax 888 * receives the total size of the list excluding 889 * the final NULL character. 890 * 891 * Otherwise, if (pszKeyName == NULL), this the 892 * enumerated list of _key_ names for the given 893 * application. *pulBufferMax receives the total 894 * size of the list excluding the final NULL character. 895 * 896 * If both pszAppName and pszKeyName are not NULL, 897 * this returns the data of the given key. 898 * pulBufferMax receives the bytes copied. 899 * 900 * Returns: 901 * 902 * -- NO_ERROR 903 */ 904 905 APIRET xprfQueryProfileData(PXINI pXIni, // in: profile opened with xprfOpenProfile 906 PCSZ pszAppName, // in: application name 907 PCSZ pszKeyName, // in: key name or NULL 908 PVOID pBuffer, // in: buffer to receive data 909 PULONG pulBufferMax) // in: buffer size, out: size of written data 910 { 911 APIRET arc = NO_ERROR; 912 ULONG ulDataLen = 0; 913 914 if (!pszAppName) 915 { 916 PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps); 917 PBYTE pbTarget = (PSZ)pBuffer; 918 ULONG cbCopied = 0; 919 while (pAppNode) 920 { 921 PXINIAPPDATA pAppDataThis = (PXINIAPPDATA)pAppNode->pItemData; 922 ULONG cbThis = strlen(pAppDataThis->pszAppName) + 1; 923 if (cbCopied + cbThis > *pulBufferMax) 924 break; 925 else 926 { 927 memcpy(pbTarget + cbCopied, 928 pAppDataThis->pszAppName, 929 cbThis); 930 cbCopied += cbThis; 931 } 932 933 pAppNode = pAppNode->pNext; 934 } 935 936 // extra byte for terminating extra null 937 pbTarget[cbCopied] = '\0'; 938 ulDataLen = cbCopied; // PMREF says terminating null is not counted 939 } 940 else 941 { 942 // app specified: 943 PXINIAPPDATA pAppData; 944 945 if (!(arc = FindApp(pXIni, 946 pszAppName, 947 &pAppData))) 948 { 949 // app exists: 950 951 if (!pszKeyName) 952 { 953 // app != NULL, but key == NULL: 954 // return size of keys list 955 PLISTNODE pKeyNode = lstQueryFirstNode(&pAppData->llKeys); 956 PBYTE pbTarget = (PSZ)pBuffer; 957 ULONG cbCopied = 0; 958 while (pKeyNode) 959 { 960 PXINIKEYDATA pKeyDataThis = (PXINIKEYDATA)pKeyNode->pItemData; 961 ULONG cbThis = strlen(pKeyDataThis->pszKeyName) + 1; 962 if (cbCopied + cbThis > *pulBufferMax) 963 break; 730 964 else 731 // file existed: read data 732 if (!ReadINI(pXIni)) 733 { 734 // error: 735 FreeINI(pXIni); 736 pXIni = NULL; 737 arc = PRFERR_READ; 738 } 739 740 if ((pXIni) && (ppxini)) 741 *ppxini = pXIni; 965 { 966 memcpy(pbTarget + cbCopied, 967 pKeyDataThis->pszKeyName, 968 cbThis); 969 cbCopied += cbThis; 970 } 971 972 pKeyNode = pKeyNode->pNext; 973 } 974 975 // extra byte for terminating extra null 976 pbTarget[cbCopied] = '\0'; 977 ulDataLen = cbCopied; // PMREF says terminating null is not counted 978 } 979 else 980 { 981 // both app and key specified: 982 PXINIKEYDATA pKeyData; 983 if (!(arc = FindKey(pAppData, 984 pszKeyName, 985 &pKeyData))) 986 { 987 ulDataLen = min(pKeyData->cbData, 988 *pulBufferMax); 989 memcpy(pBuffer, 990 pKeyData->pbData, 991 ulDataLen); 742 992 } 743 993 } 744 994 } 995 } 996 997 if (pulBufferMax) 998 *pulBufferMax = ulDataLen; 745 999 746 1000 return arc; 747 1001 } 748 749 /*750 *@@ xprfQueryProfileData:751 * similar to PrfQueryProfileData.752 *753 * @@todo: Still to be written.754 */755 756 /* BOOL xprfQueryProfileData(PXINI hIni, // in: profile opened with xprfOpenProfile757 const char *pcszApp,758 const char *pcszKey,759 PVOID pBuffer,760 PULONG pulBufferMax)761 {762 BOOL brc = FALSE;763 764 return brc;765 } */766 1002 767 1003 /* … … 792 1028 * as "dirty" so that the file will be rewritten 793 1029 * on xprfCloseProfile. 794 */ 795 796 BOOL xprfWriteProfileData(PXINI hIni, // in: profile opened with xprfOpenProfile 797 const char *pcszApp, // in: application name 798 const char *pcszKey, // in: key name or NULL 799 PVOID pData, // in: data to write or NULL 800 ULONG ulDataLen) // in: sizeof(*pData) or null 801 { 802 BOOL brc = FALSE; 803 804 if (hIni) 805 { 806 PXINI pXIni = (PXINI)hIni; 807 if (memcmp(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES)) 808 == 0) 809 { 810 // check if application exists 811 PXINIAPPDATA pAppData = FindApp(pXIni, 812 pcszApp); 813 814 // now check: does caller want entire application deleted? 815 if (!pcszKey) 1030 * 1031 * Returns: 1032 * 1033 * -- NO_ERROR 1034 */ 1035 1036 APIRET xprfWriteProfileData(PXINI pXIni, // in: profile opened with xprfOpenProfile 1037 const char *pcszApp, // in: application name 1038 const char *pcszKey, // in: key name or NULL 1039 PVOID pData, // in: data to write or NULL 1040 ULONG ulDataLen) // in: sizeof(*pData) or null 1041 { 1042 APIRET arc = NO_ERROR; 1043 1044 if ( (!pXIni) 1045 || (memcmp(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES))) 1046 ) 1047 arc = ERROR_INVALID_PARAMETER; 1048 else 1049 { 1050 // check if application exists 1051 PXINIAPPDATA pAppData; 1052 1053 if (FindApp(pXIni, 1054 pcszApp, 1055 &pAppData)) 1056 // not found: 1057 pAppData = NULL; 1058 1059 // now check: does caller want entire application deleted? 1060 if (!pcszKey) 1061 { 1062 // yes, delete application: did we find it? 1063 if (pAppData) 816 1064 { 817 // yes, delete application: did we find it? 1065 // yes: kill that 1066 FreeApp(pAppData); 1067 // and remove from list 1068 lstRemoveItem(&pXIni->llApps, pAppData); 1069 1070 // rewrite profile on close 1071 pXIni->fDirty = TRUE; 1072 } 1073 // else application doesn't exist: 1074 // nothing to do return NO_ERROR 1075 } 1076 else 1077 { 1078 // caller has specified key: 1079 // does caller want a key to be deleted? 1080 if (!ulDataLen) 1081 { 1082 // yes: delete key: 818 1083 if (pAppData) 819 1084 { 820 // yes: kill that 821 FreeApp(pAppData); 822 // and remove from list 823 brc = lstRemoveItem(&pXIni->llApps, pAppData); 824 pXIni->cApps--; 825 // rewrite profile on close 826 pXIni->fDirty = TRUE; 1085 // app exists: 1086 FreeKeyIfExists(pXIni, 1087 pAppData, 1088 pcszKey); 827 1089 } 828 else 829 // application doesn't exist: 830 brc = TRUE; 1090 // else app doesn't even exist: 1091 // nothing to do, return NO_ERROR 831 1092 } 832 1093 else 833 1094 { 834 // caller has specified key: 835 // does caller want a key to be deleted? 836 if (!ulDataLen) 1095 // key and data specified: let's add something... 1096 1097 if (!pAppData) 1098 // app doesn't exist yet: 1099 // create 1100 arc = CreateApp(pXIni, 1101 pcszApp, 1102 &pAppData); 1103 1104 if (!arc) 837 1105 { 838 // yes: delete key: 839 if (pAppData) 840 { 841 // app exists: 842 // find key 843 PXINIKEYDATA pKeyData = FindKey(pAppData, 844 pcszKey); 845 if (pKeyData) 846 { 847 // key exists: kill that 848 FreeKey(pKeyData); 849 // and remove from app's keys list 850 brc = lstRemoveItem(&pAppData->llKeys, pKeyData); 851 pAppData->cKeys--; 852 // rewrite profile on close 853 pXIni->fDirty = TRUE; 854 } 855 else 856 // key doesn't even exist: 857 brc = TRUE; 858 } 859 else 860 // app doesn't even exist: 861 brc = TRUE; 862 } 863 else 864 { 865 // key and data specified: let's add something... 866 867 if (!pAppData) 868 // app doesn't exist yet: 869 // create 870 pAppData = CreateApp(pXIni, 871 pcszApp); 872 873 if (pAppData) 874 { 875 // found or created app: 876 // check if key exists 877 PXINIKEYDATA pKeyData = FindKey(pAppData, 878 pcszKey); 879 if (!pKeyData) 880 // doesn't exist yet: 881 // create 882 pKeyData = CreateKey(pAppData, 883 pcszKey, 884 (PBYTE)pData, 885 ulDataLen); 886 887 if (pKeyData) 888 { 889 // mark as dirty 890 pXIni->fDirty = TRUE; 891 brc = TRUE; 892 } 893 } 1106 // found or created app: 1107 1108 // delete existing key if it exists 1109 PXINIKEYDATA pKeyData; 1110 1111 FreeKeyIfExists(pXIni, 1112 pAppData, 1113 pcszKey); 1114 1115 // now create new key 1116 if (!(arc = CreateKey(pAppData, 1117 pcszKey, 1118 (PBYTE)pData, 1119 ulDataLen, 1120 &pKeyData))) 1121 // mark as dirty 1122 pXIni->fDirty = TRUE; 894 1123 } 895 1124 } … … 897 1126 } 898 1127 899 return brc;1128 return arc; 900 1129 } 901 1130 … … 909 1138 * You cannot specify HINI_SYSTEM or HINI_USER for 910 1139 * hINi. 911 */ 912 913 BOOL xprfCloseProfile(PXINI hIni) // in: profile opened with xprfOpenProfile 914 { 915 BOOL brc = FALSE; 916 917 if (hIni) 918 { 919 PXINI pXIni = (PXINI)hIni; 920 if (memcmp(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES)) 921 == 0) 922 { 923 brc = TRUE; 924 925 if (pXIni->fDirty) 926 brc = WriteINI(pXIni); 927 928 if (brc) 1140 * 1141 * Returns: 1142 * 1143 * -- NO_ERROR 1144 */ 1145 1146 APIRET xprfCloseProfile(PXINI pXIni) // in: profile opened with xprfOpenProfile 1147 { 1148 APIRET arc = NO_ERROR; 1149 1150 if ( (!pXIni) 1151 || (memcmp(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES))) 1152 ) 1153 arc = ERROR_INVALID_PARAMETER; 1154 else 1155 { 1156 if (pXIni->fDirty) 1157 arc = WriteINI(pXIni); 1158 1159 if (!arc) 1160 { 1161 if (!(arc = DosClose(pXIni->hFile))) 929 1162 { 930 APIRET arc = DosProtectClose(pXIni->hFile, 931 pXIni->hLock); 932 if (arc == NO_ERROR) 933 { 934 pXIni->hFile = 0; 935 pXIni->hLock = 0; 936 937 FreeINI(pXIni); 938 } 939 else 940 brc = FALSE; 1163 pXIni->hFile = 0; 1164 1165 FreeINI(pXIni); 941 1166 } 942 1167 } 943 1168 } 944 1169 945 return brc; 946 } 947 948 1170 return arc; 1171 } 1172 1173 /* 1174 *@@ xprfQueryKeysForApp: 1175 * the equivalent of prfhQueryKeysForApp for 1176 * XINI files. 1177 * 1178 *@@added V1.0.0 (2002-09-17) [umoeller] 1179 */ 1180 1181 APIRET xprfQueryKeysForApp(PXINI hIni, // in: INI handle 1182 PCSZ pcszApp, // in: application to query list for (or NULL for applications list) 1183 PSZ *ppszKeys) // out: keys list (newly allocated) 1184 { 1185 APIRET arc = NO_ERROR; 1186 PSZ pKeys = NULL; 1187 ULONG ulSizeOfKeysList = 0; 1188 1189 // get size of keys list for pszApp 1190 if (!xprfQueryProfileSize(hIni, pcszApp, NULL, &ulSizeOfKeysList)) 1191 arc = PRFERR_KEYSLIST; 1192 else 1193 { 1194 if (ulSizeOfKeysList == 0) 1195 ulSizeOfKeysList = 1; // V0.9.19 (2002-04-11) [pr] 1196 1197 if (!(pKeys = (PSZ)malloc(ulSizeOfKeysList))) 1198 arc = ERROR_NOT_ENOUGH_MEMORY; 1199 else 1200 { 1201 *pKeys = 0; 1202 if (!xprfQueryProfileData(hIni, pcszApp, NULL, pKeys, &ulSizeOfKeysList)) 1203 arc = PRFERR_KEYSLIST; 1204 } 1205 } 1206 1207 if (!arc) // V0.9.12 (2001-05-12) [umoeller] 1208 *ppszKeys = pKeys; 1209 else 1210 if (pKeys) 1211 free(pKeys); 1212 1213 return arc; 1214 } 1215 -
trunk/src/helpers/xprf2.c
r167 r229 77 77 78 78 APIRET xprfCopyKey(HINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM) 79 P SZ pszSourceApp,// in: source application80 P SZ pszKey,// in: source/target key79 PCSZ pszSourceApp, // in: source application 80 PCSZ pszKey, // in: source/target key 81 81 PXINI hiniTarget, // in: target profile opened with xprfOpenProfile 82 P SZ pszTargetApp)// in: target app82 PCSZ pszTargetApp) // in: target app 83 83 { 84 84 ULONG ulSizeOfData = 0; 85 85 APIRET arc = NO_ERROR; 86 86 87 if (PrfQueryProfileSize(hiniSource, pszSourceApp, pszKey, &ulSizeOfData)) 87 if (PrfQueryProfileSize(hiniSource, 88 (PSZ)pszSourceApp, 89 (PSZ)pszKey, 90 &ulSizeOfData)) 88 91 { 89 92 PSZ pData = 0; … … 107 110 fflush(stdout); 108 111 if (PrfQueryProfileData(hiniSource, 109 pszSourceApp,110 pszKey,112 (PSZ)pszSourceApp, 113 (PSZ)pszKey, 111 114 pData, 112 115 &ulSizeOfData)) 113 116 { 114 if (!xprfWriteProfileData(hiniTarget, 115 pszTargetApp, 116 pszKey, 117 pData, 118 ulSizeOfData)) 117 arc = xprfWriteProfileData(hiniTarget, 118 pszTargetApp, 119 pszKey, 120 pData, 121 ulSizeOfData); 122 } 123 else 124 arc = PRFERR_READ; 125 126 free(pData); 127 } 128 else 129 arc = ERROR_NOT_ENOUGH_MEMORY; 130 } 131 else 132 arc = PRFERR_DATASIZE; 133 134 return arc; 135 } 136 137 /* 138 *@@ xprfCopyKey2: 139 * copies a single key from an xprf* PXINI to a Prf* HINI. 140 * hiniSource must therefore have been opened using 141 * xprfOpenProfile. 142 * 143 * This returns 0 (NO_ERROR) if copying succeeded. Otherwise either 144 * an OS/2 error code (ERROR_*) or one of the profile error 145 * codes defined in prfh.h is returned. 146 * 147 *@@added V1.0.0 (2002-09-17) [umoeller] 148 */ 149 150 APIRET xprfCopyKey2(PXINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM) 151 PCSZ pszSourceApp, // in: source application 152 PCSZ pszKey, // in: source/target key 153 HINI hiniTarget, // in: target profile opened with xprfOpenProfile 154 PCSZ pszTargetApp) // in: target app 155 { 156 ULONG ulSizeOfData = 0; 157 APIRET arc = NO_ERROR; 158 159 if (xprfQueryProfileSize(hiniSource, pszSourceApp, pszKey, &ulSizeOfData)) 160 { 161 PSZ pData = 0; 162 163 // copy data 164 if (ulSizeOfData == 0) 165 { 166 // data size == 0: this shouldn't really happen, 167 // but if it does, we'll just create a NULL string. 168 // Users have reported that some INI files seem to 169 // contain those "empty" keys. I don't see how these 170 // can exist, but they seem to... 171 pData = (PSZ)malloc(1); 172 *pData = 0; 173 } 174 else 175 pData = (PSZ)malloc(ulSizeOfData); 176 177 if (pData) 178 { 179 fflush(stdout); 180 if (xprfQueryProfileData(hiniSource, 181 pszSourceApp, 182 pszKey, 183 pData, 184 &ulSizeOfData)) 185 { 186 if (!PrfWriteProfileData(hiniTarget, 187 (PSZ)pszTargetApp, 188 (PSZ)pszKey, 189 pData, 190 ulSizeOfData)) 119 191 arc = PRFERR_WRITE; 120 192 } … … 135 207 /* 136 208 *@@ xprfCopyApp: 137 * copies a single application from a nPrf* HINI to an xprf* PXINI.209 * copies a single application from a Prf* HINI to an xprf* PXINI. 138 210 * hiniTarget must therefore have been opened using 139 211 * xprfOpenProfile. … … 146 218 */ 147 219 148 APIRET xprfCopyApp(HINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM)149 P SZ pszSourceApp,// in: source application150 PXINI hiniTarget, // in: target profile opened with xprfOpenProfile151 P SZ pszTargetApp,// in: name of pszSourceApp in hiniTarget152 PSZ pszErrorKey) // out: failing key in case of error; ptr can be NULL220 APIRET xprfCopyApp(HINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM) 221 PCSZ pszSourceApp, // in: source application 222 PXINI hiniTarget, // in: target profile opened with xprfOpenProfile 223 PCSZ pszTargetApp, // in: name of pszSourceApp in hiniTarget 224 PSZ pszErrorKey) // out: failing key in case of error; ptr can be NULL 153 225 { 154 226 APIRET arc = NO_ERROR; … … 167 239 { 168 240 // copy this key 169 arc = xprfCopyKey(hiniSource, 170 pszSourceApp, 171 pKey2, 172 hiniTarget, 173 pszTargetApp); 174 if (arc) 241 if (arc = xprfCopyKey(hiniSource, 242 pszSourceApp, 243 pKey2, 244 hiniTarget, 245 pszTargetApp)) 175 246 { 176 247 // error: copy failing key to buffer … … 179 250 break; 180 251 } 252 253 pKey2 += strlen(pKey2)+1; 254 } // end while (*pKey2 != 0) 255 256 free (pszKeysList); 257 } 258 else 259 arc = PRFERR_KEYSLIST; 260 261 return arc; 262 } 263 264 /* 265 *@@ xprfCopyApp2: 266 * copies a single application from an xprf* PXINI to a Prf* HINI. 267 * hiniTarget must therefore have been opened using 268 * xprfOpenProfile. 269 * 270 * This calls xprfCopyKey2 for each key in the application. 271 * 272 * This returns 0 (NO_ERROR) if copying succeeded. Otherwise either 273 * an OS/2 error code (ERROR_*) or one of the profile error 274 * codes defined in prfh.h is returned. 275 * 276 *@@added V1.0.0 (2002-09-17) [umoeller] 277 */ 278 279 APIRET xprfCopyApp2(PXINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM) 280 PCSZ pszSourceApp, // in: source application 281 HINI hiniTarget, // in: target profile opened with xprfOpenProfile 282 PCSZ pszTargetApp, // in: name of pszSourceApp in hiniTarget 283 PSZ pszErrorKey) // out: failing key in case of error; ptr can be NULL 284 { 285 APIRET arc = NO_ERROR; 286 PSZ pszKeysList = NULL; 287 288 if (pszErrorKey) 289 *pszErrorKey = 0; 290 291 if (!(arc = xprfQueryKeysForApp(hiniSource, 292 pszSourceApp, 293 &pszKeysList))) 294 { 295 PSZ pKey2 = pszKeysList; 296 297 while (*pKey2 != 0) 298 { 299 // copy this key 300 if (arc = xprfCopyKey2(hiniSource, 301 pszSourceApp, 302 pKey2, 303 hiniTarget, 304 pszTargetApp)) 305 { 306 // error: copy failing key to buffer 307 if (pszErrorKey) 308 strcpy(pszErrorKey, pKey2); 309 break; 310 } 311 181 312 pKey2 += strlen(pKey2)+1; 182 313 } // end while (*pKey2 != 0) … … 208 339 209 340 APIRET xprfCopyProfile(HINI hOld, // in: source profile (can be HINI_USER or HINI_SYSTEM) 210 P SZ pszNew,// in: new filename (can be fully qualified)341 PCSZ pszNew, // in: new filename (can be fully qualified) 211 342 PFN_PRF_PROGRESS pfnProgressCallback, 212 343 ULONG ulUser, // in: passed to pfnProgressCallback 213 344 ULONG ulCount, // in: index of INI being copied (0 <= ulCount <= ulMax) 214 ULONG ulMax) // in: maximum index (for progress); 0 means 1 INI, 1 means 2 INIs, ... 345 ULONG ulMax, // in: maximum index (for progress); 0 means 1 INI, 1 means 2 INIs, ... 346 PSZ pszFailingApp) // out: failing app on error 215 347 { 216 348 APIRET arc = NO_ERROR; … … 218 350 ULONG ulSizeOfAppsList; 219 351 352 if (pszFailingApp) 353 *pszFailingApp = 0; 354 220 355 if (!pszNew) 221 356 arc = ERROR_INVALID_PARAMETER; 222 357 else 223 358 { 224 DosDelete( pszNew);359 DosDelete((PSZ)pszNew); 225 360 226 361 // open new profile 227 arc = xprfOpenProfile(pszNew, 228 &pxiniNew); 229 230 // get size of applications list 231 if (arc == NO_ERROR) 232 { 362 if (!(arc = xprfOpenProfile(pszNew, 363 &pxiniNew))) 364 { 365 // get size of applications list 233 366 if (!PrfQueryProfileSize(hOld, NULL, NULL, &ulSizeOfAppsList)) 234 367 arc = PRFERR_APPSLIST; … … 256 389 { 257 390 CHAR szErrorKey[1000]; 391 258 392 // copy application (this will call prfhCopyKey in turn) 259 arc = xprfCopyApp(hOld, 260 pApp2, 261 pxiniNew, 262 pApp2, 263 szErrorKey); 264 265 if (pfnProgressCallback) 393 if (arc = xprfCopyApp(hOld, 394 pApp2, 395 pxiniNew, 396 pApp2, 397 szErrorKey)) 398 { 399 if (pszFailingApp) 400 strhncpy0(pszFailingApp, pApp2, CCHMAXPATH); 401 } 402 else if (pfnProgressCallback) 266 403 { 267 404 ULONG ulNow2, ulMax2; … … 325 462 APIRET xprfSaveINIs(HAB hab, // in: anchor block 326 463 PFN_PRF_PROGRESS pfnProgressCallback, 327 ULONG ulUser) 464 ULONG ulUser, 465 PSZ pszFailingINI, 466 PSZ pszFailingApp, 467 PSZ pszFailingKey) 328 468 { 329 469 PRFPROFILE Profiles; … … 400 540 401 541 if (arc == NO_ERROR) 542 { 543 if (pszFailingINI) 544 strcpy(pszFailingINI, 545 szSysNew); 546 402 547 arc = xprfCopyProfile(HINI_SYSTEM, 403 548 szSysNew, // new filename 404 549 pfnProgressCallback, 405 ulUser, 0, 1); 550 ulUser, 551 0, 552 1, 553 pszFailingApp); 554 } 555 406 556 /* 407 557 * create OS2SYS.XFL: … … 410 560 411 561 if (arc == NO_ERROR) 562 { 563 if (pszFailingINI) 564 strcpy(pszFailingINI, 565 szUserNew); 566 412 567 arc = xprfCopyProfile(HINI_USER, 413 568 szUserNew, // new filename 414 569 pfnProgressCallback, 415 ulUser, 1, 1); 570 ulUser, 571 1, 572 1, 573 pszFailingApp); 574 } 416 575 } 417 576 … … 453 612 { 454 613 // finally, replace system profiles 455 arc = DosMove(szSysNew, Profiles.pszSysName); 456 if (arc == NO_ERROR) 457 arc = DosMove(szUserNew, Profiles.pszUserName); 614 if (!(arc = DosMove(szSysNew, Profiles.pszSysName))) 615 { 616 if (arc = DosMove(szUserNew, Profiles.pszUserName)) 617 { 618 if (pszFailingINI) 619 strcpy(pszFailingINI, 620 szUserNew); 621 } 622 } 623 else 624 { 625 if (pszFailingINI) 626 strcpy(pszFailingINI, 627 szSysNew); 628 } 458 629 } 459 630 … … 468 639 // testing 469 640 470 /* BOOL _Optlink fnCallback(ULONG ulUser, ULONG ulNow, ULONG ulMax) 641 #ifdef __BUILD_XPRF2_MAIN__ 642 643 BOOL _Optlink fnCallback(ULONG ulUser, ULONG ulNow, ULONG ulMax) 471 644 { 472 645 printf("\r done %03d%%", ulNow * 100 / ulMax); … … 476 649 int main(int argc, char* argv[]) 477 650 { 478 if (argc != 3)479 printf("Syntax: xprf2 <source.ini> <target.ini>\n"); 480 else481 { 482 HAB hab = WinInitialize(0);483 484 // HINI hiniSource = PrfOpenProfile(hab, argv[1]);485 // if (hiniSource) 486 {487 APIRET arc = xprfCopyProfile(hiniSource,488 argv[2],489 fnCallback,490 0, 0, 0);491 xprfSaveProfiles(hab, NULL, 0);492 // if (arc) 493 494 495 // printf("xprfCopyProfile returned %d.\n", arc);496 }497 // else498 // printf("Cannot open %s\n", argv[1]); 499 500 WinTerminate(hab); 501 }502 503 return (0); 504 } */ 505 651 APIRET arc = 2; 652 653 HAB hab = WinInitialize(0); 654 655 CHAR szFailingINI[CCHMAXPATH] = "", 656 szFailingApp[CCHMAXPATH] = "", 657 szFailingKey[CCHMAXPATH] = ""; 658 659 arc = xprfSaveINIs(hab, 660 NULL, 661 0, 662 szFailingINI, 663 szFailingApp, 664 szFailingKey); 665 666 printf("xprfCopyProfile returned %d ('%s', '%s', '%s'.\n", 667 arc, 668 szFailingINI, 669 szFailingApp, 670 szFailingKey); 671 672 WinTerminate(hab); 673 674 return arc; 675 } 676 677 #endif 678
Note:
See TracChangeset
for help on using the changeset viewer.