Changeset 135


Ignore:
Timestamp:
Jan 31, 2002, 11:12:45 PM (24 years ago)
Author:
umoeller
Message:

Misc speed improvements.

Location:
trunk
Files:
6 edited

Legend:

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

    r133 r135  
    3232#ifndef DOSH_HEADER_INCLUDED
    3333    #define DOSH_HEADER_INCLUDED
     34
     35    /* ******************************************************************
     36     *
     37     *   Wrappers
     38     *
     39     ********************************************************************/
     40
     41    // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h,
     42    // all the following Dos* API calls are redirected to the dosh*
     43    // counterparts
     44
     45    #ifdef DOSH_STANDARDWRAPPERS
     46
     47        #ifdef INCL_DOSPROCESS
     48
     49            APIRET XWPENTRY doshSleep(ULONG msec);
     50            #define DosSleep(a) doshSleep((a))
     51
     52        #endif
     53
     54        #ifdef INCL_DOSSEMAPHORES
     55
     56            APIRET XWPENTRY doshCreateMutexSem(PSZ pszName,
     57                                               PHMTX phmtx,
     58                                               ULONG flAttr,
     59                                               BOOL32 fState);
     60            #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d))
     61
     62            APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
     63            #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t))
     64
     65            APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx);
     66            #define DosReleaseMutexSem(h) doshReleaseMutexSem((h))
     67
     68        #endif
     69
     70        #ifdef INCL_DOSEXCEPTIONS
     71
     72            APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
     73            #define DosSetExceptionHandler(a) doshSetExceptionHandler((a))
     74
     75            APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
     76            #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a))
     77
     78        #endif
     79
     80    #endif
    3481
    3582    /* ******************************************************************
     
    162209                                   PBIOSPARAMETERBLOCK pdp);
    163210
    164         BYTE doshQueryRemoveableType(PBIOSPARAMETERBLOCK pdp);
     211        BYTE doshQueryDriveType(ULONG ulLogicalDrive,
     212                                PBIOSPARAMETERBLOCK pdp,
     213                                BOOL fFixed);
    165214
    166215        APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
     
    185234    #define DRVFL_MIXEDMODECD        0x0001
    186235    #define DRVFL_TOUCHFLOPPIES      0x0002
     236    #define DRVFL_CHECKEAS           0x0004
     237    #define DRVFL_CHECKLONGNAMES     0x0008
    187238
    188239    APIRET doshAssertDrive(ULONG ulLogicalDrive,
     
    222273                            // 0x1a USHORT cCylinders;
    223274                            // 0x1c BYTE   bDeviceType;
    224                                     // DEVTYPE_48TPI                      0x0000
    225                                     // DEVTYPE_96TPI                      0x0001
    226                                     // DEVTYPE_35                         0x0002
    227                                     // DEVTYPE_8SD                        0x0003
    228                                     // DEVTYPE_8DD                        0x0004
    229                                     // DEVTYPE_FIXED                      0x0005
    230                                     // DEVTYPE_TAPE                       0x0006
    231                                     // DEVTYPE_UNKNOWN                    0x0007
     275                                #ifndef DEVTYPE_48TPI
     276                                #define DEVTYPE_48TPI                      0x0000
     277                                #define DEVTYPE_96TPI                      0x0001
     278                                #define DEVTYPE_35                         0x0002
     279                                #define DEVTYPE_8SD                        0x0003
     280                                #define DEVTYPE_8DD                        0x0004
     281                                #define DEVTYPE_FIXED                      0x0005
     282                                #define DEVTYPE_TAPE                       0x0006
     283                                #endif
     284                                #define DEVTYPE_OTHER                      0x0007
     285                                            // includes 1.44 3.5" floppy
     286                                #define DEVTYPE_RWOPTICAL                  0x0008
     287                                #define DEVTYPE_35_288MB                   0x0009
    232288                            // 0x1d USHORT fsDeviceAttr;
    233289                                #define DEVATTR_REMOVEABLE              0x0001
     
    240296                                            // addresses > 16 MB
    241297                                #define DEVATTR_PARTITIONALREMOVEABLE   0x0008
     298                                            // undocumented flag; set for ZIP drives
    242299
    243300            BYTE        bType;
    244301                // do not change these codes, XWorkplace relies
    245302                // on them too to parse WPDisk data
    246                 #define DRVTYPE_HARDDISK        0
    247                 #define DRVTYPE_FLOPPY          1
    248                 #define DRVTYPE_TAPE            2
    249                 #define DRVTYPE_VDISK           3
    250                 #define DRVTYPE_CDROM           4
    251                 #define DRVTYPE_LAN             5
     303                #define DRVTYPE_HARDDISK                0
     304                #define DRVTYPE_FLOPPY                  1
     305                #define DRVTYPE_TAPE                    2
     306                #define DRVTYPE_VDISK                   3
     307                #define DRVTYPE_CDROM                   4
     308                #define DRVTYPE_LAN                     5
    252309                #define DRVTYPE_PARTITIONABLEREMOVEABLE 6
    253                 #define DRVTYPE_UNKNOWN       255
     310                #define DRVTYPE_UNKNOWN               255
    254311
    255312            ULONG       flDevice;
     
    259316                #define DFL_FIXED                       0x0002
    260317                            // drive is fixed; otherwise it is removeable!
     318                            // always set for harddisks and zip drives
    261319                #define DFL_PARTITIONABLEREMOVEABLE     0x0004
     320                            // set for zip drives;
    262321                            // in that case, DFL_FIXED is set also
    263322                #define DFL_BOOTDRIVE                   0x0008
     
    267326
    268327                #define DFL_MEDIA_PRESENT               0x1000
    269                             // media is present in drive; always
    270                             // true for fixed and remove drives and
    271                             // drives A: and B:
     328                            // media is present in drive;
     329                            // -- always set for harddisks,
     330                            //    unless the file system is not
     331                            //    understood
     332                            // -- always set for remove drives
     333                            // -- always set for A: and B:
     334                            // -- set for CD-ROMS only if data
     335                            //    CD-ROM is inserted
    272336                #define DFL_AUDIO_CD                    0x2000
    273337                            // set for CD-ROMs only, if an audio CD
     
    276340                #define DFL_SUPPORTS_EAS                0x4000
    277341                            // drive supports extended attributes
     342                            // (assumption based on DosFSCtl,
     343                            // might not be correct for remote drives;
     344                            // reports correctly for FAT32 though)
    278345                #define DFL_SUPPORTS_LONGNAMES          0x8000
    279346                            // drive supports long names; this does not
     
    287354                            // e.g. "FAT" or "HPFS" or "JFS" or "CDFS"
    288355
    289             BYTE        bFileSystem;
     356            LONG        lFileSystem;
    290357                // do not change these codes, XWorkplace relies
    291358                // on them too to parse WPDisk data
     359                #define FSYS_UNKNOWN         0
     360                            // drive not formatted, or unknown file system
    292361                #define FSYS_FAT             1
    293362                #define FSYS_HPFS_JFS        2
    294363                #define FSYS_CDFS            3
    295                 #define FSYS_FAT32           8      // not used by WPS!
     364                #define FSYS_TVFS            7      // not used by WPS!
     365                #define FSYS_FAT32_EXT2      8      // not used by WPS!
    296366                #define FSYS_RAMFS           9      // not used by WPS!
    297367                #define FSYS_REMOTE         10
     368                // NOTE: if this has a negative value, this is
     369                // the APIRET code from DosQueryFSAttach
     370
     371            // error codes for various operations
     372            APIRET  arcIsFixedDisk,
     373                    arcQueryDiskParams,
     374                    arcQueryMedia,
     375                    arcOpenLongnames;
    298376
    299377        } XDISKINFO, *PXDISKINFO;
     
    477555    {
    478556        HFILE       hf;
    479         ULONG       hmtx;       // a HMTX really
     557        // ULONG       hmtx;       // a HMTX really
    480558
    481559        PSZ         pszFilename;    // as given to doshOpen
     
    812890     ********************************************************************/
    813891
     892    BOOL doshMatchCase(PCSZ pcszMask,
     893                       PCSZ pcszName);
     894
    814895    BOOL doshMatch(PCSZ pcszMask,
    815896                   PCSZ pcszName);
  • trunk/include/helpers/winh.h

    r127 r135  
    106106        BOOL XWPENTRY winhSetDlgItemText(HWND hwnd, ULONG id, const char *pcsz);
    107107        #define WinSetDlgItemText(a,b,c) winhSetDlgItemText((a),(b),(c))
     108
     109        #ifdef INCL_WINMESSAGEMGR
     110            APIRET XWPENTRY winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
     111            #define WinRequestMutexSem(a, b) winhRequestMutexSem((a), (b))
     112        #endif
    108113    #endif
    109114
  • trunk/src/helpers/dosh.c

    r133 r135  
    4949#define INCL_DOSMODULEMGR
    5050#define INCL_DOSPROCESS
     51#define INCL_DOSEXCEPTIONS
    5152#define INCL_DOSSESMGR
    5253#define INCL_DOSQUEUES
     
    7475
    7576// static const CHAR  G_acDriveLetters[28] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     77
     78/*
     79 *@@category: Helpers\Control program helpers\Wrappers
     80 */
     81
     82/* ******************************************************************
     83 *
     84 *   Wrappers
     85 *
     86 ********************************************************************/
     87
     88#ifdef DOSH_STANDARDWRAPPERS
     89
     90    /*
     91     *@@ doshSleep:
     92     *
     93     *@@added V0.9.16 (2002-01-26) [umoeller]
     94     */
     95
     96    APIRET doshSleep(ULONG msec)
     97    {
     98        // put the call in brackets so the macro won't apply here
     99        return (DosSleep)(msec);
     100    }
     101
     102    /*
     103     *@@ doshCreateMutexSem:
     104     *
     105     *@@added V0.9.16 (2002-01-26) [umoeller]
     106     */
     107
     108    APIRET doshCreateMutexSem(PSZ pszName,
     109                              PHMTX phmtx,
     110                              ULONG flAttr,
     111                              BOOL32 fState)
     112    {
     113        // put the call in brackets so the macro won't apply here
     114        return (DosCreateMutexSem)(pszName, phmtx, flAttr, fState);
     115    }
     116
     117    /*
     118     *@@ doshRequestMutexSem:
     119     *
     120     *@@added V0.9.16 (2002-01-26) [umoeller]
     121     */
     122
     123    APIRET doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout)
     124    {
     125        return (DosRequestMutexSem)(hmtx, ulTimeout);
     126    }
     127
     128    /*
     129     *@@ doshReleaseMutexSem:
     130     *
     131     *@@added V0.9.16 (2002-01-26) [umoeller]
     132     */
     133
     134    APIRET doshReleaseMutexSem(HMTX hmtx)
     135    {
     136        return (DosReleaseMutexSem)(hmtx);
     137    }
     138
     139    /*
     140     *@@ doshSetExceptionHandler:
     141     *
     142     *@@added V0.9.16 (2002-01-26) [umoeller]
     143     */
     144
     145    APIRET doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec)
     146    {
     147        // put the call in brackets so the macro won't apply here
     148        return (DosSetExceptionHandler)(pERegRec);
     149    }
     150
     151    /*
     152     *@@ doshUnsetExceptionHandler:
     153     *
     154     *@@added V0.9.16 (2002-01-26) [umoeller]
     155     */
     156
     157    APIRET doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec)
     158    {
     159        // put the call in brackets so the macro won't apply here
     160        return (DosUnsetExceptionHandler)(pERegRec);
     161    }
     162
     163#endif
    76164
    77165/*
     
    427515 *      removeable disks.
    428516 *
     517 *      Returns:
     518 *
     519 *      --  NO_ERROR: *pfFixed was set.
     520 *
     521 *      --  ERROR_INVALID_DRIVE: drive letter invalid
     522 *
     523 *      --  ERROR_NOT_SUPPORTED (50): for network drives.
     524 *
    429525 *@@changed V0.9.14 (2001-08-03) [umoeller]: added extra fix for A: and B:
    430526 */
     
    555651
    556652/*
    557  *@@ doshQueryRemoveableType:
     653 *@@ doshQueryDriveType:
    558654 *      tests the specified BIOSPARAMETERBLOCK
    559655 *      for whether it represents a CD-ROM or
     
    562658 *      Returns one of:
    563659 *
    564  *      --  0
     660 *      --  DRVTYPE_HARDDISK (0)
     661 *
     662 *      --  DRVTYPE_PARTITIONABLEREMOVEABLE
    565663 *
    566664 *      --  DRVTYPE_CDROM
    567665 *
    568  *      Call this only if doshIsFixedDisk
    569  *      returned FALSE.
     666 *      --  DRVTYPE_TAPE
     667 *
     668 *      --  DRVTYPE_VDISK
     669 *
     670 *      --  DRVTYPE_FLOPPY
     671 *
     672 *      --  DRVTYPE_UNKNOWN (255)
    570673 *
    571674 *      The BIOSPARAMETERBLOCK must be filled
     
    575678 */
    576679
    577 BYTE doshQueryRemoveableType(PBIOSPARAMETERBLOCK pdp)
     680BYTE doshQueryDriveType(ULONG ulLogicalDrive,
     681                        PBIOSPARAMETERBLOCK pdp,
     682                        BOOL fFixed)
    578683{
    579684    if (pdp)
    580685    {
    581         if (    (pdp->bDeviceType == 7)     // "other"
    582              && (pdp->usBytesPerSector == 2048)
    583              && (pdp->usSectorsPerTrack == (USHORT)-1)
    584            )
    585             return DRVTYPE_CDROM;
    586         else if (pdp->fsDeviceAttr & DEVATTR_PARTITIONALREMOVEABLE) // 0x08
     686        if (pdp->fsDeviceAttr & DEVATTR_PARTITIONALREMOVEABLE) // 0x08
    587687            return DRVTYPE_PARTITIONABLEREMOVEABLE;
    588         else if (pdp->bDeviceType == 6)     // tape
    589             return DRVTYPE_TAPE;
    590     }
    591 
    592     return (0);
     688        else if (fFixed)
     689            return DRVTYPE_HARDDISK;
     690        else if (    (pdp->bDeviceType == 7)     // "other"
     691                  && (pdp->usBytesPerSector == 2048)
     692                  && (pdp->usSectorsPerTrack == (USHORT)-1)
     693                )
     694                 return DRVTYPE_CDROM;
     695        else switch (pdp->bDeviceType)
     696        {
     697            case DEVTYPE_TAPE: // 6
     698                return DRVTYPE_TAPE;
     699
     700            case DEVTYPE_48TPI:     // 0, 360k  5.25" floppy
     701            case DEVTYPE_96TPI:     // 1, 1.2M  5.25" floppy
     702            case DEVTYPE_35:        // 2, 720k  3.5" floppy
     703            case DEVTYPE_OTHER:     // 7, 1.44  3.5" floppy
     704                                    //    1.84M 3.5" floppy
     705            case DEVTYPE_35_288MB:
     706                if (    (ulLogicalDrive == 1)
     707                     || (ulLogicalDrive == 2)
     708                   )
     709                    return DRVTYPE_FLOPPY;
     710                else
     711                    return DRVTYPE_VDISK;
     712
     713            case DEVTYPE_RWOPTICAL: // 8, what is this?!?
     714                return DRVTYPE_FLOPPY;
     715        }
     716    }
     717
     718    return (DRVTYPE_UNKNOWN);
    593719}
    594720
     
    854980
    855981APIRET doshQueryMedia(ULONG ulLogicalDrive,
    856                       BOOL fCDROM,
     982                      BOOL fCDROM,             // in: is drive CD-ROM?
    857983                      ULONG fl)                // in: DRVFL_* flags
    858984{
     
    9781104
    9791105            if (    (!arc)
    980                  && (DRVTYPE_CDROM == doshQueryRemoveableType(&bpb))
     1106                 && (DRVTYPE_CDROM == doshQueryDriveType(ulLogicalDrive,
     1107                                                         &bpb,
     1108                                                         fFixed))
    9811109               )
    9821110            {
     
    10351163 *
    10361164 *      This function will not provoke "Drive not
    1037  *      ready" popups, hopefully. Tested with the
    1038  *      following drive types:
    1039  *
    1040  *      --  all kinds of local partitions (FAT,
    1041  *          FAT32, HPFS, JFS)
    1042  *
    1043  *      --  remote NetBIOS drives added via "net use"
    1044  *
    1045  *      --  CD-ROM drives; one DVD drive and one
    1046  *          CD writer, even if no media is present
     1165 *      ready" popups, hopefully.
    10471166 *
    10481167 *      fl can be any combination of the following:
     
    10551174 *          default values will be returned.
    10561175 *
     1176 *      --  DRVFL_CHECKEAS: drive should always be
     1177 *          checked for EA support. If this is set,
     1178 *          we will call DosFSCtl for the non-well-known
     1179 *          file systems so we will always have a
     1180 *          value for the DFL_SUPPORTS_EAS flags.
     1181 *          Otherwise that flag might or might not
     1182 *          be set correctly.
     1183 *
     1184 *          The EA support returned by DosFSCtl
     1185 *          might not be correct for remote file
     1186 *          systems since not all of them support
     1187 *          that query.
     1188 *
     1189 *      --  DRVFL_CHECKLONGNAMES: drive should always be
     1190 *          checked for longname support. If this is
     1191 *          set, we will try a DosOpen on the drive
     1192 *          to see if it supports long filenames
     1193 *          (unless it's a "well-known" file-system
     1194 *          and we know it does). In enabled, the
     1195 *          DFL_SUPPORTS_LONGNAMES flag is reliable.
     1196 *
    10571197 *      This should return only one of the following:
    1058  *
    1059  *      --  ERROR_INVALID_DRIVE: drive letter is invalid
    1060  *
    1061  *      --  ERROR_DRIVE_LOCKED
    10621198 *
    10631199 *      --  NO_ERROR: disk info was filled, but not
    10641200 *          necessarily all info was available (e.g.
    10651201 *          if no media was present in CD-ROM drive).
     1202 *          See remarks below.
     1203 *
     1204 *      --  ERROR_INVALID_DRIVE 15): ulLogicalDrive
     1205 *          is not used at all (invalid drive letter)
     1206 *
     1207 *      --  ERROR_BAD_UNIT (20): if drive was renamed for
     1208 *          some reason (according to user reports
     1209 *
     1210 *      --  ERROR_NOT_READY (21): for ZIP disks where
     1211 *          no media is inserted, depending on the
     1212 *          driver apparently... normally ZIP drive
     1213 *          letters should disappear when no media
     1214 *          is present
     1215 *
     1216 *      --  ERROR_DRIVE_LOCKED (108)
     1217 *
     1218 *      So in order to check whether a drive is present
     1219 *      and available, use this function as follows:
     1220 *
     1221 *      1)  Call this function and check whether it
     1222 *          returns NO_ERROR for the given drive.
     1223 *          This will rule out invalid drive letters
     1224 *          and drives that are presently locked.
     1225 *
     1226 *      2)  If so, check whether XDISKINFO.flDevice
     1227 *          has the DFL_MEDIA_PRESENT flag set.
     1228 *          This will rule out removeable drives without
     1229 *          media and unformatted hard disks.
     1230 *
     1231 *      3)  If so, you can test the other fields if
     1232 *          you need more information. For example,
     1233 *          it would not be a good idea to create
     1234 *          a new file if the bType field is
     1235 *          DRVTYPE_CDROM.
     1236 *
     1237 *          If you want to exclude removeable disks,
     1238 *          instead of checking bType, you should
     1239 *          rather check flDevice for the DFL_FIXED
     1240 *          flag, which will be set for ZIP drives also.
     1241 *
     1242 *      Remarks for special drive types:
     1243 *
     1244 *      --  Hard disks always have bType == DRVTYPE_HARDDISK.
     1245 *          For them, we always check the file system.
     1246 *          If this is reported as "UNKNOWN", this means
     1247 *          that the drive is unformatted or formatted
     1248 *          with a file system that OS/2 does not understand
     1249 *          (e.g. NTFS). Only in that case, flDevice
     1250 *          has the DFL_MEDIA_PRESENT bit clear.
     1251 *
     1252 *          DFL_FIXED is always set.
     1253 *
     1254 *      --  Remote (LAN) drives always have bType == DRVTYPE_LAN.
     1255 *          flDevice will always have the DFL_REMOTE and
     1256 *          DFL_MEDIA_PRESENT bits set.
     1257 *
     1258 *      --  ZIP disks will have bType == DRVTYPE_PARTITIONABLEREMOVEABLE.
     1259 *          For them, flDevice will have both the
     1260 *          and DFL_PARTITIONABLEREMOVEABLE and DFL_FIXED
     1261 *          bits set.
     1262 *
     1263 *          ZIP disks are a bit special because they are
     1264 *          dynamically mounted and unmounted when media
     1265 *          is inserted and removed. In other words, if
     1266 *          no media is present, the drive letter becomes
     1267 *          invalid.
     1268 *
     1269 *      --  CD-ROM and DVD drives and CD writers will always
     1270 *          be reported as DRVTYPE_CDROM. The DFL_FIXED bit
     1271 *          will be clear always. For them, always check the
     1272 *          DFL_MEDIA_PRESENT present bit to avoid "Drive not
     1273 *          ready" popups.
     1274 *
     1275 *          As a special goody, we can also determine if the
     1276 *          drive currently has audio media inserted (which
     1277 *          would provoke errors also), by setting the
     1278 *          DFL_AUDIO_CD bit.
    10661279 *
    10671280 *@@added V0.9.16 (2002-01-13) [umoeller]
     
    10761289    HFILE   hf;
    10771290    ULONG   dummy;
    1078     BOOL    fCheck = TRUE;
     1291    BOOL    fCheck = TRUE,
     1292            fCheckFS = FALSE,
     1293            fCheckLongnames = FALSE,
     1294            fCheckEAs = FALSE;
    10791295
    10801296    memset(pdi, 0, sizeof(XDISKINFO));
     
    11001316            pdi->flDevice  = DFL_MEDIA_PRESENT | DFL_SUPPORTS_EAS;
    11011317            strcpy(pdi->szFileSystem, "FAT");
    1102             pdi->bFileSystem = FSYS_FAT;
     1318            pdi->lFileSystem = FSYS_FAT;
    11031319        }
    11041320    }
     
    11121328                              &fFixed);
    11131329
    1114         if (arc == ERROR_INVALID_DRIVE)
    1115             // drive letter doesn't exist at all:
    1116             pdi->fPresent = FALSE;
    1117             // return this APIRET
    1118         else
     1330        switch (arc)
    11191331        {
    1120             BOOL fCheckFS = FALSE;
    1121             BOOL fCheckLongnames = FALSE;
    1122 
    1123             if (fFixed)
    1124                 // fixed drive:
    1125                 pdi->flDevice |= DFL_FIXED | DFL_MEDIA_PRESENT;
    1126 
    1127             if (!(arc = doshQueryDiskParams(ulLogicalDrive,
    1128                                             &pdi->bpb)))
    1129             {
    1130                 if (!fFixed)
    1131                 {
    1132                     // removeable:
    1133                     BYTE bTemp;
    1134                     if (bTemp = doshQueryRemoveableType(&pdi->bpb))
    1135                     {
    1136                         // DRVTYPE_TAPE or DRVTYPE_CDROM
    1137                         pdi->bType = bTemp;
    1138 
    1139                         if (bTemp == DRVTYPE_PARTITIONABLEREMOVEABLE)
    1140                             pdi->flDevice |=    DFL_FIXED
    1141                                               | DFL_PARTITIONABLEREMOVEABLE;
    1142                     }
    1143 
    1144                     // before checking the drive, try if we have media
    1145                     if (!(arc = doshQueryMedia(ulLogicalDrive,
    1146                                                (pdi->bType == DRVTYPE_CDROM),
    1147                                                fl)))
    1148                     {
    1149                         pdi->flDevice |= DFL_MEDIA_PRESENT;
    1150                         fCheckFS = TRUE;
    1151                         fCheckLongnames = TRUE;
    1152                     }
    1153                     else if (arc == ERROR_AUDIO_CD_ROM)
    1154                     {
    1155                         pdi->flDevice |= DFL_AUDIO_CD;
    1156                         // do not check longnames and file-system
    1157                     }
    1158 
    1159                     arc = NO_ERROR;
    1160                 }
    1161                 else
    1162                 {
    1163                     pdi->bType = DRVTYPE_HARDDISK;
    1164                     fCheckFS = TRUE;
    1165                 }
    1166             }
    1167             else if (arc == ERROR_NOT_SUPPORTED)       // 50
    1168             {
     1332            case ERROR_INVALID_DRIVE:
     1333                // drive letter doesn't exist at all:
     1334                pdi->fPresent = FALSE;
     1335                // return this APIRET
     1336            break;
     1337
     1338            case ERROR_NOT_SUPPORTED:       // 50 for network drives
    11691339                // we get this for remote drives added
    11701340                // via "net use", so set these flags
    11711341                pdi->bType = DRVTYPE_LAN;
    1172                 pdi->bFileSystem = FSYS_REMOTE;
     1342                pdi->lFileSystem = FSYS_REMOTE;
    11731343                pdi->flDevice |= DFL_REMOTE | DFL_MEDIA_PRESENT;
    11741344                // but still check what file-system we
     
    11761346                fCheckFS = TRUE;
    11771347                fCheckLongnames = TRUE;
    1178             }
    1179 
    1180             if (fCheckFS)
     1348                fCheckEAs = TRUE;
     1349            break;
     1350
     1351            case NO_ERROR:
    11811352            {
    1182                 // TRUE only for local fixed disks or
    1183                 // remote drives or if media was present above
    1184                 if (!(arc = doshQueryDiskFSType(ulLogicalDrive,
    1185                                                 pdi->szFileSystem,
    1186                                                 sizeof(pdi->szFileSystem))))
     1353                if (fFixed)
    11871354                {
    1188                     if (!stricmp(pdi->szFileSystem, "FAT"))
     1355                    // fixed drive:
     1356                    pdi->flDevice |= DFL_FIXED | DFL_MEDIA_PRESENT;
     1357
     1358                    fCheckFS = TRUE;
     1359                    fCheckLongnames = TRUE;
     1360                    fCheckEAs = TRUE;
     1361                }
     1362
     1363                if (!(arc = doshQueryDiskParams(ulLogicalDrive,
     1364                                                &pdi->bpb)))
     1365                {
     1366                    BYTE bTemp = doshQueryDriveType(ulLogicalDrive,
     1367                                                    &pdi->bpb,
     1368                                                    fFixed);
     1369                    if (bTemp != DRVTYPE_UNKNOWN)
    11891370                    {
    1190                         pdi->bFileSystem = FSYS_FAT;
    1191                         pdi->flDevice |= DFL_SUPPORTS_EAS;
    1192                         fCheckLongnames = FALSE;
     1371                        // recognized: store it then
     1372                        pdi->bType = bTemp;
     1373
     1374                        if (bTemp == DRVTYPE_PARTITIONABLEREMOVEABLE)
     1375                            pdi->flDevice |=    DFL_FIXED
     1376                                              | DFL_PARTITIONABLEREMOVEABLE;
    11931377                    }
    1194                     else if (    (!stricmp(pdi->szFileSystem, "HPFS"))
    1195                               || (!stricmp(pdi->szFileSystem, "JFS"))
    1196                             )
     1378
     1379                    if (!fFixed)
    11971380                    {
    1198                         pdi->bFileSystem = FSYS_HPFS_JFS;
    1199                         pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES;
    1200                         fCheckLongnames = FALSE;
    1201                     }
    1202                     else if (!stricmp(pdi->szFileSystem, "CDFS"))
    1203                         pdi->bFileSystem = FSYS_CDFS;
    1204                     else if (!stricmp(pdi->szFileSystem, "FAT32"))
    1205                     {
    1206                         pdi->bFileSystem = FSYS_FAT32;
    1207                         pdi->flDevice |= DFL_SUPPORTS_LONGNAMES;
    1208                                 // @@todo check EA support
    1209                         fCheckLongnames = FALSE;
    1210                     }
    1211                     else if (!stricmp(pdi->szFileSystem, "RAMFS"))
    1212                     {
    1213                         pdi->bFileSystem = FSYS_RAMFS;
    1214                         pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES;
    1215                         fCheckLongnames = FALSE;
     1381                        // removeable:
     1382
     1383                        // before checking the drive, try if we have media
     1384                        if (!(arc = doshQueryMedia(ulLogicalDrive,
     1385                                                   (pdi->bType == DRVTYPE_CDROM),
     1386                                                   fl)))
     1387                        {
     1388                            pdi->flDevice |= DFL_MEDIA_PRESENT;
     1389                            fCheckFS = TRUE;
     1390                            fCheckLongnames = TRUE;
     1391                                    // but never EAs
     1392                        }
     1393                        else if (arc == ERROR_AUDIO_CD_ROM)
     1394                        {
     1395                            pdi->flDevice |= DFL_AUDIO_CD;
     1396                            // do not check longnames and file-system
     1397                        }
     1398                        else
     1399                            pdi->arcQueryMedia = arc;
     1400
     1401                        arc = NO_ERROR;
    12161402                    }
    12171403                }
    1218                 // else if this failed, we had an error popup!!
    1219                 // shouldn't happen!!
     1404                else
     1405                    pdi->arcQueryDiskParams = arc;
    12201406            }
    1221 
    1222             if (fCheckLongnames)
     1407            break;
     1408
     1409            default:
     1410                pdi->arcIsFixedDisk = arc;
     1411                // and return this
     1412            break;
     1413
     1414        } // end swich arc = doshIsFixedDisk(ulLogicalDrive, &fFixed);
     1415    }
     1416
     1417    if (fCheckFS)
     1418    {
     1419        // TRUE only for local fixed disks or
     1420        // remote drives or if media was present above
     1421        if (!(arc = doshQueryDiskFSType(ulLogicalDrive,
     1422                                        pdi->szFileSystem,
     1423                                        sizeof(pdi->szFileSystem))))
     1424        {
     1425            if (!stricmp(pdi->szFileSystem, "UNKNOWN"))
    12231426            {
    1224                 CHAR szTemp[30] = "?:\\long.name.file";
    1225                 szTemp[0]  = ulLogicalDrive + 'A' - 1;
    1226                 if (!(arc = DosOpen(szTemp,
    1227                                     &hf,
    1228                                     &dummy,
    1229                                     0,
    1230                                     0,
    1231                                     FILE_READONLY,
    1232                                     OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT,
    1233                                     0)))
    1234                 {
    1235                     DosClose(hf);
    1236                 }
    1237 
    1238                 switch (arc)
    1239                 {
    1240                     case NO_ERROR:
    1241                     case ERROR_OPEN_FAILED:
    1242                         pdi->flDevice |= DFL_SUPPORTS_LONGNAMES;
    1243 
    1244                     // otherwise we get ERROR_INVALID_NAME
    1245                     // default:
    1246                        //  printf("      drive %d returned %d\n", ulLogicalDrive, arc);
    1247                 }
    1248 
    1249                 arc = NO_ERROR;
     1427                // this is returned by the stupid DosQueryFSAttach
     1428                // if the file system is not recognized by OS/2,
     1429                // or if the drive is unformatted
     1430                pdi->lFileSystem = FSYS_UNKNOWN;
     1431                pdi->flDevice &= ~DFL_MEDIA_PRESENT;
     1432                fCheckLongnames = FALSE;
     1433                fCheckEAs = FALSE;
     1434                        // should we return ERROR_NOT_DOS_DISK (26)
     1435                        // in this case?
     1436            }
     1437            else if (!stricmp(pdi->szFileSystem, "FAT"))
     1438            {
     1439                pdi->lFileSystem = FSYS_FAT;
     1440                pdi->flDevice |= DFL_SUPPORTS_EAS;
     1441                fCheckLongnames = FALSE;
     1442                fCheckEAs = FALSE;
     1443            }
     1444            else if (    (!stricmp(pdi->szFileSystem, "HPFS"))
     1445                      || (!stricmp(pdi->szFileSystem, "JFS"))
     1446                    )
     1447            {
     1448                pdi->lFileSystem = FSYS_HPFS_JFS;
     1449                pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES;
     1450                fCheckLongnames = FALSE;
     1451                fCheckEAs = FALSE;
     1452            }
     1453            else if (!stricmp(pdi->szFileSystem, "CDFS"))
     1454                pdi->lFileSystem = FSYS_CDFS;
     1455            else if (    (!stricmp(pdi->szFileSystem, "FAT32"))
     1456                      || (!stricmp(pdi->szFileSystem, "ext2"))
     1457                    )
     1458            {
     1459                pdi->lFileSystem = FSYS_FAT32_EXT2;
     1460                fCheckLongnames = TRUE;
     1461                fCheckEAs = TRUE;
     1462            }
     1463            else if (!stricmp(pdi->szFileSystem, "RAMFS"))
     1464            {
     1465                pdi->lFileSystem = FSYS_RAMFS;
     1466                pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES;
     1467                fCheckLongnames = FALSE;
     1468                fCheckEAs = FALSE;
     1469            }
     1470            else if (!stricmp(pdi->szFileSystem, "TVFS"))
     1471            {
     1472                pdi->lFileSystem = FSYS_TVFS;
     1473                fCheckLongnames = TRUE;
     1474                fCheckEAs = TRUE;
    12501475            }
    12511476        }
     1477        else
     1478            // store negative error code
     1479            pdi->lFileSystem = -(LONG)arc;
     1480    }
     1481
     1482    if (    (!arc)
     1483         && (fCheckLongnames)
     1484         && (fl & DRVFL_CHECKLONGNAMES)
     1485       )
     1486    {
     1487        CHAR szTemp[30] = "?:\\long.name.file";
     1488        szTemp[0]  = ulLogicalDrive + 'A' - 1;
     1489        if (!(arc = DosOpen(szTemp,
     1490                            &hf,
     1491                            &dummy,
     1492                            0,
     1493                            0,
     1494                            FILE_READONLY,
     1495                            OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT,
     1496                            0)))
     1497        {
     1498            DosClose(hf);
     1499        }
     1500
     1501        switch (arc)
     1502        {
     1503            case NO_ERROR:
     1504            case ERROR_OPEN_FAILED:
     1505            case ERROR_FILE_NOT_FOUND:      // returned by TVFS
     1506                pdi->flDevice |= DFL_SUPPORTS_LONGNAMES;
     1507            break;
     1508
     1509            // if longnames are not supported,
     1510            // we get ERROR_INVALID_NAME
     1511            default:
     1512                pdi->arcOpenLongnames = arc;
     1513            break;
     1514
     1515            // default:
     1516               //  printf("      drive %d returned %d\n", ulLogicalDrive, arc);
     1517        }
     1518
     1519        arc = NO_ERROR;
     1520    }
     1521
     1522    if (    (!arc)
     1523         && (fCheckEAs)
     1524         && (fl & DRVFL_CHECKEAS)
     1525       )
     1526    {
     1527        EASIZEBUF easb = {0};
     1528        ULONG   cbData = sizeof(easb),
     1529                cbParams = 0;
     1530        CHAR    szDrive[] = "?:\\";
     1531        szDrive[0] = pdi->cDriveLetter;
     1532        if (!(arc = DosFSCtl(&easb,
     1533                             cbData,
     1534                             &cbData,
     1535                             NULL, // params,
     1536                             cbParams,
     1537                             &cbParams,
     1538                             FSCTL_MAX_EASIZE,
     1539                             szDrive,
     1540                             -1,        // HFILE
     1541                             FSCTL_PATHNAME)))
     1542            if (easb.cbMaxEASize != 0)
     1543                        // the other field (cbMaxEAListSize) is 0 always, I think
     1544                pdi->flDevice |= DFL_SUPPORTS_EAS;
    12521545    }
    12531546
     
    21272420 */
    21282421
    2129 APIRET doshLockFile(PXFILE pFile)
     2422/* APIRET doshLockFile(PXFILE pFile)
    21302423{
    21312424    if (!pFile)
     
    21402433
    21412434    return (DosRequestMutexSem(pFile->hmtx, SEM_INDEFINITE_WAIT));
    2142 }
     2435} */
    21432436
    21442437/*
     
    21482441 */
    21492442
    2150 APIRET doshUnlockFile(PXFILE pFile)
     2443/* APIRET doshUnlockFile(PXFILE pFile)
    21512444{
    21522445    if (pFile)
     
    21542447
    21552448    return (ERROR_INVALID_PARAMETER);
    2156 }
     2449} */
    21572450
    21582451/*
     
    21982491                  ULONG fl)         // in: DRFL_* flags
    21992492{
    2200     APIRET arc;
     2493    APIRET arc = NO_ERROR;
    22012494    ULONG cb = *pcb;
    22022495    ULONG ulDummy;
    22032496
    2204     if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     2497    // if (!(arc = doshLockFile(pFile)))   // this checks for pFile
    22052498    {
    22062499        *pcb = 0;
     
    23572650        }
    23582651
    2359         doshUnlockFile(pFile);
     2652        // doshUnlockFile(pFile);
    23602653    }
    23612654
     
    24442737
    24452738            if (!arc)
    2446                 if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     2739                // if (!(arc = doshLockFile(pFile)))   // this checks for pFile
    24472740                {
    24482741                    ULONG cbWritten;
     
    24592752                    }
    24602753
    2461                     doshUnlockFile(pFile);
     2754                    // doshUnlockFile(pFile);
    24622755                }
    24632756
     
    24842777                   PCSZ pbData)     // in: ptr to bytes to write (must be cb bytes)
    24852778{
    2486     APIRET arc;
    2487     if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     2779    APIRET arc = NO_ERROR;
     2780    // if (!(arc = doshLockFile(pFile)))   // this checks for pFile
    24882781    {
    24892782        ULONG cbWritten;
     
    25032796        }
    25042797
    2505         doshUnlockFile(pFile);
     2798        // doshUnlockFile(pFile);
    25062799    }
    25072800
     
    25822875        // request the mutex so that we won't be
    25832876        // taking the file away under someone's butt
    2584         if (!(arc = doshLockFile(pFile)))
     2877        // if (!(arc = doshLockFile(pFile)))
    25852878        {
    2586             HMTX hmtx = pFile->hmtx;
    2587             pFile->hmtx = NULLHANDLE;
     2879            // HMTX hmtx = pFile->hmtx;
     2880            // pFile->hmtx = NULLHANDLE;
    25882881
    25892882            // now that the file is locked,
     
    26012894            }
    26022895
    2603             doshUnlockFile(pFile);
    2604             DosCloseMutexSem(pFile->hmtx);
     2896            // doshUnlockFile(pFile);
     2897            // DosCloseMutexSem(pFile->hmtx);
    26052898        }
    26062899
     
    39614254    ULONG ul;
    39624255
    3963             printf("    type     fs       remot fixed parrm bootd       media audio eas   longn\n");
     4256            printf("Drive checker ("__DATE__")\n");
     4257            printf("    type   fs      remot fixed parrm bootd       media audio eas   longn\n");
    39644258
    39654259    for (ul = 1;
     
    39714265                                      0, // DRVFL_TOUCHFLOPPIES,
    39724266                                      &xdi);
    3973         PCSZ pcsz = "unknown";
    39744267
    39754268        printf(" %c: ", xdi.cDriveLetter, ul);
     
    39804273        {
    39814274            if (arc)
    3982                 printf("error %4d\n", arc);
     4275                printf("error %d (IsFixedDisk: %d, QueryDiskParams %d, QueryMedia %d)\n",
     4276                        arc,
     4277                        xdi.arcIsFixedDisk,
     4278                        xdi.arcQueryDiskParams,
     4279                        xdi.arcQueryMedia);
    39834280            else
    39844281            {
     
    39974294                ULONG ul2;
    39984295
     4296                PCSZ pcsz = NULL;
     4297
    39994298                switch (xdi.bType)
    40004299                {
    4001                     case DRVTYPE_HARDDISK:  pcsz = "HARDDISK";    break;
    4002                     case DRVTYPE_FLOPPY:    pcsz = "FLOPPY  "; break;
    4003                     case DRVTYPE_TAPE:      pcsz = "TAPE    "; break;
    4004                     case DRVTYPE_VDISK:     pcsz = "VDISK   "; break;
    4005                     case DRVTYPE_CDROM:     pcsz = "CDROM   "; break;
    4006                     case DRVTYPE_LAN:       pcsz = "LAN     "; break;
     4300                    case DRVTYPE_HARDDISK:  pcsz = "HDISK ";    break;
     4301                    case DRVTYPE_FLOPPY:    pcsz = "FLOPPY"; break;
     4302                    case DRVTYPE_TAPE:      pcsz = "TAPE  "; break;
     4303                    case DRVTYPE_VDISK:     pcsz = "VDISK "; break;
     4304                    case DRVTYPE_CDROM:     pcsz = "CDROM "; break;
     4305                    case DRVTYPE_LAN:       pcsz = "LAN   "; break;
    40074306                    case DRVTYPE_PARTITIONABLEREMOVEABLE:
    4008                                             pcsz = "PARTREMV"; break;
     4307                                            pcsz = "PRTREM"; break;
     4308                    default:
     4309                                            printf("bType=%d, BPB.bDevType=%d",
     4310                                                    xdi.bType,
     4311                                                    xdi.bpb.bDeviceType);
     4312                                            printf("\n           ");
    40094313                }
    40104314
    4011                 printf("%s ", pcsz);
    4012 
    4013                 printf("%8s ", xdi.szFileSystem); // , xdi.bFileSystem);
     4315                if (pcsz)
     4316                    printf("%s ", pcsz);
     4317
     4318                if (xdi.lFileSystem < 0)
     4319                    // negative means error
     4320                    printf("E%3d    ", xdi.lFileSystem); // , xdi.bFileSystem);
     4321                else
     4322                    printf("%7s ", xdi.szFileSystem); // , xdi.bFileSystem);
    40144323
    40154324                for (ul2 = 0;
     
    40204329                        printf("  X   ");
    40214330                    else
    4022                         printf("  -   ");
     4331                        if (    (xdi.arcOpenLongnames)
     4332                             && (aulFlags[ul2] == DFL_SUPPORTS_LONGNAMES)
     4333                           )
     4334                            printf(" E%03d ", xdi.arcOpenLongnames);
     4335                        else
     4336                            printf("  -   ");
    40234337                }
    40244338                printf("\n");
  • trunk/src/helpers/dosh2.c

    r129 r135  
    21132113 *          one will.
    21142114 *
     2115 *      --  THIS COMPARES WITH RESPECT TO CASE.
     2116 *
    21152117 *      This replaces strhMatchOS2 which has been removed with
    21162118 *      V0.9.16 and is a lot faster than the old code, which has
     
    21202122 */
    21212123
    2122 BOOL doshMatch(const char *pcszMask,     // in: mask (e.g. "*.txt")
    2123                const char *pcszName)     // in: string to check (e.g. "test.txt")
     2124BOOL doshMatchCase(const char *pcszMask,     // in: mask (e.g. "*.TXT")
     2125                   const char *pcszName)     // in: string to check (e.g. "TEST.TXT")
    21242126{
    21252127    BOOL    brc = FALSE;
     
    21282130            iNameDrive = -1;
    21292131
    2130     ULONG   cbMask = strlen(pcszMask),
    2131             cbName = strlen(pcszName);
    2132     PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
    2133             pszName = (PSZ)_alloca(cbName + 1);
     2132    // ULONG   cbMask = strlen(pcszMask),
     2133    //         cbName = strlen(pcszName);
     2134    // PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
     2135    //         pszName = (PSZ)_alloca(cbName + 1);
    21342136
    21352137    PCSZ    pLastMaskComponent,
     
    21412143    CHAR    c;
    21422144
    2143     memcpy(pszMask, pcszMask, cbMask + 1);
    2144     nlsUpper(pszMask, cbMask);
    2145     memcpy(pszName, pcszName, cbName + 1);
    2146     nlsUpper(pszName, cbName);
    2147 
    2148     if (pLastMaskComponent = strrchr(pszMask, '\\'))
     2145    if (pLastMaskComponent = strrchr(pcszMask, '\\'))
    21492146    {
    21502147        // length of path component
    2151         cbMaskPath = pLastMaskComponent - pszMask;
     2148        cbMaskPath = pLastMaskComponent - pcszMask;
    21522149        pLastMaskComponent++;
    21532150    }
    21542151    else
    2155         pLastMaskComponent = pszMask;
    2156 
    2157     if (pLastNameComponent = strrchr(pszName, '\\'))
     2152        pLastMaskComponent = pcszMask;
     2153
     2154    if (pLastNameComponent = strrchr(pcszName, '\\'))
    21582155    {
    21592156        // length of path component
    2160         cbNamePath = pLastNameComponent - pszName;
     2157        cbNamePath = pLastNameComponent - pcszName;
    21612158        pLastNameComponent++;
    21622159    }
    21632160    else
    2164         pLastNameComponent = pszName;
     2161        pLastNameComponent = pcszName;
    21652162
    21662163    // compare paths; if the lengths are different
     
    21682165    if (    (cbMaskPath == cbNamePath)      // can both be null
    21692166         && (    (cbMaskPath == 0)
    2170               || (!memcmp(pszMask, pszName, cbMaskPath))
     2167              || (!memcmp(pcszMask, pcszName, cbMaskPath))
    21712168            )
    21722169       )
     
    21832180}
    21842181
    2185 
     2182/*
     2183 *@@ doshMatch:
     2184 *      like doshMatchCase, but compares without respect
     2185 *      to case.
     2186 *
     2187 *@@added V0.9.16 (2002-01-26) [umoeller]
     2188 */
     2189
     2190BOOL doshMatch(const char *pcszMask,     // in: mask (e.g. "*.TXT")
     2191               const char *pcszName)     // in: string to check (e.g. "TEST.TXT")
     2192{
     2193    ULONG   cbMask = strlen(pcszMask),
     2194            cbName = strlen(pcszName);
     2195    PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
     2196            pszName = (PSZ)_alloca(cbName + 1);
     2197
     2198    memcpy(pszMask, pcszMask, cbMask + 1);
     2199    nlsUpper(pszMask, cbMask);
     2200    memcpy(pszName, pcszName, cbName + 1);
     2201    nlsUpper(pszName, cbName);
     2202
     2203    return (doshMatchCase(pszMask,
     2204                          pszName));
     2205}
  • trunk/src/helpers/gpih.c

    r131 r135  
    5555#include "setup.h"                      // code generation and debugging options
    5656
     57#ifdef WINH_STANDARDWRAPPERS
     58#undef WINH_STANDARDWRAPPERS
     59#endif
    5760#include "helpers\winh.h"
    5861#include "helpers\gpih.h"
  • trunk/src/helpers/winh.c

    r132 r135  
    217217        // put the call in brackets so the macro won't apply here
    218218        return (WinSetDlgItemText)(hwnd, id, (PSZ)pcsz);
     219    }
     220
     221    /*
     222     *@@ winhRequestMutexSem:
     223     *
     224     *@@added V0.9.16 (2002-01-26) [umoeller]
     225     */
     226
     227    APIRET winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout)
     228    {
     229        // put the call in brackets so the macro won't apply here
     230        return (WinRequestMutexSem)(hmtx, ulTimeout);
    219231    }
    220232
Note: See TracChangeset for help on using the changeset viewer.