Changeset 103 for trunk/dll/valid.c
- Timestamp:
- Jun 17, 2004, 6:40:41 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/valid.c
r70 r103 6 6 File name manipulation routines 7 7 8 Copyright (c) 1993 -98 M. Kimes9 Copyright (c) 2002 Steven H.Levine8 Copyright (c) 1993, 1998 M. Kimes 9 Copyright (c) 2002, 2004 Steven H.Levine 10 10 11 11 Revisions 23 Nov 02 SHL - RootName: rework for sanity 12 12 27 Nov 02 SHL - MakeFullName: correct typo 13 13 11 Jun 03 SHL - Add JFS and FAT32 support 14 15 Jun 04 SHL - Implement Jim Read's removable logic 14 15 15 16 ***********************************************************************/ … … 17 18 #define INCL_DOS 18 19 #define INCL_WIN 20 #define INCL_DOSDEVICES // DosDevIOCtl 21 #define INCL_DOSDEVIOCTL // DosDevIOCtl 19 22 20 23 #include <os2.h> … … 23 26 #include <string.h> 24 27 #include <ctype.h> 28 25 29 #include "fm3dll.h" 26 30 … … 34 38 35 39 36 APIRET MakeFullName (char * filename) {37 38 /* filename must be CCHMAXPATH long minimum! */39 40 char fullname[CCHMAXPATH];40 APIRET MakeFullName (char *pszFileName) 41 { 42 /* pszFileName must be CCHMAXPATH long minimum! */ 43 44 char szPathName[CCHMAXPATH]; 41 45 APIRET rc; 42 46 43 47 DosError(FERR_DISABLEHARDERR); 44 rc = DosQueryPathInfo( filename,45 46 fullname,47 sizeof(fullname));48 rc = DosQueryPathInfo(pszFileName, 49 FIL_QUERYFULLNAME, 50 szPathName, 51 sizeof(szPathName)); 48 52 if(!rc) 49 strcpy( filename, fullname); // Useactual name53 strcpy(pszFileName, szPathName); // Pass back actual name 50 54 return rc; 51 55 } 52 56 53 57 54 char *RootName (char *filename) {55 58 char *RootName (char *filename) 59 { 56 60 char *p = NULL,*pp; 57 61 … … 63 67 pp = strrchr(filename,'/'); 64 68 p = (p) ? 65 66 67 68 69 70 69 (pp) ? 70 (p > pp) ? 71 p : 72 pp : 73 p : 74 pp; 71 75 } 72 76 if(!p) /* name is itself a root */ … … 78 82 79 83 80 int TestDates (char *file1,char *file2) {81 84 int TestDates (char *file1,char *file2) 85 { 82 86 /* 83 87 * return 1 (file2 newer than file1), … … 91 95 DosError(FERR_DISABLEHARDERR); 92 96 if(!DosQueryPathInfo(file1, 93 94 95 97 FIL_STANDARD, 98 &fs3o, 99 sizeof(fs3o))) { 96 100 DosError(FERR_DISABLEHARDERR); 97 101 if(!DosQueryPathInfo(file2, 98 99 100 102 FIL_STANDARD, 103 &fs3n, 104 sizeof(fs3n))) { 101 105 comp = (fs3n.fdateLastWrite.year > 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 106 fs3o.fdateLastWrite.year) ? 1 : 107 (fs3n.fdateLastWrite.year < 108 fs3o.fdateLastWrite.year) ? -1 : 109 (fs3n.fdateLastWrite.month > 110 fs3o.fdateLastWrite.month) ? 1 : 111 (fs3n.fdateLastWrite.month < 112 fs3o.fdateLastWrite.month) ? -1 : 113 (fs3n.fdateLastWrite.day > 114 fs3o.fdateLastWrite.day) ? 1 : 115 (fs3n.fdateLastWrite.day < 116 fs3o.fdateLastWrite.day) ? -1 : 117 (fs3n.ftimeLastWrite.hours > 118 fs3o.ftimeLastWrite.hours) ? 1 : 119 (fs3n.ftimeLastWrite.hours < 120 fs3o.ftimeLastWrite.hours) ? -1 : 121 (fs3n.ftimeLastWrite.minutes > 122 fs3o.ftimeLastWrite.minutes) ? 1 : 123 (fs3n.ftimeLastWrite.minutes < 124 fs3o.ftimeLastWrite.minutes) ? -1 : 125 (fs3n.ftimeLastWrite.twosecs > 126 fs3o.ftimeLastWrite.twosecs) ? 1 : 127 (fs3n.ftimeLastWrite.twosecs < 128 fs3o.ftimeLastWrite.twosecs) ? -1 : 129 0; 126 130 } 127 131 } … … 130 134 131 135 132 BOOL IsNewer (char *file1,char *file2) {133 136 BOOL IsNewer (char *file1,char *file2) 137 { 134 138 /* return TRUE if file2 is newer than file1 */ 135 139 … … 138 142 139 143 140 BOOL IsDesktop (HAB hab,HWND hwnd) {141 144 BOOL IsDesktop (HAB hab,HWND hwnd) 145 { 142 146 HWND hwndDesktop; 143 147 … … 150 154 } 151 155 152 BOOL ParentIsDesktop (HWND hwnd,HWND hwndParent) {153 156 BOOL ParentIsDesktop (HWND hwnd,HWND hwndParent) 157 { 154 158 HWND hwndDesktop; 155 159 BOOL ret = FALSE; … … 170 174 INT CheckDrive (CHAR chDrive, CHAR *pszFileSystem, ULONG *pulType) 171 175 { 172 CHAR Path[3],*Buffer = NULL,*pfsn = NULL,*pfsd = NULL; 173 ULONG Size,Status,action,LengthIn,LengthOut; 174 HFILE Handle; 175 BYTE Command = 0,NonRemovable; 176 CHAR szPath[3]; 177 VOID *pvBuffer = NULL; 178 CHAR *pfsn; 179 CHAR *pfsd; 180 ULONG clBufferSize; 181 APIRET ulrc; 182 ULONG ulAction; 183 ULONG clParmBytes; 184 ULONG clDataBytes; 185 HFILE hDev; 186 # pragma pack(1) 187 struct { 188 BYTE Cmd; 189 BYTE Unit; 190 } parmPkt = {0, 0}; 191 # define BPB_REMOVABLE_MEDIA 0x08 // 3 - Media is removable 192 struct 193 { 194 BIOSPARAMETERBLOCK bpb; 195 USHORT cCylinders; // Documented but not implemented 196 BYTE bDeviceType; // Documented but not implemented 197 USHORT fsDeviceAttr; // Documented but not implemented 198 } dataPkt; 199 # pragma pack() 200 BYTE NonRemovable; 176 201 PFSQBUFFER2 pfsq; 177 202 … … 181 206 *pulType = 0; 182 207 183 if(DosAllocMem((PVOID)&Buffer,4096, 184 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) { 208 # define BUFFER_BYTES 4096 209 if(DosAllocMem(&pvBuffer,BUFFER_BYTES, 210 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) { 185 211 DosBeep(50,50); 186 212 return -1; // Say failed 187 213 } 188 214 189 Path[0] = chDrive;190 Path[1] = ':';191 Path[2] = 0;192 Size = 4096;215 szPath[0] = chDrive; 216 szPath[1] = ':'; 217 szPath[2] = 0; 218 clBufferSize = BUFFER_BYTES; 193 219 DosError(FERR_DISABLEHARDERR); 194 Status = DosQueryFSAttach(Path, 0, FSAIL_QUERYNAME,195 (PFSQBUFFER2)Buffer, &Size);196 if ( Status)220 ulrc = DosQueryFSAttach(szPath, 0, FSAIL_QUERYNAME, 221 (PFSQBUFFER2)pvBuffer, &clBufferSize); 222 if (ulrc) 197 223 { 198 224 /* can't get any info at all */ 199 DosFreeMem( Buffer);225 DosFreeMem(pvBuffer); 200 226 DosError(FERR_DISABLEHARDERR); 201 227 return -1; // Say failed 202 228 } 203 229 204 pfsq = (PFSQBUFFER2) Buffer;230 pfsq = (PFSQBUFFER2)pvBuffer; 205 231 pfsn = pfsq->szName + pfsq->cbName + 1; 206 232 pfsd = pfsn + pfsq->cbFSDName + 1; … … 215 241 *pulType |= DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE; 216 242 217 if (((PFSQBUFFER2) Buffer)->iType == FSAT_REMOTEDRV)243 if (((PFSQBUFFER2)pvBuffer)->iType == FSAT_REMOTEDRV) 218 244 { 219 245 if (pulType) … … 226 252 if (pfsq->cbFSAData) 227 253 { 228 229 230 254 ULONG FType; 255 256 if (CheckDrive(*pfsd,NULL,&FType) != -1) 231 257 { 232 233 234 235 236 258 if (FType & DRIVE_REMOVABLE) 259 *pulType |= DRIVE_REMOVABLE; 260 if (~FType & DRIVE_NOLONGNAMES) 261 *pulType &= ~DRIVE_NOLONGNAMES; 262 } 237 263 } 238 264 } 239 265 if (pulType && 240 241 242 243 266 (!strcmp(pfsn,HPFS) || 267 !strcmp(pfsn,JFS) || 268 !strcmp(pfsn,FAT32) || 269 !strcmp(pfsn,HPFS386))) 244 270 { 245 271 *pulType &= ~DRIVE_NOLONGNAMES; 246 272 } 247 DosFreeMem( Buffer);248 return 0; // Saynon-removable273 DosFreeMem(pvBuffer); 274 return 0; // Remotes are non-removable 249 275 } 250 276 … … 257 283 { 258 284 if(pulType) 259 (*pulType) |= DRIVE_NOLONGNAMES; 285 (*pulType) |= DRIVE_NOLONGNAMES; // Others can not have long names 260 286 } 261 287 262 288 DosError(FERR_DISABLEHARDERR); 263 Status = DosOpen(Path, &Handle, &action, 0, 0, FILE_OPEN,264 265 266 if( Status)289 ulrc = DosOpen(szPath, &hDev, &ulAction, 0, 0, FILE_OPEN, 290 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | 291 OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR, 0); 292 if(ulrc) 267 293 { 268 294 DosError(FERR_DISABLEHARDERR); 269 295 if (pulType) 270 296 *pulType |= DRIVE_REMOVABLE; // Assume removable if can not access 271 DosFreeMem( Buffer);297 DosFreeMem(pvBuffer); 272 298 return 1; // Say removable 273 299 } 274 LengthIn = sizeof(Command); 275 LengthOut = sizeof(NonRemovable); 276 NonRemovable = 1; 300 301 clParmBytes = sizeof(parmPkt.Cmd); 302 clDataBytes = sizeof(NonRemovable); 303 NonRemovable = 1; // Preset as non removable 277 304 DosError(FERR_DISABLEHARDERR); 278 DosDevIOCtl(Handle, 8, 0x20,&Command, sizeof(Command), &LengthIn, 279 &NonRemovable, sizeof(NonRemovable), &LengthOut); 280 DosClose(Handle); 305 ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE, 306 &parmPkt.Cmd, /* Address of the command-specific argument list. */ 307 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ 308 &clParmBytes, /* Pointer to the length of parameters. */ 309 &NonRemovable, /* Address of the data area. */ 310 sizeof(NonRemovable), /* Length, in bytes, of pData. */ 311 &clDataBytes); /* Pointer to the length of data. */ 312 313 if (!ulrc && NonRemovable) { 314 // Could be USB so check BPB flags 315 clParmBytes = sizeof(parmPkt.Cmd); 316 clDataBytes = sizeof(dataPkt); 317 memset(&dataPkt, 0xff, sizeof(dataPkt)); 318 DosError(FERR_DISABLEHARDERR); 319 ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS, 320 &parmPkt.Cmd, /* Address of the command-specific argument list. */ 321 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ 322 &clParmBytes, /* Pointer to the length of parameters. */ 323 &dataPkt, /* Address of the data area. */ 324 sizeof(dataPkt), /* Length, in bytes, of pData. */ 325 &clDataBytes); /* Pointer to the length of data. */ 326 327 if (!ulrc && (dataPkt.bpb.fsDeviceAttr & BPB_REMOVABLE_MEDIA)) 328 NonRemovable = 0; 329 } 330 331 DosClose(hDev); 332 281 333 if (!NonRemovable && pulType) 282 334 *pulType |= DRIVE_REMOVABLE; 283 DosFreeMem(Buffer); 335 336 DosFreeMem(pvBuffer); 337 284 338 return NonRemovable ? 0 : 1; 285 339 } 286 340 287 341 288 BOOL IsFileSame (CHAR *filename1,CHAR *filename2) {289 342 BOOL IsFileSame (CHAR *filename1,CHAR *filename2) 343 { 290 344 /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */ 291 345 … … 296 350 DosError(FERR_DISABLEHARDERR); 297 351 ret = DosQueryPathInfo(filename1,FIL_STANDARD,&fsa1, 298 352 (ULONG)sizeof(fsa1)); 299 353 if(!ret) { 300 354 DosError(FERR_DISABLEHARDERR); 301 355 ret = DosQueryPathInfo(filename2,FIL_STANDARD,&fsa2, 302 356 (ULONG)sizeof(fsa2)); 303 357 if(!ret) { 304 305 306 307 358 if(fsa1.cbFile == fsa2.cbFile && 359 (fsa1.attrFile & (~FILE_ARCHIVED)) == 360 (fsa2.attrFile & (~FILE_ARCHIVED))) 361 return TRUE; 308 362 } 309 363 } … … 313 367 314 368 315 INT IsFile (CHAR *filename) {316 369 INT IsFile (CHAR *filename) 370 { 317 371 /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */ 318 372 … … 323 377 DosError(FERR_DISABLEHARDERR); 324 378 ret = DosQueryPathInfo(filename, 325 326 327 379 FIL_STANDARD, 380 &fsa, 381 (ULONG)sizeof(fsa)); 328 382 if(!ret) 329 383 return ((fsa.attrFile & FILE_DIRECTORY) == 0); … … 335 389 336 390 337 BOOL IsFullName (CHAR *filename) {338 391 BOOL IsFullName (CHAR *filename) 392 { 339 393 return (filename) ? 340 341 342 } 343 344 345 BOOL IsRoot (CHAR *filename) {346 394 (isalpha(*filename) && filename[1] == ':' && filename[2] == '\\') : 395 0; 396 } 397 398 399 BOOL IsRoot (CHAR *filename) 400 { 347 401 return (filename && isalpha(*filename) && filename[1] == ':' && 348 349 } 350 351 352 BOOL IsValidDir (CHAR *path) {353 402 filename[2] == '\\' && !filename[3]); 403 } 404 405 406 BOOL IsValidDir (CHAR *path) 407 { 354 408 CHAR fullname[CCHMAXPATH]; 355 409 FILESTATUS3 fs; … … 358 412 DosError(FERR_DISABLEHARDERR); 359 413 if(!DosQueryPathInfo(path, 360 361 362 414 FIL_QUERYFULLNAME, 415 fullname, 416 sizeof(fullname))) { 363 417 if(IsValidDrive(*fullname)) { 364 365 366 367 368 369 370 371 372 373 374 418 if(!IsRoot(fullname)) { 419 DosError(FERR_DISABLEHARDERR); 420 if(!DosQueryPathInfo(fullname, 421 FIL_STANDARD, 422 &fs, 423 sizeof(fs)) && 424 (fs.attrFile & FILE_DIRECTORY)) 425 return TRUE; 426 } 427 else 428 return TRUE; 375 429 } 376 430 } … … 380 434 381 435 382 BOOL IsValidDrive (CHAR drive) {383 436 BOOL IsValidDrive (CHAR drive) 437 { 384 438 CHAR Path[] = " :",Buffer[256]; 385 439 APIRET Status; … … 399 453 DosError(FERR_DISABLEHARDERR); 400 454 Status = DosQueryFSAttach(Path, 401 402 403 404 455 0, 456 FSAIL_QUERYNAME, 457 (PFSQBUFFER2)Buffer, 458 &Size); 405 459 } 406 460 return (Status == 0); … … 408 462 409 463 410 CHAR * MakeValidDir (CHAR *path) {411 464 CHAR * MakeValidDir (CHAR *path) 465 { 412 466 CHAR fullname[CCHMAXPATH],drive; 413 467 register CHAR *p; … … 418 472 if(IsValidDrive(*path)) { 419 473 for(;;) { 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 474 if(IsRoot(path)) 475 return path; 476 DosError(FERR_DISABLEHARDERR); 477 status = DosQueryPathInfo(path, 478 FIL_STANDARD, 479 &fs, 480 sizeof(fs)); 481 if(!status && 482 (fs.attrFile & FILE_DIRECTORY) != 0) 483 return path; 484 p = strrchr(path,'\\'); 485 if(p) { 486 if(p < path + 3) 487 p++; 488 *p = 0; 489 } 490 else 491 break; 438 492 } 439 493 } … … 441 495 DosError(FERR_DISABLEHARDERR); 442 496 if(!DosQuerySysInfo(QSV_BOOT_DRIVE, 443 444 445 497 QSV_BOOT_DRIVE, 498 &drive, 499 1L)) { 446 500 drive += '@'; 447 501 if(drive < 'C') … … 456 510 457 511 458 BOOL IsExecutable (CHAR *filename) {459 512 BOOL IsExecutable (CHAR *filename) 513 { 460 514 register CHAR *p; 461 515 APIRET ret; … … 467 521 if(p) 468 522 ret = DosQAppType(filename, 469 523 &apptype); 470 524 else { 471 525 … … 475 529 strcat(fname,"."); 476 530 ret = DosQAppType(fname, 477 531 &apptype); 478 532 } 479 533 if((!ret && (!apptype || 480 481 482 483 484 485 486 487 488 489 534 (apptype & 535 (FAPPTYP_NOTWINDOWCOMPAT | 536 FAPPTYP_WINDOWCOMPAT | 537 FAPPTYP_WINDOWAPI | 538 FAPPTYP_BOUND | 539 FAPPTYP_DOS | 540 FAPPTYP_WINDOWSREAL | 541 FAPPTYP_WINDOWSPROT | 542 FAPPTYP_32BIT | 543 0x1000)))) || 490 544 (p && 491 492 545 (!stricmp(p,".CMD") || 546 !stricmp(p,".BAT")))) 493 547 return TRUE; 494 548 } … … 497 551 498 552 499 VOID ArgDriveFlags (INT argc,CHAR **argv) {500 553 VOID ArgDriveFlags (INT argc,CHAR **argv) 554 { 501 555 INT x; 502 556 … … 507 561 508 562 while(isalpha(*p)) { 509 510 563 driveflags[toupper(*p) - 'A'] |= DRIVE_IGNORE; 564 p++; 511 565 } 512 566 } … … 516 570 517 571 while(isalpha(*p)) { 518 519 572 driveflags[toupper(*p) - 'A'] |= DRIVE_NOPRESCAN; 573 p++; 520 574 } 521 575 } … … 525 579 526 580 while(isalpha(*p)) { 527 528 581 driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADICONS; 582 p++; 529 583 } 530 584 } … … 534 588 535 589 while(isalpha(*p)) { 536 537 590 driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADSUBJS; 591 p++; 538 592 } 539 593 } … … 543 597 544 598 while(isalpha(*p)) { 545 546 599 driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADLONGS; 600 p++; 547 601 } 548 602 } … … 563 617 driveserial[x] = -1; 564 618 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | 565 566 619 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | 620 DRIVE_INCLUDEFILES | DRIVE_SLOW); 567 621 if(removable != -1) 568 622 { … … 583 637 driveflags[x] |= DRIVE_INVALID; 584 638 driveflags[x] |= ((removable == -1 || removable == 1) ? 585 639 DRIVE_REMOVABLE : 0); 586 640 if(drvtype & DRIVE_REMOTE) 587 641 driveflags[x] |= DRIVE_REMOTE; … … 597 651 removable = 1; 598 652 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | 599 653 DRIVE_CDROM); 600 654 } 601 655 else if(!stricmp(FileSystem,CBSIFS)) { … … 610 664 611 665 612 VOID FillInDriveFlags (VOID *dummy) {613 666 VOID FillInDriveFlags (VOID *dummy) 667 { 614 668 ULONG ulDriveNum,ulDriveMap; 615 669 register INT x; … … 617 671 for(x = 0;x < 26;x++) 618 672 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | 619 620 673 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | 674 DRIVE_INCLUDEFILES | DRIVE_SLOW); 621 675 memset(driveserial,-1,sizeof(driveserial)); 622 676 DosError(FERR_DISABLEHARDERR); … … 625 679 if(ulDriveMap & (1L << x) && !(driveflags[x] & DRIVE_IGNORE)) { 626 680 { 627 628 629 630 631 632 633 681 CHAR s[80]; 682 ULONG flags = 0,size = sizeof(ULONG); 683 684 sprintf(s,"%c.DriveFlags",(CHAR)(x + 'A')); 685 if(PrfQueryProfileData(fmprof,appname,s,&flags,&size) && 686 size == sizeof(ULONG)) 687 driveflags[x] |= flags; 634 688 } 635 689 636 690 if(x > 1) { 637 638 639 640 691 if(!(driveflags[x] & DRIVE_NOPRESCAN)) 692 DriveFlagsOne(x); 693 else 694 driveserial[x] = -1; 641 695 } 642 696 else { 643 644 697 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES); 698 driveserial[x] = -1; 645 699 } 646 700 } … … 653 707 DosError(FERR_DISABLEHARDERR); 654 708 DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE, 655 709 (PVOID)&startdrive,(ULONG)sizeof(ULONG)); 656 710 if(startdrive) 657 711 driveflags[startdrive - 1] |= DRIVE_BOOT; … … 660 714 661 715 662 CHAR * assign_ignores (CHAR *s) {663 716 CHAR * assign_ignores (CHAR *s) 717 { 664 718 register INT x; 665 719 register CHAR *p,*pp; … … 671 725 for(x = 0;x < 26;x++) { 672 726 if((driveflags[x] & DRIVE_IGNORE) != 0) { 673 674 675 727 *p = (CHAR)x + 'A'; 728 p++; 729 *p = 0; 676 730 } 677 731 } … … 692 746 for(x = 0;x < 26;x++) { 693 747 if((driveflags[x] & DRIVE_NOPRESCAN) != 0) { 694 695 696 748 *p = (CHAR)x + 'A'; 749 p++; 750 *p = 0; 697 751 } 698 752 } … … 709 763 for(x = 0;x < 26;x++) { 710 764 if((driveflags[x] & DRIVE_NOLOADICONS) != 0) { 711 712 713 765 *p = (CHAR)x + 'A'; 766 p++; 767 *p = 0; 714 768 } 715 769 } … … 726 780 for(x = 0;x < 26;x++) { 727 781 if((driveflags[x] & DRIVE_NOLOADSUBJS) != 0) { 728 729 730 782 *p = (CHAR)x + 'A'; 783 p++; 784 *p = 0; 731 785 } 732 786 } … … 743 797 for(x = 0;x < 26;x++) { 744 798 if((driveflags[x] & DRIVE_NOLOADLONGS) != 0) { 745 746 747 799 *p = (CHAR)x + 'A'; 800 p++; 801 *p = 0; 748 802 } 749 803 } … … 756 810 757 811 758 BOOL needs_quoting (register CHAR *f) {759 812 BOOL needs_quoting (register CHAR *f) 813 { 760 814 register CHAR *p = " &|<>"; 761 815 … … 769 823 770 824 771 BOOL IsBinary (register CHAR *str,ULONG len) {772 825 BOOL IsBinary (register CHAR *str,ULONG len) 826 { 773 827 register ULONG x = 0L; 774 828 … … 776 830 while(x < len) { 777 831 if(str[x] < ' ' && str[x] != '\r' && str[x] != '\n' && str[x] != '\t' && 778 779 780 832 str[x] != '\x1b' && str[x] != '\x1a' && str[x] != '\07' && 833 str[x] != '\x0c') 834 return TRUE; 781 835 x++; 782 836 } … … 786 840 787 841 788 BOOL TestBinary (CHAR *filename) {789 842 BOOL TestBinary (CHAR *filename) 843 { 790 844 HFILE handle; 791 ULONG action,len; 792 APIRET rc; 845 ULONG ulAction; 846 ULONG len; 847 APIRET ulrc; 793 848 CHAR buff[512]; 794 849 795 850 if(filename) { 796 if(!DosOpen(filename,&handle,& action,0L,0L,797 798 799 800 851 if(!DosOpen(filename,&handle,&ulAction,0L,0L, 852 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 853 OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | 854 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | 855 OPEN_ACCESS_READONLY,0L)) { 801 856 len = 512; 802 rc = DosRead(handle,buff,len,&len);857 ulrc = DosRead(handle,buff,len,&len); 803 858 DosClose(handle); 804 if(! rc && len)805 859 if(!ulrc && len) 860 return IsBinary(buff,len); 806 861 } 807 862 } … … 810 865 811 866 812 char *IsVowel (char a) {813 867 char *IsVowel (char a) 868 { 814 869 return (strchr("aeiouAEIOU",a) != NULL) ? "n" : NullStr; 815 870 } 816 871 817 872 818 VOID GetDesktopName (CHAR *objectpath,ULONG size) {819 873 VOID GetDesktopName (CHAR *objectpath,ULONG size) 874 { 820 875 PFN WQDPath; 821 876 HMODULE hmod = 0; 822 APIRET rc;877 APIRET ulrc; 823 878 ULONG startdrive = 3L; 824 879 CHAR objerr[CCHMAXPATH]; … … 832 887 * this way... 833 888 */ 834 rc = DosLoadModule(objerr,835 836 837 838 if(! rc) {839 rc = DosQueryProcAddr(hmod,840 841 842 843 if(! rc)844 889 ulrc = DosLoadModule(objerr, 890 sizeof(objerr), 891 "PMWP", 892 &hmod); 893 if(!ulrc) { 894 ulrc = DosQueryProcAddr(hmod, 895 262, 896 NULL, 897 &WQDPath); 898 if(!ulrc) 899 WQDPath(objectpath,size); 845 900 DosFreeModule(hmod); 846 901 } … … 848 903 if(!*objectpath) { 849 904 if(!PrfQueryProfileString(HINI_SYSTEMPROFILE, 850 851 852 853 854 905 "FolderWorkareaRunningObjects", 906 NULL, 907 "\0", 908 (PVOID)objectpath, 909 sizeof(objectpath))) 855 910 *objectpath = 0; 856 911 if(!*objectpath || IsFile(objectpath)) { … … 858 913 DosError(FERR_DISABLEHARDERR); 859 914 DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE, 860 915 (PVOID)&startdrive,(ULONG)sizeof(ULONG)); 861 916 sprintf(objectpath, 862 863 864 } 865 } 866 } 917 "%c:\\DESKTOP", 918 ((CHAR)startdrive) + '@'); 919 } 920 } 921 }
Note:
See TracChangeset
for help on using the changeset viewer.