Changeset 41


Ignore:
Timestamp:
Mar 3, 2001, 11:58:48 AM (24 years ago)
Author:
umoeller
Message:

Updated timers.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/animate.h

    r17 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/ansiscrn.h

    r7 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/cnrh.h

    r35 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/comctl.h

    r29 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/datetime.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/debug.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/dosh.h

    r40 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/except.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/linklist.h

    r38 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/lvm.h

    r14 r41  
    4343
    4444    /* A BYTE is 8 bits of memory with no interpretation attached. */
    45     typedef unsigned char BYTE;
     45    // typedef unsigned char BYTE;
    4646
    4747    /* A BOOLEAN variable is one which is either TRUE or FALSE. */
    4848    typedef unsigned char  BOOLEAN;
    49     #define TRUE  1
    50     #define FALSE 0;
     49    /* #define TRUE  1
     50    #define FALSE 0; */
    5151
    5252    /* An ADDRESS variable is one which holds the address of a location in memory. */
    53     typedef void * ADDRESS;
     53    // typedef void * ADDRESS;
    5454
    5555    /* pSTRING is a pointer to an array of characters. */
     
    5757
    5858    /* 4 bytes */
    59     typedef unsigned long DoubleWord;
     59    // typedef unsigned long DoubleUSHORT;
    6060
    6161    /* 2 bytes */
    62     typedef short unsigned int Word;
     62    // typedef short unsigned int USHORT;
    6363
    6464    /* Define a Partition Sector Number.  A Partition Sector Number is relative to the start of a partition.
     
    9393    typedef struct _Partition_Record
    9494    {
    95         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
     95        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
    9898                                         order bits of the starting cylinder. */
    99         Byte       Starting_Cylinder; /* The cylinder number is a 10 bit value.  The high order
     99        BYTE       Starting_Cylinder; /* The cylinder number is a 10 bit value.  The high order
    100100                                         bits of the 10 bit value come from bits 6 & 7 of the
    101101                                         Starting_Sector field.                                */
    102         Byte       Format_Indicator;  /* An indicator of the format/operation system on this
     102        BYTE       Format_Indicator;  /* An indicator of the format/operation system on this
    103103                                         partition.                                            */
    104         Byte       Ending_Head;
    105         Byte       Ending_Sector;
    106         Byte       Ending_Cylinder;
    107         DoubleWord Sector_Offset;     /* The number of sectors on the disk which are prior to
     104        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
    108108                                         the start of this partition.                          */
    109         DoubleWord Sector_Count;      /* The number of sectors in this partition. */
     109        ULONG Sector_Count;      /* The number of sectors in this partition. */
    110110    } Partition_Record;
    111111
    112112    typedef struct _Master_Boot_Record
    113113    {
    114         Byte                Reserved[446];
     114        BYTE                Reserved[446];
    115115       Partition_Record    Partition_Table[4];
    116        Word                Signature;            /* AA55h in this field indicates that this
     116       USHORT                Signature;            /* AA55h in this field indicates that this
    117117                                                    is a valid partition table/MBR.         */
    118118    } Master_Boot_Record;
     
    201201    typedef struct _DLA_Entry
    202202    {
    203         DoubleWord  Volume_Serial_Number;                /* The serial number of the volume
     203        ULONG  Volume_Serial_Number;                /* The serial number of the volume
    204204                                                            that this partition belongs to.         */
    205         DoubleWord  Partition_Serial_Number;             /* The serial number of this partition.    */
    206         DoubleWord  Partition_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.  */
    207207        LBA         Partition_Start;                     /* The starting sector of the partition.   */
    208208        BOOLEAN     On_Boot_Manager_Menu;                /* Set to TRUE if this volume/partition
     
    221221    typedef struct _DLA_Table_Sector
    222222    {
    223         DoubleWord     DLA_Signature1;             /* The magic signature (part 1) of a
     223        ULONG     DLA_Signature1;             /* The magic signature (part 1) of a
    224224                                                      Drive Letter Assignment Table.               */
    225         DoubleWord     DLA_Signature2;             /* The magic signature (part 2) of a
     225        ULONG     DLA_Signature2;             /* The magic signature (part 2) of a
    226226                                                      Drive Letter Assignment Table.               */
    227         DoubleWord     DLA_CRC;                    /* The 32 bit CRC for this sector.
     227        ULONG     DLA_CRC;                    /* The 32 bit CRC for this sector.
    228228                                                      Calculated assuming that this
    229229                                                      field and all unused space in
    230230                                                      the sector is 0.                             */
    231         DoubleWord     Disk_Serial_Number;         /* The serial number assigned to
     231        ULONG     Disk_Serial_Number;         /* The serial number assigned to
    232232                                                      this disk.                                   */
    233         DoubleWord     Boot_Disk_Serial_Number;    /* The serial number of the disk used to
     233        ULONG     Boot_Disk_Serial_Number;    /* The serial number of the disk used to
    234234                                                      boot the system.  This is for conflict
    235235                                                      resolution when multiple volumes want
     
    298298    typedef struct _LVM_Feature_Data
    299299    {
    300         DoubleWord     Feature_ID;                            /* The ID of the feature. */
     300        ULONG     Feature_ID;                            /* The ID of the feature. */
    301301        PSN            Location_Of_Primary_Feature_Data;      /* The PSN of the starting sector of
    302302                                                                 the private data for this feature.*/
     
    304304                                                                 the backup copy of the private
    305305                                                                 data for this feature.            */
    306         DoubleWord     Feature_Data_Size;                     /* The number of sectors used by this
     306        ULONG     Feature_Data_Size;                     /* The number of sectors used by this
    307307                                                                 feature for its private data.     */
    308         Word           Feature_Major_Version_Number;          /* The integer portion of the version
     308        USHORT           Feature_Major_Version_Number;          /* The integer portion of the version
    309309                                                                 number of this feature.           */
    310         Word           Feature_Minor_Version_Number;          /* The decimal portion of the version
     310        USHORT           Feature_Minor_Version_Number;          /* The decimal portion of the version
    311311                                                                 number of this feature.           */
    312312        BOOLEAN        Feature_Active;                        /* TRUE if this feature is active on
     
    322322       that it is a part of, as well as which LVM features (BBR, drive linking,
    323323       etc.) are active on the volume that this partition is a part of. */
    324 
     324#if 0
    325325    typedef struct _LVM_Signature_Sector
    326326    {
    327         DoubleWord        LVM_Signature1;                             /* The first part of the
     327        ULONG        LVM_Signature1;                             /* The first part of the
    328328                                                                         magic LVM signature. */
    329         DoubleWord        LVM_Signature2;                             /* The second part of
     329        ULONG        LVM_Signature2;                             /* The second part of
    330330                                                                         the magic LVM
    331331                                                                         signature.           */
    332         DoubleWord        Signature_Sector_CRC;                       /* 32 bit CRC for this
     332        ULONG        Signature_Sector_CRC;                       /* 32 bit CRC for this
    333333                                                                         sector.  Calculated
    334334                                                                         using 0 for this
    335335                                                                         field.               */
    336         DoubleWord        Partition_Serial_Number;                    /* The LVM assigned
     336        ULONG        Partition_Serial_Number;                    /* The LVM assigned
    337337                                                                         serial number for this
    338338                                                                         partition.           */
     
    342342        LBA               Partition_End;                              /* LBA of the last sector
    343343                                                                         of this partition.   */
    344         DoubleWord        Partition_Sector_Count;                     /* The number of sectors
     344        ULONG        Partition_Sector_Count;                     /* The number of sectors
    345345                                                                         in this partition.   */
    346         DoubleWord        LVM_Reserved_Sector_Count;                  /* The number of sectors
     346        ULONG        LVM_Reserved_Sector_Count;                  /* The number of sectors
    347347                                                                         reserved for use by
    348348                                                                         LVM.                 */
    349         DoubleWord        Partition_Size_To_Report_To_User;           /* The size of the
     349        ULONG        Partition_Size_To_Report_To_User;           /* The size of the
    350350                                                                         partition as the user
    351351                                                                         sees it - i.e. (the
     
    355355                                                                         rounded to a track
    356356                                                                         boundary.            */
    357         DoubleWord        Boot_Disk_Serial_Number;                    /* The serial number of
     357        ULONG        Boot_Disk_Serial_Number;                    /* The serial number of
    358358                                                                         the boot disk for the
    359359                                                                         system.  If the system
     
    364364                                                                         active copy of Boot
    365365                                                                         Manager.             */
    366         DoubleWord        Volume_Serial_Number;                       /* The serial number of
     366        ULONG        Volume_Serial_Number;                       /* The serial number of
    367367                                                                         the volume that this
    368368                                                                         partition belongs to.*/
     
    370370                                                                         of a Fake EBR, if one
    371371                                                                         has been allocated.  */
    372         Word              LVM_Major_Version_Number;                   /* Major version number
     372        USHORT              LVM_Major_Version_Number;                   /* Major version number
    373373                                                                         of the LVM that
    374374                                                                         created this
    375375                                                                         partition.           */
    376         Word              LVM_Minor_Version_Number;                   /* Minor version number
     376        USHORT              LVM_Minor_Version_Number;                   /* Minor version number
    377377                                                                         of the LVM that
    378378                                                                         created this
     
    401401           else the CRC will not come out correctly.                                          */
    402402    } LVM_Signature_Sector;
     403#endif
    403404
    404405    /* ******************************************************************
     
    527528        CARDINAL32   Drive_Number;        /* OS/2 Drive Number for this drive. */
    528529        CARDINAL32   Drive_Size;          /* The total number of sectors on the drive. */
    529         DoubleWord   Drive_Serial_Number; /* The serial number assigned to this drive.
     530        ULONG   Drive_Serial_Number; /* The serial number assigned to this drive.
    530531                                             For info. purposes only. */
    531         ADDRESS      Drive_Handle;        /* Handle used for operations on the disk that
     532        PVOID      Drive_Handle;        /* Handle used for operations on the disk that
    532533                                             this record corresponds to. */
    533534        CARDINAL32   Cylinder_Count;      /* The number of cylinders on the drive. */
     
    570571    typedef struct _Partition_Information_Record
    571572    {
    572         ADDRESS      Partition_Handle;                      /* The handle used to perform
     573        PVOID      Partition_Handle;                      /* The handle used to perform
    573574                                                               operations on this partition. */
    574         ADDRESS      Volume_Handle;                         /* If this partition is part
     575        PVOID      Volume_Handle;                         /* If this partition is part
    575576                                                               of a volume, this will be the
    576577                                                               handle of the volume.  If
     
    578579                                                               part of a volume, then
    579580                                                               this handle will be 0.        */
    580         ADDRESS      Drive_Handle;                          /* The handle for the drive
     581        PVOID      Drive_Handle;                          /* The handle for the drive
    581582                                                               this partition resides on. */
    582         DoubleWord   Partition_Serial_Number;               /* The serial number assigned
     583        ULONG   Partition_Serial_Number;               /* The serial number assigned
    583584                                                               to this partition.         */
    584585        CARDINAL32   Partition_Start;                       /* The LBA of the first
     
    703704    typedef struct _Volume_Control_Record
    704705    {
    705         DoubleWord Volume_Serial_Number;            /* The serial number assigned to this volume. */
    706         ADDRESS    Volume_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. */
    707708        BOOLEAN    Compatibility_Volume;            /* TRUE indicates that this volume is compatible with older versions of OS/2.
    708709                                                       FALSE indicates that this is an LVM specific volume and can not be used without OS2LVM.DMD. */
     
    746747    typedef struct _Boot_Manager_Menu_Item
    747748    {
    748         ADDRESS     Handle;            /* A Volume or Partition handle. */
     749        PVOID     Handle;            /* A Volume or Partition handle. */
    749750        BOOLEAN     Volume;            /* If TRUE, then Handle is the handle of a Volume.  Otherwise, Handle is the handle of a partition. */
    750751    } Boot_Manager_Menu_Item;
     
    997998     *      Input:
    998999     *
    999      *      -- ADDRESS Drive_Handle: The handle of the drive to use.
     1000     *      -- PVOID Drive_Handle: The handle of the drive to use.
    10001001     *                    Drive handles are obtained through the
    10011002     *                    Get_Drive_Control_Data function.
     
    10131014     */
    10141015
    1015     Drive_Information_Record _System Get_Drive_Status( ADDRESS Drive_Handle, CARDINAL32 * Error_Code );
     1016    Drive_Information_Record _System Get_Drive_Status( PVOID Drive_Handle, CARDINAL32 * Error_Code );
    10161017
    10171018    /* ******************************************************************
     
    10281029     *      Input:
    10291030     *
    1030      *      -- ADDRESS Handle: This is the handle of a drive or volume.
     1031     *      -- PVOID Handle: This is the handle of a drive or volume.
    10311032     *             Drive handles are obtained through the
    10321033     *             Get_Drive_Control_Data function.  Volume
     
    10731074     */
    10741075
    1075     Partition_Information_Array _System Get_Partitions( ADDRESS Handle, CARDINAL32 * Error_Code );
     1076    Partition_Information_Array _System Get_Partitions( PVOID Handle, CARDINAL32 * Error_Code );
    10761077
    10771078    /*
     
    11001101     */
    11011102
    1102     ADDRESS _System Get_Partition_Handle( CARDINAL32 Serial_Number, CARDINAL32 * Error_Code );
     1103    PVOID _System Get_Partition_Handle( CARDINAL32 Serial_Number, CARDINAL32 * Error_Code );
    11031104
    11041105    /*
     
    11091110     *      Input:
    11101111     *
    1111      *      -- ADDRESS Partition_Handle:
     1112     *      -- PVOID Partition_Handle:
    11121113     *          The handle associated with the partition for which the
    11131114     *          Partition_Information_Record is desired.
     
    11241125     */
    11251126
    1126     Partition_Information_Record  _System Get_Partition_Information( ADDRESS Partition_Handle, CARDINAL32 * Error_Code );
     1127    Partition_Information_Record  _System Get_Partition_Information( PVOID Partition_Handle, CARDINAL32 * Error_Code );
    11271128
    11281129    /*
     
    11321133     *      Input:
    11331134     *
    1134      *      --  ADDRESS Handle: The handle of a disk drive or a block
     1135     *      --  PVOID Handle: The handle of a disk drive or a block
    11351136     *          of free space.
    11361137     *
     
    11841185     */
    11851186
    1186     ADDRESS _System Create_Partition( ADDRESS               Handle,
     1187    PVOID _System Create_Partition( PVOID               Handle,
    11871188                                      CARDINAL32            Size,
    11881189                                      char                  Name[ PARTITION_NAME_SIZE ],
     
    12001201     *      Input:
    12011202     *
    1202      *      --  ADDRESS Partition_Handle: The handle associated with the*
     1203     *      --  PVOID Partition_Handle: The handle associated with the*
    12031204     *          partition to be deleted.
    12041205     *
     
    12221223     */
    12231224
    1224     void _System Delete_Partition( ADDRESS Partition_Handle, CARDINAL32 * Error_Code );
     1225    void _System Delete_Partition( PVOID Partition_Handle, CARDINAL32 * Error_Code );
    12251226
    12261227    /*
     
    12301231     *      Input:
    12311232     *
    1232      *      --  ADDRESS Partition_Handle: The handle of the partition
     1233     *      --  PVOID Partition_Handle: The handle of the partition
    12331234     *          whose Active Flag is to be set.
    12341235     *
     
    12571258     */
    12581259
    1259     void _System Set_Active_Flag ( ADDRESS      Partition_Handle,
     1260    void _System Set_Active_Flag ( PVOID      Partition_Handle,
    12601261                                   BYTE         Active_Flag,
    12611262                                   CARDINAL32 * Error_Code
     
    12711272     *      Input:
    12721273     *
    1273      *      --  ADDRESS Partition_Handle: The handle of the partition
     1274     *      --  PVOID Partition_Handle: The handle of the partition
    12741275     *          whose Active Flag is to be set.
    12751276     *      --  BYTE OS_Flag - The new value for the OS Flag.
     
    12981299     */
    12991300
    1300     void _System Set_OS_Flag ( ADDRESS      Partition_Handle,
     1301    void _System Set_OS_Flag ( PVOID      Partition_Handle,
    13011302                               BYTE         OS_Flag,
    13021303                               CARDINAL32 * Error_Code
     
    13571358     *      Input:
    13581359     *
    1359      *      --  ADDRESS Volume_Handle: The handle of the volume about
     1360     *      --  PVOID Volume_Handle: The handle of the volume about
    13601361     *          which information is desired.
    13611362     *
     
    13731374     */
    13741375
    1375     Volume_Information_Record _System Get_Volume_Information( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
     1376    Volume_Information_Record _System Get_Volume_Information( PVOID Volume_Handle, CARDINAL32 * Error_Code );
    13761377
    13771378    /*
     
    13981399     *          link together to form the volume being created.
    13991400     *
    1400      *      --  ADDRESS Partition_Handles[]: An array of partition handles
     1401     *      --  PVOID Partition_Handles[]: An array of partition handles
    14011402     *          with one entry for each partition that is to become part
    14021403     *          of the volume being created.
     
    14301431                                CARDINAL32   FeaturesToUse,
    14311432                                CARDINAL32   Partition_Count,
    1432                                 ADDRESS      Partition_Handles[],
     1433                                PVOID      Partition_Handles[],
    14331434                                CARDINAL32 * Error_Code
    14341435                              );
     
    14401441     *      Input:
    14411442     *
    1442      *      -- ADDRESS Volume_Handle: The handle of the volume to
     1443     *      -- PVOID Volume_Handle: The handle of the volume to
    14431444     *                         delete.  All partitions which are
    14441445     *                         part of the specified volume will
     
    14701471     */
    14711472
    1472     void _System Delete_Volume( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
     1473    void _System Delete_Volume( PVOID Volume_Handle, CARDINAL32 * Error_Code );
    14731474
    14741475    /*
     
    14801481     *      Input:
    14811482     *
    1482      *      -- ADDRESS Volume_Handle: The handle of the volume to hide.
     1483     *      -- PVOID Volume_Handle: The handle of the volume to hide.
    14831484     *
    14841485     *      Output:
     
    14981499     */
    14991500
    1500     void _System Hide_Volume( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
     1501    void _System Hide_Volume( PVOID Volume_Handle, CARDINAL32 * Error_Code );
    15011502
    15021503    /*
     
    15061507     *      Input:
    15071508     *
    1508      *      --  ADDRESS Volume_Handle: The handle of the volume to be
     1509     *      --  PVOID Volume_Handle: The handle of the volume to be
    15091510     *          expanded.
    15101511     *
     
    15121513     *          volumes to be added to the volume being expanded.
    15131514     *
    1514      *      -- ADDRESS Partition_Handles[] - An array of handles.  Each
     1515     *      -- PVOID Partition_Handles[] - An array of handles.  Each
    15151516     *          handle in the array is the handle of a partition which
    15161517     *          is to be added to the volume being expanded.
     
    15491550     */
    15501551
    1551     void _System Expand_Volume ( ADDRESS         Volume_Handle,
     1552    void _System Expand_Volume ( PVOID         Volume_Handle,
    15521553                                 CARDINAL32      Partition_Count,
    1553                                  ADDRESS         Partition_Handles[],
     1554                                 PVOID         Partition_Handles[],
    15541555                                 CARDINAL32 *    Error_Code
    15551556                               );
     
    15611562     *      Input:
    15621563     *
    1563      *      --  ADDRESS Volume_Handle: The handle of the volume which
     1564     *      --  PVOID Volume_Handle: The handle of the volume which
    15641565     *          is to have its assigned drive letter changed.
    15651566     *
     
    15911592     */
    15921593
    1593     void _System Assign_Drive_Letter( ADDRESS      Volume_Handle,
     1594    void _System Assign_Drive_Letter( PVOID      Volume_Handle,
    15941595                                      char         New_Drive_Preference,
    15951596                                      CARDINAL32 * Error_Code
     
    16021603     *      Input:
    16031604     *
    1604      *      --  ADDRESS Volume_Handle: The handle of the volume to which
     1605     *      --  PVOID Volume_Handle: The handle of the volume to which
    16051606     *          OS/2 should be installed.
    16061607     *
     
    16221623     */
    16231624
    1624     void _System Set_Installable ( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
     1625    void _System Set_Installable ( PVOID Volume_Handle, CARDINAL32 * Error_Code );
    16251626
    16261627    /*
     
    16501651     *      Input:
    16511652     *
    1652      *      --  ADDRESS Handle: The handle of the drive, partition, or
     1653     *      --  PVOID Handle: The handle of the drive, partition, or
    16531654     *          volume which is to have its name set.
    16541655     *
     
    16701671     */
    16711672
    1672     void _System Set_Name ( ADDRESS      Handle,
     1673    void _System Set_Name ( PVOID      Handle,
    16731674                            char         New_Name[],
    16741675                            CARDINAL32 * Error_Code
     
    16851686     *      Input:
    16861687     *
    1687      *      --  ADDRESS Handle: The handle of the partition or volume
     1688     *      --  PVOID Handle: The handle of the partition or volume
    16881689     *          which is to be set startable.
    16891690     *
     
    17071708     */
    17081709
    1709     void _System Set_Startable ( ADDRESS      Handle,
     1710    void _System Set_Startable ( PVOID      Handle,
    17101711                                 CARDINAL32 * Error_Code
    17111712                               );
     
    17221723     *      Input:
    17231724     *
    1724      *      --  ADDRESS Handle: This is any valid drive, volume, or
     1725     *      --  PVOID Handle: This is any valid drive, volume, or
    17251726     *          partition handle.
    17261727     *
     
    17451746     */
    17461747
    1747     CARDINAL32 _System Get_Valid_Options( ADDRESS Handle, CARDINAL32 * Error_Code );
     1748    CARDINAL32 _System Get_Valid_Options( PVOID Handle, CARDINAL32 * Error_Code );
    17481749
    17491750    /* ******************************************************************
     
    17751776     *      Input:
    17761777     *
    1777      *      --  ADDRESS Handle: The handle of a partition or volume that
     1778     *      --  PVOID Handle: The handle of a partition or volume that
    17781779     *          is to be added to the Boot Manager menu.
    17791780     *
     
    18001801     */
    18011802
    1802     void _System Add_To_Boot_Manager ( ADDRESS Handle, CARDINAL32 * Error_Code );
     1803    void _System Add_To_Boot_Manager ( PVOID Handle, CARDINAL32 * Error_Code );
    18031804
    18041805    /*
     
    18271828     */
    18281829
    1829     void _System Remove_From_Boot_Manager ( ADDRESS Handle, CARDINAL32 * Error_Code );
     1830    void _System Remove_From_Boot_Manager ( PVOID Handle, CARDINAL32 * Error_Code );
    18301831
    18311832    /*
     
    19161917     *      Input:
    19171918     *
    1918      *      --  ADDRESS Handle - The handle of the partition or volume
     1919     *      --  PVOID Handle - The handle of the partition or volume
    19191920     *          to boot if the time-out timer is active and the time-out
    19201921     *          value is reached.
     
    19451946     */
    19461947
    1947     void _System Set_Boot_Manager_Options( ADDRESS      Handle,
     1948    void _System Set_Boot_Manager_Options( PVOID      Handle,
    19481949                                           BOOLEAN      Timer_Active,
    19491950                                           CARDINAL32   Time_Out_Value,
     
    19591960     *      Input:
    19601961     *
    1961      *      --  ADDRESS * Handle - The handle for the default boot
     1962     *      --  PVOID * Handle - The handle for the default boot
    19621963     *          volume or partition.
    19631964     *
     
    19921993     */
    19931994
    1994     void _System Get_Boot_Manager_Options( ADDRESS    *  Handle,
     1995    void _System Get_Boot_Manager_Options( PVOID    *  Handle,
    19951996                                           BOOLEAN    *  Handle_Is_Volume,
    19961997                                           BOOLEAN    *  Timer_Active,
     
    20132014     *      Input:
    20142015     *
    2015      *      --  ADDRESS Object: The address of the memory object to
     2016     *      --  PVOID Object: The address of the memory object to
    20162017     *          free.  This could be the Drive_Control_Data field of
    20172018     *          a Drive_Control_Record, the Partition_Array field of
     
    20262027     */
    20272028
    2028     void _System Free_Engine_Memory( ADDRESS Object );
     2029    void _System Free_Engine_Memory( PVOID Object );
    20292030
    20302031    /*
     
    20342035     *      Input:
    20352036     *
    2036      *      --  ADDRESS Drive_Handle - The handle of the drive on which
     2037     *      --  PVOID Drive_Handle - The handle of the drive on which
    20372038     *          the new MBR is to be placed.
    20382039     *
     
    20542055     */
    20552056
    2056     void _System New_MBR( ADDRESS Drive_Handle, CARDINAL32 * Error_Code );
     2057    void _System New_MBR( PVOID Drive_Handle, CARDINAL32 * Error_Code );
    20572058
    20582059    /*
     
    22522253     *          read into memory.
    22532254     *
    2254      *      --  ADDRESS Buffer : The location to put the data read into.
     2255     *      --  PVOID Buffer : The location to put the data read into.
    22552256     *
    22562257     *      Output:
     
    22742275                                LBA                 Starting_Sector,
    22752276                                CARDINAL32          Sectors_To_Read,
    2276                                 ADDRESS             Buffer,
     2277                                PVOID             Buffer,
    22772278                                CARDINAL32 *        Error);
    22782279
     
    22932294     *          be written.
    22942295     *
    2295      *      --  ADDRESS Buffer : The location of the data to be written
     2296     *      --  PVOID Buffer : The location of the data to be written
    22962297     *          to disk.
    22972298     *
     
    23162317                                 LBA                 Starting_Sector,
    23172318                                 CARDINAL32          Sectors_To_Write,
    2318                                  ADDRESS             Buffer,
     2319                                 PVOID             Buffer,
    23192320                                 CARDINAL32 *        Error);
    23202321
  • trunk/include/helpers/pmprintf.h

    r7 r41  
    1 /* $Id$ */
    2 
    31/*---------------------------------------------------------------------------+
    42|
  • trunk/include/helpers/prfh.h

    r33 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/procstat.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/resh.h

    r7 r41  
    1 /* $Id$ */
    21
    32/*
  • trunk/include/helpers/shapewin.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/stringh.h

    r38 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/syssound.h

    r14 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/threads.h

    r33 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/timer.h

    r14 r41  
    3131    #define TIMER_HEADER_INCLUDED
    3232
    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     */
    3638
    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;
    4047
    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;
    4467
    4568#endif
  • trunk/include/helpers/tmsgfile.h

    r7 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/undoc.h

    r15 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/winh.h

    r31 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/wphandle.h

    r29 r41  
    1 /* $Id$ */
    2 
    31
    42/*
  • trunk/include/helpers/wpsdebug.h

    r7 r41  
    1 /* $Id$ */
    2 
    31/*---------------------------------------------------------------------------+
    42|
  • trunk/include/helpers/xstring.h

    r38 r41  
    161161    typedef XSTRFINDREPLACEC *PXSTRFINDREPLACEC;
    162162
     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
    163171    // V0.9.9 (2001-01-29) [lafaix]: constants added
    164172    #define CRLF2LF TRUE
  • trunk/src/helpers/timer.c

    r21 r41  
    22/*
    33 *@@sourcefile timer.c:
    4  *      XTimers, which can replace the PM timers.
     4 *      XTimers, which can be used to avoid excessive PM
     5 *      timer usage.
    56 *
    67 *      These timers operate similar to PM timers started
     
    910 *      WM_TIMER messages regularly.
    1011 *
    11  *      Instead of WinStartTimer, use tmrStartTimer.
    12  *      Instead of WinStopTimer, use tmrStopTimer.
     12 *      Instead of WinStartTimer, use tmrStartXTimer.
     13 *      Instead of WinStopTimer, use tmrStopXTimer.
    1314 *
    1415 *      The main advantage of the XTimers is that these
     
    7576#define INCL_DOSERRORS
    7677
     78#define INCL_WINWINDOWMGR
    7779#define INCL_WINMESSAGEMGR
     80#define INCL_WINTIMER
    7881#include <os2.h>
    7982
     
    108111typedef struct _XTIMER
    109112{
    110     USHORT     usTimerID;           // timer ID, as passed to tmrStartTimer
    111     HWND       hwndTarget;          // target window, as passed to tmrStartTimer
     113    USHORT     usTimerID;           // timer ID, as passed to tmrStartXTimer
     114    HWND       hwndTarget;          // target window, as passed to tmrStartXTimer
    112115    ULONG      ulTimeout;           // timer's timeout (in ms)
    113116    ULONG      ulNextFire;          // next time scalar (from dtGetULongTime) to fire at
     
    121124
    122125// timers thread
    123 HMTX                G_hmtxTimers = NULLHANDLE;  // timers lock mutex
    124 THREADINFO          G_tiTimers = {0};           // timers thread (only running
     126// HMTX                G_hmtxTimers = NULLHANDLE;  // timers lock mutex
     127// THREADINFO          G_tiTimers = {0};           // timers thread (only running
    125128                                                // 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
    171131
    172132/*
     
    177137 *
    178138 *      This thread is dynamically started when the
    179  *      first timer is started thru tmrStartTimer.
     139 *      first timer is started thru tmrStartXTimer.
    180140 *      It is automatically stopped (to be precise:
    181141 *      it terminates itself) when the last timer
    182  *      is stopped thru tmrStopTimer, which then
     142 *      is stopped thru tmrStopXTimer, which then
    183143 *      sets the thread's fExit flag to TRUE.
    184144 *
     
    186146 */
    187147
    188 void _Optlink fntTimersThread(PTHREADINFO ptiMyself)
     148/* void _Optlink fntTimersThread(PTHREADINFO ptiMyself)
    189149{
    190150    ULONG       ulInterval = 25;
     
    225185            if (fLocked)
    226186            {
    227                 // go thru all XTimers and see which one
    228                 // has elapsed; for all of these, post WM_TIMER
    229                 // to the target window proc
    230                 PLISTNODE pTimerNode = lstQueryFirstNode(&G_llTimers);
    231                 if (!pTimerNode)
    232                     // no more timers left:
    233                     // terminate thread
    234                     ptiMyself->fExit = TRUE;
    235                 else
    236                 {
    237                     // we have timers:
    238                     BOOL      fFoundInvalid = FALSE;
    239 
    240                     // get current time
    241                     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                             else
    263                             {
    264                                 // window has been destroyed:
    265                                 #ifdef __DEBUG__
    266                                     DosBeep(100, 100);
    267                                 #endif
    268                                 lstAppendItem(&llInvalidTimers,
    269                                               (PVOID)pTimerNode);
    270                                 fFoundInvalid = TRUE;
    271                             }
    272                         } // end if (pTimer->ulNextFire < ulTimeNow)
    273 
    274                         // adjust DosSleep interval
    275                         if (pTimer->ulTimeout < ulInterval)
    276                             ulInterval = pTimer->ulTimeout;
    277 
    278                         // next timer
    279                         pTimerNode = pTimerNode->pNext;
    280                     } // end while (pTimerNode)
    281 
    282                     // destroy invalid timers, if any
    283                     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)
    296187            } // end if (fLocked)
    297188        }
     
    313204        DosBeep(1500, 30);
    314205    #endif
    315 }
     206} */
     207
     208/* ******************************************************************
     209 *
     210 *   Private functions
     211 *
     212 ********************************************************************/
    316213
    317214/*
     
    322219 *
    323220 *      Internal function.
    324  *
    325  *      Preconditions:
    326  *
    327  *      -- The caller must call LockTimers() first.
    328  */
    329 
    330 PXTIMER FindTimer(HWND hwnd,
     221 */
     222
     223PXTIMER FindTimer(PXTIMERSET pSet,
     224                  HWND hwnd,
    331225                  USHORT usTimerID)
    332226{
    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)
    340232        {
    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;
    342242        }
    343 
    344         pNode = pNode->pNext;
    345243    }
     244
    346245    return (NULL);
    347246}
     
    359258 */
    360259
    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); */
     260VOID 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    }
    369273}
    370274
    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
     291PXTIMERSET 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
     325VOID 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
     366VOID 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:
    373481 *      starts an XTimer.
    374482 *
     
    380488 *      Returns a new timer or resets an existing
    381489 *      timer (if usTimerID is already used with
    382  *      hwnd). Use tmrStopTimer to stop the timer.
     490 *      hwnd). Use tmrStopXTimer to stop the timer.
    383491 *
    384492 *      The timer is _not_ stopped automatically
     
    388496 */
    389497
    390 USHORT APIENTRY tmrStartTimer(HWND hwnd,
    391                               USHORT usTimerID,
    392                               ULONG ulTimeout)
     498USHORT XWPENTRY tmrStartXTimer(PXTIMERSET pSet,
     499                               HWND hwnd,
     500                               USHORT usTimerID,
     501                               ULONG ulTimeout)
    393502{
    394503    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))
    403512        {
    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));
    429533                if (pTimer)
    430534                {
    431                     // exists already: reset only
    432535                    ULONG ulTimeNow;
    433536                    DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT,
    434537                                    &ulTimeNow, sizeof(ulTimeNow));
     538                    pTimer->usTimerID = usTimerID;
     539                    pTimer->hwndTarget = hwnd;
     540                    pTimer->ulTimeout = ulTimeout;
    435541                    pTimer->ulNextFire = ulTimeNow + ulTimeout;
     542
     543                    lstAppendItem(pllXTimers,
     544                                  pTimer);
    436545                    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"));
    456548                }
    457549            }
    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));
    470565
    471566    return (usrc);
     
    473568
    474569/*
    475  *@@ tmrStopTimer:
     570 *@@ tmrStopXTimer:
    476571 *      similar to WinStopTimer, this stops the
    477572 *      specified timer (which must have been
    478573 *      started with the same hwnd and usTimerID
    479  *      using tmrStartTimer).
     574 *      using tmrStartXTimer).
    480575 *
    481576 *      Returns TRUE if the timer was stopped.
    482577 */
    483578
    484 BOOL APIENTRY tmrStopTimer(HWND hwnd,
    485                            USHORT usTimerID)
     579BOOL XWPENTRY tmrStopXTimer(PXTIMERSET pSet,
     580                            HWND hwnd,
     581                            USHORT usTimerID)
    486582{
    487583    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)
    497593        {
    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;
    505596        }
    506597    }
    507     CATCH(excpt1) { } END_CATCH();
    508 
    509     // unlock the sems outside the exception handler
    510     if (fLocked)
    511     {
    512         UnlockTimers();
    513         fLocked = FALSE;
    514     }
    515 
    516     DosExitMustComplete(&ulNesting);
    517598
    518599    return (brc);
    519600}
    520601
    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  
    106106#include <stdio.h>
    107107#include <string.h>
     108#include <ctype.h>
    108109
    109110#include "setup.h"                      // code generation and debugging options
     
    10511052
    10521053/*
     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
     1089ULONG 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
     1144ULONG 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/*
    10531221 *@@ xstrConvertLineFormat:
    10541222 *      converts between line formats.
Note: See TracChangeset for help on using the changeset viewer.