- Timestamp:
- Dec 9, 2000, 8:19:42 PM (25 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 1 added
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/animate.c
r8 r14 22 22 /* 23 23 * Copyright (C) 1997-2000 Ulrich Mller. 24 * This file is part of the XWorkplacesource package.25 * XWorkplaceis free software; you can redistribute it and/or modify24 * This file is part of the "XWorkplace helpers" source package. 25 * This is free software; you can redistribute it and/or modify 26 26 * it under the terms of the GNU General Public License as published 27 27 * by the Free Software Foundation, in version 2 as it comes in the … … 38 38 // as unsigned char 39 39 40 #define INCL_DOS 41 #define INCL_DOSERRORS 40 #define INCL_DOSPROCESS 42 41 #define INCL_DOSDEVICES 43 42 #define INCL_DOSDEVIOCTL 44 45 #define INCL_WIN 43 #define INCL_DOSERRORS 44 45 #define INCL_WINPOINTERS 46 46 #define INCL_WINSYS 47 47 … … 164 164 165 165 /* ****************************************************************** 166 * *167 * Other animations *168 * *166 * 167 * Other animations 168 * 169 169 ********************************************************************/ 170 170 -
trunk/src/helpers/cctl_chart.c
r8 r14 16 16 /* 17 17 * Copyright (C) 1997-2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 84 84 85 85 /* ****************************************************************** 86 * *87 * Chart Control *88 * *86 * 87 * Chart Control 88 * 89 89 ********************************************************************/ 90 90 -
trunk/src/helpers/cctl_checkcnr.c
r8 r14 16 16 /* 17 17 * Copyright (C) 1997-2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 84 84 85 85 /* ****************************************************************** 86 * *87 * Global variables *88 * *86 * 87 * Global variables 88 * 89 89 ********************************************************************/ 90 90 … … 94 94 95 95 /* ****************************************************************** 96 * *97 * Checkbox container record cores *98 * *96 * 97 * Checkbox container record cores 98 * 99 99 ********************************************************************/ 100 100 -
trunk/src/helpers/cctl_progbar.c
r13 r14 16 16 /* 17 17 * Copyright (C) 1997-2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 84 84 85 85 /* ****************************************************************** 86 * *87 * Progress bars *88 * *86 * 87 * Progress bars 88 * 89 89 ********************************************************************/ 90 90 -
trunk/src/helpers/cctl_splitwin.c
r8 r14 16 16 /* 17 17 * Copyright (C) 1997-2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 84 84 85 85 /* ****************************************************************** 86 * *87 * Split windows *88 * *86 * 87 * Split windows 88 * 89 89 ********************************************************************/ 90 90 -
trunk/src/helpers/cctl_tooltip.c
r8 r14 16 16 /* 17 17 * Copyright (C) 1997-2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 84 84 85 85 /* ****************************************************************** 86 * *87 * Global variables *88 * *86 * 87 * Global variables 88 * 89 89 ********************************************************************/ 90 90 … … 98 98 99 99 /* ****************************************************************** 100 * *101 * "Tooltip" control *102 * *100 * 101 * "Tooltip" control 102 * 103 103 ********************************************************************/ 104 104 … … 724 724 PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1); 725 725 726 TRY_LOUD(excpt1 , NULL)726 TRY_LOUD(excpt1) 727 727 { 728 728 switch (msg) -
trunk/src/helpers/cnrh.c
r8 r14 22 22 /* 23 23 * Copyright (C) 1997-2000 Ulrich Mller. 24 * This file is part of the XWorkplacesource package.25 * XWorkplaceis free software; you can redistribute it and/or modify24 * This file is part of the "XWorkplace helpers" source package. 25 * This is free software; you can redistribute it and/or modify 26 26 * it under the terms of the GNU General Public License as published 27 27 * by the Free Software Foundation, in version 2 as it comes in the … … 38 38 // as unsigned char 39 39 40 #define INCL_WIN 40 #define INCL_WINWINDOWMGR 41 #define INCL_WINRECTANGLES 42 #define INCL_WININPUT 43 #define INCL_WINPOINTERS 44 #define INCL_WINMENUS 45 #define INCL_WINSYS 46 #define INCL_WINSTDDRAG 47 #define INCL_WINSTDCNR 48 41 49 #define INCL_GPILOGCOLORTABLE 42 50 #define INCL_GPIPRIMITIVES … … 59 67 60 68 /* ****************************************************************** 61 * *62 * Details view field infos *63 * *69 * 70 * Details view field infos 71 * 64 72 ********************************************************************/ 65 73 … … 338 346 339 347 /* ****************************************************************** 340 * *341 * Record core management *342 * *348 * 349 * Record core management 350 * 343 351 ********************************************************************/ 344 352 … … 353 361 * by following the RECORDCORE.preccNextRecord pointers 354 362 * (i.e. we have a linked list here). 363 * 364 * Returns NULL on errors (what CM_ALLOCRECORD returns). 355 365 * 356 366 * The record cores returned by the container are … … 735 745 736 746 /* ****************************************************************** 737 * *738 * View management *739 * *747 * 748 * View management 749 * 740 750 ********************************************************************/ 741 751 … … 1119 1129 // convert this to screen coordinates 1120 1130 WinMapWindowPoints(hwndCnr, 1121 HWND_DESKTOP,1122 &ptl,1123 1);1131 HWND_DESKTOP, 1132 &ptl, 1133 1); 1124 1134 fQueried = TRUE; 1125 1135 } … … 1303 1313 1304 1314 /* ****************************************************************** 1305 * *1306 * Record relations/iteration *1307 * *1315 * 1316 * Record relations/iteration 1317 * 1308 1318 ********************************************************************/ 1309 1319 … … 1580 1590 1581 1591 /* ****************************************************************** 1582 * *1583 * Miscellaneous *1584 * *1592 * 1593 * Miscellaneous 1594 * 1585 1595 ********************************************************************/ 1586 1596 -
trunk/src/helpers/comctl.c
r8 r14 53 53 /* 54 54 * Copyright (C) 1997-2000 Ulrich Mller. 55 * This file is part of the XWorkplacesource package.56 * XWorkplaceis free software; you can redistribute it and/or modify55 * This file is part of the "XWorkplace helpers" source package. 56 * This is free software; you can redistribute it and/or modify 57 57 * it under the terms of the GNU General Public License as published 58 58 * by the Free Software Foundation, in version 2 as it comes in the … … 117 117 118 118 /* ****************************************************************** 119 * *120 * Global variables *121 * *119 * 120 * Global variables 121 * 122 122 ********************************************************************/ 123 123 … … 127 127 128 128 /* ****************************************************************** 129 * *130 * "Menu button" control *131 * *129 * 130 * "Menu button" control 131 * 132 132 ********************************************************************/ 133 133 … … 149 149 HWND hwndMenu; 150 150 } MENUBUTTONDATA, *PMENUBUTTONDATA; 151 152 /* 153 *@@ ctlDisplayButtonMenu: 154 * displays the specified menu above the button. 155 * 156 *@@added V0.9.7 (2000-11-29) [umoeller] 157 */ 158 159 VOID ctlDisplayButtonMenu(HWND hwndButton, 160 HWND hwndMenu) 161 { 162 SWP swpButton; 163 POINTL ptlMenu; 164 WinQueryWindowPos(hwndButton, &swpButton); 165 ptlMenu.x = swpButton.x; 166 ptlMenu.y = swpButton.y; 167 168 // ptlMenu now has button coordinates 169 // relative to the button's parent; 170 // convert this to screen coordinates: 171 WinMapWindowPoints(WinQueryWindow(hwndButton, QW_PARENT), 172 HWND_DESKTOP, 173 &ptlMenu, 174 1); 175 176 // now show the menu on top of the button 177 WinPopupMenu(HWND_DESKTOP, // menu parent 178 hwndButton, // owner 179 hwndMenu, 180 (SHORT)(ptlMenu.x), 181 (SHORT)(ptlMenu.y + swpButton.cy - 1), 182 0, // ID 183 PU_NONE 184 | PU_MOUSEBUTTON1 185 | PU_KEYBOARD 186 | PU_HCONSTRAIN 187 | PU_VCONSTRAIN); 188 } 151 189 152 190 /* … … 288 326 // menu successfully loaded: 289 327 // find out where to put it 290 SWP swpButton; 291 POINTL ptlMenu; 292 WinQueryWindowPos(hwndButton, &swpButton); 293 ptlMenu.x = swpButton.x; 294 ptlMenu.y = swpButton.y; 295 296 // ptlMenu now has button coordinates 297 // relative to the button's parent; 298 // convert this to screen coordinates: 299 WinMapWindowPoints(WinQueryWindow(hwndButton, QW_PARENT), 300 HWND_DESKTOP, 301 &ptlMenu, 302 1); 303 304 // now show the menu on top of the button 305 WinPopupMenu(HWND_DESKTOP, // menu parent 306 hwndButton, // owner 307 pmbd->hwndMenu, 308 (SHORT)(ptlMenu.x), 309 (SHORT)(ptlMenu.y + swpButton.cy - 1), 310 0, // ID 311 PU_NONE 312 | PU_MOUSEBUTTON1 313 | PU_KEYBOARD 314 | PU_HCONSTRAIN 315 | PU_VCONSTRAIN); 328 ctlDisplayButtonMenu(hwndButton, 329 pmbd->hwndMenu); 316 330 } // end if (pmbd->hwndMenu) 317 331 else … … 484 498 485 499 /* ****************************************************************** 486 * *487 * Subclassed Static Bitmap Control *488 * *500 * 501 * Subclassed Static Bitmap Control 502 * 489 503 ********************************************************************/ 490 504 … … 788 802 789 803 /* ****************************************************************** 790 * *791 * Icon animation *792 * *804 * 805 * Icon animation 806 * 793 807 ********************************************************************/ 794 808 … … 967 981 968 982 /* ****************************************************************** 969 * *970 * Bitmap functions *971 * *983 * 984 * Bitmap functions 985 * 972 986 ********************************************************************/ 973 987 … … 1050 1064 1051 1065 /* ****************************************************************** 1052 * *1053 * Hotkey entry field *1054 * *1066 * 1067 * Hotkey entry field 1068 * 1055 1069 ********************************************************************/ 1056 1070 -
trunk/src/helpers/datetime.c
r8 r14 25 25 /* 26 26 * This file Copyright (C) 1997-2000 Ulrich Mller. 27 * This file is part of the XWorkplacesource package.28 * XWorkplaceis free software; you can redistribute it and/or modify27 * This file is part of the "XWorkplace helpers" source package. 28 * This is free software; you can redistribute it and/or modify 29 29 * it under the terms of the GNU General Public License as published 30 30 * by the Free Software Foundation, in version 2 as it comes in the … … 63 63 const char *pcszFormatTimestamp = "%4u%02u%02u%02u%02u%02u%"; 64 64 65 ULONG G_ulDateScalarFirstCalled = 0; 66 65 67 /* 66 68 *@@ dtGetULongTime: … … 71 73 * time in milliseconds. 72 74 * 73 * Warning: this does not handle day information. When called twice 74 * in between day changes, this returns incorrect information. 75 * Even though this does handle date information (i.e. 76 * will still return an increasing number when the 77 * clock switches from 23:59:59:9999 to 0:00:00:0000), 78 * this will not work forver after the first call. 79 * Here's the calculation: 80 * 81 + 1000 ms per second 82 + * 60 secs per minute 83 + * 60 minutes per hour 84 + * 24 hours per day 85 + = 86'400'000 after 23:59:59:9999 86 * 87 * A ULONG can hold a max value of 4'294'967'295. 88 * So this overflows after 49.71... days. 89 * 90 *@@changed V0.9.7 (2000-12-05) [umoeller]: now handling date also 75 91 */ 76 92 … … 78 94 { 79 95 DATETIME dt; 96 ULONG ulTime, 97 ulDateScalarPassed = 1; 80 98 DosGetDateTime(&dt); 81 return (10*(dt.hundredths + 100*(dt.seconds + 60*(dt.minutes + 60*(dt.hours))))); 99 ulTime = (10*(dt.hundredths + 100*(dt.seconds + 60*(dt.minutes + 60*(dt.hours))))); 100 101 if (G_ulDateScalarFirstCalled == 0) 102 { 103 // first call: 104 G_ulDateScalarFirstCalled = dtDate2Scalar(dt.year, 105 dt.month, 106 dt.day); 107 } 108 else 109 { 110 // not first call: 111 ULONG ulDateScalarNow = dtDate2Scalar(dt.year, 112 dt.month, 113 dt.day); 114 // calculate days passed since first call; 115 // this should be 1 if the date hasn't changed 116 ulDateScalarPassed = (G_ulDateScalarFirstCalled - ulDateScalarNow) + 1; 117 } 118 119 return (ulTime * ulDateScalarPassed); 82 120 } 83 121 … … 147 185 148 186 /* 187 ** 188 ** 189 ** day: day of month 190 ** mon: month (1-12) 191 ** yr: year 192 ** 193 ** 194 */ 195 196 /* 197 *@@ dtDayOfWeek: 198 * returns an integer that represents the day of 199 * the week for the date passed as parameters. 200 * 201 * Returns 0-6 where 0 is sunday. 202 * 203 *@@added V0.9.7 (2000-12-05) [umoeller] 204 */ 205 206 ULONG dtDayOfWeek(ULONG day, 207 ULONG mon, // 1-12 208 ULONG yr) 209 { 210 int dow; 211 212 if (mon <= 2) 213 { 214 mon += 12; 215 yr -= 1; 216 } 217 dow = ( day 218 + mon * 2 219 + ((mon + 1) * 6) / 10 220 + yr 221 + yr / 4 222 - yr / 100 223 + yr / 400 224 + 2); 225 dow = dow % 7; 226 return ((dow ? dow : 7) - 1); 227 } 228 229 /* 149 230 *@@ dtIsLeapYear: 150 231 * returns TRUE if yr is a leap year. … … 164 245 /* 165 246 *@@ dtMonths2Days: 166 * returns the no. of days for month. 247 * returns the no. of days for the beginning 248 * of "month" (starting from 1). 249 * 250 * For example, if you pass 1 (for january), 251 * you get 0 because there's no days at jan 1st 252 * yet. 253 * 254 * If you pass 2 (for february), you get 31. 255 * 256 * If you pass 3 (for march), you get 61. 257 * 258 * This is useful for computing a day index 259 * for a given month/day pair. Pass the month 260 * in here and add (day-1); for march 3rd, 261 * you then get 63. 167 262 * 168 263 * (c) Ray Gardner. … … 171 266 unsigned dtMonths2Days(unsigned month) 172 267 { 173 return (month * 3057 - 3007) / 100;268 return (month * 3057 - 3007) / 100; 174 269 } 175 270 … … 228 323 *pyr = n; 229 324 n = (unsigned)(scalar - dtYears2Days(n-1)); 230 if ( n > 59 ) { /* adjust if past February */ 325 if ( n > 59 ) /* adjust if past February */ 326 { 231 327 n += 2; 232 328 if ( dtIsLeapYear(*pyr) ) … … 237 333 } 238 334 239 335 /* 336 *@@ dtIsValidDate: 337 * returns TRUE if the given date is valid. 338 * 339 *@@added V0.9.7 (2000-12-05) [umoeller] 340 */ 341 342 BOOL dtIsValidDate(LONG day, // in: day (1-31) 343 LONG month, // in: month (1-12) 344 ULONG year) // in: year (e.g. 1999) 345 { 346 BOOL brc = FALSE; 347 if (day > 0) 348 { 349 switch( month ) 350 { 351 case 1 : 352 case 3 : 353 case 5 : 354 case 7 : 355 case 8 : 356 case 10 : 357 case 12 : 358 if (day <= 31) 359 brc = TRUE; 360 break; 361 362 case 4 : 363 case 6 : 364 case 9 : 365 case 11 : 366 if (day <= 30) 367 brc = TRUE; 368 break; 369 370 case 2 : 371 if (day < 29) 372 brc = TRUE; 373 else 374 if (day == 29) 375 if (dtIsLeapYear(year)) 376 return 1 ; 377 } 378 } 379 return (brc); 380 } 381 -
trunk/src/helpers/debug.c
r13 r14 34 34 * John Currier, 35 35 * Anthony Cruise. 36 * This file is part of the XWorkplacesource package.37 * XWorkplaceis free software; you can redistribute it and/or modify36 * This file is part of the "XWorkplace helpers" source package. 37 * This is free software; you can redistribute it and/or modify 38 38 * it under the terms of the GNU General Public License as published 39 39 * by the Free Software Foundation, in version 2 as it comes in the … … 50 50 // as unsigned char 51 51 52 #define INCL_BASE 52 #define INCL_DOSPROCESS 53 #define INCL_DOSMODULEMGR 54 #define INCL_DOSMISC 55 #define INCL_DOSERRORS 53 56 #include <os2.h> 54 57 … … 88 91 89 92 /* ****************************************************************** 90 * *91 * Global variables *92 * *93 * 94 * Global variables 95 * 93 96 ********************************************************************/ 94 97 … … 353 356 354 357 /* ****************************************************************** 355 * *356 * PART 1: ANALYZE DEBUG CODE *357 * *358 * 359 * PART 1: ANALYZE DEBUG CODE 360 * 358 361 ********************************************************************/ 359 362 … … 1129 1132 1130 1133 /* ****************************************************************** 1131 * *1132 * PART 2: ANALYZE VARIABLES *1133 * *1134 * 1135 * PART 2: ANALYZE VARIABLES 1136 * 1134 1137 ********************************************************************/ 1135 1138 … … 1421 1424 1422 1425 /* ****************************************************************** 1423 * *1424 * PART 3: ANALYZE SYMBOL (.SYM) FILE *1425 * *1426 * 1427 * PART 3: ANALYZE SYMBOL (.SYM) FILE 1428 * 1426 1429 ********************************************************************/ 1427 1430 … … 1566 1569 1567 1570 /* ****************************************************************** 1568 * *1569 * PART 4: dbgPrintStack *1570 * *1571 * 1572 * PART 4: dbgPrintStack 1573 * 1571 1574 ********************************************************************/ 1572 1575 -
trunk/src/helpers/dosh.c
r13 r14 31 31 /* 32 32 * This file Copyright (C) 1997-2000 Ulrich Mller. 33 * This file is part of the XWorkplacesource package.34 * XWorkplaceis free software; you can redistribute it and/or modify33 * This file is part of the "XWorkplace helpers" source package. 34 * This is free software; you can redistribute it and/or modify 35 35 * it under the terms of the GNU General Public License as published 36 36 * by the Free Software Foundation, in version 2 as it comes in the … … 47 47 // as unsigned char 48 48 49 #define INCL_DOS 49 #define INCL_DOSMODULEMGR 50 #define INCL_DOSPROCESS 51 #define INCL_DOSSESMGR 52 #define INCL_DOSQUEUES 53 #define INCL_DOSMISC 54 #define INCL_DOSDEVICES 50 55 #define INCL_DOSDEVIOCTL 51 56 #define INCL_DOSERRORS 57 52 58 #define INCL_KBD 53 59 #include <os2.h> 60 54 61 #include <stdlib.h> 55 62 #include <string.h> 56 63 #include <stdio.h> 57 // #include <ctype.h>58 64 59 65 #include "setup.h" // code generation and debugging options … … 70 76 71 77 /* ****************************************************************** 72 * *73 * Miscellaneous *74 * *78 * 79 * Miscellaneous 80 * 75 81 ********************************************************************/ 76 82 … … 172 178 173 179 return (s_brc); 180 } 181 182 /* 183 *@@ doshQueryAvailPhysMem: 184 * returns the amount of physical memory which 185 * is presently available (before the swapper 186 * would have to be expanded). 187 * 188 * This number is calculated by getting the 189 * total available memory (QSV_TOTRESMEM) 190 * and subtracting the free space on the 191 * drive with the swap file from it. 192 * 193 * As a result, you also need to specify 194 * the logical drive on which the swapper 195 * resides (3 = C, 4 = D, and so on). 196 * 197 *@@added V0.9.7 (2000-12-01) [umoeller] 198 */ 199 200 APIRET doshQueryAvailPhysMem(PULONG pulMem, 201 ULONG ulLogicalSwapDrive) 202 { 203 APIRET arc = DosQuerySysInfo(QSV_TOTAVAILMEM, 204 QSV_TOTAVAILMEM, 205 pulMem, 206 sizeof(*pulMem)); 207 if (arc == NO_ERROR) 208 { 209 double dFree = 0; 210 arc = doshQueryDiskFree(ulLogicalSwapDrive, 211 &dFree); 212 *pulMem -= (ULONG)dFree; 213 } 214 215 return (arc); 174 216 } 175 217 … … 213 255 214 256 /* ****************************************************************** 215 * *216 * Memory helpers *217 * *257 * 258 * Memory helpers 259 * 218 260 ********************************************************************/ 219 261 … … 283 325 284 326 /* ****************************************************************** 285 * *286 * Drive helpers *287 * *327 * 328 * Drive helpers 329 * 288 330 ********************************************************************/ 289 331 … … 417 459 { 418 460 ULONG ulBootDrive; 419 DosQuerySysInfo(5, 5, &ulBootDrive, sizeof(ulBootDrive)); 461 DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, 462 &ulBootDrive, 463 sizeof(ulBootDrive)); 420 464 return (G_acDriveLetters[ulBootDrive]); 421 465 } … … 461 505 OPEN_FLAGS_DASD 462 506 | OPEN_FLAGS_FAIL_ON_ERROR 507 | OPEN_FLAGS_NOINHERIT // V0.9.6 (2000-11-25) [pr] 463 508 | OPEN_ACCESS_READONLY 464 509 | OPEN_SHARE_DENYNONE, … … 523 568 524 569 /* 570 *@@ doshSetLogicalMap: 571 * sets the mapping of logical floppy drives onto a single 572 * physical floppy drive. 573 * This means selecting either drive A: or drive B: to refer 574 * to the physical drive. 575 * 576 *@@added V0.9.6 (2000-11-24) [pr] 577 */ 578 579 APIRET doshSetLogicalMap(ULONG ulLogicalDrive) 580 { 581 CHAR name[3] = "?:"; 582 ULONG fd = 0, 583 action = 0, 584 paramsize = 0, 585 datasize = 0; 586 APIRET rc = NO_ERROR; 587 USHORT data, 588 param; 589 590 name[0] = doshQueryBootDrive(); 591 rc = DosOpen(name, 592 &fd, 593 &action, 594 0, 595 0, 596 OPEN_ACTION_FAIL_IF_NEW 597 | OPEN_ACTION_OPEN_IF_EXISTS, 598 OPEN_FLAGS_DASD 599 | OPEN_FLAGS_FAIL_ON_ERROR 600 | OPEN_FLAGS_NOINHERIT 601 | OPEN_ACCESS_READONLY 602 | OPEN_SHARE_DENYNONE, 603 0); 604 if (rc == NO_ERROR) 605 { 606 param = 0; 607 data = (USHORT)ulLogicalDrive; 608 paramsize = sizeof(param); 609 datasize = sizeof(data); 610 rc = DosDevIOCtl(fd, 611 IOCTL_DISK, DSK_SETLOGICALMAP, 612 ¶m, paramsize, ¶msize, 613 &data, datasize, &datasize); 614 DosClose(fd); 615 } 616 617 return(rc); 618 } 619 620 /* 525 621 *@@ doshQueryDiskFree: 526 622 * returns the number of bytes remaining on the disk 527 * specified by the given logical drive , or -1 upon errors.623 * specified by the given logical drive. 528 624 * 529 625 * Note: This returns a "double" value, because a ULONG … … 532 628 * 533 629 *@@changed V0.9.0 [umoeller]: fixed another > 4 GB bug (thanks to Rdiger Ihle) 534 */ 535 536 double doshQueryDiskFree(ULONG ulLogicalDrive) // in: 1 for A:, 2 for B:, 3 for C:, ... 537 { 630 *@@changed V0.9.7 (2000-12-01) [umoeller]: changed prototype 631 */ 632 633 APIRET doshQueryDiskFree(ULONG ulLogicalDrive, // in: 1 for A:, 2 for B:, 3 for C:, ... 634 double *pdFree) 635 { 636 APIRET arc = NO_ERROR; 538 637 FSALLOCATE fsa; 539 638 double dbl = -1; 540 639 541 if (ulLogicalDrive) 542 if (DosQueryFSInfo(ulLogicalDrive, FSIL_ALLOC, &fsa, sizeof(fsa)) 543 == NO_ERROR) 544 dbl = ((double)fsa.cSectorUnit * fsa.cbSector * fsa.cUnitAvail); 640 arc = DosQueryFSInfo(ulLogicalDrive, FSIL_ALLOC, &fsa, sizeof(fsa)); 641 if (arc == NO_ERROR) 642 *pdFree = ((double)fsa.cSectorUnit * fsa.cbSector * fsa.cUnitAvail); 545 643 // ^ fixed V0.9.0 546 644 547 return ( dbl);645 return (arc); 548 646 } 549 647 … … 779 877 780 878 /* ****************************************************************** 781 * *782 * File helpers *783 * *879 * 880 * File helpers 881 * 784 882 ********************************************************************/ 785 883 … … 1226 1324 1227 1325 /* ****************************************************************** 1228 * *1229 * Directory helpers *1230 * *1326 * 1327 * Directory helpers 1328 * 1231 1329 ********************************************************************/ 1232 1330 … … 1459 1557 1460 1558 /* 1559 *@@category: Helpers\Control program helpers\Performance (CPU load) helpers 1560 */ 1561 1562 /* ****************************************************************** 1563 * 1564 * Performance Counters (CPU Load) 1565 * 1566 ********************************************************************/ 1567 1568 /* 1569 *@@ doshPerfOpen: 1570 * initializes the OS/2 DosPerfSysCall API for 1571 * the calling thread. 1572 * 1573 * Note: This API is not supported on all OS/2 1574 * versions. I believe it came up with some Warp 4 1575 * fixpak. The API is resolved dynamically by 1576 * this function (using DosQueryProcAddr). Only 1577 * if NO_ERROR is returned, you may call doshPerfGet 1578 * afterwards. 1579 * 1580 * This properly initializes the internal counters 1581 * which the OS/2 kernel uses for this API. Apparently, 1582 * with newer kernels (FP13/14), IBM has chosen to no 1583 * longer do this automatically, which is the reason 1584 * why many "pulse" utilities display garbage with these 1585 * fixpaks. 1586 * 1587 * After NO_ERROR is returned, DOSHPERFSYS.cProcessors 1588 * contains the no. of processors found on the system. 1589 * All pointers in DOSHPERFSYS then point to arrays 1590 * which have exactly cProcessors array items. 1591 * 1592 * Call doshPerfClose to clean up resources allocated 1593 * by this function. 1594 * 1595 * Example code: 1596 * 1597 + PDOSHPERFSYS pPerf = NULL; 1598 + APIRET arc = doshPerfOpen(&pPerf); 1599 + if (arc == NO_ERROR) 1600 + { 1601 + // this should really be in a timer 1602 + ULONG ulCPU; 1603 + arc = doshPerfGet(&pPerf); 1604 + // go thru all CPUs 1605 + for (ulCPU = 0; ulCPU < pPerf->cProcessors; ulCPU++) 1606 + { 1607 + LONG lLoadThis = pPerf->palLoads[ulCPU]; 1608 + ... 1609 + } 1610 + 1611 + ... 1612 + 1613 + // clean up 1614 + doshPerfClose(&pPerf); 1615 + } 1616 + 1617 * 1618 *@@added V0.9.7 (2000-12-02) [umoeller] 1619 */ 1620 1621 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys) // out: new DOSHPERFSYS structure 1622 { 1623 APIRET arc = NO_ERROR; 1624 1625 // allocate DOSHPERFSYS structure 1626 *ppPerfSys = (PDOSHPERFSYS)malloc(sizeof(DOSHPERFSYS)); 1627 if (!*ppPerfSys) 1628 arc = ERROR_NOT_ENOUGH_MEMORY; 1629 else 1630 { 1631 // initialize structure 1632 PDOSHPERFSYS pPerfSys = *ppPerfSys; 1633 memset(pPerfSys, 0, sizeof(*pPerfSys)); 1634 1635 // resolve DosPerfSysCall API entry 1636 arc = DosLoadModule(NULL, 0, "DOSCALLS", &pPerfSys->hmod); 1637 if (arc == NO_ERROR) 1638 { 1639 arc = DosQueryProcAddr(pPerfSys->hmod, 1640 976, 1641 "DosPerfSysCall", 1642 (PFN*)(&pPerfSys->pDosPerfSysCall)); 1643 if (arc == NO_ERROR) 1644 { 1645 // OK, we got the API: initialize! 1646 arc = pPerfSys->pDosPerfSysCall(CMD_KI_ENABLE, 0, 0, 0); 1647 if (arc == NO_ERROR) 1648 { 1649 pPerfSys->fInitialized = TRUE; 1650 // call CMD_KI_DISABLE later 1651 1652 arc = pPerfSys->pDosPerfSysCall(CMD_PERF_INFO, 1653 0, 1654 (ULONG)(&pPerfSys->cProcessors), 1655 0); 1656 if (arc == NO_ERROR) 1657 { 1658 ULONG ul = 0; 1659 1660 // allocate arrays 1661 pPerfSys->paCPUUtils = (PCPUUTIL)calloc(pPerfSys->cProcessors, 1662 sizeof(CPUUTIL)); 1663 if (!pPerfSys->paCPUUtils) 1664 arc = ERROR_NOT_ENOUGH_MEMORY; 1665 else 1666 { 1667 pPerfSys->padBusyPrev = (double*)malloc(pPerfSys->cProcessors * sizeof(double)); 1668 if (!pPerfSys->padBusyPrev) 1669 arc = ERROR_NOT_ENOUGH_MEMORY; 1670 else 1671 { 1672 pPerfSys->padTimePrev 1673 = (double*)malloc(pPerfSys->cProcessors * sizeof(double)); 1674 if (!pPerfSys->padTimePrev) 1675 arc = ERROR_NOT_ENOUGH_MEMORY; 1676 else 1677 { 1678 pPerfSys->palLoads = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG)); 1679 if (!pPerfSys->palLoads) 1680 arc = ERROR_NOT_ENOUGH_MEMORY; 1681 else 1682 { 1683 for (ul = 0; ul < pPerfSys->cProcessors; ul++) 1684 { 1685 pPerfSys->padBusyPrev[ul] = 0.0; 1686 pPerfSys->padTimePrev[ul] = 0.0; 1687 pPerfSys->palLoads[ul] = 0; 1688 } 1689 } 1690 } 1691 } 1692 } 1693 } 1694 } 1695 } // end if (arc == NO_ERROR) 1696 } // end if (arc == NO_ERROR) 1697 1698 if (arc != NO_ERROR) 1699 { 1700 doshPerfClose(ppPerfSys); 1701 } 1702 } // end else if (!*ppPerfSys) 1703 1704 return (arc); 1705 } 1706 1707 /* 1708 *@@ doshPerfGet: 1709 * calculates a current snapshot of the system load, 1710 * compared with the load which was calculated on 1711 * the previous call. 1712 * 1713 * If you want to continually measure the system CPU 1714 * load, this is the function you will want to call 1715 * regularly -- e.g. with a timer once per second. 1716 * 1717 * Call this ONLY if doshPerfOpen returned NO_ERROR, 1718 * or you'll get crashes. 1719 * 1720 * If this call returns NO_ERROR, you get a LONG 1721 * CPU load for each CPU in the system in the 1722 * DOSHPERFSYS.palLoads array (in per-mille, 0-1000). 1723 * 1724 * For example, if there are two CPUs, after this call, 1725 * 1726 * -- DOSHPERFSYS.palLoads[0] contains the load of 1727 * the first CPU, 1728 * 1729 * -- DOSHPERFSYS.palLoads[1] contains the load of 1730 * the second CPU. 1731 * 1732 * See doshPerfOpen for example code. 1733 * 1734 *@@added V0.9.7 (2000-12-02) [umoeller] 1735 */ 1736 1737 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys) 1738 { 1739 APIRET arc = NO_ERROR; 1740 if (!pPerfSys->pDosPerfSysCall) 1741 arc = ERROR_INVALID_PARAMETER; 1742 else 1743 { 1744 arc = pPerfSys->pDosPerfSysCall(CMD_KI_RDCNT, 1745 (ULONG)pPerfSys->paCPUUtils, 1746 0, 0); 1747 if (arc == NO_ERROR) 1748 { 1749 // go thru all processors 1750 ULONG ul = 0; 1751 for (; ul < pPerfSys->cProcessors; ul++) 1752 { 1753 PCPUUTIL pCPUUtilThis = &pPerfSys->paCPUUtils[ul]; 1754 1755 double dTime = LL2F(pCPUUtilThis->ulTimeHigh, 1756 pCPUUtilThis->ulTimeLow); 1757 double dBusy = LL2F(pCPUUtilThis->ulBusyHigh, 1758 pCPUUtilThis->ulBusyLow); 1759 1760 double *pdBusyPrevThis = &pPerfSys->padBusyPrev[ul]; 1761 double *pdTimePrevThis = &pPerfSys->padTimePrev[ul]; 1762 1763 // avoid division by zero 1764 double dTimeDelta = (dTime - *pdTimePrevThis); 1765 if (dTimeDelta) 1766 pPerfSys->palLoads[ul] 1767 = (LONG)( (double)( (dBusy - *pdBusyPrevThis) 1768 / dTimeDelta 1769 * 1000.0 1770 ) 1771 ); 1772 else 1773 pPerfSys->palLoads[ul] = 0; 1774 1775 *pdTimePrevThis = dTime; 1776 *pdBusyPrevThis = dBusy; 1777 } 1778 } 1779 } 1780 1781 return (arc); 1782 } 1783 1784 /* 1785 *@@ doshPerfClose: 1786 * frees all resources allocated by doshPerfOpen. 1787 * 1788 *@@added V0.9.7 (2000-12-02) [umoeller] 1789 */ 1790 1791 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys) 1792 { 1793 APIRET arc = NO_ERROR; 1794 PDOSHPERFSYS pPerfSys = *ppPerfSys; 1795 if (!pPerfSys) 1796 arc = ERROR_INVALID_PARAMETER; 1797 else 1798 { 1799 if (pPerfSys->fInitialized) 1800 pPerfSys->pDosPerfSysCall(CMD_KI_DISABLE, 1801 0, 0, 0); 1802 1803 if (pPerfSys->paCPUUtils) 1804 free(pPerfSys->paCPUUtils); 1805 if (pPerfSys->padBusyPrev) 1806 free(pPerfSys->padBusyPrev); 1807 if (pPerfSys->padTimePrev) 1808 free(pPerfSys->padTimePrev); 1809 1810 if (pPerfSys->hmod) 1811 DosFreeModule(pPerfSys->hmod); 1812 free(pPerfSys); 1813 *ppPerfSys = NULL; 1814 } 1815 1816 return (arc); 1817 } 1818 1819 /* 1461 1820 *@@category: Helpers\Control program helpers\Process management 1462 1821 */ 1463 1822 1464 1823 /* ****************************************************************** 1465 * *1466 * Process helpers *1467 * *1824 * 1825 * Process helpers 1826 * 1468 1827 ********************************************************************/ 1469 1828 -
trunk/src/helpers/dosh2.c
r8 r14 30 30 * This file Copyright (C) 1997-2000 Ulrich Mller, 31 31 * Dmitry A. Steklenev. 32 * This file is part of the XWorkplacesource package.33 * XWorkplaceis free software; you can redistribute it and/or modify32 * This file is part of the "XWorkplace helpers" source package. 33 * This is free software; you can redistribute it and/or modify 34 34 * it under the terms of the GNU General Public License as published 35 35 * by the Free Software Foundation, in version 2 as it comes in the … … 46 46 // as unsigned char 47 47 48 #define INCL_DOSMODULEMGR 49 #define INCL_DOSPROCESS 50 #define INCL_DOSSESMGR 51 #define INCL_DOSQUEUES 52 #define INCL_DOSMISC 53 #define INCL_DOSDEVICES 48 54 #define INCL_DOSDEVIOCTL 49 #define INCL_DOS50 55 #define INCL_DOSERRORS 51 // #define INCL_GPI52 56 #include <os2.h> 57 53 58 #include <stdlib.h> 54 59 #include <string.h> … … 68 73 69 74 /* ****************************************************************** 70 * *71 * Miscellaneous *72 * *75 * 76 * Miscellaneous 77 * 73 78 ********************************************************************/ 74 79 … … 109 114 BOOL fFullyQualified) // in: if TRUE, pcszFile must be fully q'fied 110 115 { 116 APIRET arc = NO_ERROR; 111 117 CHAR szPath[CCHMAXPATH+4] = " :"; 112 118 CHAR szComponent[CCHMAXPATH]; … … 120 126 || (*(pcszFile + 2) != '\\') 121 127 ) 122 return (ERROR_CURRENT_DIRECTORY);128 arc = ERROR_CURRENT_DIRECTORY; 123 129 } 124 130 … … 127 133 { 128 134 CHAR cDrive = toupper(*pcszFile); 135 double d; 129 136 // drive specified: 130 137 strcpy(szPath, pcszFile); 131 138 szPath[0] = toupper(*pcszFile); 132 if (doshQueryDiskFree(cDrive - 'A' + 1) == -1) 133 return (ERROR_INVALID_DRIVE); 139 arc = doshQueryDiskFree(cDrive - 'A' + 1, &d); 134 140 } 135 141 else … … 138 144 ULONG ulDriveNum = 0, 139 145 ulDriveMap = 0; 140 DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);146 arc = DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap); 141 147 szPath[0] = ((UCHAR)ulDriveNum) + 'A' - 1; 142 148 szPath[1] = ':'; … … 144 150 } 145 151 146 fIsFAT = doshIsFileOnFAT(szPath); 147 148 pszInvalid = (fIsFAT) 149 ? "<>|+=:;,\"/[] " // invalid characters in FAT 150 : "<>|:\"/"; // invalid characters in IFS's 151 152 // now separate path components 153 p1 = &szPath[2]; // advance past ':' 154 155 do { 156 157 if (*p1 == '\\') 158 p1++; 159 160 p2 = strchr(p1, '\\'); 161 if (p2 == NULL) 162 p2 = p1 + strlen(p1); 163 164 if (p1 != p2) 165 { 166 LONG lDotOfs = -1, 167 lAfterDot = -1; 168 ULONG cbFile, 169 ul; 170 PSZ pSource = szComponent; 171 172 strncpy(szComponent, p1, p2-p1); 173 szComponent[p2-p1] = 0; 174 cbFile = strlen(szComponent); 175 176 // now check each path component 177 for (ul = 0; ul < cbFile; ul++) 152 if (arc == NO_ERROR) 153 { 154 fIsFAT = doshIsFileOnFAT(szPath); 155 156 pszInvalid = (fIsFAT) 157 ? "<>|+=:;,\"/[] " // invalid characters in FAT 158 : "<>|:\"/"; // invalid characters in IFS's 159 160 // now separate path components 161 p1 = &szPath[2]; // advance past ':' 162 163 do { 164 165 if (*p1 == '\\') 166 p1++; 167 168 p2 = strchr(p1, '\\'); 169 if (p2 == NULL) 170 p2 = p1 + strlen(p1); 171 172 if (p1 != p2) 178 173 { 174 LONG lDotOfs = -1, 175 lAfterDot = -1; 176 ULONG cbFile, 177 ul; 178 PSZ pSource = szComponent; 179 180 strncpy(szComponent, p1, p2-p1); 181 szComponent[p2-p1] = 0; 182 cbFile = strlen(szComponent); 183 184 // now check each path component 185 for (ul = 0; ul < cbFile; ul++) 186 { 187 if (fIsFAT) 188 { 189 // on FAT: only 8 characters allowed before dot 190 if (*pSource == '.') 191 { 192 lDotOfs = ul; 193 lAfterDot = 0; 194 if (ul > 7) 195 return (ERROR_FILENAME_EXCED_RANGE); 196 } 197 } 198 // and check for invalid characters 199 if (strchr(pszInvalid, *pSource) != NULL) 200 return (ERROR_INVALID_NAME); 201 202 pSource++; 203 204 // on FAT, allow only three chars after dot 205 if (fIsFAT) 206 if (lAfterDot != -1) 207 { 208 lAfterDot++; 209 if (lAfterDot > 3) 210 return (ERROR_FILENAME_EXCED_RANGE); 211 } 212 } 213 214 // we are still missing the case of a FAT file 215 // name without extension; if so, check whether 216 // the file stem is <= 8 chars 179 217 if (fIsFAT) 180 { 181 // on FAT: only 8 characters allowed before dot 182 if (*pSource == '.') 183 { 184 lDotOfs = ul; 185 lAfterDot = 0; 186 if (ul > 7) 218 if (lDotOfs == -1) // dot not found: 219 if (cbFile > 8) 187 220 return (ERROR_FILENAME_EXCED_RANGE); 188 }189 }190 // and check for invalid characters191 if (strchr(pszInvalid, *pSource) != NULL)192 return (ERROR_INVALID_NAME);193 194 pSource++;195 196 // on FAT, allow only three chars after dot197 if (fIsFAT)198 if (lAfterDot != -1)199 {200 lAfterDot++;201 if (lAfterDot > 3)202 return(ERROR_FILENAME_EXCED_RANGE);203 }204 221 } 205 222 206 // we are still missing the case of a FAT file 207 // name without extension; if so, check whether 208 // the file stem is <= 8 chars 209 if (fIsFAT) 210 if (lDotOfs == -1) // dot not found: 211 if (cbFile > 8) 212 return (ERROR_FILENAME_EXCED_RANGE); 213 } 214 215 // go for next component 216 p1 = p2+1; 217 } while (*p2); 218 219 return (NO_ERROR); 223 // go for next component 224 p1 = p2+1; 225 } while (*p2); 226 } 227 228 return (arc); 220 229 } 221 230 … … 340 349 341 350 /* ****************************************************************** 342 * *343 * Environment helpers *344 * *351 * 352 * Environment helpers 353 * 345 354 ********************************************************************/ 346 355 … … 716 725 717 726 /* ****************************************************************** 718 * *719 * Module handling helpers *720 * *727 * 728 * Module handling helpers 729 * 721 730 ********************************************************************/ 722 731 … … 773 782 774 783 /******************************************************************** 775 * *776 * Executable functions *777 * *784 * 785 * Executable functions 786 * 778 787 ********************************************************************/ 779 788 … … 1219 1228 1220 1229 /******************************************************************** 1221 * *1222 * Partition functions *1223 * *1230 * 1231 * Partition functions 1232 * 1224 1233 ********************************************************************/ 1225 1234 -
trunk/src/helpers/eah.c
r8 r14 67 67 * Copyright (C) 1995 Massachusetts Institute of Technology. 68 68 * Copyright (C) 1997-2000 Ulrich Mller. 69 * This file is part of the XWorkplacesource package.70 * XWorkplaceis free software; you can redistribute it and/or modify69 * This file is part of the "XWorkplace helpers" source package. 70 * This is free software; you can redistribute it and/or modify 71 71 * it under the terms of the GNU General Public License as published 72 72 * by the Free Software Foundation, in version 2 as it comes in the … … 83 83 // as unsigned char 84 84 85 #define INCL_DOS 85 #define INCL_DOSFILEMGR 86 86 #define INCL_DOSERRORS 87 87 #include <os2.h> … … 101 101 102 102 /******************************************************************** 103 * *104 * Extended Attribute handling *105 * *103 * 104 * Extended Attribute handling 105 * 106 106 ********************************************************************/ 107 107 … … 173 173 174 174 /* ****************************************************************** 175 * *176 * Read-EA functions *177 * *175 * 176 * Read-EA functions 177 * 178 178 ********************************************************************/ 179 179 … … 196 196 */ 197 197 198 ULONG eaPathQueryTotalSize( PSZ pszPath)198 ULONG eaPathQueryTotalSize(const char *pcszPath) 199 199 { 200 200 APIRET arc; … … 202 202 FILEFINDBUF4 ffb4; 203 203 204 _Pmpf(("eaPathQueryTotalSize %s", pszPath)); 205 206 arc = DosQueryPathInfo(pszPath, 204 arc = DosQueryPathInfo((PSZ)pcszPath, 207 205 FIL_QUERYEASIZE, 208 206 &ffb4, … … 220 218 221 219 arc = DosEnumAttribute(ENUMEA_REFTYPE_PATH, 222 pszPath,220 (PSZ)pcszPath, 223 221 1, 224 222 abBuf, … … 230 228 pdena2 = (PDENA2)abBuf; 231 229 232 _Pmpf((" %s: arc = %d, count = %d", pszPath, arc, lCount));233 234 230 if (lCount > 0) 235 231 { … … 247 243 } 248 244 249 _Pmpf((" %s: total %d", pszPath, ulTotalEASize));250 251 245 return (ulTotalEASize); 252 246 } … … 259 253 */ 260 254 261 PEALIST eaPathReadAll( PSZ path)262 { 263 return (ReadEAList(ENUMEA_REFTYPE_PATH, path));255 PEALIST eaPathReadAll(const char *pcszPath) 256 { 257 return (ReadEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath)); 264 258 } 265 259 … … 283 277 */ 284 278 285 PEABINDING eaPathReadOneByIndex( PSZ path, ULONG index)286 { 287 return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, path, index));279 PEABINDING eaPathReadOneByIndex(const char *pcszPath, ULONG index) 280 { 281 return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, index)); 288 282 } 289 283 … … 305 299 */ 306 300 307 PEABINDING eaPathReadOneByName( PSZ path, PSZ name)308 { 309 return (ReadEAByName(ENUMEA_REFTYPE_PATH, path, name));301 PEABINDING eaPathReadOneByName(const char *pcszPath, const char *pcszEAName) 302 { 303 return (ReadEAByName(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, (PSZ)pcszEAName)); 310 304 } 311 305 … … 315 309 */ 316 310 317 PEABINDING eaHFileReadOneByName(HFILE hfile, PSZ name)318 { 319 return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), name));311 PEABINDING eaHFileReadOneByName(HFILE hfile, const char *pcszEAName) 312 { 313 return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), (PSZ)pcszEAName)); 320 314 } 321 315 322 316 /* ****************************************************************** 323 * *324 * Write-EA functions *325 * *317 * 318 * Write-EA functions 319 * 326 320 ********************************************************************/ 327 321 … … 335 329 * field is 0; only in that case, the EABINDING.value 336 330 * field may also be NULL. 337 */ 338 339 void eaPathWriteAll(PSZ path, PEALIST list) 340 { 341 WriteEAList(ENUMEA_REFTYPE_PATH, path, list); 331 * 332 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET 333 */ 334 335 APIRET eaPathWriteAll(const char *pcszPath, PEALIST list) 336 { 337 return (WriteEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, list)); 342 338 } 343 339 … … 345 341 *@@ eaHFileWriteAll: 346 342 * like eaPathWriteAll, but for an open file handle. 347 */ 348 349 void eaHFileWriteAll(HFILE hfile, PEALIST list) 350 { 351 WriteEAList(ENUMEA_REFTYPE_FHANDLE, (&hfile), list); 343 * 344 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET 345 */ 346 347 APIRET eaHFileWriteAll(HFILE hfile, PEALIST list) 348 { 349 return (WriteEAList(ENUMEA_REFTYPE_FHANDLE, (&hfile), list)); 352 350 } 353 351 … … 362 360 * 363 361 * To delete an EA, you may also use eaPathDeleteOne. 364 */ 365 366 void eaPathWriteOne(PSZ path, PEABINDING peab) 367 { 368 WriteEA(ENUMEA_REFTYPE_PATH, path, peab); 362 * 363 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET 364 */ 365 366 APIRET eaPathWriteOne(const char *pcszPath, PEABINDING peab) 367 { 368 return (WriteEA(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, peab)); 369 369 } 370 370 … … 372 372 *@@ eaHFileWriteOne: 373 373 * like eaPathWriteOne, but for an open file handle. 374 */ 375 376 void eaHFileWriteOne(HFILE hfile, PEABINDING peab) 377 { 378 WriteEA(ENUMEA_REFTYPE_FHANDLE, (&hfile), peab); 374 * 375 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET 376 */ 377 378 APIRET eaHFileWriteOne(HFILE hfile, PEABINDING peab) 379 { 380 return (WriteEA(ENUMEA_REFTYPE_FHANDLE, (&hfile), peab)); 379 381 } 380 382 … … 386 388 * 387 389 *@@added V0.9.0 [umoeller] 388 */ 389 390 void eaPathDeleteOne(PSZ path, PSZ pszEAName) 390 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET 391 */ 392 393 APIRET eaPathDeleteOne(const char *pcszPath, const char *pcszEAName) 391 394 { 392 395 EABINDING eab; 393 396 eab.bFlags = 0; 394 eab.bNameLength = strlen(p szEAName);395 eab.pszName = pszEAName;397 eab.bNameLength = strlen(pcszEAName); 398 eab.pszName = (PSZ)pcszEAName; 396 399 eab.usValueLength = 0; 397 400 eab.pszValue = 0; 398 eaPathWriteOne(path, &eab);401 return (eaPathWriteOne(pcszPath, &eab)); 399 402 } 400 403 … … 404 407 405 408 /******************************************************************** 406 * *407 * Translation funcs *408 * *409 * 410 * Translation funcs 411 * 409 412 ********************************************************************/ 410 413 … … 484 487 */ 485 488 486 PEABINDING eaCreateBindingFromPSZ( PSZ pszEAName,// in: EA name (e.g. ".LONGNAME")487 PSZ pszString)// in: string for EAT_ASCII EA489 PEABINDING eaCreateBindingFromPSZ(const char *pcszEAName, // in: EA name (e.g. ".LONGNAME") 490 const char *pcszInput) // in: string for EAT_ASCII EA 488 491 { 489 492 PEABINDING peab = (PEABINDING)malloc(sizeof(EABINDING)); … … 491 494 { 492 495 SHORT cbString = 0; 493 if (p szString)494 cbString = strlen(p szString);496 if (pcszInput) 497 cbString = strlen(pcszInput); 495 498 496 499 peab->bFlags = 0; 497 peab->bNameLength = strlen(p szEAName);498 peab->pszName = strdup(p szEAName);500 peab->bNameLength = strlen(pcszEAName); 501 peab->pszName = strdup(pcszEAName); 499 502 500 503 if (cbString) … … 510 513 *((PUSHORT)(peab->pszValue + 2)) = cbString; 511 514 // copy string to byte 4 (no null-terminator) 512 memcpy(peab->pszValue + 4, p szString, cbString);515 memcpy(peab->pszValue + 4, pcszInput, cbString); 513 516 } 514 517 else … … 743 746 744 747 PSZ eaCreatePSZFromMVBinding(PEABINDING peab, // in: EAT_MVMT binding 745 PSZ pszSeparator, // in: null-terminated string used as separator748 const char *pcszSeparator, // in: null-terminated string used as separator 746 749 PUSHORT pusCodepage) // out: codepage found in binding (ptr can be NULL) 747 750 { … … 765 768 USHORT us = 0; 766 769 USHORT cbComment = 0; 767 USHORT cbSeparator = strlen(p szSeparator);770 USHORT cbSeparator = strlen(pcszSeparator); 768 771 while (us < usMVCount) 769 772 { … … 794 797 // append separator 795 798 memcpy(pszTotal + cbCommentOld, 796 p szSeparator,799 pcszSeparator, 797 800 cbSeparator); 798 801 // copy the rest after the separator (below) … … 846 849 */ 847 850 848 PEABINDING eaCreateMVBindingFromPSZ( PSZ pszEAName, // in: EA name (e.g. ".KEYPHRASES")849 PSZ pszInput, // in: string to parse850 PSZ pszSeparator, // in: separator used in pszInput851 PEABINDING eaCreateMVBindingFromPSZ(const char *pcszEAName, // in: EA name (e.g. ".KEYPHRASES") 852 const char *pcszInput, // in: string to parse 853 const char *pcszSeparator, // in: separator used in pszInput 851 854 USHORT usCodepage) // in: codepage to set in EAT_MVMT 852 855 { 853 856 PEABINDING peab; 854 if (p szInput)857 if (pcszInput) 855 858 { 856 859 peab = (PEABINDING)malloc(sizeof(EABINDING)); 857 860 if (peab) 858 861 { 859 PSZ p = pszInput,860 pSource,861 862 USHORT cbInput = strlen(p szInput),863 cbSep = strlen(p szSeparator),862 const char *p = pcszInput, 863 *pSource; 864 PSZ pTarget; 865 USHORT cbInput = strlen(pcszInput), 866 cbSep = strlen(pcszSeparator), 864 867 usSepCount = 0, 865 868 cbToAlloc = 0, … … 868 871 869 872 peab->bFlags = 0; 870 peab->bNameLength = strlen(p szEAName);871 peab->pszName = strdup(p szEAName);873 peab->bNameLength = strlen(pcszEAName); 874 peab->pszName = strdup(pcszEAName); 872 875 873 876 // now count the number of pszSeparators in pszInput 874 while ((p = strstr(p, p szSeparator)))877 while ((p = strstr(p, pcszSeparator))) 875 878 { 876 879 usSepCount++; … … 898 901 899 902 // set pointer to first field 900 pSource = p szInput;903 pSource = pcszInput; 901 904 pTarget = peab->pszValue + 6; 902 905 … … 907 910 { 908 911 // find the next separator 909 PSZ pNextSep = strstr(pSource, p szSeparator);912 PSZ pNextSep = strstr(pSource, pcszSeparator); 910 913 // calculate the length of the substring 911 914 cbThis = pNextSep - pSource; … … 934 937 935 938 /******************************************************************** 936 * *937 * EA helper funcs *938 * *939 * 940 * EA helper funcs 941 * 939 942 ********************************************************************/ 940 943 … … 1217 1220 1218 1221 /* ****************************************************************** 1219 * *1220 * Direct plain-string EA handling *1221 * *1222 * 1223 * Direct plain-string EA handling 1224 * 1222 1225 ********************************************************************/ 1223 1226 -
trunk/src/helpers/except.c
r13 r14 3 3 *@@sourcefile except.c: 4 4 * this file contains powerful exception handlers. 5 * except.h also defines easy-to-use macros for them. 5 6 * 6 7 * Usage: All OS/2 programs, PM or text mode. 7 8 * 8 * <B>except.h macros</B> 9 * 10 * except.h declares a few handy macros to easily install 11 * exception handling for a section of code. 12 * 13 * These macros automatically insert code for properly 14 * registering and deregistering the handlers. You should 15 * ALWAYS use these macros instead of directly registering 9 * <B>Introduction</B> 10 * 11 * OS/2 exception handlers are a mess to program and, 12 * if installed wrongly, almost impossible to debug. 13 * The problem is that for any program that does a bit 14 * more than showing a message box, using exception 15 * handlers is a must to avoid system hangs. This 16 * especially applies to multi-thread programs using 17 * mutex semaphores (more on that below). The functions 18 * and macros in here are designed to make that more simple. 19 * 20 * The macros in except.h automatically insert code for properly 21 * registering and deregistering the handlers in except.c. You 22 * should ALWAYS use these macros instead of directly registering 16 23 * the handlers to avoid accidentally forgetting to deregister 17 24 * them. If you forget to deregister an exception handler, this … … 20 27 * might get completely messed up. 21 28 * 22 * The general idea of these macros is to define 23 * TRY / CATCH blocks similar to C++. If an exception 24 * occurs in the TRY block, execution is transferred 25 * to the CATCH block. (This works in both C and C++, 26 * by the way.) 27 * 28 * In addition, with the TRY statement, you may specify 29 * an optional "OnKill" function which gets called if 30 * the thread gets killed while code in the TRY block is 31 * executed (new with V0.9.0). If you need no such 32 * function, specify NULL. Details follow. 29 * The general idea of these macros is to define TRY / CATCH 30 * blocks similar to C++. If an exception occurs in the TRY block, 31 * execution is transferred to the CATCH block. (This works in both 32 * C and C++, by the way.) 33 * 34 * The "OnKill" function that was added with V0.9.0 has been 35 * removed again with V0.9.7. Use DosEnterMustComplete instead. 36 * Details follow. 33 37 * 34 38 * The general usage is like this: … … 36 40 + int your_protected_func(int ...) 37 41 + { 38 + TRY_LOUD(excptid, OnKillFunc) 39 + // or: TRY_QUIET(excptid, OnKillFunc) 40 + // OnKillFunc can be NULL 42 + TRY_LOUD(excptid) // or: TRY_QUIET(excptid) 41 43 + { 42 44 + .... // the stuff in here is protected by … … 50 52 + } // end of your_func 51 53 * 52 * TRY_LOUD is for excHandlerLoud (see below).53 * TRY_QUIET is for excHandlerQuiet (see below).54 * TRY_LOUD is for installing excHandlerLoud. 55 * TRY_QUIET is for installing excHandlerQuiet. 54 56 * CATCH / END_CATCH are the same for the two. This 55 57 * is where the exception handler jumps to if an … … 58 60 * in there. 59 61 * 60 * "excptid" can be any identifier which is not used in62 * "excptid" can be any C identifier which is not used in 61 63 * your current variable scope, e.g. "excpt1". This 62 64 * is used for creating an EXCEPTSTRUCT variable of … … 65 67 * store the exception handler data. 66 68 * 67 * It is possible to nest these handlers though. You 68 * must use different "excptid"'s only if more than one 69 * TRY_* block exists in the same variable scope. Avoid 70 * using gotos to jump between the different CATCH blocks, 71 * because this might not properly deregister the handlers. 69 * These macros may be nested if you use different 70 * "excptid"'s for sub-macros. 71 * 72 * Inside the TRY and CATCH blocks, you must not use 73 * "goto" (to a location outside the block) or "return", 74 * because this will not deregister the handler. 72 75 * 73 76 * Keep in mind that all the code in the TRY_* block is … … 76 79 * TRY_* block, your entire application is protected. 77 80 * 78 * Your "OnKillFunc" must be declared as 79 + VOID APIENTRY YourOnKillFunc(VOID) {...}. 80 * This gets called when the thread gets terminated 81 * while being executed in the TRY block (that is, 82 * if either the thread gets killed explicitly or 83 * the entire process ends for some reason). After 84 * that function got executed, the thread will _always_ 85 * be terminated; the CATCH block will not be executed 86 * then. You can specify NULL for the "OnKillFunc", if 87 * you don't need one. 88 * 89 * To summarize: If an exception occurs in the TRY 90 * block, 91 * 92 * a) "OnKillFunc" gets called if the thread got 93 * killed, and the thread then terminates; 94 * 95 * b) the CATCH block is executed for other exceptions 96 * and execution continues. 81 * <B>Asynchronous exceptions</B> 82 * 83 * The exception handlers in this file (which are installed 84 * with the TRY/CATCH mechanism) only intercept synchronous 85 * exceptions (see excHandlerLoud for a list). They do not 86 * protect your code against asynchronous exceptions. 87 * 88 * OS/2 defines asynchronous exceptions to be those that 89 * can be delayed. With OS/2, there are only three of these: 90 * 91 * -- XCPT_PROCESS_TERMINATE 92 * -- XCPT_ASYNC_PROCESS_TERMINATE 93 * -- XCPT_SIGNAL (thread 1 only) 94 * 95 * To protect yourself against these also, put the section 96 * in question in a DosEnterMustComplete/DosExitMustComplete 97 * block as well. 97 98 * 98 99 * <B>Mutex semaphores</B> 99 100 * 100 * Here's how to deal with mutex semaphores: WHENEVER 101 * you request a mutex semaphore, enclose the block 102 * with TRY/CATCH in case an error occurs, like this: 101 * The problem with OS/2 mutex semaphores is that they are 102 * not automatically released when a thread terminates. 103 * If the thread owning the mutex died without releasing 104 * the mutex, other threads which are blocked on that mutex 105 * will wait forever and become zombie threads. Even worse, 106 * if this happens to a PM thread, this will hang the system. 107 * 108 * Here's the typical scenario with two threads: 109 * 110 * 1) Thread 2 requests a mutex and does lots of processing. 111 * 112 * 2) Thread 1 requests the mutex. Since it's still owned 113 * by thread 2, thread 1 blocks. 114 * 115 * 3) Thread 2 crashes in its processing. Without an 116 * exception handler, OS/2 will terminate the process. 117 * It will first kill thread 2 and then attempt to 118 * kill thread 1. This fails because it is still 119 * blocking on the semaphore that thread 2 never 120 * released. Boom. 121 * 122 * The same scenario happens when a process gets killed. 123 * Since OS/2 will kill secondary threads before thread 1, 124 * the same situation can arise. 125 * 126 * As a result, you must protect any section of code which 127 * requests a semaphore _both_ against crashes _and_ 128 * termination. 129 * 130 * So _whenever_ you request a mutex semaphore, enclose 131 * the block with TRY/CATCH in case the code crashes. 132 * Besides, enclose the TRY/CATCH block in a must-complete 133 * section, like this: 103 134 * 104 135 + HMTX hmtx = ... 105 +106 + VOID APIENTRY OnKillYourFunc(VOID)107 + {108 + DosReleaseMutexSem(hmtx);109 + }110 136 + 111 137 + int your_func(int) 112 138 + { 113 + BOOL fSemOwned = FALSE; 139 + BOOL fSemOwned = FALSE; 140 + ULONG ulNesting = 0; 141 + 142 + DosEnterMustComplete(&ulNesting); 114 143 + TRY_QUIET(excpt1, OnKillYourFunc) // or TRY_LOUD 115 144 + { … … 126 155 + fSemOwned = FALSE; 127 156 + } 157 + DosExitMustComplete(&ulNesting); 128 158 + } // end of your_func 129 159 * 130 * This way your mutex semaphore gets released even if 131 * exceptions occur in your code. If you don't do this, 132 * threads waiting for that semaphore will be blocked 133 * forever when exceptions occur. As a result, depending 134 * on the thread, PM will hang, or the application will 135 * never terminate. 160 * This way your mutex semaphore gets released in every 161 * possible condition. 136 162 * 137 163 * <B>Customizing</B> 138 164 * 139 * Note: As opposed to versions < 0.9.0, thisis now165 * As opposed to versions before 0.9.0, this code is now 140 166 * completely independent of XWorkplace. This file now 141 167 * contains "pure" exception handlers only. … … 146 172 * If excRegisterHooks is not called, the following safe 147 173 * defaults are used: 174 * 148 175 * -- the trap log file is TRAP.LOG in the root 149 176 * directory of your boot drive. … … 182 209 * John Currier, 183 210 * Anthony Cruise. 184 * This file is part of the XWorkplacesource package.185 * XWorkplaceis free software; you can redistribute it and/or modify211 * This file is part of the "XWorkplace helpers" source package. 212 * This is free software; you can redistribute it and/or modify 186 213 * it under the terms of the GNU General Public License as published 187 214 * by the Free Software Foundation, in version 2 as it comes in the … … 223 250 224 251 /* ****************************************************************** 225 * *226 * Global variables *227 * *252 * 253 * Global variables 254 * 228 255 ********************************************************************/ 229 256 … … 240 267 241 268 /* ****************************************************************** 242 * *243 * Exception helper routines *244 * *269 * 270 * Exception helper routines 271 * 245 272 ********************************************************************/ 246 273 … … 490 517 case XCPT_ACCESS_VIOLATION: 491 518 { 492 fprintf(file, "\n Access violation: ");519 fprintf(file, "\nXCPT_ACCESS_VIOLATION: "); 493 520 if (pReportRec->ExceptionInfo[0] & XCPT_READ_ACCESS) 494 521 fprintf(file, "Invalid read access from 0x%04lX:%08lX.\n", … … 516 543 case XCPT_INTEGER_DIVIDE_BY_ZERO: 517 544 { 518 fprintf(file, "\n Integer division by zero.\n");545 fprintf(file, "\nXCPT_INTEGER_DIVIDE_BY_ZERO.\n"); 519 546 fprintf(file, 520 547 "Explanation: An attempt was made to divide an integer value by zero,\n" … … 525 552 case XCPT_ILLEGAL_INSTRUCTION: 526 553 { 527 fprintf(file, "\n Illegal instruction found.\n");554 fprintf(file, "\nXCPT_ILLEGAL_INSTRUCTION.\n"); 528 555 fprintf(file, 529 556 "Explanation: An attempt was made to execute an instruction that\n" … … 534 561 case XCPT_PRIVILEGED_INSTRUCTION: 535 562 { 536 fprintf(file, "\n Privileged instruction found.\n");563 fprintf(file, "\nXCPT_PRIVILEGED_INSTRUCTION.\n"); 537 564 fprintf(file, 538 565 "Explanation: An attempt was made to execute an instruction that\n" … … 543 570 544 571 case XCPT_INTEGER_OVERFLOW: 545 fprintf(file, "\n Integer overflow.\n");572 fprintf(file, "\nXCPT_INTEGER_OVERFLOW.\n"); 546 573 fprintf(file, 547 574 "Explanation: An integer operation generated a carry-out of the most\n" 548 575 " significant bit. This is a sign of an attempt to store\n" 549 576 " a value which does not fit into an integer variable.\n"); 577 578 default: 579 fprintf(file, "\nUnknown OS/2 exception number %d.\n", pReportRec->ExceptionNum); 580 fprintf(file, "Look this up in the OS/2 header files.\n"); 550 581 } 551 582 … … 700 731 701 732 /* ****************************************************************** 702 * *703 * Exported routines *704 * *733 * 734 * Exported routines 735 * 705 736 ********************************************************************/ 706 737 … … 722 753 * The hooks are as follows: 723 754 * 724 * pfnExcOpenFileNew gets called to open755 * -- pfnExcOpenFileNew gets called to open 725 756 * the trap log file. This must return a FILE* 726 757 * pointer from fopen(). If this is not defined, … … 729 760 * into it before the actual exception info. 730 761 * 731 * pfnExcHookNew gets called while the trap log762 * -- pfnExcHookNew gets called while the trap log 732 763 * is being written. At this point, 733 764 * the following info has been written into … … 743 774 * Use this hook to write additional application 744 775 * info into the trap log, such as the state 745 * of your threads.746 * 747 * pfnExcHookError gets called when the TRY_* macros776 * of your own threads and mutexes. 777 * 778 * -- pfnExcHookError gets called when the TRY_* macros 748 779 * fail to install an exception handler (when 749 * DosSetExceptionHandler fails). 780 * DosSetExceptionHandler fails). I've never seen 781 * this happen. 750 782 * 751 783 *@@added V0.9.0 [umoeller] … … 772 804 * to the thread to continue execution, i.e. the 773 805 * default OS/2 exception handler will never get 774 * called. This requires a setjmp() call on 806 * called. 807 * 808 * This requires a setjmp() call on 775 809 * EXCEPTIONREGISTRATIONRECORD2.jmpThread before 776 * being installed. 777 * 778 * This is best registered thru the TRY_LOUD macro 779 * (new with V0.84, described in except.c), which 780 * does the necessary setup. 781 * 782 * Depending on the type of exception, the following 783 * happens: 784 * 785 * <B>a) "real" exceptions</B> 810 * being installed. The TRY_LOUD macro will take 811 * care of this for you (see except.c). 812 * 813 * This intercepts the following exceptions (see 814 * the OS/2 Control Program Reference for details): 786 815 * 787 816 * -- XCPT_ACCESS_VIOLATION (traps 0x0d, 0x0e) … … 795 824 * what source code corresponds to the error. 796 825 * 826 * See excRegisterHooks for the default setup of this. 827 * 797 828 * Note that to get meaningful debugging information 798 829 * in this handler's traplog, you need the following: 830 * 799 831 * a) have a MAP file created at link time (/MAP) 832 * 800 833 * b) convert the MAP to a SYM file using MAPSYM 834 * 801 835 * c) put the SYM file in the same directory of 802 * the executable. This must have the same 803 * filestem as the executable. 804 * 805 * See the "Control Programming Guide and Reference" 806 * for details. 836 * the module (EXE or DLL). This must have the 837 * same filestem as the module. 838 * 807 839 * All other exceptions are passed to the next handler 808 840 * in the exception handler chain. This might be the 809 841 * C/C++ compiler handler or the default OS/2 handler, 810 842 * which will probably terminate the process. 811 *812 * <B>b) thread kills</B>813 *814 * -- XCPT_PROCESS_TERMINATE815 * -- XCPT_ASYNC_PROCESS_TERMINATE:816 *817 * If EXCEPTIONREGISTRATIONRECORD2.pfnOnKill is != NULL,818 * that function gets called to allow for thread cleanup819 * before the thread really terminates. This should be820 * used for releasing mutex semaphores.821 843 * 822 844 *@@changed V0.9.0 [umoeller]: added support for thread termination … … 852 874 switch (pReportRec->ExceptionNum) 853 875 { 854 case XCPT_PROCESS_TERMINATE:876 /* case XCPT_PROCESS_TERMINATE: 855 877 case XCPT_ASYNC_PROCESS_TERMINATE: 856 878 // thread terminated: … … 859 881 if (pRegRec2->pfnOnKill) 860 882 // call the "OnKill" function 861 pRegRec2->pfnOnKill( );883 pRegRec2->pfnOnKill(pRegRec2); 862 884 // get outta here, which will kill the thread 863 break; 885 break; */ 864 886 865 887 case XCPT_ACCESS_VIOLATION: … … 867 889 case XCPT_ILLEGAL_INSTRUCTION: 868 890 case XCPT_PRIVILEGED_INSTRUCTION: 891 case XCPT_INVALID_LOCK_SEQUENCE: 869 892 case XCPT_INTEGER_OVERFLOW: 870 893 { … … 924 947 * this is useful for certain error-prone functions, where 925 948 * exceptions are likely to appear, for example used by 926 * cmnCheckObject to implement a fail-safe SOM object check.949 * wpshCheckObject to implement a fail-safe SOM object check. 927 950 * 928 951 * This does _not_ write an error log and makes _no_ sound. … … 953 976 switch (pReportRec->ExceptionNum) 954 977 { 955 case XCPT_PROCESS_TERMINATE:978 /* case XCPT_PROCESS_TERMINATE: 956 979 case XCPT_ASYNC_PROCESS_TERMINATE: 957 980 // thread terminated: … … 960 983 if (pRegRec2->pfnOnKill) 961 984 // call the "OnKill" function 962 pRegRec2->pfnOnKill( );985 pRegRec2->pfnOnKill(pRegRec2); 963 986 // get outta here, which will kill the thread 964 break; 987 break; */ 965 988 966 989 case XCPT_ACCESS_VIOLATION: … … 968 991 case XCPT_ILLEGAL_INSTRUCTION: 969 992 case XCPT_PRIVILEGED_INSTRUCTION: 993 case XCPT_INVALID_LOCK_SEQUENCE: 970 994 case XCPT_INTEGER_OVERFLOW: 971 995 // write excpt explanation only if the 972 // resp. debugging #define is set ( common.h)996 // resp. debugging #define is set (setup.h) 973 997 #ifdef DEBUG_WRITEQUIETEXCPT 974 998 { -
trunk/src/helpers/gpih.c
r13 r14 6 6 * Usage: All PM programs. 7 7 * 8 * A word about GPI rectangles: In general, graphics operations involving 9 * device coordinates (such as regions, bit maps and bit blts, and window 10 * management) use inclusive-exclusive rectangles. All other graphics 11 * operations, such as GPI functions that define paths, use inclusive-inclusive 12 * rectangles. 8 * A word about GPI rectangles: In general, graphics operations 9 * involving device coordinates (such as regions, bit maps and 10 * bit blts, and window management) use inclusive-exclusive 11 * rectangles. All other graphics operations, such as GPI 12 * functions that define paths, use inclusive-inclusive rectangles. 13 * 14 * This can be a problem with mixing Win and Gpi functions. For 15 * example, WinQueryWindowRect returns an inclusive-exclusive 16 * rectangle (so that the xRight value is the same as the window 17 * width). However, GpiBox expects an inclusive-inclusive rectangle. 13 18 * 14 19 * Function prefixes (new with V0.81): … … 23 28 /* 24 29 * Copyright (C) 1997-2000 Ulrich Mller. 25 * This file is part of the XWorkplacesource package.26 * XWorkplaceis free software; you can redistribute it and/or modify30 * This file is part of the "XWorkplace helpers" source package. 31 * This is free software; you can redistribute it and/or modify 27 32 * it under the terms of the GNU General Public License as published 28 33 * by the Free Software Foundation, in version 2 as it comes in the … … 39 44 // as unsigned char 40 45 41 #define INCL_DOSDEVIOCTL42 #define INCL_DOS43 46 #define INCL_DOSERRORS 44 #define INCL_WIN 45 #define INCL_GPI 47 48 #define INCL_WINWINDOWMGR 49 #define INCL_WINPOINTERS 50 #define INCL_WINSYS 51 52 #define INCL_GPIPRIMITIVES 53 #define INCL_GPIBITMAPS 54 #define INCL_GPILOGCOLORTABLE 55 #define INCL_GPILCIDS 46 56 #include <os2.h> 47 57 … … 68 78 69 79 /* ****************************************************************** 70 * *71 * Device helpers *72 * *80 * 81 * Device helpers 82 * 73 83 ********************************************************************/ 74 84 … … 100 110 101 111 /* ****************************************************************** 102 * *103 * Color helpers *104 * *112 * 113 * Color helpers 114 * 105 115 ********************************************************************/ 106 116 … … 139 149 140 150 /* ****************************************************************** 141 * *142 * Drawing primitives helpers *143 * *151 * 152 * Drawing primitives helpers 153 * 144 154 ********************************************************************/ 145 155 … … 187 197 * the top right point lies _outside_ the rectangle 188 198 * which is actually drawn. This is the same as with 189 * WinFillRect. 199 * WinFillRect. ### I don't think so any more... GpiBox 200 * uses inclusive-inclusive rectangles... 190 201 * 191 202 * Changes to the HPS: … … 252 263 GpiMove(hps, &ptlSave); 253 264 GpiSetColor(hps, lColorSave); 265 } 266 267 /* 268 *@@ gpihThickBox: 269 * draws a box from the specified rectangle with the 270 * specified width. 271 * 272 * The specified rectangle is inclusive, that is, the top 273 * right corner specifies the top right pixel to be drawn. 274 * 275 * If usWidth > 1, the additional pixels will be drawn towards 276 * the _center_ of the rectangle. prcl thus always specifies 277 * the bottom left and top right pixels to be drawn. 278 * 279 * This is different from using GpiSetLineWidth, with which 280 * I was unable to find out in which direction lines are 281 * extended. 282 * 283 * This is similar to gpihDraw3DFrame, except that everything 284 * is painted in the current color. 285 * 286 *@@added V0.9.7 (2000-12-06) [umoeller] 287 */ 288 289 VOID gpihDrawThickFrame(HPS hps, // in: presentation space for output 290 PRECTL prcl, // in: rectangle to draw (exclusive) 291 ULONG ulWidth) // in: line width (>= 1) 292 { 293 ULONG ul = 0; 294 for (; 295 ul < ulWidth; 296 ul++) 297 { 298 GpiMove(hps, (PPOINTL)prcl); 299 GpiBox(hps, 300 DRO_OUTLINE, 301 (PPOINTL)&(prcl->xRight), 302 0, 303 0); 304 305 // and one more to the outside 306 prcl->xLeft++; 307 prcl->yBottom++; 308 prcl->xRight--; 309 prcl->yTop--; 310 } 254 311 } 255 312 … … 355 412 356 413 /* ****************************************************************** 357 * *358 * Font helpers *359 * *414 * 415 * Font helpers 416 * 360 417 ********************************************************************/ 361 418 … … 1030 1087 1031 1088 /* ****************************************************************** 1032 * *1033 * Bitmap helpers *1034 * *1089 * 1090 * Bitmap helpers 1091 * 1035 1092 ********************************************************************/ 1036 1093 -
trunk/src/helpers/helpers_post.in
r13 r14 153 153 $(PROJECTINC)\setup.h 154 154 155 $(OUTPUTDIR)\timer.obj: $(@B).c $(HLPINC)\$(@B).h \ 156 $(HLPINC)\datetime.h $(HLPINC)\except.h $(HLPINC)\linklist.h $(HLPINC)\threads.h \ 157 $(PROJECTINC)\setup.h 158 155 159 $(OUTPUTDIR)\tmsgfile.obj: $(@B).c $(HLPINC)\$(@B).h \ 156 160 $(PROJECTINC)\setup.h \ -
trunk/src/helpers/helpers_pre.in
r13 r14 80 80 $(OUTPUTDIR)\textview.obj \ 81 81 $(OUTPUTDIR)\textv_html.obj \ 82 $(OUTPUTDIR)\timer.obj \ 82 83 $(OUTPUTDIR)\winh.obj 83 84 -
trunk/src/helpers/level.c
r8 r14 16 16 * Copyright (C) 1994 Martin Lafaix (EDM/2 2-05). 17 17 * Copyright (C) 2000 Ulrich Mller. 18 * This file is part of the XWorkplacesource package.19 * XWorkplaceis free software; you can redistribute it and/or modify18 * This file is part of the "XWorkplace helpers" source package. 19 * This is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published 21 21 * by the Free Software Foundation, in version 2 as it comes in the … … 33 33 34 34 #define INCL_DOSFILEMGR 35 #define INCL_NOPMAPI36 35 #include <os2.h> 37 36 … … 54 53 55 54 /* ****************************************************************** 56 * *57 * Interface *58 * *55 * 56 * Interface 57 * 59 58 ********************************************************************/ 60 59 … … 473 472 474 473 /* ****************************************************************** 475 * *476 * Local helper functions *477 * *474 * 475 * Local helper functions 476 * 478 477 ********************************************************************/ 479 478 -
trunk/src/helpers/linklist.c
r8 r14 57 57 /* 58 58 * Copyright (C) 1997-2000 Ulrich Mller. 59 * This file is part of the XWorkplacesource package.60 * XWorkplaceis free software; you can redistribute it and/or modify59 * This file is part of the "XWorkplace helpers" source package. 60 * This is free software; you can redistribute it and/or modify 61 61 * it under the terms of the GNU General Public License as published 62 62 * by the Free Software Foundation, in version 2 as it comes in the … … 82 82 83 83 /* ****************************************************************** 84 * *85 * List base functions *86 * *84 * 85 * List base functions 86 * 87 87 ********************************************************************/ 88 89 /* 90 *@@ lstMalloc: 91 * wrapper around malloc() to make sure memory is 92 * allocated from the C runtime the helpers were 93 * compiled with. This is useful for auto-free 94 * lists. 95 * 96 *@@added V0.9.7 (2000-12-07) [umoeller] 97 */ 98 99 void* lstMalloc(size_t size) 100 { 101 return (malloc(size)); 102 } 103 104 /* 105 *@@ lstStrDup: 106 * wrapper around strdup() to make sure memory is 107 * allocated from the C runtime the helpers were 108 * compiled with. This is useful for auto-free 109 * lists. 110 * 111 *@@added V0.9.7 (2000-12-07) [umoeller] 112 */ 113 114 void* lstStrDup(const char *pcsz) 115 { 116 return (strdup(pcsz)); 117 } 88 118 89 119 /* … … 111 141 * you're storing other objects, such as numbers 112 142 * or other static items. 143 * 144 * This of course will be a "flat" free(). If 145 * you store structures in the list using other 146 * heap pointers, auto-free would cause memory leaks. 147 * 148 * Also, auto-free only works if the malloc() that 149 * has been used on the list item is in the same C 150 * runtime as with the linklist functions. If the 151 * caller uses a different runtime (e.g. from a DLL), 152 * it can use lstMalloc() for allocating the list 153 * item and still use auto-free. 113 154 * 114 155 * Note: You better call lstInit only once per list, … … 758 799 759 800 /* ****************************************************************** 760 * *761 * List sorting *762 * *801 * 802 * List sorting 803 * 763 804 ********************************************************************/ 764 805 … … 933 974 934 975 /* ****************************************************************** 935 * *936 * List pseudo-stacks *937 * *976 * 977 * List pseudo-stacks 978 * 938 979 ********************************************************************/ 939 980 -
trunk/src/helpers/memdebug.c
r13 r14 134 134 135 135 /* ****************************************************************** 136 * *137 * Global variables *138 * *136 * 137 * Global variables 138 * 139 139 ********************************************************************/ 140 140 … … 156 156 157 157 /* ****************************************************************** 158 * *159 * Debug heap management *160 * *158 * 159 * Debug heap management 160 * 161 161 ********************************************************************/ 162 162 … … 660 660 661 661 /* ****************************************************************** 662 * *663 * XFolder debugging helpers *664 * *662 * 663 * XFolder debugging helpers 664 * 665 665 ********************************************************************/ 666 666 -
trunk/src/helpers/prfh.c
r13 r14 19 19 /* 20 20 * Copyright (C) 1997-2000 Ulrich Mller. 21 * This file is part of the XWorkplacesource package.22 * XWorkplaceis free software; you can redistribute it and/or modify21 * This file is part of the "XWorkplace helpers" source package. 22 * This is free software; you can redistribute it and/or modify 23 23 * it under the terms of the GNU General Public License as published 24 24 * by the Free Software Foundation, in version 2 as it comes in the … … 35 35 // as unsigned char 36 36 37 #define INCL_DOS38 37 #define INCL_DOSERRORS 39 #define INCL_WIN 38 #define INCL_WINSHELLDATA 40 39 #include <os2.h> 41 40 … … 170 169 171 170 PSZ prfhQueryProfileData(HINI hIni, // in: INI handle (can be HINI_USER or HINI_SYSTEM) 172 PSZ pszApp,// in: application to query173 PSZ pszKey,// in: key to query174 PULONG pcbBuf) // out: size of the returned buffer171 PSZ pszApp, // in: application to query 172 PSZ pszKey, // in: key to query 173 PULONG pcbBuf) // out: size of the returned buffer; ptr can be NULL 175 174 { 176 175 PSZ pData = NULL; … … 238 237 * -- cDateSep = '/' (date separator); 239 238 * -- cTimeSep = ':' (time separator); 239 * -- cDecimal = '.' (decimal separator). 240 240 * -- cThousands = ',' (thousands separator). 241 241 * 242 242 *@@added V0.9.0 [umoeller] 243 *@@changed V0.9.7 (2000-12-02) [umoeller]: added cDecimal 243 244 */ 244 245 … … 247 248 if (pcs) 248 249 { 249 pcs->ulDateFormat = PrfQueryProfileInt(HINI_USER, "PM_National", "iDate", 0); 250 pcs->ulTimeFormat = PrfQueryProfileInt(HINI_USER, "PM_National", "iTime", 0); 251 pcs->cDateSep = prfhQueryProfileChar(HINI_USER, "PM_National", "sDate", '/'); 252 pcs->cTimeSep = prfhQueryProfileChar(HINI_USER, "PM_National", "sTime", ':'); 253 pcs->cThousands = prfhQueryProfileChar(HINI_USER, "PM_National", "sThousand", ','); 250 const char *pcszApp = "PM_National"; 251 pcs->ulDateFormat = PrfQueryProfileInt(HINI_USER, (PSZ)pcszApp, "iDate", 0); 252 pcs->ulTimeFormat = PrfQueryProfileInt(HINI_USER, (PSZ)pcszApp, "iTime", 0); 253 pcs->cDateSep = prfhQueryProfileChar(HINI_USER, (PSZ)pcszApp, "sDate", '/'); 254 pcs->cTimeSep = prfhQueryProfileChar(HINI_USER, (PSZ)pcszApp, "sTime", ':'); 255 pcs->cDecimal = prfhQueryProfileChar(HINI_USER, (PSZ)pcszApp, "sDecimal", '.'); 256 pcs->cThousands = prfhQueryProfileChar(HINI_USER, (PSZ)pcszApp, "sThousand", ','); 254 257 } 255 258 } -
trunk/src/helpers/prfh2.c
r13 r14 24 24 /* 25 25 * Copyright (C) 1997-2000 Ulrich Mller. 26 * This file is part of the XWorkplacesource package.27 * XWorkplaceis free software; you can redistribute it and/or modify26 * This file is part of the "XWorkplace helpers" source package. 27 * This is free software; you can redistribute it and/or modify 28 28 * it under the terms of the GNU General Public License as published 29 29 * by the Free Software Foundation, in version 2 as it comes in the … … 40 40 // as unsigned char 41 41 42 #define INCL_DOS43 42 #define INCL_DOSERRORS 44 #define INCL_WIN 43 #define INCL_WINSHELLDATA 45 44 #include <os2.h> 46 45 -
trunk/src/helpers/procstat.c
r13 r14 34 34 * Copyright (C) 1992-1994 Kai Uwe Rommel. 35 35 * Copyright (C) 1998-2000 Ulrich Mller. 36 * This file is part of the XWorkplacesource package.37 * XWorkplaceis free software; you can redistribute it and/or modify36 * This file is part of the "XWorkplace helpers" source package. 37 * This is free software; you can redistribute it and/or modify 38 38 * it under the terms of the GNU General Public License as published 39 39 * by the Free Software Foundation, in version 2 as it comes in the … … 50 50 // as unsigned char 51 51 52 #define INCL_DOS 52 #define INCL_DOSMODULEMGR 53 53 #define INCL_DOSERRORS 54 #define INCL_DOSMODULEMGR55 54 #include <os2.h> 56 55 … … 70 69 71 70 /******************************************************************** 72 * *73 * DosQProcStat (16-bit) interface *74 * *71 * 72 * DosQProcStat (16-bit) interface 73 * 75 74 ********************************************************************/ 76 75 … … 196 195 197 196 /******************************************************************** 198 * *199 * DosQProcStat (16-bit) helpers *200 * *197 * 198 * DosQProcStat (16-bit) helpers 199 * 201 200 ********************************************************************/ 202 201 … … 439 438 440 439 /******************************************************************** 441 * *442 * DosQuerySysState (32-bit) interface *443 * *440 * 441 * DosQuerySysState (32-bit) interface 442 * 444 443 ********************************************************************/ 445 444 -
trunk/src/helpers/resh.c
r8 r14 34 34 // as unsigned char 35 35 36 #define INCL_DOSMODULEMGR 37 #define INCL_DOSRESOURCES 36 38 #define INCL_DOSERRORS 37 #define INCL_DOS38 #define INCL_DOS39 39 #include <os2.h> 40 40 -
trunk/src/helpers/shapewin.c
r8 r14 167 167 * Akira Hatakeyama, 168 168 * Takayuki Suwa. 169 * This file is part of the XWorkplacesource package.170 * XWorkplaceis free software; you can redistribute it and/or modify169 * This file is part of the "XWorkplace helpers" source package. 170 * This is free software; you can redistribute it and/or modify 171 171 * it under the terms of the GNU General Public License as published 172 172 * by the Free Software Foundation, in version 2 as it comes in the … … 184 184 // as unsigned char 185 185 186 #define INCL_DOS187 186 #define INCL_DOSERRORS 188 #define INCL_WIN 187 188 #define INCL_WINWINDOWMGR 189 #define INCL_WINFRAMEMGR 190 #define INCL_WINDIALOGS 191 #define INCL_WININPUT 192 #define INCL_WINPOINTERS 189 193 #define INCL_WINSYS 194 #define INCL_WINRECTANGLES 195 #define INCL_WINTRACKRECT 196 190 197 #define INCL_GPILOGCOLORTABLE 191 198 #define INCL_GPIPRIMITIVES … … 209 216 210 217 /* ****************************************************************** 211 * *212 * Global variables *213 * *218 * 219 * Global variables 220 * 214 221 ********************************************************************/ 215 222 … … 217 224 218 225 /* ****************************************************************** 219 * *220 * Part 1: Shape window functions *221 * *226 * 227 * Part 1: Shape window functions 228 * 222 229 ********************************************************************/ 223 230 … … 515 522 HPS hps ; 516 523 517 pRgn = (PSHPREGION) 524 pRgn = (PSHPREGION)WinQueryWindowPtr(hwnd, 0); 518 525 519 526 switch (msg) … … 1216 1223 case WM_QUERYDLGCODE: 1217 1224 // TRACE("WM_QUERYDLGCODE\n"); 1218 return (MRESULT) 1225 return (MRESULT)DLGC_STATIC; 1219 1226 1220 1227 /* … … 1295 1302 1296 1303 /* ****************************************************************** 1297 * *1298 * Part 2: Shape frame functions *1299 * *1304 * 1305 * Part 2: Shape frame functions 1306 * 1300 1307 ********************************************************************/ 1301 1308 -
trunk/src/helpers/stringh.c
r13 r14 25 25 * Copyright (C) 1997-2000 Ulrich Mller. 26 26 * Parts Copyright (C) 1991-1999 iMatix Corporation. 27 * This file is part of the XWorkplacesource package.28 * XWorkplaceis free software; you can redistribute it and/or modify27 * This file is part of the "XWorkplace helpers" source package. 28 * This is free software; you can redistribute it and/or modify 29 29 * it under the terms of the GNU General Public License as published 30 30 * by the Free Software Foundation, in version 2 as it comes in the … … 1709 1709 1710 1710 /* ****************************************************************** 1711 * *1712 * Miscellaneous *1713 * *1711 * 1712 * Miscellaneous 1713 * 1714 1714 ********************************************************************/ 1715 1715 … … 1742 1742 1743 1743 VOID strhArrayAppend(PSZ *ppszRoot, // in: root of array 1744 PSZ pszNew,// in: string to append1744 const char *pcszNew, // in: string to append 1745 1745 PULONG pcbRoot) // in/out: size of array 1746 1746 { 1747 ULONG cbNew = strlen(p szNew);1747 ULONG cbNew = strlen(pcszNew); 1748 1748 PSZ pszTemp = (PSZ)malloc(*pcbRoot 1749 1749 + cbNew … … 1759 1759 // append new string 1760 1760 strcpy(pszTemp + *pcbRoot, 1761 p szNew);1761 pcszNew); 1762 1762 // update root 1763 1763 *ppszRoot = pszTemp; … … 1859 1859 1860 1860 /* ****************************************************************** 1861 * *1862 * Wildcard matching *1863 * *1861 * 1862 * Wildcard matching 1863 * 1864 1864 ********************************************************************/ 1865 1865 … … 2457 2457 2458 2458 /* ****************************************************************** 2459 * *2460 * Fast string searches *2461 * *2459 * 2460 * Fast string searches 2461 * 2462 2462 ********************************************************************/ 2463 2463 -
trunk/src/helpers/textv_html.c
r13 r14 59 59 60 60 /* ****************************************************************** 61 * *62 * Declarations *63 * *61 * 62 * Declarations 63 * 64 64 ********************************************************************/ 65 65 … … 150 150 151 151 /* ****************************************************************** 152 * *153 * Global variables *154 * *152 * 153 * Global variables 154 * 155 155 ********************************************************************/ 156 156 157 157 /* ****************************************************************** 158 * *159 * Append-char helpers *160 * *158 * 159 * Append-char helpers 160 * 161 161 ********************************************************************/ 162 162 … … 299 299 300 300 /* ****************************************************************** 301 * *302 * Tag converter functions *303 * *301 * 302 * Tag converter functions 303 * 304 304 ********************************************************************/ 305 305 … … 885 885 886 886 /* ****************************************************************** 887 * *888 * Tag helpers *889 * *887 * 888 * Tag helpers 889 * 890 890 ********************************************************************/ 891 891 … … 1972 1972 1973 1973 /* ****************************************************************** 1974 * *1975 * Entry points *1976 * *1974 * 1975 * Entry points 1976 * 1977 1977 ********************************************************************/ 1978 1978 -
trunk/src/helpers/textview.c
r13 r14 252 252 253 253 /* ****************************************************************** 254 * *255 * Device-independent functions *256 * *254 * 255 * Device-independent functions 256 * 257 257 ********************************************************************/ 258 258 … … 466 466 467 467 /* ****************************************************************** 468 * *469 * Device-independent text formatting *470 * *468 * 469 * Device-independent text formatting 470 * 471 471 ********************************************************************/ 472 472 … … 1400 1400 1401 1401 /* ****************************************************************** 1402 * *1403 * Device-independent text painting *1404 * *1402 * 1403 * Device-independent text painting 1404 * 1405 1405 ********************************************************************/ 1406 1406 … … 1806 1806 1807 1807 /* ****************************************************************** 1808 * *1809 * Window-dependent functions *1810 * *1808 * 1809 * Window-dependent functions 1810 * 1811 1811 ********************************************************************/ 1812 1812 … … 3180 3180 3181 3181 /* ****************************************************************** 3182 * *3183 * Printer-dependent functions *3184 * *3182 * 3183 * Printer-dependent functions 3184 * 3185 3185 ********************************************************************/ 3186 3186 -
trunk/src/helpers/threads.c
r8 r14 24 24 /* 25 25 * Copyright (C) 1997-2000 Ulrich Mller. 26 * This file is part of the XWorkplacesource package.27 * XWorkplaceis free software; you can redistribute it and/or modify26 * This file is part of the "XWorkplace helpers" source package. 27 * This is free software; you can redistribute it and/or modify 28 28 * it under the terms of the GNU General Public License as published 29 29 * by the Free Software Foundation, in version 2 as it comes in the … … 102 102 ((PTHREADFUNC)pti->pThreadFunc)(pti); 103 103 104 if (pti->flFlags & THRF_WAIT) 105 // "Wait" flag set: delete semaphore 106 DosCloseEventSem(pti->hevRunning); 107 104 108 // thread func returns: 105 109 pti->fExitComplete = TRUE; 106 110 pti->tid = NULLHANDLE; 107 108 if (pti->flFlags & THRF_WAIT)109 // "Wait" flag set: delete semaphore110 DosCloseEventSem(pti->hevRunning);111 111 112 112 if (pti->pfRunning) -
trunk/src/helpers/tmsgfile.c
r13 r14 50 50 * Copyright (C) 1999 Christian Langanke. 51 51 * Copyright (C) 1999-2000 Ulrich Mller. 52 * This file is part of the XWorkplacesource package.53 * XWorkplaceis free software; you can redistribute it and/or modify52 * This file is part of the "XWorkplace helpers" source package. 53 * This is free software; you can redistribute it and/or modify 54 54 * it under the terms of the GNU General Public License as published 55 55 * by the Free Software Foundation, in version 2 as it comes in the … … 66 66 // as unsigned char 67 67 68 #define INCL_DOS 69 #define INCL_ERRORS 68 #define INCL_DOSFILEMGR 69 #define INCL_DOSMISC 70 #define INCL_DOSNLS 71 #define INCL_DOSERRORS 70 72 #include <os2.h> 71 73 … … 85 87 86 88 /* ****************************************************************** 87 * *88 * Declarations *89 * *89 * 90 * Declarations 91 * 90 92 ********************************************************************/ 91 93 … … 111 113 112 114 /* ****************************************************************** 113 * *114 * Text Message File Code *115 * *115 * 116 * Text Message File Code 117 * 116 118 ********************************************************************/ 117 119 -
trunk/src/helpers/tree.c
r13 r14 89 89 * Copyright (C) 1991-99 iMatix Corporation. 90 90 * Copyright (C) 2000 Ulrich Mller. 91 * This file is part of the XWorkplacesource package.92 * XWorkplaceis free software; you can redistribute it and/or modify91 * This file is part of the "XWorkplace helpers" source package. 92 * This is free software; you can redistribute it and/or modify 93 93 * it under the terms of the GNU General Public License as published 94 94 * by the Free Software Foundation, in version 2 as it comes in the -
trunk/src/helpers/winh.c
r13 r14 20 20 /* 21 21 * Copyright (C) 1997-2000 Ulrich Mller. 22 * This file is part of the XWorkplacesource package.23 * XWorkplaceis free software; you can redistribute it and/or modify22 * This file is part of the "XWorkplace helpers" source package. 23 * This is free software; you can redistribute it and/or modify 24 24 * it under the terms of the GNU General Public License as published 25 25 * by the Free Software Foundation, in version 2 as it comes in the … … 36 36 // as unsigned char 37 37 38 #define INCL_DOSPROCESS 39 #define INCL_DOSMODULEMGR 40 #define INCL_DOSSEMAPHORES 41 #define INCL_DOSDEVICES 38 42 #define INCL_DOSDEVIOCTL 39 #define INCL_DOS40 43 #define INCL_DOSERRORS 41 #define INCL_WIN 42 #define INCL_GPI 43 44 // spooler #include's 45 #define INCL_BASE 44 45 #define INCL_WINWINDOWMGR 46 #define INCL_WINMESSAGEMGR 47 #define INCL_WINFRAMEMGR 48 #define INCL_WININPUT 49 #define INCL_WINDIALOGS 50 #define INCL_WINPOINTERS 51 #define INCL_WINRECTANGLES 52 #define INCL_WINSHELLDATA 53 #define INCL_WINSYS 54 #define INCL_WINHELP 55 #define INCL_WINPROGRAMLIST 56 #define INCL_WINSWITCHLIST 57 #define INCL_WINMENUS 58 #define INCL_WINSCROLLBARS 59 #define INCL_WINLISTBOXES 60 #define INCL_WINSTDSPIN 61 #define INCL_WINSTDSLIDER 62 #define INCL_WINCIRCULARSLIDER 63 #define INCL_WINSTDFILE 64 46 65 #define INCL_SPL 47 66 #define INCL_SPLDOSPRINT 48 67 #define INCL_SPLERRORS 49 68 69 #define INCL_GPIBITMAPS 70 #define INCL_GPIPRIMITIVES 50 71 #include <os2.h> 51 72 … … 69 90 70 91 /* ****************************************************************** 71 * *72 * Menu helpers *73 * *92 * 93 * Menu helpers 94 * 74 95 ********************************************************************/ 75 96 … … 255 276 * not found. 256 277 * 257 * If something != NULL is returned, you258 * should free() the buffer afterwards.278 * Returns NULL on error. Use winhFree() 279 * to free the return value. 259 280 * 260 281 * Use the WinSetMenuItemText macro to … … 387 408 388 409 /* ****************************************************************** 389 * *390 * Slider helpers *391 * *410 * 411 * Slider helpers 412 * 392 413 ********************************************************************/ 393 414 … … 791 812 792 813 /* ****************************************************************** 793 * *794 * Spin button helpers *795 * *814 * 815 * Spin button helpers 816 * 796 817 ********************************************************************/ 797 818 … … 896 917 897 918 /* ****************************************************************** 898 * *899 * List box helpers *900 * *919 * 920 * List box helpers 921 * 901 922 ********************************************************************/ 902 923 … … 905 926 * returns the text of the specified 906 927 * list box item in a newly allocated 907 * buffer, which you should free() afterwards, 908 * or NULL upon errors. 928 * buffer. 929 * 930 * Returns NULL on error. Use winhFree() 931 * to free the return value. 909 932 * 910 933 *@@added V0.9.1 (99-12-14) [umoeller] … … 1025 1048 1026 1049 /* ****************************************************************** 1027 * *1028 * Scroll bar helpers *1029 * *1050 * 1051 * Scroll bar helpers 1052 * 1030 1053 ********************************************************************/ 1031 1054 … … 1503 1526 1504 1527 /* ****************************************************************** 1505 * *1506 * Window positioning helpers *1507 * *1528 * 1529 * Window positioning helpers 1530 * 1508 1531 ********************************************************************/ 1509 1532 … … 1916 1939 1917 1940 /* 1941 *@@ winhFindWindowBelow: 1942 * finds the window with the same parent 1943 * which sits right below hwndFind in the 1944 * window Z-order. 1945 * 1946 *@@added V0.9.7 (2000-12-04) [umoeller] 1947 */ 1948 1949 HWND winhFindWindowBelow(HWND hwndFind) 1950 { 1951 HWND hwnd = NULLHANDLE, 1952 hwndParent = WinQueryWindow(hwndFind, QW_PARENT); 1953 1954 if (hwndParent) 1955 { 1956 HENUM henum = WinBeginEnumWindows(hwndParent); 1957 HWND hwndThis; 1958 while (hwndThis = WinGetNextWindow(henum)) 1959 { 1960 SWP swp; 1961 WinQueryWindowPos(hwndThis, &swp); 1962 if (swp.hwndInsertBehind == hwndFind) 1963 { 1964 hwnd = hwndThis; 1965 break; 1966 } 1967 } 1968 WinEndEnumWindows(henum); 1969 } 1970 1971 return (hwnd); 1972 } 1973 1974 /* 1918 1975 *@@category: Helpers\PM helpers\Presentation parameters 1919 1976 */ 1920 1977 1921 1978 /* ****************************************************************** 1922 * *1923 * Presparams helpers *1924 * *1979 * 1980 * Presparams helpers 1981 * 1925 1982 ********************************************************************/ 1926 1983 … … 1928 1985 *@@ winhQueryWindowFont: 1929 1986 * returns the window font presentation parameter 1930 * in a newly allocated buffer, which you must 1931 * free() afterwards. Returns NULL if not found. 1987 * in a newly allocated buffer. 1988 * 1989 * Returns NULL on error. Use winhFree() 1990 * to free the return value. 1932 1991 * 1933 1992 *@@added V0.9.1 (2000-02-14) [umoeller] … … 1966 2025 1967 2026 BOOL winhSetWindowFont(HWND hwnd, 1968 PSZ pszFont)2027 const char *pcszFont) 1969 2028 { 1970 2029 CHAR szFont[256]; 1971 2030 1972 if (p szFont == NULL)2031 if (pcszFont == NULL) 1973 2032 { 1974 2033 if (doshIsWarp4()) … … 1978 2037 } 1979 2038 else 1980 strhncpy0(szFont, p szFont, sizeof(szFont));2039 strhncpy0(szFont, pcszFont, sizeof(szFont)); 1981 2040 1982 2041 return (WinSetPresParam(hwnd, … … 2060 2119 * Use free() on your PPRESPARAMS pointer (whose 2061 2120 * address was passed) after WinCreateWindow. 2121 * 2122 * See winhQueryPresColor for typical presparams 2123 * used in OS/2. 2062 2124 * 2063 2125 * Example: … … 2139 2201 * 3) if this fails or (fInherit == FALSE), WinQuerySysColor 2140 2202 * is called to get lSysColor (which should be a SYSCLR_* 2141 * index). 2203 * index), if lSysColor != -1; 2204 * 4) if (lSysColor == -1), -1 is returned. 2142 2205 * 2143 2206 * The return value is always an RGB LONG, _not_ a color index. … … 2205 2268 *@@changed V0.9.0 [umoeller]: removed INI key query, using SYSCLR_* instead; function prototype changed 2206 2269 *@@changed V0.9.0 [umoeller]: added fInherit parameter 2270 *@@changed V0.9.7 (2000-12-02) [umoeller]: added lSysColor == -1 support 2207 2271 */ 2208 2272 … … 2229 2293 2230 2294 // not found: get system color 2231 return (WinQuerySysColor(HWND_DESKTOP, lSysColor, 0)); 2295 if (lSysColor != -1) 2296 return (WinQuerySysColor(HWND_DESKTOP, lSysColor, 0)); 2297 2298 return -1; 2232 2299 } 2233 2300 … … 2237 2304 2238 2305 /* ****************************************************************** 2239 * *2240 * Help instance helpers *2241 * *2306 * 2307 * Help instance helpers 2308 * 2242 2309 ********************************************************************/ 2243 2310 … … 2760 2827 2761 2828 /* ****************************************************************** 2762 * *2763 * Miscellaneous *2764 * *2829 * 2830 * Miscellaneous 2831 * 2765 2832 ********************************************************************/ 2833 2834 /* 2835 *@@ winhFree: 2836 * frees a block of memory allocated by the 2837 * winh* functions. 2838 * 2839 * Since the winh* functions use malloc(), 2840 * you can also use free() directly on such 2841 * blocks. However, you must use winhFree 2842 * if the winh* functions are in a module 2843 * with a different C runtime. 2844 * 2845 *@@added V0.9.7 (2000-12-06) [umoeller] 2846 */ 2847 2848 VOID winhFree(PVOID p) 2849 { 2850 if (p) 2851 free(p); 2852 } 2766 2853 2767 2854 /* … … 2930 3017 *@@ winhQueryWindowText: 2931 3018 * this returns the window text of the specified 2932 * HWND in a newly allocated buffer , which has2933 * the exact size of the window text.2934 * 2935 * This buffer must be free()'d later.3019 * HWND in a newly allocated buffer. 3020 * 3021 * Returns NULL on error. Use winhFree() 3022 * to free the return value. 2936 3023 */ 2937 3024 … … 3058 3145 *@@added V0.9.0 [umoeller] 3059 3146 *@@changed V0.9.5 (2000-08-13) [umoeller]: flStyleClient never worked, fixed 3147 *@@changed V0.9.7 (2000-12-08) [umoeller]: fixed client calc for invisible window 3060 3148 */ 3061 3149 … … 3119 3207 3120 3208 // position client 3121 WinQueryWindowRect(hwndFrame, &rclClient); 3122 WinCalcFrameRect(hwndFrame, &rclClient, 3209 // WinQueryWindowRect(hwndFrame, &rclClient); 3210 // doesn't work because it might be invisible V0.9.7 (2000-12-08) [umoeller] 3211 rclClient.xLeft = 0; 3212 rclClient.yBottom = 0; 3213 rclClient.xRight = pswpFrame->cx; 3214 rclClient.yTop = pswpFrame->cy; 3215 WinCalcFrameRect(hwndFrame, 3216 &rclClient, 3123 3217 TRUE); // calc client from frame 3124 3218 WinSetWindowPos(*phwndClient, … … 3515 3609 3516 3610 /* 3611 *@@ winhQuerySwitchList: 3612 * returns the switch list in a newly 3613 * allocated buffer. This does the 3614 * regular double WinQuerySwitchList 3615 * call to first get the no. of items 3616 * and then get the items. 3617 * 3618 * The no. of items can be found in 3619 * the returned SWBLOCK.cwsentry. 3620 * 3621 * Returns NULL on errors. Use 3622 * winhFree to free the return value. 3623 * 3624 *@@added V0.9.7 (2000-12-06) [umoeller] 3625 */ 3626 3627 PSWBLOCK winhQuerySwitchList(HAB hab) 3628 { 3629 ULONG cItems = WinQuerySwitchList(hab, NULL, 0); 3630 ULONG ulBufSize = (cItems * sizeof(SWENTRY)) + sizeof(HSWITCH); 3631 PSWBLOCK pSwBlock = (PSWBLOCK)malloc(ulBufSize); 3632 if (pSwBlock) 3633 { 3634 cItems = WinQuerySwitchList(hab, pSwBlock, ulBufSize); 3635 if (!cItems) 3636 { 3637 free(pSwBlock); 3638 pSwBlock = NULL; 3639 } 3640 } 3641 3642 return (pSwBlock); 3643 } 3644 3645 /* 3646 *@@ winhQueryTasklistWindow: 3647 * returns the window handle of the PM task list. 3648 * 3649 *@@added V0.9.7 (2000-12-07) [umoeller] 3650 */ 3651 3652 HWND winhQueryTasklistWindow(VOID) 3653 { 3654 SWBLOCK swblock; 3655 HWND hwndTasklist = winhQueryTasklistWindow(); 3656 // the tasklist has entry #0 in the SWBLOCK 3657 WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK)); 3658 return (swblock.aswentry[0].swctl.hwnd); 3659 } 3660 3661 /* 3517 3662 *@@ winhKillTasklist: 3518 3663 * this will destroy the Tasklist (window list) window. … … 3525 3670 VOID winhKillTasklist(VOID) 3526 3671 { 3527 SWBLOCK swblock; 3528 HWND hwndTasklist; 3529 // the tasklist has entry #0 in the SWBLOCK 3530 WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK)); 3531 hwndTasklist = swblock.aswentry[0].swctl.hwnd; 3672 HWND hwndTasklist = winhQueryTasklistWindow(); 3532 3673 WinPostMsg(hwndTasklist, 3533 3674 0x0454, // undocumented msg for killing tasklist … … 3695 3836 3696 3837 /* ****************************************************************** 3697 * *3698 * WPS Class List helpers *3699 * *3838 * 3839 * WPS Class List helpers 3840 * 3700 3841 ********************************************************************/ 3701 3842 … … 3712 3853 * See WinEnumObjectClasses() for details. 3713 3854 * 3714 * The buffer is allocated using malloc(), so 3715 * you should free() it when it is no longer 3716 * needed. 3717 * 3718 * This returns NULL if an error occured. 3855 * Returns NULL on error. Use winhFree() 3856 * to free the return value. 3719 3857 * 3720 3858 *@@added V0.9.0 [umoeller] -
trunk/src/helpers/wphandle.c
r8 r14 24 24 * This file Copyright (C) 1997-2000 Ulrich Mller, 25 25 * Henk Kelder. 26 * This file is part of the XWorkplacesource package.27 * XWorkplaceis free software; you can redistribute it and/or modify26 * This file is part of the "XWorkplace helpers" source package. 27 * This is free software; you can redistribute it and/or modify 28 28 * it under the terms of the GNU General Public License as published 29 29 * by the Free Software Foundation, in version 2 as it comes in the … … 40 40 // as unsigned char 41 41 42 #define INCL_DOS43 42 #define INCL_WINSHELLDATA 44 43 #include <os2.h> … … 73 72 74 73 /* ****************************************************************** 75 * *76 * Helper functions *77 * *74 * 75 * Helper functions 76 * 78 77 ********************************************************************/ 79 78 … … 281 280 282 281 /* ****************************************************************** 283 * *284 * Get HOBJECT from filename *285 * *282 * 283 * Get HOBJECT from filename 284 * 286 285 ********************************************************************/ 287 286 … … 521 520 522 521 /* ****************************************************************** 523 * *524 * Get filename from HOBJECT *525 * *522 * 523 * Get filename from HOBJECT 524 * 526 525 ********************************************************************/ 527 526 … … 640 639 641 640 /* ****************************************************************** 642 * *643 * Manipulation functions *644 * *641 * 642 * Manipulation functions 643 * 645 644 ********************************************************************/ 646 645 -
trunk/src/helpers/xml.c
r13 r14 46 46 /* 47 47 * Copyright (C) 2000 Ulrich Mller. 48 * This file is part of the XWorkplacesource package.49 * XWorkplaceis free software; you can redistribute it and/or modify48 * This file is part of the "XWorkplace helpers" source package. 49 * This is free software; you can redistribute it and/or modify 50 50 * it under the terms of the GNU General Public License as published 51 51 * by the Free Software Foundation, in version 2 as it comes in the -
trunk/src/helpers/xprf.c
r8 r14 75 75 /* 76 76 * Copyright (C) 2000 Ulrich Mller. 77 * This file is part of the XWorkplacesource package.78 * XWorkplaceis free software; you can redistribute it and/or modify77 * This file is part of the "XWorkplace helpers" source package. 78 * This is free software; you can redistribute it and/or modify 79 79 * it under the terms of the GNU General Public License as published 80 80 * by the Free Software Foundation, in version 2 as it comes in the … … 91 91 // as unsigned char 92 92 93 #define INCL_DOS94 93 #define INCL_DOSERRORS 95 94 #define INCL_WINSHELLDATA … … 113 112 114 113 /* ****************************************************************** 115 * *116 * Declarations *117 * *114 * 115 * Declarations 116 * 118 117 ********************************************************************/ 119 118 … … 143 142 144 143 /* ****************************************************************** 145 * *146 * Helpers *147 * *144 * 145 * Helpers 146 * 148 147 ********************************************************************/ 149 148 … … 352 351 353 352 /* ****************************************************************** 354 * *355 * Read/write data *356 * *353 * 354 * Read/write data 355 * 357 356 ********************************************************************/ 358 357 … … 670 669 671 670 /* ****************************************************************** 672 * *673 * API Functions *674 * *671 * 672 * API Functions 673 * 675 674 ********************************************************************/ 676 675 -
trunk/src/helpers/xprf2.c
r12 r14 22 22 /* 23 23 * Copyright (C) 2000 Ulrich Mller. 24 * This file is part of the XWorkplacesource package.25 * XWorkplaceis free software; you can redistribute it and/or modify24 * This file is part of the "XWorkplace helpers" source package. 25 * This is free software; you can redistribute it and/or modify 26 26 * it under the terms of the GNU General Public License as published 27 27 * by the Free Software Foundation, in version 2 as it comes in the … … 38 38 // as unsigned char 39 39 40 #define INCL_DOS41 40 #define INCL_DOSERRORS 42 41 #define INCL_WINSHELLDATA … … 61 60 62 61 /* ****************************************************************** 63 * *64 * Copy API Functions *65 * *62 * 63 * Copy API Functions 64 * 66 65 ********************************************************************/ 67 66 -
trunk/src/helpers/xstring.c
r13 r14 85 85 /* 86 86 * Copyright (C) 1999-2000 Ulrich Mller. 87 * This file is part of the XWorkplacesource package.88 * XWorkplaceis free software; you can redistribute it and/or modify87 * This file is part of the "XWorkplace helpers" source package. 88 * This is free software; you can redistribute it and/or modify 89 89 * it under the terms of the GNU General Public License as published 90 90 * by the Free Software Foundation, in version 2 as it comes in the
Note:
See TracChangeset
for help on using the changeset viewer.