Changeset 41
- Timestamp:
- Mar 3, 2001, 11:58:48 AM (24 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/animate.h
r17 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/ansiscrn.h
r7 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/cnrh.h
r35 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/comctl.h
r29 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/datetime.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/debug.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/dosh.h
r40 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/except.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/linklist.h
r38 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/lvm.h
r14 r41 43 43 44 44 /* A BYTE is 8 bits of memory with no interpretation attached. */ 45 typedef unsigned char BYTE;45 // typedef unsigned char BYTE; 46 46 47 47 /* A BOOLEAN variable is one which is either TRUE or FALSE. */ 48 48 typedef unsigned char BOOLEAN; 49 #define TRUE 150 #define FALSE 0; 49 /* #define TRUE 1 50 #define FALSE 0; */ 51 51 52 52 /* An ADDRESS variable is one which holds the address of a location in memory. */ 53 typedef void * ADDRESS;53 // typedef void * ADDRESS; 54 54 55 55 /* pSTRING is a pointer to an array of characters. */ … … 57 57 58 58 /* 4 bytes */ 59 typedef unsigned long DoubleWord;59 // typedef unsigned long DoubleUSHORT; 60 60 61 61 /* 2 bytes */ 62 typedef short unsigned int Word;62 // typedef short unsigned int USHORT; 63 63 64 64 /* Define a Partition Sector Number. A Partition Sector Number is relative to the start of a partition. … … 93 93 typedef struct _Partition_Record 94 94 { 95 B yteBoot_Indicator; /* 80h = active partition. */96 B yteStarting_Head;97 B yteStarting_Sector; /* Bits 0-5 are the sector. Bits 6 and 7 are the high95 BYTE Boot_Indicator; /* 80h = active partition. */ 96 BYTE Starting_Head; 97 BYTE Starting_Sector; /* Bits 0-5 are the sector. Bits 6 and 7 are the high 98 98 order bits of the starting cylinder. */ 99 B yteStarting_Cylinder; /* The cylinder number is a 10 bit value. The high order99 BYTE Starting_Cylinder; /* The cylinder number is a 10 bit value. The high order 100 100 bits of the 10 bit value come from bits 6 & 7 of the 101 101 Starting_Sector field. */ 102 B yteFormat_Indicator; /* An indicator of the format/operation system on this102 BYTE Format_Indicator; /* An indicator of the format/operation system on this 103 103 partition. */ 104 B yteEnding_Head;105 B yteEnding_Sector;106 B yteEnding_Cylinder;107 DoubleWordSector_Offset; /* The number of sectors on the disk which are prior to104 BYTE Ending_Head; 105 BYTE Ending_Sector; 106 BYTE Ending_Cylinder; 107 ULONG Sector_Offset; /* The number of sectors on the disk which are prior to 108 108 the start of this partition. */ 109 DoubleWordSector_Count; /* The number of sectors in this partition. */109 ULONG Sector_Count; /* The number of sectors in this partition. */ 110 110 } Partition_Record; 111 111 112 112 typedef struct _Master_Boot_Record 113 113 { 114 B yteReserved[446];114 BYTE Reserved[446]; 115 115 Partition_Record Partition_Table[4]; 116 WordSignature; /* AA55h in this field indicates that this116 USHORT Signature; /* AA55h in this field indicates that this 117 117 is a valid partition table/MBR. */ 118 118 } Master_Boot_Record; … … 201 201 typedef struct _DLA_Entry 202 202 { 203 DoubleWordVolume_Serial_Number; /* The serial number of the volume203 ULONG Volume_Serial_Number; /* The serial number of the volume 204 204 that this partition belongs to. */ 205 DoubleWordPartition_Serial_Number; /* The serial number of this partition. */206 DoubleWordPartition_Size; /* The size of the partition, in sectors. */205 ULONG Partition_Serial_Number; /* The serial number of this partition. */ 206 ULONG Partition_Size; /* The size of the partition, in sectors. */ 207 207 LBA Partition_Start; /* The starting sector of the partition. */ 208 208 BOOLEAN On_Boot_Manager_Menu; /* Set to TRUE if this volume/partition … … 221 221 typedef struct _DLA_Table_Sector 222 222 { 223 DoubleWordDLA_Signature1; /* The magic signature (part 1) of a223 ULONG DLA_Signature1; /* The magic signature (part 1) of a 224 224 Drive Letter Assignment Table. */ 225 DoubleWordDLA_Signature2; /* The magic signature (part 2) of a225 ULONG DLA_Signature2; /* The magic signature (part 2) of a 226 226 Drive Letter Assignment Table. */ 227 DoubleWordDLA_CRC; /* The 32 bit CRC for this sector.227 ULONG DLA_CRC; /* The 32 bit CRC for this sector. 228 228 Calculated assuming that this 229 229 field and all unused space in 230 230 the sector is 0. */ 231 DoubleWordDisk_Serial_Number; /* The serial number assigned to231 ULONG Disk_Serial_Number; /* The serial number assigned to 232 232 this disk. */ 233 DoubleWordBoot_Disk_Serial_Number; /* The serial number of the disk used to233 ULONG Boot_Disk_Serial_Number; /* The serial number of the disk used to 234 234 boot the system. This is for conflict 235 235 resolution when multiple volumes want … … 298 298 typedef struct _LVM_Feature_Data 299 299 { 300 DoubleWordFeature_ID; /* The ID of the feature. */300 ULONG Feature_ID; /* The ID of the feature. */ 301 301 PSN Location_Of_Primary_Feature_Data; /* The PSN of the starting sector of 302 302 the private data for this feature.*/ … … 304 304 the backup copy of the private 305 305 data for this feature. */ 306 DoubleWordFeature_Data_Size; /* The number of sectors used by this306 ULONG Feature_Data_Size; /* The number of sectors used by this 307 307 feature for its private data. */ 308 WordFeature_Major_Version_Number; /* The integer portion of the version308 USHORT Feature_Major_Version_Number; /* The integer portion of the version 309 309 number of this feature. */ 310 WordFeature_Minor_Version_Number; /* The decimal portion of the version310 USHORT Feature_Minor_Version_Number; /* The decimal portion of the version 311 311 number of this feature. */ 312 312 BOOLEAN Feature_Active; /* TRUE if this feature is active on … … 322 322 that it is a part of, as well as which LVM features (BBR, drive linking, 323 323 etc.) are active on the volume that this partition is a part of. */ 324 324 #if 0 325 325 typedef struct _LVM_Signature_Sector 326 326 { 327 DoubleWordLVM_Signature1; /* The first part of the327 ULONG LVM_Signature1; /* The first part of the 328 328 magic LVM signature. */ 329 DoubleWordLVM_Signature2; /* The second part of329 ULONG LVM_Signature2; /* The second part of 330 330 the magic LVM 331 331 signature. */ 332 DoubleWordSignature_Sector_CRC; /* 32 bit CRC for this332 ULONG Signature_Sector_CRC; /* 32 bit CRC for this 333 333 sector. Calculated 334 334 using 0 for this 335 335 field. */ 336 DoubleWordPartition_Serial_Number; /* The LVM assigned336 ULONG Partition_Serial_Number; /* The LVM assigned 337 337 serial number for this 338 338 partition. */ … … 342 342 LBA Partition_End; /* LBA of the last sector 343 343 of this partition. */ 344 DoubleWordPartition_Sector_Count; /* The number of sectors344 ULONG Partition_Sector_Count; /* The number of sectors 345 345 in this partition. */ 346 DoubleWordLVM_Reserved_Sector_Count; /* The number of sectors346 ULONG LVM_Reserved_Sector_Count; /* The number of sectors 347 347 reserved for use by 348 348 LVM. */ 349 DoubleWordPartition_Size_To_Report_To_User; /* The size of the349 ULONG Partition_Size_To_Report_To_User; /* The size of the 350 350 partition as the user 351 351 sees it - i.e. (the … … 355 355 rounded to a track 356 356 boundary. */ 357 DoubleWordBoot_Disk_Serial_Number; /* The serial number of357 ULONG Boot_Disk_Serial_Number; /* The serial number of 358 358 the boot disk for the 359 359 system. If the system … … 364 364 active copy of Boot 365 365 Manager. */ 366 DoubleWordVolume_Serial_Number; /* The serial number of366 ULONG Volume_Serial_Number; /* The serial number of 367 367 the volume that this 368 368 partition belongs to.*/ … … 370 370 of a Fake EBR, if one 371 371 has been allocated. */ 372 WordLVM_Major_Version_Number; /* Major version number372 USHORT LVM_Major_Version_Number; /* Major version number 373 373 of the LVM that 374 374 created this 375 375 partition. */ 376 WordLVM_Minor_Version_Number; /* Minor version number376 USHORT LVM_Minor_Version_Number; /* Minor version number 377 377 of the LVM that 378 378 created this … … 401 401 else the CRC will not come out correctly. */ 402 402 } LVM_Signature_Sector; 403 #endif 403 404 404 405 /* ****************************************************************** … … 527 528 CARDINAL32 Drive_Number; /* OS/2 Drive Number for this drive. */ 528 529 CARDINAL32 Drive_Size; /* The total number of sectors on the drive. */ 529 DoubleWordDrive_Serial_Number; /* The serial number assigned to this drive.530 ULONG Drive_Serial_Number; /* The serial number assigned to this drive. 530 531 For info. purposes only. */ 531 ADDRESSDrive_Handle; /* Handle used for operations on the disk that532 PVOID Drive_Handle; /* Handle used for operations on the disk that 532 533 this record corresponds to. */ 533 534 CARDINAL32 Cylinder_Count; /* The number of cylinders on the drive. */ … … 570 571 typedef struct _Partition_Information_Record 571 572 { 572 ADDRESSPartition_Handle; /* The handle used to perform573 PVOID Partition_Handle; /* The handle used to perform 573 574 operations on this partition. */ 574 ADDRESSVolume_Handle; /* If this partition is part575 PVOID Volume_Handle; /* If this partition is part 575 576 of a volume, this will be the 576 577 handle of the volume. If … … 578 579 part of a volume, then 579 580 this handle will be 0. */ 580 ADDRESSDrive_Handle; /* The handle for the drive581 PVOID Drive_Handle; /* The handle for the drive 581 582 this partition resides on. */ 582 DoubleWordPartition_Serial_Number; /* The serial number assigned583 ULONG Partition_Serial_Number; /* The serial number assigned 583 584 to this partition. */ 584 585 CARDINAL32 Partition_Start; /* The LBA of the first … … 703 704 typedef struct _Volume_Control_Record 704 705 { 705 DoubleWordVolume_Serial_Number; /* The serial number assigned to this volume. */706 ADDRESSVolume_Handle; /* The handle used to perform operations on this volume. */706 ULONG Volume_Serial_Number; /* The serial number assigned to this volume. */ 707 PVOID Volume_Handle; /* The handle used to perform operations on this volume. */ 707 708 BOOLEAN Compatibility_Volume; /* TRUE indicates that this volume is compatible with older versions of OS/2. 708 709 FALSE indicates that this is an LVM specific volume and can not be used without OS2LVM.DMD. */ … … 746 747 typedef struct _Boot_Manager_Menu_Item 747 748 { 748 ADDRESSHandle; /* A Volume or Partition handle. */749 PVOID Handle; /* A Volume or Partition handle. */ 749 750 BOOLEAN Volume; /* If TRUE, then Handle is the handle of a Volume. Otherwise, Handle is the handle of a partition. */ 750 751 } Boot_Manager_Menu_Item; … … 997 998 * Input: 998 999 * 999 * -- ADDRESSDrive_Handle: The handle of the drive to use.1000 * -- PVOID Drive_Handle: The handle of the drive to use. 1000 1001 * Drive handles are obtained through the 1001 1002 * Get_Drive_Control_Data function. … … 1013 1014 */ 1014 1015 1015 Drive_Information_Record _System Get_Drive_Status( ADDRESSDrive_Handle, CARDINAL32 * Error_Code );1016 Drive_Information_Record _System Get_Drive_Status( PVOID Drive_Handle, CARDINAL32 * Error_Code ); 1016 1017 1017 1018 /* ****************************************************************** … … 1028 1029 * Input: 1029 1030 * 1030 * -- ADDRESSHandle: This is the handle of a drive or volume.1031 * -- PVOID Handle: This is the handle of a drive or volume. 1031 1032 * Drive handles are obtained through the 1032 1033 * Get_Drive_Control_Data function. Volume … … 1073 1074 */ 1074 1075 1075 Partition_Information_Array _System Get_Partitions( ADDRESSHandle, CARDINAL32 * Error_Code );1076 Partition_Information_Array _System Get_Partitions( PVOID Handle, CARDINAL32 * Error_Code ); 1076 1077 1077 1078 /* … … 1100 1101 */ 1101 1102 1102 ADDRESS_System Get_Partition_Handle( CARDINAL32 Serial_Number, CARDINAL32 * Error_Code );1103 PVOID _System Get_Partition_Handle( CARDINAL32 Serial_Number, CARDINAL32 * Error_Code ); 1103 1104 1104 1105 /* … … 1109 1110 * Input: 1110 1111 * 1111 * -- ADDRESSPartition_Handle:1112 * -- PVOID Partition_Handle: 1112 1113 * The handle associated with the partition for which the 1113 1114 * Partition_Information_Record is desired. … … 1124 1125 */ 1125 1126 1126 Partition_Information_Record _System Get_Partition_Information( ADDRESSPartition_Handle, CARDINAL32 * Error_Code );1127 Partition_Information_Record _System Get_Partition_Information( PVOID Partition_Handle, CARDINAL32 * Error_Code ); 1127 1128 1128 1129 /* … … 1132 1133 * Input: 1133 1134 * 1134 * -- ADDRESSHandle: The handle of a disk drive or a block1135 * -- PVOID Handle: The handle of a disk drive or a block 1135 1136 * of free space. 1136 1137 * … … 1184 1185 */ 1185 1186 1186 ADDRESS _System Create_Partition( ADDRESSHandle,1187 PVOID _System Create_Partition( PVOID Handle, 1187 1188 CARDINAL32 Size, 1188 1189 char Name[ PARTITION_NAME_SIZE ], … … 1200 1201 * Input: 1201 1202 * 1202 * -- ADDRESSPartition_Handle: The handle associated with the*1203 * -- PVOID Partition_Handle: The handle associated with the* 1203 1204 * partition to be deleted. 1204 1205 * … … 1222 1223 */ 1223 1224 1224 void _System Delete_Partition( ADDRESSPartition_Handle, CARDINAL32 * Error_Code );1225 void _System Delete_Partition( PVOID Partition_Handle, CARDINAL32 * Error_Code ); 1225 1226 1226 1227 /* … … 1230 1231 * Input: 1231 1232 * 1232 * -- ADDRESSPartition_Handle: The handle of the partition1233 * -- PVOID Partition_Handle: The handle of the partition 1233 1234 * whose Active Flag is to be set. 1234 1235 * … … 1257 1258 */ 1258 1259 1259 void _System Set_Active_Flag ( ADDRESSPartition_Handle,1260 void _System Set_Active_Flag ( PVOID Partition_Handle, 1260 1261 BYTE Active_Flag, 1261 1262 CARDINAL32 * Error_Code … … 1271 1272 * Input: 1272 1273 * 1273 * -- ADDRESSPartition_Handle: The handle of the partition1274 * -- PVOID Partition_Handle: The handle of the partition 1274 1275 * whose Active Flag is to be set. 1275 1276 * -- BYTE OS_Flag - The new value for the OS Flag. … … 1298 1299 */ 1299 1300 1300 void _System Set_OS_Flag ( ADDRESSPartition_Handle,1301 void _System Set_OS_Flag ( PVOID Partition_Handle, 1301 1302 BYTE OS_Flag, 1302 1303 CARDINAL32 * Error_Code … … 1357 1358 * Input: 1358 1359 * 1359 * -- ADDRESSVolume_Handle: The handle of the volume about1360 * -- PVOID Volume_Handle: The handle of the volume about 1360 1361 * which information is desired. 1361 1362 * … … 1373 1374 */ 1374 1375 1375 Volume_Information_Record _System Get_Volume_Information( ADDRESSVolume_Handle, CARDINAL32 * Error_Code );1376 Volume_Information_Record _System Get_Volume_Information( PVOID Volume_Handle, CARDINAL32 * Error_Code ); 1376 1377 1377 1378 /* … … 1398 1399 * link together to form the volume being created. 1399 1400 * 1400 * -- ADDRESSPartition_Handles[]: An array of partition handles1401 * -- PVOID Partition_Handles[]: An array of partition handles 1401 1402 * with one entry for each partition that is to become part 1402 1403 * of the volume being created. … … 1430 1431 CARDINAL32 FeaturesToUse, 1431 1432 CARDINAL32 Partition_Count, 1432 ADDRESSPartition_Handles[],1433 PVOID Partition_Handles[], 1433 1434 CARDINAL32 * Error_Code 1434 1435 ); … … 1440 1441 * Input: 1441 1442 * 1442 * -- ADDRESSVolume_Handle: The handle of the volume to1443 * -- PVOID Volume_Handle: The handle of the volume to 1443 1444 * delete. All partitions which are 1444 1445 * part of the specified volume will … … 1470 1471 */ 1471 1472 1472 void _System Delete_Volume( ADDRESSVolume_Handle, CARDINAL32 * Error_Code );1473 void _System Delete_Volume( PVOID Volume_Handle, CARDINAL32 * Error_Code ); 1473 1474 1474 1475 /* … … 1480 1481 * Input: 1481 1482 * 1482 * -- ADDRESSVolume_Handle: The handle of the volume to hide.1483 * -- PVOID Volume_Handle: The handle of the volume to hide. 1483 1484 * 1484 1485 * Output: … … 1498 1499 */ 1499 1500 1500 void _System Hide_Volume( ADDRESSVolume_Handle, CARDINAL32 * Error_Code );1501 void _System Hide_Volume( PVOID Volume_Handle, CARDINAL32 * Error_Code ); 1501 1502 1502 1503 /* … … 1506 1507 * Input: 1507 1508 * 1508 * -- ADDRESSVolume_Handle: The handle of the volume to be1509 * -- PVOID Volume_Handle: The handle of the volume to be 1509 1510 * expanded. 1510 1511 * … … 1512 1513 * volumes to be added to the volume being expanded. 1513 1514 * 1514 * -- ADDRESSPartition_Handles[] - An array of handles. Each1515 * -- PVOID Partition_Handles[] - An array of handles. Each 1515 1516 * handle in the array is the handle of a partition which 1516 1517 * is to be added to the volume being expanded. … … 1549 1550 */ 1550 1551 1551 void _System Expand_Volume ( ADDRESSVolume_Handle,1552 void _System Expand_Volume ( PVOID Volume_Handle, 1552 1553 CARDINAL32 Partition_Count, 1553 ADDRESSPartition_Handles[],1554 PVOID Partition_Handles[], 1554 1555 CARDINAL32 * Error_Code 1555 1556 ); … … 1561 1562 * Input: 1562 1563 * 1563 * -- ADDRESSVolume_Handle: The handle of the volume which1564 * -- PVOID Volume_Handle: The handle of the volume which 1564 1565 * is to have its assigned drive letter changed. 1565 1566 * … … 1591 1592 */ 1592 1593 1593 void _System Assign_Drive_Letter( ADDRESSVolume_Handle,1594 void _System Assign_Drive_Letter( PVOID Volume_Handle, 1594 1595 char New_Drive_Preference, 1595 1596 CARDINAL32 * Error_Code … … 1602 1603 * Input: 1603 1604 * 1604 * -- ADDRESSVolume_Handle: The handle of the volume to which1605 * -- PVOID Volume_Handle: The handle of the volume to which 1605 1606 * OS/2 should be installed. 1606 1607 * … … 1622 1623 */ 1623 1624 1624 void _System Set_Installable ( ADDRESSVolume_Handle, CARDINAL32 * Error_Code );1625 void _System Set_Installable ( PVOID Volume_Handle, CARDINAL32 * Error_Code ); 1625 1626 1626 1627 /* … … 1650 1651 * Input: 1651 1652 * 1652 * -- ADDRESSHandle: The handle of the drive, partition, or1653 * -- PVOID Handle: The handle of the drive, partition, or 1653 1654 * volume which is to have its name set. 1654 1655 * … … 1670 1671 */ 1671 1672 1672 void _System Set_Name ( ADDRESSHandle,1673 void _System Set_Name ( PVOID Handle, 1673 1674 char New_Name[], 1674 1675 CARDINAL32 * Error_Code … … 1685 1686 * Input: 1686 1687 * 1687 * -- ADDRESSHandle: The handle of the partition or volume1688 * -- PVOID Handle: The handle of the partition or volume 1688 1689 * which is to be set startable. 1689 1690 * … … 1707 1708 */ 1708 1709 1709 void _System Set_Startable ( ADDRESSHandle,1710 void _System Set_Startable ( PVOID Handle, 1710 1711 CARDINAL32 * Error_Code 1711 1712 ); … … 1722 1723 * Input: 1723 1724 * 1724 * -- ADDRESSHandle: This is any valid drive, volume, or1725 * -- PVOID Handle: This is any valid drive, volume, or 1725 1726 * partition handle. 1726 1727 * … … 1745 1746 */ 1746 1747 1747 CARDINAL32 _System Get_Valid_Options( ADDRESSHandle, CARDINAL32 * Error_Code );1748 CARDINAL32 _System Get_Valid_Options( PVOID Handle, CARDINAL32 * Error_Code ); 1748 1749 1749 1750 /* ****************************************************************** … … 1775 1776 * Input: 1776 1777 * 1777 * -- ADDRESSHandle: The handle of a partition or volume that1778 * -- PVOID Handle: The handle of a partition or volume that 1778 1779 * is to be added to the Boot Manager menu. 1779 1780 * … … 1800 1801 */ 1801 1802 1802 void _System Add_To_Boot_Manager ( ADDRESSHandle, CARDINAL32 * Error_Code );1803 void _System Add_To_Boot_Manager ( PVOID Handle, CARDINAL32 * Error_Code ); 1803 1804 1804 1805 /* … … 1827 1828 */ 1828 1829 1829 void _System Remove_From_Boot_Manager ( ADDRESSHandle, CARDINAL32 * Error_Code );1830 void _System Remove_From_Boot_Manager ( PVOID Handle, CARDINAL32 * Error_Code ); 1830 1831 1831 1832 /* … … 1916 1917 * Input: 1917 1918 * 1918 * -- ADDRESSHandle - The handle of the partition or volume1919 * -- PVOID Handle - The handle of the partition or volume 1919 1920 * to boot if the time-out timer is active and the time-out 1920 1921 * value is reached. … … 1945 1946 */ 1946 1947 1947 void _System Set_Boot_Manager_Options( ADDRESSHandle,1948 void _System Set_Boot_Manager_Options( PVOID Handle, 1948 1949 BOOLEAN Timer_Active, 1949 1950 CARDINAL32 Time_Out_Value, … … 1959 1960 * Input: 1960 1961 * 1961 * -- ADDRESS* Handle - The handle for the default boot1962 * -- PVOID * Handle - The handle for the default boot 1962 1963 * volume or partition. 1963 1964 * … … 1992 1993 */ 1993 1994 1994 void _System Get_Boot_Manager_Options( ADDRESS* Handle,1995 void _System Get_Boot_Manager_Options( PVOID * Handle, 1995 1996 BOOLEAN * Handle_Is_Volume, 1996 1997 BOOLEAN * Timer_Active, … … 2013 2014 * Input: 2014 2015 * 2015 * -- ADDRESSObject: The address of the memory object to2016 * -- PVOID Object: The address of the memory object to 2016 2017 * free. This could be the Drive_Control_Data field of 2017 2018 * a Drive_Control_Record, the Partition_Array field of … … 2026 2027 */ 2027 2028 2028 void _System Free_Engine_Memory( ADDRESSObject );2029 void _System Free_Engine_Memory( PVOID Object ); 2029 2030 2030 2031 /* … … 2034 2035 * Input: 2035 2036 * 2036 * -- ADDRESSDrive_Handle - The handle of the drive on which2037 * -- PVOID Drive_Handle - The handle of the drive on which 2037 2038 * the new MBR is to be placed. 2038 2039 * … … 2054 2055 */ 2055 2056 2056 void _System New_MBR( ADDRESSDrive_Handle, CARDINAL32 * Error_Code );2057 void _System New_MBR( PVOID Drive_Handle, CARDINAL32 * Error_Code ); 2057 2058 2058 2059 /* … … 2252 2253 * read into memory. 2253 2254 * 2254 * -- ADDRESSBuffer : The location to put the data read into.2255 * -- PVOID Buffer : The location to put the data read into. 2255 2256 * 2256 2257 * Output: … … 2274 2275 LBA Starting_Sector, 2275 2276 CARDINAL32 Sectors_To_Read, 2276 ADDRESSBuffer,2277 PVOID Buffer, 2277 2278 CARDINAL32 * Error); 2278 2279 … … 2293 2294 * be written. 2294 2295 * 2295 * -- ADDRESSBuffer : The location of the data to be written2296 * -- PVOID Buffer : The location of the data to be written 2296 2297 * to disk. 2297 2298 * … … 2316 2317 LBA Starting_Sector, 2317 2318 CARDINAL32 Sectors_To_Write, 2318 ADDRESSBuffer,2319 PVOID Buffer, 2319 2320 CARDINAL32 * Error); 2320 2321 -
trunk/include/helpers/pmprintf.h
r7 r41 1 /* $Id$ */2 3 1 /*---------------------------------------------------------------------------+ 4 2 | -
trunk/include/helpers/prfh.h
r33 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/procstat.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/resh.h
r7 r41 1 /* $Id$ */2 1 3 2 /* -
trunk/include/helpers/shapewin.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/stringh.h
r38 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/syssound.h
r14 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/threads.h
r33 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/timer.h
r14 r41 31 31 #define TIMER_HEADER_INCLUDED 32 32 33 USHORT APIENTRY tmrStartTimer(HWND hwnd, USHORT usTimerID, ULONG ulTimeout); 34 typedef USHORT APIENTRY TMRSTARTTIMER(HWND hwnd, USHORT usTimerID, ULONG ulTimeout); 35 typedef TMRSTARTTIMER *PTMRSTARTTIMER; 33 /* 34 *@@ XTIMERSET: 35 * 36 *@@added V0.9.9 (2001-02-28) [umoeller] 37 */ 36 38 37 BOOL APIENTRY tmrStopTimer(HWND hwnd, USHORT usTimerID); 38 typedef BOOL APIENTRY TMRSTOPTIMER(HWND hwnd, USHORT usTimerID); 39 typedef TMRSTOPTIMER *PTMRSTOPTIMER; 39 typedef struct _XTIMERSET 40 { 41 HAB hab; 42 HWND hwndOwner; // owner of XTimers (who has the PM timer) 43 USHORT idPMTimer; // ID of main PM timer 44 USHORT idPMTimerRunning; // if != 0, PM timer is running 45 PVOID pvllXTimers; // linked list of current XTIMER structures, auto-free 46 } XTIMERSET, *PXTIMERSET; 40 47 41 VOID tmrStopAllTimers(HWND hwnd); 42 typedef VOID TMRSTOPALLTIMERS(HWND hwnd); 43 typedef TMRSTOPALLTIMERS *PTMRSTOPALLTIMERS; 48 PXTIMERSET XWPENTRY tmrCreateSet(HWND hwndOwner, USHORT usPMTimerID); 49 typedef PXTIMERSET XWPENTRY TMRCREATESET(HWND hwndOwner, USHORT usPMTimerID); 50 typedef TMRCREATESET *PTMRCREATESET; 51 52 VOID XWPENTRY tmrDestroySet(PXTIMERSET pSet); 53 typedef VOID XWPENTRY TMRDESTROYSET(PXTIMERSET pSet); 54 typedef TMRDESTROYSET *PTMRDESTROYSET; 55 56 USHORT XWPENTRY tmrStartXTimer(PXTIMERSET pSet, HWND hwnd, USHORT usTimerID, ULONG ulTimeout); 57 typedef USHORT XWPENTRY TMRSTARTXTIMER(PXTIMERSET pSet, HWND hwnd, USHORT usTimerID, ULONG ulTimeout); 58 typedef TMRSTARTXTIMER *PTMRSTARTXTIMER; 59 60 BOOL XWPENTRY tmrStopXTimer(PXTIMERSET pSet, HWND hwnd, USHORT usTimerID); 61 typedef BOOL XWPENTRY TMRSTOPXTIMER(PXTIMERSET pSet, HWND hwnd, USHORT usTimerID); 62 typedef TMRSTOPXTIMER *PTMRSTOPXTIMER; 63 64 VOID XWPENTRY tmrTimerTick(PXTIMERSET pSet); 65 typedef VOID XWPENTRY TMRTIMERTICK(PXTIMERSET pSet); 66 typedef TMRTIMERTICK *PTMRTIMERTICK; 44 67 45 68 #endif -
trunk/include/helpers/tmsgfile.h
r7 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/undoc.h
r15 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/winh.h
r31 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/wphandle.h
r29 r41 1 /* $Id$ */2 3 1 4 2 /* -
trunk/include/helpers/wpsdebug.h
r7 r41 1 /* $Id$ */2 3 1 /*---------------------------------------------------------------------------+ 4 2 | -
trunk/include/helpers/xstring.h
r38 r41 161 161 typedef XSTRFINDREPLACEC *PXSTRFINDREPLACEC; 162 162 163 ULONG XWPENTRY xstrEncode(PXSTRING pxstr, const char *pcszEncode); 164 typedef ULONG XWPENTRY XSTRENCODE(PXSTRING pxstr, const char *pcszEncode); 165 typedef XSTRENCODE *PXSTRENCODE; 166 167 ULONG XWPENTRY xstrDecode(PXSTRING pxstr); 168 typedef ULONG XWPENTRY XSTRDECODE(PXSTRING pxstr); 169 typedef XSTRDECODE *PXSTRDECODE; 170 163 171 // V0.9.9 (2001-01-29) [lafaix]: constants added 164 172 #define CRLF2LF TRUE -
trunk/src/helpers/timer.c
r21 r41 2 2 /* 3 3 *@@sourcefile timer.c: 4 * XTimers, which can replace the PM timers. 4 * XTimers, which can be used to avoid excessive PM 5 * timer usage. 5 6 * 6 7 * These timers operate similar to PM timers started … … 9 10 * WM_TIMER messages regularly. 10 11 * 11 * Instead of WinStartTimer, use tmrStart Timer.12 * Instead of WinStopTimer, use tmrStop Timer.12 * Instead of WinStartTimer, use tmrStartXTimer. 13 * Instead of WinStopTimer, use tmrStopXTimer. 13 14 * 14 15 * The main advantage of the XTimers is that these … … 75 76 #define INCL_DOSERRORS 76 77 78 #define INCL_WINWINDOWMGR 77 79 #define INCL_WINMESSAGEMGR 80 #define INCL_WINTIMER 78 81 #include <os2.h> 79 82 … … 108 111 typedef struct _XTIMER 109 112 { 110 USHORT usTimerID; // timer ID, as passed to tmrStart Timer111 HWND hwndTarget; // target window, as passed to tmrStart Timer113 USHORT usTimerID; // timer ID, as passed to tmrStartXTimer 114 HWND hwndTarget; // target window, as passed to tmrStartXTimer 112 115 ULONG ulTimeout; // timer's timeout (in ms) 113 116 ULONG ulNextFire; // next time scalar (from dtGetULongTime) to fire at … … 121 124 122 125 // timers thread 123 HMTX G_hmtxTimers = NULLHANDLE; // timers lock mutex124 THREADINFO G_tiTimers = {0}; // timers thread (only running126 // HMTX G_hmtxTimers = NULLHANDLE; // timers lock mutex 127 // THREADINFO G_tiTimers = {0}; // timers thread (only running 125 128 // if any timers were requested) 126 BOOL G_fTimersThreadRunning = FALSE; 127 LINKLIST G_llTimers; // linked list of XTIMER pointers 128 129 /* ****************************************************************** 130 * 131 * Timer helpers 132 * 133 ********************************************************************/ 134 135 /* 136 *@@ LockTimers: 137 * locks the global timer resources. 138 * You MUST call UnlockTimers after this. 139 */ 140 141 BOOL LockTimers(VOID) 142 { 143 BOOL brc = FALSE; 144 if (G_hmtxTimers == NULLHANDLE) 145 { 146 // this initializes all globals 147 lstInit(&G_llTimers, 148 TRUE); // auto-free 149 150 brc = (DosCreateMutexSem(NULL, // unnamed 151 &G_hmtxTimers, 152 0, // unshared 153 TRUE) // lock! 154 == NO_ERROR); 155 } 156 else 157 brc = (WinRequestMutexSem(G_hmtxTimers, SEM_INDEFINITE_WAIT) 158 == NO_ERROR); 159 return (brc); 160 } 161 162 /* 163 *@@ UnlockTimers: 164 * the reverse to LockTimers. 165 */ 166 167 VOID UnlockTimers(VOID) 168 { 169 DosReleaseMutexSem(G_hmtxTimers); 170 } 129 // BOOL G_fTimersThreadRunning = FALSE; 130 // LINKLIST G_llTimers; // linked list of XTIMER pointers 171 131 172 132 /* … … 177 137 * 178 138 * This thread is dynamically started when the 179 * first timer is started thru tmrStart Timer.139 * first timer is started thru tmrStartXTimer. 180 140 * It is automatically stopped (to be precise: 181 141 * it terminates itself) when the last timer 182 * is stopped thru tmrStop Timer, which then142 * is stopped thru tmrStopXTimer, which then 183 143 * sets the thread's fExit flag to TRUE. 184 144 * … … 186 146 */ 187 147 188 void _Optlink fntTimersThread(PTHREADINFO ptiMyself)148 /* void _Optlink fntTimersThread(PTHREADINFO ptiMyself) 189 149 { 190 150 ULONG ulInterval = 25; … … 225 185 if (fLocked) 226 186 { 227 // go thru all XTimers and see which one228 // has elapsed; for all of these, post WM_TIMER229 // to the target window proc230 PLISTNODE pTimerNode = lstQueryFirstNode(&G_llTimers);231 if (!pTimerNode)232 // no more timers left:233 // terminate thread234 ptiMyself->fExit = TRUE;235 else236 {237 // we have timers:238 BOOL fFoundInvalid = FALSE;239 240 // get current time241 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT,242 &ulTimeNow, sizeof(ulTimeNow));243 244 while ((pTimerNode) && (!ptiMyself->fExit))245 {246 PXTIMER pTimer = (PXTIMER)pTimerNode->pItemData;247 248 if (pTimer->ulNextFire < ulTimeNow)249 {250 // this timer has elapsed:251 // fire!252 if (WinIsWindow(hab,253 pTimer->hwndTarget))254 {255 // window still valid:256 WinPostMsg(pTimer->hwndTarget,257 WM_TIMER,258 (MPARAM)pTimer->usTimerID,259 0);260 pTimer->ulNextFire = ulTimeNow + pTimer->ulTimeout;261 }262 else263 {264 // window has been destroyed:265 #ifdef __DEBUG__266 DosBeep(100, 100);267 #endif268 lstAppendItem(&llInvalidTimers,269 (PVOID)pTimerNode);270 fFoundInvalid = TRUE;271 }272 } // end if (pTimer->ulNextFire < ulTimeNow)273 274 // adjust DosSleep interval275 if (pTimer->ulTimeout < ulInterval)276 ulInterval = pTimer->ulTimeout;277 278 // next timer279 pTimerNode = pTimerNode->pNext;280 } // end while (pTimerNode)281 282 // destroy invalid timers, if any283 if ((fFoundInvalid) && (!ptiMyself->fExit))284 {285 PLISTNODE pNodeNode = lstQueryFirstNode(&llInvalidTimers);286 while (pNodeNode)287 {288 PLISTNODE pNode2Remove = (PLISTNODE)pNodeNode->pItemData;289 lstRemoveNode(&G_llTimers,290 pNode2Remove);291 pNodeNode = pNodeNode->pNext;292 }293 lstClear(&llInvalidTimers);294 }295 } // end else if (!pTimerNode)296 187 } // end if (fLocked) 297 188 } … … 313 204 DosBeep(1500, 30); 314 205 #endif 315 } 206 } */ 207 208 /* ****************************************************************** 209 * 210 * Private functions 211 * 212 ********************************************************************/ 316 213 317 214 /* … … 322 219 * 323 220 * Internal function. 324 * 325 * Preconditions: 326 * 327 * -- The caller must call LockTimers() first. 328 */ 329 330 PXTIMER FindTimer(HWND hwnd, 221 */ 222 223 PXTIMER FindTimer(PXTIMERSET pSet, 224 HWND hwnd, 331 225 USHORT usTimerID) 332 226 { 333 PLISTNODE pNode = lstQueryFirstNode(&G_llTimers); 334 while (pNode) 335 { 336 PXTIMER pTimer = (PXTIMER)pNode->pItemData; 337 if ( (pTimer->usTimerID == usTimerID) 338 && (pTimer->hwndTarget == hwnd) 339 ) 227 if (pSet && pSet->pvllXTimers) 228 { 229 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 230 PLISTNODE pNode = lstQueryFirstNode(pllXTimers); 231 while (pNode) 340 232 { 341 return (pTimer); 233 PXTIMER pTimer = (PXTIMER)pNode->pItemData; 234 if ( (pTimer->usTimerID == usTimerID) 235 && (pTimer->hwndTarget == hwnd) 236 ) 237 { 238 return (pTimer); 239 } 240 241 pNode = pNode->pNext; 342 242 } 343 344 pNode = pNode->pNext;345 243 } 244 346 245 return (NULL); 347 246 } … … 359 258 */ 360 259 361 VOID RemoveTimer(PXTIMER pTimer) 362 { 363 lstRemoveItem(&G_llTimers, 364 pTimer); // auto-free! 365 /* if (lstCountItems(&G_llTimers) == 0) 366 // no more timers left: 367 // stop the main timer 368 thrClose(&G_tiTimers); */ 260 VOID RemoveTimer(PXTIMERSET pSet, 261 PXTIMER pTimer) 262 { 263 if (pSet && pSet->pvllXTimers) 264 { 265 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 266 lstRemoveItem(pllXTimers, 267 pTimer); // auto-free! 268 /* if (lstCountItems(&G_llTimers) == 0) 269 // no more timers left: 270 // stop the main timer 271 thrClose(&G_tiTimers); */ 272 } 369 273 } 370 274 371 /* 372 *@@ tmrStartTimer: 275 /* ****************************************************************** 276 * 277 * Exported functions 278 * 279 ********************************************************************/ 280 281 /* 282 *@@ tmrCreateSet: 283 * creates a "timer set" for use with the XTimer functions. 284 * This is the first step if you want to use the XTimers. 285 * 286 * Use tmrDestroySet to free all resources again. 287 * 288 *@@added V0.9.9 (2001-02-28) [umoeller] 289 */ 290 291 PXTIMERSET tmrCreateSet(HWND hwndOwner, 292 USHORT usPMTimerID) 293 { 294 PXTIMERSET pSet = NULL; 295 296 // _Pmpf((__FUNCTION__ ": entering")); 297 298 pSet = (PXTIMERSET)malloc(sizeof(*pSet)); 299 if (pSet) 300 { 301 pSet->hab = WinQueryAnchorBlock(hwndOwner); 302 pSet->hwndOwner = hwndOwner; 303 pSet->idPMTimer = usPMTimerID; 304 pSet->idPMTimerRunning = 0; 305 306 pSet->pvllXTimers = (PVOID)lstCreate(TRUE); 307 } 308 309 // _Pmpf((__FUNCTION__ ": leaving, returning 0x%lX", pSet)); 310 311 return (pSet); 312 } 313 314 /* 315 *@@ tmrDestroySet: 316 * destroys a timer set previously created using 317 * tmrCreateSet. 318 * 319 * Of course, this will stop all XTimers which 320 * might still be running with this set. 321 * 322 *@@added V0.9.9 (2001-02-28) [umoeller] 323 */ 324 325 VOID tmrDestroySet(PXTIMERSET pSet) 326 { 327 // _Pmpf((__FUNCTION__ ": entering")); 328 329 if (pSet) 330 { 331 if (pSet->pvllXTimers) 332 { 333 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 334 335 PLISTNODE pTimerNode; 336 337 while (pTimerNode = lstQueryFirstNode(pllXTimers)) 338 { 339 PXTIMER pTimer = (PXTIMER)pTimerNode->pItemData; 340 RemoveTimer(pSet, pTimer); 341 } 342 343 lstFree(pllXTimers); 344 } 345 346 free(pSet); 347 } 348 349 // _Pmpf((__FUNCTION__ ": leaving")); 350 } 351 352 /* 353 *@@ tmrTimerTick: 354 * implements a PM timer tick. 355 * 356 * When your window procs receives WM_TIMER for the 357 * one PM timer which is supposed to trigger all the 358 * XTimers, it must call this function. This will 359 * evaluate all XTimers on the list and "fire" them 360 * by calling the window procs directly with the 361 * WM_TIMER message. 362 * 363 *@@added V0.9.9 (2001-02-28) [umoeller] 364 */ 365 366 VOID tmrTimerTick(PXTIMERSET pSet) 367 { 368 // _Pmpf((__FUNCTION__ ": entering")); 369 370 if (pSet && pSet->pvllXTimers) 371 { 372 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 373 // go thru all XTimers and see which one 374 // has elapsed; for all of these, post WM_TIMER 375 // to the target window proc 376 PLISTNODE pTimerNode = lstQueryFirstNode(pllXTimers); 377 378 // stop the PM timer for now; we'll restart it later 379 WinStopTimer(pSet->hab, 380 pSet->hwndOwner, 381 pSet->idPMTimer); 382 pSet->idPMTimerRunning = 0; 383 384 if (pTimerNode) 385 { 386 // we have timers: 387 BOOL fFoundInvalid = FALSE; 388 389 ULONG ulInterval = 100, 390 ulTimeNow = 0; 391 392 // linked list of timers found to be invalid; 393 // this holds LISTNODE pointers from the global 394 // list to be removed 395 LINKLIST llInvalidTimers; 396 lstInit(&llInvalidTimers, 397 FALSE); // no auto-free 398 399 // get current time 400 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, 401 &ulTimeNow, sizeof(ulTimeNow)); 402 403 while (pTimerNode) 404 { 405 PXTIMER pTimer = (PXTIMER)pTimerNode->pItemData; 406 407 if (pTimer->ulNextFire < ulTimeNow) 408 { 409 // this timer has elapsed: 410 // fire! 411 if (WinIsWindow(pSet->hab, 412 pTimer->hwndTarget)) 413 { 414 // window still valid: 415 // get the window's window proc 416 PFNWP pfnwp = (PFNWP)WinQueryWindowPtr(pTimer->hwndTarget, 417 QWP_PFNWP); 418 // call the window proc DIRECTLY 419 pfnwp(pTimer->hwndTarget, 420 WM_TIMER, 421 (MPARAM)pTimer->usTimerID, 422 0); 423 pTimer->ulNextFire = ulTimeNow + pTimer->ulTimeout; 424 } 425 else 426 { 427 // window has been destroyed: 428 lstAppendItem(&llInvalidTimers, 429 (PVOID)pTimerNode); 430 fFoundInvalid = TRUE; 431 } 432 } // end if (pTimer->ulNextFire < ulTimeNow) 433 434 // adjust DosSleep interval 435 if (pTimer->ulTimeout < ulInterval) 436 ulInterval = pTimer->ulTimeout; 437 438 // next timer 439 pTimerNode = pTimerNode->pNext; 440 } // end while (pTimerNode) 441 442 // destroy invalid timers, if any 443 if (fFoundInvalid) 444 { 445 PLISTNODE pNodeNode = lstQueryFirstNode(&llInvalidTimers); 446 while (pNodeNode) 447 { 448 PLISTNODE pNode2Remove = (PLISTNODE)pNodeNode->pItemData; 449 lstRemoveNode(pllXTimers, 450 pNode2Remove); 451 pNodeNode = pNodeNode->pNext; 452 } 453 lstClear(&llInvalidTimers); 454 } 455 456 if (lstCountItems(pllXTimers)) 457 { 458 // any timers left: 459 // restart timer with the timeout calculated above 460 pSet->idPMTimerRunning = WinStartTimer(pSet->hab, 461 pSet->hwndOwner, 462 pSet->idPMTimer, 463 ulInterval); 464 /* _Pmpf((" %d timers left, restarted PM timer == %d, interval %d", 465 lstCountItems(pllXTimers), 466 pSet->idPMTimerRunning, 467 ulInterval)); 468 _Pmpf((" pSet->hab: 0x%lX, hwndOwner = 0x%lX, usPMTimerID = %d", 469 pSet->hab, 470 pSet->hwndOwner, 471 pSet->idPMTimer)); */ 472 } 473 } // end else if (!pTimerNode) 474 } 475 476 // _Pmpf((__FUNCTION__ ": leaving")); 477 } 478 479 /* 480 *@@ tmrStartXTimer: 373 481 * starts an XTimer. 374 482 * … … 380 488 * Returns a new timer or resets an existing 381 489 * timer (if usTimerID is already used with 382 * hwnd). Use tmrStop Timer to stop the timer.490 * hwnd). Use tmrStopXTimer to stop the timer. 383 491 * 384 492 * The timer is _not_ stopped automatically … … 388 496 */ 389 497 390 USHORT APIENTRY tmrStartTimer(HWND hwnd, 391 USHORT usTimerID, 392 ULONG ulTimeout) 498 USHORT XWPENTRY tmrStartXTimer(PXTIMERSET pSet, 499 HWND hwnd, 500 USHORT usTimerID, 501 ULONG ulTimeout) 393 502 { 394 503 USHORT usrc = 0; 395 BOOL fLocked = FALSE; 396 397 if ((hwnd) && (ulTimeout)) 398 {399 ULONG ulNesting = 0;400 DosEnterMustComplete(&ulNesting);401 402 TRY_LOUD(excpt1)504 505 // _Pmpf((__FUNCTION__ ": entering")); 506 507 if (pSet && pSet->pvllXTimers) 508 { 509 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 510 511 if ((hwnd) && (ulTimeout)) 403 512 { 404 fLocked = LockTimers(); 405 if (fLocked) 406 { 407 PXTIMER pTimer; 408 409 // if the timers thread is not yet running, 410 // start it now (i.e. this is the first timer) 411 if (!G_fTimersThreadRunning) 412 { 413 // main timer not yet running: 414 thrCreate(&G_tiTimers, 415 fntTimersThread, 416 &G_fTimersThreadRunning, 417 THRF_WAIT, // no msgq, but wait 418 0); 419 // raise priority 420 DosSetPriority(PRTYS_THREAD, 421 PRTYC_REGULAR, // 3 422 PRTYD_MAXIMUM, 423 G_tiTimers.tid); 424 } 425 426 // check if this timer exists already 427 pTimer = FindTimer(hwnd, 428 usTimerID); 513 PXTIMER pTimer; 514 515 // check if this timer exists already 516 pTimer = FindTimer(pSet, 517 hwnd, 518 usTimerID); 519 if (pTimer) 520 { 521 // exists already: reset only 522 ULONG ulTimeNow; 523 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, 524 &ulTimeNow, sizeof(ulTimeNow)); 525 pTimer->ulNextFire = ulTimeNow + ulTimeout; 526 usrc = pTimer->usTimerID; 527 // _Pmpf((" timer existed, reset")); 528 } 529 else 530 { 531 // new timer needed: 532 pTimer = (PXTIMER)malloc(sizeof(XTIMER)); 429 533 if (pTimer) 430 534 { 431 // exists already: reset only432 535 ULONG ulTimeNow; 433 536 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, 434 537 &ulTimeNow, sizeof(ulTimeNow)); 538 pTimer->usTimerID = usTimerID; 539 pTimer->hwndTarget = hwnd; 540 pTimer->ulTimeout = ulTimeout; 435 541 pTimer->ulNextFire = ulTimeNow + ulTimeout; 542 543 lstAppendItem(pllXTimers, 544 pTimer); 436 545 usrc = pTimer->usTimerID; 437 } 438 else 439 { 440 // new timer needed: 441 pTimer = (PXTIMER)malloc(sizeof(XTIMER)); 442 if (pTimer) 443 { 444 ULONG ulTimeNow; 445 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, 446 &ulTimeNow, sizeof(ulTimeNow)); 447 pTimer->usTimerID = usTimerID; 448 pTimer->hwndTarget = hwnd; 449 pTimer->ulTimeout = ulTimeout; 450 pTimer->ulNextFire = ulTimeNow + ulTimeout; 451 452 lstAppendItem(&G_llTimers, 453 pTimer); 454 usrc = pTimer->usTimerID; 455 } 546 547 // _Pmpf((" new timer created")); 456 548 } 457 549 } 458 } 459 CATCH(excpt1) { } END_CATCH(); 460 461 // unlock the sems outside the exception handler 462 if (fLocked) 463 { 464 UnlockTimers(); 465 fLocked = FALSE; 466 } 467 468 DosExitMustComplete(&ulNesting); 469 } // if ((hwnd) && (ulTimeout)) 550 551 if (usrc) 552 { 553 // timer created or reset: 554 // start main PM timer 555 pSet->idPMTimerRunning = WinStartTimer(pSet->hab, 556 pSet->hwndOwner, 557 pSet->idPMTimer, 558 100); 559 // _Pmpf((" started PM timer %d", pSet->idPMTimerRunning)); 560 } 561 } // if ((hwnd) && (ulTimeout)) 562 } 563 564 // _Pmpf((__FUNCTION__ ": leaving, returning %d", usrc)); 470 565 471 566 return (usrc); … … 473 568 474 569 /* 475 *@@ tmrStop Timer:570 *@@ tmrStopXTimer: 476 571 * similar to WinStopTimer, this stops the 477 572 * specified timer (which must have been 478 573 * started with the same hwnd and usTimerID 479 * using tmrStart Timer).574 * using tmrStartXTimer). 480 575 * 481 576 * Returns TRUE if the timer was stopped. 482 577 */ 483 578 484 BOOL APIENTRY tmrStopTimer(HWND hwnd, 485 USHORT usTimerID) 579 BOOL XWPENTRY tmrStopXTimer(PXTIMERSET pSet, 580 HWND hwnd, 581 USHORT usTimerID) 486 582 { 487 583 BOOL brc = FALSE; 488 BOOL fLocked = FALSE;489 490 ULONG ulNesting = 0;491 DosEnterMustComplete(&ulNesting);492 493 TRY_LOUD(excpt1)494 {495 fLocked = LockTimers();496 if ( fLocked)584 if (pSet && pSet->pvllXTimers) 585 { 586 PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers; 587 BOOL fLocked = FALSE; 588 589 PXTIMER pTimer = FindTimer(pSet, 590 hwnd, 591 usTimerID); 592 if (pTimer) 497 593 { 498 PXTIMER pTimer = FindTimer(hwnd, 499 usTimerID); 500 if (pTimer) 501 { 502 RemoveTimer(pTimer); 503 brc = TRUE; 504 } 594 RemoveTimer(pSet, pTimer); 595 brc = TRUE; 505 596 } 506 597 } 507 CATCH(excpt1) { } END_CATCH();508 509 // unlock the sems outside the exception handler510 if (fLocked)511 {512 UnlockTimers();513 fLocked = FALSE;514 }515 516 DosExitMustComplete(&ulNesting);517 598 518 599 return (brc); 519 600 } 520 601 521 /* 522 *@@ tmrStopAllTimers: 523 * stops all timers which are running for the 524 * specified window. This is a useful helper 525 * that you should call during WM_DESTROY of 526 * a window that has started timers. 527 */ 528 529 VOID tmrStopAllTimers(HWND hwnd) 530 { 531 BOOL fLocked = FALSE; 532 533 ULONG ulNesting = 0; 534 DosEnterMustComplete(&ulNesting); 535 536 TRY_LOUD(excpt1) 537 { 538 fLocked = LockTimers(); 539 if (fLocked) 540 { 541 PLISTNODE pTimerNode = lstQueryFirstNode(&G_llTimers); 542 while (pTimerNode) 543 { 544 PXTIMER pTimer = (PXTIMER)pTimerNode->pItemData; 545 if (pTimer->hwndTarget == hwnd) 546 { 547 RemoveTimer(pTimer); 548 // start over 549 pTimerNode = lstQueryFirstNode(&G_llTimers); 550 } 551 else 552 pTimerNode = pTimerNode->pNext; 553 } 554 } 555 } 556 CATCH(excpt1) { } END_CATCH(); 557 558 // unlock the sems outside the exception handler 559 if (fLocked) 560 { 561 UnlockTimers(); 562 fLocked = FALSE; 563 } 564 565 DosExitMustComplete(&ulNesting); 566 } 567 568 602 -
trunk/src/helpers/xstring.c
r39 r41 106 106 #include <stdio.h> 107 107 #include <string.h> 108 #include <ctype.h> 108 109 109 110 #include "setup.h" // code generation and debugging options … … 1051 1052 1052 1053 /* 1054 *@@ xstrEncode: 1055 * encodes characters in a string. 1056 * 1057 * This searches pxstr for all occurences of the 1058 * characters in pcszEncode (which must be a 1059 * null-terminated list of characters to be 1060 * encoded). Each occurence that is found is 1061 * replaced with "%hh", with "hh" being the 1062 * two-digit hex number of the encoded character. 1063 * 1064 * For example, to encode strings for the XCenter, 1065 * set pcszEncode to "%,();=". 1066 * 1067 * Returns the no. of characters replaced. 1068 * 1069 * NOTE: You must make sure that pcszEncode ALWAYS 1070 * contains the "%" character as well, which must 1071 * always be encoded (i.e. escaped) because it is 1072 * used for encoding the characters. Otherwise 1073 * you won't be able to decode the string again. 1074 * 1075 * Example: To encode all occurences of 1076 * "a", "b", and "c" in a string, do this: 1077 * 1078 + XSTRING str; 1079 + xstrInitCopy(&str, "Sample characters."; 1080 + xstrEncode(&str, "abc%"; 1081 * 1082 * would convert str to contain: 1083 * 1084 + S%61mple %63hara%63ters. 1085 * 1086 *@@added V0.9.9 (2001-02-28) [umoeller] 1087 */ 1088 1089 ULONG xstrEncode(PXSTRING pxstr, // in/out: string to convert 1090 const char *pcszEncode) // in: characters to encode (e.g. "%,();=") 1091 { 1092 ULONG ulrc = 0, 1093 ul; 1094 1095 // now encode the widget setup string... 1096 for (ul = 0; 1097 ul < strlen(pcszEncode); 1098 ul++) 1099 { 1100 CHAR szFind[3] = "?", 1101 szReplace[10] = "%xx"; 1102 XSTRING strFind, 1103 strReplace; 1104 size_t ShiftTable[256]; 1105 BOOL fRepeat = FALSE; 1106 ULONG ulOfs = 0; 1107 1108 // search string: 1109 szFind[0] = pcszEncode[ul]; 1110 xstrInitSet(&strFind, szFind); 1111 1112 // replace string: ASCII encoding 1113 sprintf(szReplace, "%%%lX", pcszEncode[ul]); 1114 xstrInitSet(&strReplace, szReplace); 1115 1116 // replace all occurences 1117 while (xstrFindReplace(pxstr, 1118 &ulOfs, 1119 &strFind, 1120 &strReplace, 1121 ShiftTable, 1122 &fRepeat)) 1123 ulrc++; 1124 1125 } // for ul; next encoding 1126 1127 return (ulrc); 1128 } 1129 1130 /* 1131 *@@ xstrDecode: 1132 * decodes a string previously encoded by xstrEncode. 1133 * 1134 * This simply assumes that all '%' characters in 1135 * pxstr contain encodings and the next two characters 1136 * after '%' always are a hex character code. This 1137 * only recognizes hex in upper case. 1138 * 1139 * Returns the no. of characters replaced. 1140 * 1141 *@@added V0.9.9 (2001-02-28) [umoeller] 1142 */ 1143 1144 ULONG xstrDecode(PXSTRING pxstr) // in/out: string to be decoded 1145 { 1146 ULONG ulrc = 0; 1147 1148 if ( (pxstr) 1149 && (pxstr->ulLength) 1150 ) 1151 { 1152 ULONG cbAllocated = pxstr->ulLength + 1; 1153 // decoded string cannot be longer than source 1154 PSZ pszDest = (PSZ)malloc(cbAllocated); 1155 1156 if (pszDest) 1157 { 1158 const char *pSource = pxstr->psz; 1159 PSZ pDest = pszDest; 1160 1161 CHAR c; 1162 1163 while ((c = *pSource++)) 1164 { 1165 // pSource points to next char now 1166 1167 if (c == '%') 1168 { 1169 static char ach[] = "01234567989ABCDEF"; 1170 1171 // convert two chars after '%' 1172 CHAR c2, // first char after '%' 1173 c3; // second char after '%' 1174 const char *p2, // for first char: points into ach or is NULL 1175 *p3; // for second char: points into ach or is NULL 1176 if ( (c2 = *pSource) 1177 && (p2 = strchr(ach, c2)) 1178 && (c3 = *(pSource + 1)) 1179 && (p3 = strchr(ach, c3)) 1180 ) 1181 { 1182 // both chars after '%' were valid: 1183 *pDest++ = (p2 - ach) // 0 for '0', 10 for 'A', ... 1184 + ((p3 - ach) << 4); 1185 // go on after that 1186 pSource += 2; 1187 // raise return count 1188 ulrc++; 1189 // next in loop 1190 continue; 1191 } 1192 } 1193 1194 // not encoding, or null after '%', or invalid encoding: 1195 // just copy this 1196 *pDest++ = c; 1197 } // while ((ch = *pSource++)) 1198 1199 if (ulrc) 1200 { 1201 // any encodings found: 1202 // terminate target 1203 *pDest = 0; 1204 1205 // replace source with target 1206 free(pxstr->psz); 1207 pxstr->psz = pszDest; 1208 pxstr->cbAllocated = cbAllocated; 1209 pxstr->ulLength = (pDest - pszDest); 1210 } 1211 else 1212 // no encodings found: 1213 free(pszDest); 1214 } 1215 } 1216 1217 return (ulrc); 1218 } 1219 1220 /* 1053 1221 *@@ xstrConvertLineFormat: 1054 1222 * converts between line formats.
Note:
See TracChangeset
for help on using the changeset viewer.