Changeset 1157 for trunk/dll/eas.c
- Timestamp:
- Sep 5, 2008, 11:39:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/dll/eas.c ¶
r1039 r1157 38 38 #include "fm3str.h" 39 39 #include "mle.h" 40 #include "errutil.h" // Dos_Error... 41 #include "strutil.h" // GetPString 40 #include "errutil.h" // Dos_Error... 41 #include "strutil.h" // GetPString 42 #include "defview.h" // QuickView 42 43 #include "fm3dll.h" 44 #include "eas.h" 43 45 #include "fortify.h" 44 46 … … 47 49 static PSZ pszSrcFile = __FILE__; 48 50 51 static PVOID SaveEA(CHAR * filename, HOLDFEA * current, CHAR * newdata, 52 BOOL silentfail); 49 53 50 54 typedef struct … … 72 76 while (info) { 73 77 if (!strcmp(info->name, eaname)) 74 78 return info; 75 79 info = info->next; 76 80 } … … 108 112 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2); 109 113 WinSendDlgItemMsg(hwnd, EAC_NAME, EM_SETTEXTLIMIT, 110 114 MPFROM2SHORT(1024, 0), MPVOID); 111 115 WinCheckButton(hwnd, EAC_ASCII, TRUE); 112 116 break; … … 118 122 case UM_PAINT: 119 123 PaintRecessedWindow(WinWindowFromID(hwnd, EAC_TEXT), (HPS) 0, FALSE, 120 124 FALSE); 121 125 return 0; 122 126 … … 131 135 filename = add->filename; 132 136 { 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 *(USHORT *) eaval = (USHORT) 0;/* codepage */198 199 *(USHORT *) eaval = (USHORT) 1;/* number */200 201 *(USHORT *) eaval = (USHORT) EAT_ASCII;/* type */202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 137 CHAR s[1025]; 138 INT x; 139 USHORT type = EAT_ASCII; 140 141 *s = 0; 142 WinQueryDlgItemText(hwnd, EAC_NAME, 1024, s); 143 bstrip(s); 144 if (!*s) 145 WinDismissDlg(hwnd, 0); 146 else { 147 if (CheckEA(head, s)) { 148 DosBeep(50, 100); 149 WinSetDlgItemText(hwnd, EAC_TEXT, 150 GetPString(IDS_EANAMEEXISTSTEXT)); 151 break; 152 } 153 for (x = 0; *forbidden[x]; x++) { 154 if (!strcmp(forbidden[x], s)) { 155 DosBeep(50, 100); 156 WinSetDlgItemText(hwnd, EAC_TEXT, 157 GetPString(IDS_EANAMERESERVEDTEXT)); 158 return 0; 159 } 160 } 161 if (WinQueryButtonCheckstate(hwnd, EAC_MVST)) 162 type = EAT_MVST; 163 else if (WinQueryButtonCheckstate(hwnd, EAC_MVMT)) 164 type = EAT_MVMT; 165 for (x = 0; *restypes[x].name; x++) { 166 if (!strcmp(restypes[x].name, s)) { 167 if (type != restypes[x].type) { 168 DosBeep(50, 100); 169 WinSetDlgItemText(hwnd, EAC_TEXT, 170 GetPString(IDS_EAWRONGTYPETEXT)); 171 return 0; 172 } 173 break; 174 } 175 } 176 /* if we get here, create dummy ea */ 177 { 178 PFEA2LIST pfealist = NULL; 179 EAOP2 eaop; 180 ULONG ealen; 181 CHAR *eaval; 182 APIRET rc; 183 184 ealen = sizeof(FEA2LIST) + strlen(s) + 64; 185 rc = DosAllocMem((PPVOID) & pfealist, ealen + 1, 186 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE); 187 if (rc) 188 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 189 GetPString(IDS_OUTOFMEMORY)); 190 else { 191 memset(pfealist, 0, ealen + 1); 192 pfealist->cbList = ealen; 193 pfealist->list[0].oNextEntryOffset = 0; 194 pfealist->list[0].fEA = 0; 195 pfealist->list[0].cbName = strlen(s); 196 strcpy(pfealist->list[0].szName, s); 197 eaval = pfealist->list[0].szName + strlen(s) + 1; 198 *(USHORT *) eaval = (USHORT) type; 199 eaval += sizeof(USHORT); 200 if (type == EAT_MVST || type == EAT_MVMT) { 201 *(USHORT *) eaval = (USHORT) 0; /* codepage */ 202 eaval += sizeof(USHORT); 203 *(USHORT *) eaval = (USHORT) 1; /* number */ 204 eaval += sizeof(USHORT); 205 *(USHORT *) eaval = (USHORT) EAT_ASCII; /* type */ 206 eaval += sizeof(USHORT); 207 } 208 *(USHORT *) eaval = (USHORT) 4; 209 eaval += sizeof(USHORT); 210 memcpy(eaval, GetPString(IDS_FAKETEXT), 4); 211 pfealist->list[0].cbValue = 4 + (sizeof(USHORT) * 2) + 212 ((type == EAT_MVST || 213 type == EAT_MVMT) ? sizeof(USHORT) * 3 : 0); 214 eaop.fpGEA2List = (PGEA2LIST) 0; 215 eaop.fpFEA2List = pfealist; 216 eaop.oError = 0; 217 xDosSetPathInfo(filename, FIL_QUERYEASIZE, 218 &eaop, sizeof(eaop), DSPI_WRTTHRU); 219 WinDismissDlg(hwnd, 1); 220 } 221 } 222 } 219 223 } 220 224 break; … … 226 230 case IDM_HELP: 227 231 if (hwndHelp) 228 229 232 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 233 MPFROM2SHORT(HELP_ADDEA, 0), MPFROMSHORT(HM_RESOURCEID)); 230 234 break; 231 235 } … … 257 261 a = s + 6; 258 262 do { 259 260 261 262 263 sprintf(a, "%02x ", (UCHAR)*p); 264 a += 3; 265 p++; 266 x++; 263 267 } 264 268 while (x < cbValue && (x % 16)); 265 269 if (x % 16) { 266 267 268 269 270 271 272 270 z = x; 271 while (z % 16) { 272 *a++ = ' '; 273 *a++ = ' '; 274 *a++ = ' '; 275 z++; 276 } 273 277 } 274 278 *a++ = ' '; 275 279 p = pp; 276 280 do { 277 278 279 280 281 282 283 284 281 if (*p) 282 *a++ = *p++; 283 else { 284 *a++ = '.'; 285 p++; 286 } 287 *a = 0; 288 y++; 285 289 } 286 290 while (y < x); 287 291 if ((SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0), 288 289 292 MPFROMP(s)) < 0) 293 break; 290 294 pp = p; 291 295 } … … 329 333 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) eap); 330 334 WinSendDlgItemMsg(hwnd, 331 335 EA_ENTRY, EM_SETTEXTLIMIT, MPFROM2SHORT(40, 0), MPVOID); 332 336 MLEsetlimit(WinWindowFromID(hwnd, EA_MLE), 32767); 333 337 MLEsetformat(WinWindowFromID(hwnd, EA_MLE), MLFIE_NOTRANS); … … 338 342 339 343 for (x = 0; eap->list[x]; x++) { 340 341 342 343 344 345 346 344 if (DosQueryPathInfo(eap->list[x], FIL_QUERYFULLNAME, s, sizeof(s))) 345 strcpy(s, eap->list[x]); 346 if (IsFile(s) != -1) 347 WinSendDlgItemMsg(hwnd, 348 EA_NAMES, 349 LM_INSERTITEM, 350 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s)); 347 351 } 348 352 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 349 350 353 EA_NAMES, 354 LM_QUERYITEMCOUNT, MPVOID, MPVOID); 351 355 if (sSelect > 0) 352 353 354 355 356 WinSendDlgItemMsg(hwnd, 357 EA_NAMES, 358 LM_SELECTITEM, 359 MPFROM2SHORT(0, 0), MPFROMSHORT(TRUE)); 356 360 else 357 361 WinDismissDlg(hwnd, 0); 358 362 } 359 363 break; … … 362 366 if (*eap->filename) { 363 367 if (eap->head) 364 368 Free_FEAList(eap->head); 365 369 eap->head = GetFileEAs(eap->filename, FALSE, FALSE); 366 370 if (!isalpha(*eap->filename) || 367 368 369 370 371 (driveflags[toupper(*eap->filename) - 'A'] & DRIVE_NOTWRITEABLE)) { 372 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 373 WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), FALSE); 374 WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE); 371 375 } 372 376 else { 373 374 375 377 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 378 WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), TRUE); 379 WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE); 376 380 } 377 381 WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID); … … 394 398 info = eap->head; 395 399 while (info) { 396 397 398 400 WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_INSERTITEM, 401 MPFROM2SHORT(LIT_END, 0), MPFROMP(info->name)); 402 info = info->next; 399 403 } 400 404 WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_SELECTITEM, 401 405 MPFROM2SHORT(0, 0), MPFROM2SHORT(TRUE, 0)); 402 406 } 403 407 else … … 412 416 PaintRecessedWindow(WinWindowFromID(hwnd, EA_HELP), (HPS) 0, FALSE, TRUE); 413 417 PaintRecessedWindow(WinWindowFromID(hwnd, EA_TEXT), (HPS) 0, FALSE, 414 418 FALSE); 415 419 return 0; 416 420 … … 420 424 switch (SHORT2FROMMP(mp1)) { 421 425 case LN_SETFOCUS: 422 423 426 WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EAFILENAMESHELPTEXT)); 427 break; 424 428 case LN_KILLFOCUS: 425 426 429 WinSetDlgItemText(hwnd, EA_HELP, NullStr); 430 break; 427 431 case LN_ENTER: 428 432 case LN_SELECT: 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 433 { 434 CHAR s[1025]; 435 SHORT sSelect; 436 437 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, EA_NAMES, 438 LM_QUERYSELECTION, 439 MPFROM2SHORT(LIT_FIRST, 0), 440 MPVOID); 441 if (sSelect >= 0) { 442 *s = 0; 443 WinSendDlgItemMsg(hwnd, EA_NAMES, LM_QUERYITEMTEXT, 444 MPFROM2SHORT(sSelect, 1024), MPFROMP(s)); 445 if (*s) { 446 strcpy(eap->filename, s); 447 if (SHORT2FROMMP(mp1) == LN_SELECT) 448 WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID); 449 else 450 QuickView(hwnd, eap->filename); 451 } 452 } 453 } 454 break; 451 455 } 452 456 break; … … 455 459 switch (SHORT2FROMMP(mp1)) { 456 460 case LN_SETFOCUS: 457 458 461 WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EATYPESHELPTEXT)); 462 break; 459 463 case LN_KILLFOCUS: 460 461 464 WinSetDlgItemText(hwnd, EA_HELP, NullStr); 465 break; 462 466 case LN_SELECT: 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 467 { 468 CHAR s[1024]; 469 SHORT sSelect; 470 471 eap->current = NULL; 472 if (eap->head) { 473 WinSetDlgItemText(hwnd, EA_TEXT, NullStr); 474 WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), FALSE); 475 WinSetDlgItemText(hwnd, EA_ENTRY, NullStr); 476 MLEclearall(WinWindowFromID(hwnd, EA_MLE)); 477 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE); 478 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 479 WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE); 480 WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), FALSE); 481 WinSendDlgItemMsg(hwnd, EA_HEXDUMP, LM_DELETEALL, MPVOID, MPVOID); 482 *s = 0; 483 sSelect = (USHORT) WinSendDlgItemMsg(hwnd, EA_LISTBOX, 484 LM_QUERYSELECTION, 485 MPFROMSHORT(LIT_FIRST), 486 MPVOID); 487 if (sSelect >= 0) { 488 WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_QUERYITEMTEXT, 489 MPFROM2SHORT(sSelect, 1024), MPFROMP(s)); 490 if (*s) { 491 492 USHORT len, num, type; 493 CHAR *data; 494 CHAR last = '\n'; 495 const CHAR *linefeed = "\n"; 496 BOOL alltext; 497 IPT pos = 0; 498 499 info = eap->head; 500 while (info) { 501 if (!strcmp(s, info->name)) { 502 eap->current = info; 503 WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE); 504 switch (*(USHORT *) info->value) { 505 case EAT_EA: 506 case EAT_ASCII: 507 if (!strcmp(info->name, SUBJECT)) 508 WinSendDlgItemMsg(hwnd, EA_ENTRY, 509 EM_SETTEXTLIMIT, 510 MPFROM2SHORT(1024, 0), MPVOID); 511 else 512 WinSendDlgItemMsg(hwnd, EA_ENTRY, 513 EM_SETTEXTLIMIT, 514 MPFROM2SHORT(1024, 0), MPVOID); 515 WinSetDlgItemText(hwnd, EA_ENTRY, 516 info->value + (sizeof(USHORT) * 2)); 517 WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), TRUE); 518 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), 519 FALSE); 520 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 521 { 522 CHAR str[81]; 523 524 sprintf(str, 525 GetPString(IDS_DATAANDBYTESTEXT), 526 (*(USHORT *) info->value == EAT_ASCII) ? 527 GetPString(IDS_TEXTTEXT) : 528 GetPString(IDS_EAREFTEXT), info->cbValue); 529 WinSetDlgItemText(hwnd, EA_TEXT, str); 530 } 531 break; 532 case EAT_MVST: 533 MLEclearall(WinWindowFromID(hwnd, EA_MLE)); 534 num = *(USHORT *) (info->value + (sizeof(USHORT) * 2)); 535 type = *(USHORT *) (info->value + (sizeof(USHORT) * 3)); 536 if (type == EAT_ASCII) { 537 data = info->value + (sizeof(USHORT) * 4); 538 len = *(USHORT *) data; 539 data += sizeof(USHORT); 540 while ((data - info->value) + len <= info->cbValue) { 541 if (last != '\n') { 542 WinSendDlgItemMsg(hwnd, 543 EA_MLE, 544 MLM_SETIMPORTEXPORT, 545 MPFROMP(linefeed), 546 MPFROMLONG(1)); 547 WinSendDlgItemMsg(hwnd, 548 EA_MLE, 549 MLM_IMPORT, 550 MPFROMP(&pos), MPFROMLONG(1)); 551 } 552 WinSendDlgItemMsg(hwnd, 553 EA_MLE, 554 MLM_SETIMPORTEXPORT, 555 MPFROMP(data), 556 MPFROMLONG((ULONG) len)); 557 WinSendDlgItemMsg(hwnd, 558 EA_MLE, 559 MLM_IMPORT, 560 MPFROMP(&pos), 561 MPFROMLONG((ULONG) len)); 562 data += len; 563 last = *(data - 1); 564 if (data - info->value >= info->cbValue) 565 break; 566 len = *(USHORT *) data; 567 data += sizeof(USHORT); 568 } 569 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), TRUE); 570 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), 571 FALSE); 572 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 573 } 574 else { 575 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE); 576 HexDumpEA(hwnd, info); 577 WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), 578 TRUE); 579 } 580 { 581 CHAR str[81]; 582 583 sprintf(str, 584 GetPString(IDS_MVSTTEXT), 585 num, 586 (num == 1) ? 587 GetPString(IDS_YTEXT) : 588 GetPString(IDS_IESTEXT), info->cbValue); 589 WinSetDlgItemText(hwnd, EA_TEXT, str); 590 } 591 break; 592 case EAT_MVMT: 593 MLEclearall(WinWindowFromID(hwnd, EA_MLE)); 594 num = *(USHORT *) (info->value + (sizeof(USHORT) * 2)); 595 data = info->value + (sizeof(USHORT) * 3); 596 type = *(USHORT *) data; 597 data += sizeof(USHORT); 598 len = *(USHORT *) data; 599 data += sizeof(USHORT); 600 alltext = TRUE; 601 while ((data - info->value) - len <= info->cbValue) { 602 if (type != EAT_ASCII) { 603 alltext = FALSE; 604 break; 605 } 606 data += len; 607 if (data - info->value >= info->cbValue) 608 break; 609 type = *(USHORT *) data; 610 data += sizeof(USHORT); 611 len = *(USHORT *) data; 612 data += sizeof(USHORT); 613 } 614 if (alltext) { 615 data = info->value + (sizeof(USHORT) * 3); 616 type = *(USHORT *) data; 617 data += sizeof(USHORT); 618 len = *(USHORT *) data; 619 data += sizeof(USHORT); 620 while ((data - info->value) - len <= info->cbValue) { 621 if (last != '\n') { 622 WinSendDlgItemMsg(hwnd, 623 EA_MLE, 624 MLM_SETIMPORTEXPORT, 625 MPFROMP(linefeed), 626 MPFROMLONG(1)); 627 WinSendDlgItemMsg(hwnd, 628 EA_MLE, 629 MLM_IMPORT, 630 MPFROMP(&pos), MPFROMLONG(1)); 631 } 632 WinSendDlgItemMsg(hwnd, 633 EA_MLE, 634 MLM_SETIMPORTEXPORT, 635 MPFROMP(data), 636 MPFROMLONG((ULONG) len)); 637 WinSendDlgItemMsg(hwnd, 638 EA_MLE, 639 MLM_IMPORT, 640 MPFROMP(&pos), 641 MPFROMLONG((ULONG) len)); 642 data += len; 643 last = *(data - 1); 644 if (data - info->value >= info->cbValue) 645 break; 646 type = *(USHORT *) data; 647 data += sizeof(USHORT); 648 len = *(USHORT *) data; 649 data += sizeof(USHORT); 650 } 651 } 652 if (alltext) { 653 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), TRUE); 654 WinEnableWindow(WinWindowFromID(hwnd, 655 EA_CHANGE), FALSE); 656 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 657 } 658 else { 659 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE); 660 HexDumpEA(hwnd, info); 661 WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), 662 TRUE); 663 } 664 { 665 CHAR str[81]; 666 667 sprintf(str, 668 GetPString(IDS_MVMTTEXT), 669 num, 670 (num == 1) ? 671 GetPString(IDS_YTEXT) : 672 GetPString(IDS_IESTEXT), 673 info->cbValue, 674 (alltext) ? 675 GetPString(IDS_ALLTEXTTEXT) : 676 GetPString(IDS_MIXEDTYPESTEXT)); 677 WinSetDlgItemText(hwnd, EA_TEXT, str); 678 } 679 break; 680 default: 681 HexDumpEA(hwnd, info); 682 WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), TRUE); 683 switch (*(USHORT *) info->value) { 684 case EAT_BINARY: 685 { 686 CHAR str[81]; 687 688 sprintf(str, 689 GetPString(IDS_BINARYBYTESTEXT), 690 info->cbValue); 691 WinSetDlgItemText(hwnd, EA_TEXT, str); 692 } 693 break; 694 case EAT_BITMAP: 695 { 696 CHAR str[81]; 697 698 sprintf(str, 699 GetPString(IDS_BITMAPBYTESTEXT), 700 info->cbValue); 701 WinSetDlgItemText(hwnd, EA_TEXT, str); 702 } 703 break; 704 case EAT_METAFILE: 705 { 706 CHAR str[81]; 707 708 sprintf(str, 709 GetPString(IDS_METAFILEBYTESTEXT), 710 info->cbValue); 711 WinSetDlgItemText(hwnd, EA_TEXT, str); 712 } 713 break; 714 case EAT_ICON: 715 { 716 CHAR str[81]; 717 718 sprintf(str, 719 GetPString(IDS_ICONBYTESTEXT), 720 info->cbValue); 721 WinSetDlgItemText(hwnd, EA_TEXT, str); 722 } 723 break; 724 case EAT_ASN1: 725 { 726 CHAR str[81]; 727 728 sprintf(str, 729 GetPString(IDS_ASN1BYTESTEXT), 730 info->cbValue); 731 WinSetDlgItemText(hwnd, EA_TEXT, str); 732 } 733 break; 734 default: 735 { 736 CHAR str[81]; 737 738 sprintf(str, 739 GetPString(IDS_UNKNOWNBYTESTEXT), 740 *(USHORT *) info->value, info->cbValue); 741 WinSetDlgItemText(hwnd, EA_TEXT, str); 742 } 743 break; 744 } 745 break; 746 } 747 } 748 info = info->next; 749 } 750 } 751 } 752 } 753 if (!isalpha(*eap->filename) || 754 (driveflags[toupper(*eap->filename) - 'A'] & 755 DRIVE_NOTWRITEABLE)) { 756 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 757 WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), FALSE); 758 WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE); 759 } 760 else { 761 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 762 WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), TRUE); 763 WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE); 764 } 765 } 766 break; 763 767 } 764 768 break; … … 767 771 switch (SHORT2FROMMP(mp1)) { 768 772 case EN_SETFOCUS: 769 770 773 WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT)); 774 break; 771 775 case EN_KILLFOCUS: 772 773 776 WinSetDlgItemText(hwnd, EA_HELP, NullStr); 777 break; 774 778 case EN_CHANGE: 775 776 779 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 780 break; 777 781 } 778 782 break; … … 781 785 switch (SHORT2FROMMP(mp1)) { 782 786 case LN_SETFOCUS: 783 784 787 WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT)); 788 break; 785 789 case LN_KILLFOCUS: 786 787 790 WinSetDlgItemText(hwnd, EA_HELP, NullStr); 791 break; 788 792 } 789 793 break; … … 792 796 switch (SHORT2FROMMP(mp1)) { 793 797 case MLN_SETFOCUS: 794 795 798 WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT)); 799 break; 796 800 case MLN_KILLFOCUS: 797 798 801 WinSetDlgItemText(hwnd, EA_HELP, NullStr); 802 break; 799 803 case MLN_CHANGE: 800 801 804 WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE); 805 break; 802 806 } 803 807 break; … … 809 813 case EA_ADD: 810 814 { 811 812 813 814 815 816 817 818 819 820 815 ADDEA add; 816 817 add.filename = eap->filename; 818 add.head = eap->head; 819 if (WinDlgBox(HWND_DESKTOP, hwnd, AddEAProc, FM3ModHandle, 820 EAC_FRAME, &add)) { 821 Free_FEAList(eap->head); 822 eap->head = GetFileEAs(eap->filename, FALSE, FALSE); 823 WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID); 824 } 821 825 } 822 826 break; 823 827 case EA_CHANGE: 824 828 if (!eap->current) 825 829 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 826 830 else { 827 831 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 832 CHAR *s; 833 USHORT control; 834 835 if (!eap->head || !*eap->filename) 836 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 837 else { 838 switch (*(USHORT *) eap->current->value) { 839 case EAT_EA: 840 case EAT_ASCII: 841 control = EA_ENTRY; 842 break; 843 case EAT_MVMT: 844 control = EA_MLE; 845 break; 846 case EAT_MVST: 847 control = EA_MLE; 848 break; 849 default: 850 Runtime_Error(pszSrcFile, __LINE__, "unexpected type"); 851 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 852 control = 0; 853 } 854 if (control) { 855 s = xmalloc(32768, pszSrcFile, __LINE__); 856 if (s) { 857 *s = 0; 858 WinQueryDlgItemText(hwnd, control, 32767, (PCH) s); 859 if (!*s) 860 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 861 else { 862 PFEA2LIST pfealist; 863 864 pfealist = SaveEA(eap->filename, eap->current, s, FALSE); 865 if (!pfealist) 866 Runtime_Error(pszSrcFile, __LINE__, "SaveEA"); 867 else { 868 PFEA2 pfea; 869 870 pfea = xmalloc(pfealist->cbList, pszSrcFile, __LINE__); 871 if (pfea) { 872 memcpy(pfea, pfealist->list, 873 pfealist->cbList - sizeof(ULONG)); 874 free(eap->current->pfea); 875 eap->current->pfea = pfea; 876 eap->current->name = eap->current->pfea->szName; 877 eap->current->cbName = eap->current->pfea->cbName; 878 eap->current->cbValue = eap->current->pfea->cbValue; 879 eap->current->value = eap->current->pfea->szName + 880 eap->current->pfea->cbName + 1; 881 eap->current->value[eap->current->cbValue] = 0; 882 PostMsg(hwnd, WM_CONTROL, 883 MPFROM2SHORT(EA_LISTBOX, LN_SELECT), MPVOID); 884 } 885 DosFreeMem(pfealist); 886 } 887 } 888 free(s); 889 } 890 } 891 } 888 892 } 889 893 break; … … 892 896 if (eap->head && eap->current) { 893 897 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 898 EAOP2 eaop; 899 PFEA2LIST pfealist; 900 GEA2LIST gealist; 901 APIRET rc; 902 SHORT sSelect; 903 904 pfealist = 905 xmallocz(sizeof(FEA2LIST) + eap->current->cbName + 1, pszSrcFile, 906 __LINE__); 907 if (pfealist) { 908 pfealist->cbList = sizeof(FEA2LIST) + eap->current->cbName + 1; 909 pfealist->list[0].cbName = eap->current->cbName; 910 strcpy(pfealist->list[0].szName, eap->current->name); 911 pfealist->list[0].cbValue = 0; 912 memset(&gealist, 0, sizeof(GEA2LIST)); 913 gealist.cbList = sizeof(GEA2LIST); 914 eaop.fpGEA2List = &gealist; 915 eaop.fpFEA2List = pfealist; 916 eaop.oError = 0; 917 rc = xDosSetPathInfo(eap->filename, FIL_QUERYEASIZE, 918 &eaop, sizeof(eaop), DSPI_WRTTHRU); 919 free(pfealist); 920 if (rc) 921 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__, 922 "xDosSetPathInfo"); 923 else { 924 sSelect = 0; 925 if (eap->current == eap->head) { 926 eap->head = eap->head->next; 927 free(eap->current->pfea); 928 free(eap->current); 929 eap->current = NULL; 930 } 931 else { 932 info = eap->head; 933 while (info) { 934 if (info->next == eap->current) { 935 sSelect++; 936 info->next = eap->current->next; 937 free(eap->current->pfea); 938 free(eap->current); 939 eap->current = NULL; 940 break; 941 } 942 sSelect++; 943 info = info->next; 944 } 945 } 946 WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_DELETEITEM, 947 MPFROM2SHORT(sSelect, 0), MPVOID); 948 WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), FALSE); 949 WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE); 950 WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE); 951 WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE); 952 WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), FALSE); 953 WinSetDlgItemText(hwnd, EA_ENTRY, NullStr); 954 MLEclearall(WinWindowFromID(hwnd, EA_MLE)); 955 WinSendDlgItemMsg(hwnd, EA_HEXDUMP, LM_DELETEALL, MPVOID, MPVOID); 956 if (sSelect && (SHORT) WinSendDlgItemMsg(hwnd, EA_LISTBOX, 957 LM_QUERYITEMCOUNT, 958 MPVOID, MPVOID) <= 959 sSelect) 960 sSelect--; 961 WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_SELECTITEM, 962 MPFROM2SHORT(sSelect, 0), 963 MPFROM2SHORT(TRUE, 0)); 964 } 965 } 962 966 } 963 967 if (!eap->head) 964 968 WinSetDlgItemText(hwnd, EA_TEXT, GetPString(IDS_EANOEAS)); 965 969 break; 966 970 967 971 case IDM_HELP: 968 972 if (hwndHelp) 969 970 973 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 974 MPFROM2SHORT(HELP_EAS, 0), MPFROMSHORT(HM_RESOURCEID)); 971 975 break; 972 976 … … 987 991 if (eap) { 988 992 if (eap->head) 989 993 Free_FEAList(eap->head); 990 994 free(eap); 991 995 if (hptrIcon) 992 996 WinDestroyPointer(hptrIcon); 993 997 hptrIcon = (HPOINTER) 0; 994 998 } 995 999 break; 996 } 1000 } // switch 997 1001 return WinDefDlgProc(hwnd, msg, mp1, mp2); 998 1002 } 999 1003 1000 1004 PVOID SaveEA(CHAR * filename, HOLDFEA * current, CHAR * newdata, 1001 1005 BOOL silentfail) 1002 1006 { 1003 1007 /* save an ea to disk */ … … 1014 1018 len = strlen(newdata); 1015 1019 ealen = sizeof(FEA2LIST) + 24 + (ULONG) current->cbName + 1 + 1016 1020 (ULONG)len + 4; 1017 1021 switch (*(USHORT *) current->value) { 1018 1022 case EAT_EA: … … 1026 1030 while (*p) { 1027 1031 if (*p == '\n' && *(p + 1)) 1028 1032 ealen += sizeof(USHORT); 1029 1033 p++; 1030 1034 } … … 1037 1041 while (*p) { 1038 1042 if (*p == '\n' && *(p + 1)) 1039 1043 ealen += (sizeof(USHORT) * 2); 1040 1044 p++; 1041 1045 } … … 1046 1050 1047 1051 rc = DosAllocMem((PPVOID) & pfealist, ealen, 1048 1052 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE); 1049 1053 if (rc) 1050 1054 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 1051 1055 GetPString(IDS_OUTOFMEMORY)); 1052 1056 else { 1053 1057 memset(pfealist, 0, ealen); 1054 1058 pfealist->list[0].oNextEntryOffset = 0; 1055 pfealist->list[0].fEA = 0; 1059 pfealist->list[0].fEA = 0; //current->fEA; 1056 1060 1057 1061 pfealist->list[0].cbName = current->cbName; 1058 1062 memcpy(pfealist->list[0].szName, current->name, 1059 1063 pfealist->list[0].cbName + 1); 1060 1064 eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1; 1061 1065 switch (*(USHORT *) current->value) { … … 1084 1088 p = newdata; 1085 1089 while (*p == '\n') 1086 1090 p++; 1087 1091 while (*p) { 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1092 while (*p) { 1093 if (*p == '\n') 1094 p++; 1095 *eaval++ = *p++; 1096 (*plen)++; 1097 } 1098 if (*p || *plen) 1099 (*num)++; 1100 if (*p) { 1101 plen = (USHORT *) eaval; 1102 *plen = 0; 1103 eaval += sizeof(USHORT); 1104 } 1101 1105 } 1102 1106 break; … … 1128 1132 p = newdata; 1129 1133 while (*p == '\n') 1130 1134 p++; 1131 1135 while (*p) { 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1136 while (*p) { 1137 if (*p == '\n') 1138 p++; 1139 *eaval++ = *p++; 1140 (*plen)++; 1141 } 1142 if (*p || *plen) 1143 (*num)++; 1144 if (*p) { 1145 *(USHORT *) eaval = (USHORT) EAT_ASCII; 1146 eaval += sizeof(USHORT); 1147 plen = (USHORT *) eaval; 1148 *plen = 0; 1149 eaval += sizeof(USHORT); 1150 } 1147 1151 } 1148 1152 break; 1149 1153 } 1150 1154 pfealist->list[0].cbValue = /*(ULONG)*/ (eaval - 1151 1152 1155 (pfealist->list[0].szName + 1156 pfealist->list[0].cbName + 1)); 1153 1157 eaop.fpGEA2List = (PGEA2LIST) 0; 1154 1158 eaop.fpFEA2List = pfealist; 1155 1159 eaop.oError = 0; 1156 1160 pfealist->cbList = 13 + (ULONG) pfealist->list[0].cbName + 1157 1161 (ULONG)pfealist->list[0].cbValue; 1158 1162 1159 1163 rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE, 1160 1164 &eaop, sizeof(eaop), DSPI_WRTTHRU); 1161 1165 if (rc) { 1162 1166 DosFreeMem(pfealist); … … 1165 1169 if (rc && !silentfail) { 1166 1170 if (rc == ERROR_ACCESS_DENIED || rc == ERROR_SHARING_VIOLATION) { 1167 1168 1169 1170 1171 saymsg(MB_ENTER, 1172 HWND_DESKTOP, 1173 GetPString(IDS_OOPSTEXT), 1174 GetPString(IDS_CANTWRITEEATEXT), current->name, filename); 1171 1175 } 1172 1176 else { 1173 1174 1175 1176 1177 1178 1179 1177 Dos_Error(MB_ENTER, 1178 rc, 1179 HWND_DESKTOP, 1180 pszSrcFile, 1181 __LINE__, 1182 GetPString(IDS_ERRORWRITEEATEXT), 1183 current->name, filename, eaop.oError); 1180 1184 } 1181 1185 } … … 1197 1201 return head; 1198 1202 if (ishandle || !DosOpen(filename, &handle, &action, 0, 0, 1199 1200 1201 1202 1203 1203 OPEN_ACTION_FAIL_IF_NEW | 1204 OPEN_ACTION_OPEN_IF_EXISTS, 1205 OPEN_FLAGS_NOINHERIT | 1206 OPEN_SHARE_DENYREADWRITE | 1207 OPEN_ACCESS_READWRITE, (PEAOP2)0)) { 1204 1208 if (ishandle) 1205 1209 handle = *(HFILE *) filename; 1206 1210 if (!DosQueryFileInfo(handle, FIL_QUERYEASIZE, (PVOID)&fsa4, 1207 1208 1211 (ULONG) sizeof(fsa4)) && 1212 fsa4.cbList > 4) 1209 1213 { 1210 1214 PDENA2 pdena; … … 1213 1217 PFEA2LIST pfealist; 1214 1218 PGEA2 pgea; 1215 ULONG ulEntry = 1; 1216 ULONG ulCount = 1; 1219 ULONG ulEntry = 1; // Ordinal of EA to return 1220 ULONG ulCount = 1; // # of EAs to return 1217 1221 1218 1222 pdena = xmalloc(65536 + 1024, pszSrcFile, __LINE__); 1219 1223 if (pdena) { 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1224 while (!DosEnumAttribute(ENUMEA_REFTYPE_FHANDLE, 1225 &handle, 1226 ulEntry, 1227 (PVOID)pdena, 1228 (ULONG)65536, 1229 &ulCount, 1230 ENUMEA_LEVEL_NO_VALUE) && 1231 ulCount) 1232 { 1233 // 64 is for header and spare - fixme to allocate smarter 1234 pgealist = xmalloc(64 + pdena->cbName, pszSrcFile, __LINE__); 1235 if (pgealist) { 1236 pgealist->cbList = 64 + pdena->cbName; 1237 pgea = pgealist->list; 1238 pgea->oNextEntryOffset = 0; 1239 pgea->cbName = pdena->cbName; 1240 memcpy(pgea->szName, pdena->szName, pdena->cbName + 1); 1241 pfealist = xmallocz(64 + pdena->cbName + pdena->cbValue, 1242 pszSrcFile, __LINE__); 1243 if (pfealist) { 1244 pfealist->cbList = 64 + pdena->cbName + pdena->cbValue; 1245 eaop.fpGEA2List = pgealist; 1246 eaop.fpFEA2List = pfealist; 1247 eaop.oError = 0; 1248 // saymsg(MB_ENTER,HWND_DESKTOP,"Debug1","\"%s\" %ld",pdena->szName,ulEntry); 1249 rc = 1250 DosQueryFileInfo(handle, FIL_QUERYEASFROMLIST, (PVOID) & eaop, 1251 (ULONG) sizeof(EAOP2)); 1252 if (rc) { 1253 if (!silentfail) { 1254 Dos_Error(MB_ENTER, 1255 rc, 1256 HWND_DESKTOP, 1257 pszSrcFile, 1258 __LINE__, 1259 GetPString(IDS_ERRORREADEATEXT), pdena->szName); 1260 } 1261 } 1262 else { 1263 info = xmalloc(sizeof(HOLDFEA), pszSrcFile, __LINE__); 1264 if (info) { 1265 // 05 Jul 07 SHL was one short 1266 info->pfea = xmalloc(eaop.fpFEA2List->cbList - sizeof(ULONG) + 1, 1267 pszSrcFile, __LINE__); 1268 memcpy(info->pfea, eaop.fpFEA2List->list, 1269 eaop.fpFEA2List->cbList - sizeof(ULONG)); 1270 info->name = info->pfea->szName; 1271 info->cbName = info->pfea->cbName; 1272 info->cbValue = info->pfea->cbValue; 1273 info->value = info->pfea->szName + info->pfea->cbName + 1; 1274 info->value[info->cbValue] = 0; 1275 info->next = NULL; 1276 if (!head) 1277 head = info; 1278 else 1279 last->next = info; 1280 last = info; 1281 } 1282 } 1283 free(pfealist); 1284 } 1285 free(pgealist); 1286 } 1287 ulEntry += ulCount; 1288 } // while 1289 free(pdena); 1290 DosPostEventSem(CompactSem); 1287 1291 } 1288 1292 } … … 1295 1299 /* try it without opening it */ 1296 1300 if (!DosQueryPathInfo(filename, FIL_QUERYEASIZE, (PVOID) & fsa4, 1297 1298 1301 (ULONG) sizeof(fsa4)) && 1302 fsa4.cbList > 4) 1299 1303 { 1300 1304 PDENA2 pdena; … … 1307 1311 pdena = xmalloc(65536 + 1024, pszSrcFile, __LINE__); 1308 1312 if (pdena) { 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1313 while (!DosEnumAttribute 1314 (ENUMEA_REFTYPE_PATH, filename, ulEntry, (PVOID) pdena, 1315 (ULONG) 65536, &ulCount, ENUMEA_LEVEL_NO_VALUE) && ulCount) 1316 { 1317 pgealist = xmalloc(64 + pdena->cbName, pszSrcFile, __LINE__); 1318 if (pgealist) { 1319 pgealist->cbList = 64 + pdena->cbName; 1320 pgea = pgealist->list; 1321 pgea->oNextEntryOffset = 0; 1322 pgea->cbName = pdena->cbName; 1323 memcpy(pgea->szName, pdena->szName, pdena->cbName + 1); 1324 pfealist = 1325 xmallocz(64 + pdena->cbName + pdena->cbValue, pszSrcFile, 1326 __LINE__); 1327 if (pfealist) { 1328 pfealist->cbList = 64 + pdena->cbName + pdena->cbValue; 1329 eaop.fpGEA2List = pgealist; 1330 eaop.fpFEA2List = pfealist; 1331 eaop.oError = 0; 1332 // saymsg(MB_ENTER,HWND_DESKTOP,"Debug2","\"%s\" %ld",pdena->szName,ulEntry); 1333 rc = DosQueryPathInfo(filename, FIL_QUERYEASFROMLIST, 1334 (PVOID) & eaop, (ULONG) sizeof(EAOP2)); 1335 if (!rc) { 1336 info = xmalloc(sizeof(HOLDFEA), pszSrcFile, __LINE__); 1337 if (info) { 1334 1338 // 29 Nov 07 GKY One short (EA search crash) 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1339 info->pfea = 1340 xmalloc(eaop.fpFEA2List->cbList - sizeof(ULONG) + 1, 1341 pszSrcFile, __LINE__); 1342 memcpy(info->pfea, eaop.fpFEA2List->list, 1343 eaop.fpFEA2List->cbList - sizeof(ULONG)); 1344 info->name = info->pfea->szName; 1345 info->cbName = info->pfea->cbName; 1346 info->cbValue = info->pfea->cbValue; 1347 info->value = info->pfea->szName + info->pfea->cbName + 1; 1348 info->value[info->cbValue] = 0; 1349 info->next = NULL; 1350 if (!head) 1351 head = info; 1352 else 1353 last->next = info; 1354 last = info; 1355 } 1356 else 1357 free(pfealist); 1358 } 1359 else { 1360 free(pfealist); 1361 if (!silentfail) { 1362 if (rc == ERROR_ACCESS_DENIED 1363 || rc == ERROR_SHARING_VIOLATION) { 1364 rc = 1365 saymsg(MB_ENTER | MB_CANCEL, HWND_DESKTOP, 1366 GetPString(IDS_OOPSTEXT), 1367 GetPString(IDS_CANTREADEATEXT), filename, 1368 pdena->szName); 1369 if (rc == MBID_CANCEL) { 1370 free(pgealist); 1371 break; 1372 } 1373 } 1374 else { 1375 Dos_Error(MB_ENTER, 1376 rc, 1377 HWND_DESKTOP, 1378 pszSrcFile, 1379 __LINE__, 1380 GetPString(IDS_ERRORREADEATEXT), pdena->szName); 1381 } 1382 } 1383 } 1384 } 1385 free(pgealist); 1386 } 1387 ulEntry += ulCount; 1388 } // while 1389 free(pdena); 1390 DosPostEventSem(CompactSem); 1387 1391 } 1388 1392 }
Note:
See TracChangeset
for help on using the changeset viewer.