Changeset 328 for trunk/dll/valid.c
- Timestamp:
- Jul 25, 2006, 8:37:24 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/valid.c
r274 r328 7 7 8 8 Copyright (c) 1993, 1998 M. Kimes 9 Copyright (c) 2002, 200 5Steven H.Levine9 Copyright (c) 2002, 2006 Steven H.Levine 10 10 11 11 23 Nov 02 SHL RootName: rework for sanity … … 17 17 03 Jun 05 SHL Drop CD_DEBUG logic 18 18 28 Nov 05 SHL MakeValidDir: correct DosQuerySysInfo args 19 22 Jul 06 SHL Use Runtime_Error 19 20 20 21 ***********************************************************************/ … … 24 25 #define INCL_DOSDEVICES // DosDevIOCtl 25 26 #define INCL_DOSDEVIOCTL // DosDevIOCtl 26 27 27 #include <os2.h> 28 28 29 #include <stdlib.h> 29 30 #include <stdio.h> … … 32 33 33 34 #include "fm3dll.h" 35 #include "fm3str.h" 36 37 static PSZ pszSrcFile = __FILE__; 34 38 35 39 #pragma alloc_text(VALID,CheckDrive,IsRoot,IsFile,IsFullName,needsquoting) … … 189 193 CHAR *pfsd; 190 194 ULONG clBufferSize; 191 APIRET ulrc;195 APIRET rc; 192 196 ULONG ulAction; 193 197 ULONG clParmBytes; … … 217 221 218 222 # define BUFFER_BYTES 4096 219 if(DosAllocMem(&pvBuffer,BUFFER_BYTES,220 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {221 Dos Beep(50,50);223 rc = DosAllocMem(&pvBuffer,BUFFER_BYTES,PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 224 if (rc) { 225 Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 222 226 return -1; // Say failed 223 227 } … … 228 232 clBufferSize = BUFFER_BYTES; 229 233 DosError(FERR_DISABLEHARDERR); 230 ulrc = DosQueryFSAttach(szPath, 0, FSAIL_QUERYNAME,234 rc = DosQueryFSAttach(szPath, 0, FSAIL_QUERYNAME, 231 235 (PFSQBUFFER2)pvBuffer, &clBufferSize); 232 if ( ulrc)236 if (rc) 233 237 { 234 238 /* can't get any info at all */ … … 297 301 298 302 DosError(FERR_DISABLEHARDERR); 299 ulrc = DosOpen(szPath, &hDev, &ulAction, 0, 0, FILE_OPEN,303 rc = DosOpen(szPath, &hDev, &ulAction, 0, 0, FILE_OPEN, 300 304 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | 301 305 OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR, 0); 302 if( ulrc)306 if(rc) 303 307 { 304 308 DosError(FERR_DISABLEHARDERR); … … 313 317 NonRemovable = 1; // Preset as non removable 314 318 DosError(FERR_DISABLEHARDERR); 315 ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE,319 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE, 316 320 &parmPkt.Cmd, /* Address of the command-specific argument list. */ 317 321 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ … … 321 325 &clDataBytes); /* Pointer to the length of data. */ 322 326 323 if (! ulrc && NonRemovable) {327 if (!rc && NonRemovable) { 324 328 // Could be USB so check BPB flags 325 329 clParmBytes = sizeof(parmPkt.Cmd); … … 327 331 memset(&dataPkt, 0xff, sizeof(dataPkt)); 328 332 DosError(FERR_DISABLEHARDERR); 329 ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS,333 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS, 330 334 &parmPkt.Cmd, /* Address of the command-specific argument list. */ 331 335 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ … … 335 339 &clDataBytes); /* Pointer to the length of data. */ 336 340 337 if (! ulrc && (dataPkt.bpb.fsDeviceAttr & BPB_REMOVABLE_MEDIA))341 if (!rc && (dataPkt.bpb.fsDeviceAttr & BPB_REMOVABLE_MEDIA)) 338 342 NonRemovable = 0; 339 343 } … … 857 861 ULONG ulAction; 858 862 ULONG len; 859 APIRET ulrc;863 APIRET rc; 860 864 CHAR buff[512]; 861 865 … … 867 871 OPEN_ACCESS_READONLY,0L)) { 868 872 len = 512; 869 ulrc = DosRead(handle,buff,len,&len);873 rc = DosRead(handle,buff,len,&len); 870 874 DosClose(handle); 871 if(! ulrc && len)875 if(!rc && len) 872 876 return IsBinary(buff,len); 873 877 } … … 887 891 PFN WQDPath; 888 892 HMODULE hmod = 0; 889 APIRET ulrc;893 APIRET rc; 890 894 ULONG startdrive = 3L; 891 895 CHAR objerr[CCHMAXPATH]; 892 896 893 if(!objectpath) 897 if (!objectpath) { 898 Runtime_Error(pszSrcFile, __LINE__, "null pointer"); 894 899 return; 900 } 895 901 *objectpath = 0; 896 if (OS2ver[0] > 20 || (OS2ver[0] == 20 && OS2ver[1] >= 30)) {902 if (OS2ver[0] > 20 || (OS2ver[0] == 20 && OS2ver[1] >= 30)) { 897 903 /* 898 904 * if running under warp, we can get the desktop name 899 905 * this way... 900 906 */ 901 ulrc = DosLoadModule(objerr,907 rc = DosLoadModule(objerr, 902 908 sizeof(objerr), 903 909 "PMWP", 904 910 &hmod); 905 if(! ulrc) {906 ulrc = DosQueryProcAddr(hmod,911 if(!rc) { 912 rc = DosQueryProcAddr(hmod, 907 913 262, 908 914 NULL, 909 915 &WQDPath); 910 if(! ulrc)916 if(!rc) 911 917 WQDPath(objectpath,size); 912 918 DosFreeModule(hmod); 913 919 } 914 920 } 915 if(!*objectpath) { 916 if(!PrfQueryProfileString(HINI_SYSTEMPROFILE, 917 "FolderWorkareaRunningObjects", 918 NULL, 919 "\0", 920 (PVOID)objectpath, 921 sizeof(objectpath))) 921 if (!*objectpath) { 922 // Fall back to INI content 923 if (!PrfQueryProfileString(HINI_SYSTEMPROFILE, 924 "FolderWorkareaRunningObjects", 925 NULL, 926 "\0", 927 (PVOID)objectpath, 928 sizeof(objectpath))) { 929 Win_Error(HWND_DESKTOP,HWND_DESKTOP,pszSrcFile,__LINE__,"PrfQueryProfileString"); 922 930 *objectpath = 0; 923 if(!*objectpath || IsFile(objectpath)) { 924 DosBeep(250,10); 931 } 932 else if (!*objectpath || IsFile(objectpath)) { 933 Runtime_Error(pszSrcFile, __LINE__, "bad FolderWorkareaRunningObjects"); 934 *objectpath = 0; 935 } 936 if (!*objectpath) { 937 // Fall back - fixme to work for NLS 925 938 DosError(FERR_DISABLEHARDERR); 926 939 DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,
Note:
See TracChangeset
for help on using the changeset viewer.