Changeset 1161 for trunk/dll/grep2.c
- Timestamp:
- Sep 5, 2008, 11:42:27 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/grep2.c
r1119 r1161 31 31 #include <ctype.h> 32 32 #include <share.h> 33 #include <process.h> 33 #include <process.h> // _beginthread 34 34 35 35 #define INCL_DOS 36 36 #define INCL_WIN 37 #define INCL_LONGLONG 38 #define INCL_WINSTDCNR 37 #define INCL_LONGLONG // dircnrs.h 38 #define INCL_WINSTDCNR // makelist.h 39 39 40 40 #include "fm3dlg.h" … … 42 42 #include "mle.h" 43 43 #include "grep.h" 44 #include "errutil.h" 45 #include "strutil.h" 44 #include "errutil.h" // Dos_Error... 45 #include "strutil.h" // GetPString 46 46 #include "pathutil.h" // BldFullPathName 47 #include "walkem.h" // FillPathListBox 48 #include "grep2.h" 47 49 #include "fm3dll.h" 50 #include "misc.h" // LoadLibPath 48 51 #include "fortify.h" 49 52 … … 67 70 *(CHAR *)mp2 = 0; 68 71 { 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 72 CHAR *p; 73 CHAR *pp; 74 75 p = GetPString(IDS_ENVVARNAMES); 76 while (*p == ' ') 77 p++; 78 while (*p) { 79 *szPath = 0; 80 pp = szPath; 81 while (*p && *p != ' ') 82 *pp++ = *p++; 83 *pp = 0; 84 while (*p == ' ') 85 p++; 86 if (*szPath) 87 WinSendDlgItemMsg(hwnd, 88 ENV_LISTBOX, 89 LM_INSERTITEM, 90 MPFROM2SHORT(LIT_END, 0), MPFROMP(szPath)); 91 } 89 92 } 90 93 WinSendDlgItemMsg(hwnd, 91 92 94 ENV_NAME, 95 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); 93 96 WinSetDlgItemText(hwnd, ENV_NAME, lastenv); 94 97 WinSendDlgItemMsg(hwnd, 95 96 98 ENV_NAME, 99 EM_SETSEL, MPFROM2SHORT(0, CCHMAXPATH), MPVOID); 97 100 } 98 101 else … … 105 108 switch (SHORT2FROMMP(mp1)) { 106 109 case LN_SELECT: 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 110 { 111 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 112 ENV_LISTBOX, 113 LM_QUERYSELECTION, 114 MPFROMSHORT(LIT_FIRST), MPVOID); 115 if (sSelect >= 0) { 116 *s = 0; 117 WinSendDlgItemMsg(hwnd, 118 ENV_LISTBOX, 119 LM_QUERYITEMTEXT, 120 MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s)); 121 bstrip(s); 122 if (*s) 123 WinSetDlgItemText(hwnd, ENV_NAME, s); 124 } 125 } 126 break; 124 127 case LN_ENTER: 125 126 128 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID); 129 break; 127 130 } 128 131 } … … 137 140 p = WinQueryWindowPtr(hwnd, QWL_USER); 138 141 if (p) { 139 140 141 142 143 144 145 146 147 148 142 WinQueryDlgItemText(hwnd, ENV_NAME, CCHMAXPATH, p); 143 bstrip(p); 144 if (!*p) { 145 DosBeep(50, 100); 146 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ENV_NAME)); 147 } 148 else { 149 strcpy(lastenv, p); 150 WinDismissDlg(hwnd, 1); 151 } 149 152 } 150 153 break; 151 154 case IDM_HELP: 152 155 if (hwndHelp) 153 154 155 156 WinSendMsg(hwndHelp, 157 HM_DISPLAY_HELP, 158 MPFROM2SHORT(HELP_ENV, 0), MPFROMSHORT(HM_RESOURCEID)); 156 159 break; 157 160 } … … 199 202 WinSetWindowULong(hwnd, QWL_USER, *(HWND *) mp2); 200 203 WinSendDlgItemMsg(hwnd, 201 202 204 GREP_MASK, 205 EM_SETTEXTLIMIT, MPFROM2SHORT(8192, 0), MPVOID); 203 206 MLEsetlimit(hwndMLE, 4096); 204 207 MLEsetformat(hwndMLE, MLFIE_NOTRANS); 205 208 WinSendDlgItemMsg(hwnd, 206 207 209 GREP_NEWER, 210 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID); 208 211 WinSendDlgItemMsg(hwnd, 209 210 212 GREP_OLDER, 213 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID); 211 214 WinSendDlgItemMsg(hwnd, 212 213 215 GREP_GREATER, 216 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID); 214 217 WinSendDlgItemMsg(hwnd, 215 216 218 GREP_LESSER, 219 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID); 217 220 WinSetDlgItemText(hwnd, GREP_MASK, lastmask); 218 221 WinSendDlgItemMsg(hwnd, 219 222 GREP_MASK, EM_SETSEL, MPFROM2SHORT(0, 8192), MPVOID); 220 223 PrfQueryProfileData(fmprof, FM3Str, "RememberFlagsGrep", 221 224 (PVOID) & gRemember, &size); 222 225 WinCheckButton(hwnd, GREP_REMEMBERFLAGS, gRemember); 223 226 if (gRemember) { 224 227 PrfQueryProfileData(fmprof, FM3Str, "Grep_Recurse", 225 228 (PVOID) & recurse, &size); 226 229 PrfQueryProfileData(fmprof, FM3Str, "Grep_Absolute", 227 230 (PVOID) & absolute, &size); 228 231 PrfQueryProfileData(fmprof, FM3Str, "Grep_Case", 229 232 (PVOID) & sensitive, &size); 230 233 PrfQueryProfileData(fmprof, FM3Str, "Grep_Sayfiles", 231 234 (PVOID) & sayfiles, &size); 232 235 PrfQueryProfileData(fmprof, FM3Str, "Grep_Searchfiles", 233 236 (PVOID) & searchFiles, &size); 234 237 PrfQueryProfileData(fmprof, FM3Str, "Grep_SearchfEAs", 235 238 (PVOID) & searchEAs, &size); 236 239 } 237 240 if (!gRemember) { … … 248 251 MLEsetcurposa(hwndMLE, 4096); 249 252 if (!searchEAs) 250 253 searchFiles = TRUE; 251 254 } 252 255 WinCheckButton(hwnd, GREP_RECURSE, recurse); … … 275 278 if (fp) { 276 279 while (!feof(fp)) { 277 278 279 280 281 282 283 284 280 if (!xfgets_bstripcr(s, 8192 + 4, fp, pszSrcFile, __LINE__)) 281 break; 282 if (*s && *s != ';') { 283 WinSendDlgItemMsg(hwnd, 284 GREP_LISTBOX, 285 LM_INSERTITEM, 286 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s)); 287 } 285 288 } 286 289 fclose(fp); … … 288 291 289 292 FillPathListBox(hwnd, 290 291 293 WinWindowFromID(hwnd, GREP_DRIVELIST), 294 (HWND) 0, NULL, FALSE); 292 295 break; 293 296 … … 298 301 case UM_SETDIR: 299 302 PaintRecessedWindow(WinWindowFromID(hwnd, GREP_HELP), 300 303 (HPS) 0, FALSE, TRUE); 301 304 return 0; 302 305 … … 311 314 case GREP_REMEMBERFLAGS: 312 315 { 313 314 315 316 316 BOOL gRemember = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS); 317 318 PrfWriteProfileData(fmprof, FM3Str, "RememberFlagsGrep", 319 (PVOID) & gRemember, sizeof(BOOL)); 317 320 } 318 321 break; … … 321 324 switch (SHORT2FROMMP(mp1)) { 322 325 case LN_KILLFOCUS: 323 324 325 326 WinSetDlgItemText(hwnd, 327 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 328 break; 326 329 case LN_SETFOCUS: 327 328 329 330 WinSetDlgItemText(hwnd, 331 GREP_HELP, GetPString(IDS_2CLICKADDDRVMASKTEXT)); 332 break; 330 333 case LN_ENTER: 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 break;// LN_ENTER380 } 334 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s); 335 bstrip(s); 336 p = strrchr(s, '\\'); 337 if (p) 338 strcpy(simple, p); 339 else if (*s) { 340 strcpy(simple, "\\"); 341 strcat(simple, s); 342 *s = 0; 343 } 344 else 345 strcpy(simple, "\\*"); 346 if (simple[strlen(simple) - 1] == ';') 347 simple[strlen(simple) - 1] = 0; 348 lLen = strlen(simple) + 1; 349 if (strlen(s) > 8192 - lLen) { 350 Runtime_Error(pszSrcFile, __LINE__, "too big"); 351 WinSetDlgItemText(hwnd, GREP_MASK, s); 352 break; 353 } 354 355 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 356 GREP_DRIVELIST, 357 LM_QUERYSELECTION, 358 MPFROMSHORT(LIT_FIRST), MPVOID); 359 if (sSelect >= 0) { 360 if (*s && s[strlen(s) - 1] != ';') 361 strcat(s, ";"); 362 WinSendDlgItemMsg(hwnd, 363 GREP_DRIVELIST, 364 LM_QUERYITEMTEXT, 365 MPFROM2SHORT(sSelect, 366 (8192 - strlen(s)) - lLen), 367 MPFROMP(&s[strlen(s)])); 368 rstrip(s); 369 if (*s) { 370 strcat(s, simple); 371 WinSetDlgItemText(hwnd, GREP_MASK, s); 372 WinSendDlgItemMsg(hwnd, 373 GREP_MASK, 374 EM_SETSEL, 375 MPFROM2SHORT(strlen(s) - (lLen + 1), 376 strlen(s)), MPVOID); 377 PostMsg(hwnd, 378 UM_FOCUSME, 379 MPFROMLONG(WinWindowFromID(hwnd, GREP_MASK)), MPVOID); 380 } 381 } 382 break; // LN_ENTER 383 } // switch 381 384 break; 382 385 … … 384 387 switch (SHORT2FROMMP(mp1)) { 385 388 case LN_KILLFOCUS: 386 387 388 389 WinSetDlgItemText(hwnd, 390 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 391 break; 389 392 case LN_SETFOCUS: 390 391 393 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_ADDSELDELMASKTEXT)); 394 break; 392 395 case LN_ENTER: 393 396 case LN_SELECT: 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 397 if ((SHORT2FROMMP(mp1) == LN_ENTER && 398 !WinQueryButtonCheckstate(hwnd, GREP_APPEND)) || 399 (SHORT2FROMMP(mp1) == LN_SELECT && 400 WinQueryButtonCheckstate(hwnd, GREP_APPEND))) 401 break; 402 { 403 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 404 GREP_LISTBOX, 405 LM_QUERYSELECTION, 406 MPFROMSHORT(LIT_FIRST), MPVOID); 407 if (sSelect >= 0) { 408 *s = 0; 409 if (WinQueryButtonCheckstate(hwnd, GREP_APPEND)) { 410 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s); 411 bstrip(s); 412 if (*s && strlen(s) < 8190 && s[strlen(s) - 1] != ';') 413 strcat(s, ";"); 414 } 415 WinSendDlgItemMsg(hwnd, 416 GREP_LISTBOX, 417 LM_QUERYITEMTEXT, 418 MPFROM2SHORT(sSelect, 8192 - strlen(s)), 419 MPFROMP(s + strlen(s))); 420 bstrip(s); 421 if (*s) 422 WinSetDlgItemText(hwnd, GREP_MASK, s); 423 } 424 } 425 break; 423 426 } 424 427 break; … … 426 429 case GREP_MASK: 427 430 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) 428 429 431 WinSetDlgItemText(hwnd, 432 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 430 433 if (SHORT2FROMMP(mp1) == EN_SETFOCUS) 431 434 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MASKSFINDTEXT)); 432 435 break; 433 436 case GREP_SEARCH: 434 437 if (SHORT2FROMMP(mp1) == MLN_KILLFOCUS) 435 436 438 WinSetDlgItemText(hwnd, 439 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 437 440 if (SHORT2FROMMP(mp1) == MLN_SETFOCUS) 438 441 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_TEXTFINDTEXT)); 439 442 break; 440 443 case GREP_GREATER: 441 444 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) 442 443 445 WinSetDlgItemText(hwnd, 446 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 444 447 if (SHORT2FROMMP(mp1) == EN_SETFOCUS) 445 448 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MINSIZEFINDTEXT)); 446 449 break; 447 450 case GREP_LESSER: 448 451 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) 449 450 452 WinSetDlgItemText(hwnd, 453 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 451 454 if (SHORT2FROMMP(mp1) == EN_SETFOCUS) 452 455 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MAXSIZEFINDTEXT)); 453 456 break; 454 457 case GREP_NEWER: 455 458 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) 456 457 459 WinSetDlgItemText(hwnd, 460 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 458 461 if (SHORT2FROMMP(mp1) == EN_SETFOCUS) 459 462 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MAXAGEFINDTEXT)); 460 463 break; 461 464 case GREP_OLDER: 462 465 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) 463 464 466 WinSetDlgItemText(hwnd, 467 GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); 465 468 if (SHORT2FROMMP(mp1) == EN_SETFOCUS) 466 469 WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MINAGEFINDTEXT)); 467 470 break; 468 471 case GREP_FINDDUPES: 469 472 { 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 473 BOOL finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES); 474 475 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCH), !finddupes); 476 WinEnableWindow(WinWindowFromID(hwnd, GREP_ABSOLUTE), !finddupes); 477 WinEnableWindow(WinWindowFromID(hwnd, GREP_CASE), !finddupes); 478 WinEnableWindow(WinWindowFromID(hwnd, GREP_CRCDUPES), finddupes); 479 WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), finddupes); 480 WinEnableWindow(WinWindowFromID(hwnd, GREP_IGNOREEXTDUPES), 481 finddupes); 482 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCHFILES), !finddupes); 483 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCHEAS), !finddupes); 484 WinEnableWindow(WinWindowFromID(hwnd, GREP_GREATER), !finddupes); 485 WinEnableWindow(WinWindowFromID(hwnd, GREP_LESSER), !finddupes); 486 WinEnableWindow(WinWindowFromID(hwnd, GREP_NEWER), !finddupes); 487 WinEnableWindow(WinWindowFromID(hwnd, GREP_OLDER), !finddupes); 488 WinEnableWindow(WinWindowFromID(hwnd, GREP_FINDIFANY), !finddupes); 489 WinEnableWindow(WinWindowFromID(hwnd, GREP_GK), !finddupes); 490 WinEnableWindow(WinWindowFromID(hwnd, GREP_LK), !finddupes); 491 WinEnableWindow(WinWindowFromID(hwnd, GREP_NM), !finddupes); 492 WinEnableWindow(WinWindowFromID(hwnd, GREP_OM), !finddupes); 493 if (finddupes) 494 WinCheckButton(hwnd, GREP_RECURSE, TRUE); 492 495 } 493 496 } … … 498 501 case GREP_ENV: 499 502 { 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 503 CHAR *t; 504 CHAR env[8192]; 505 506 *path = 0; 507 if (!WinDlgBox(HWND_DESKTOP, 508 hwnd, EnvDlgProc, FM3ModHandle, ENV_FRAME, path)) { 509 break; 510 } 511 bstrip(path); 512 if (!*path) 513 break; 514 if (!stricmp(path, "LIBPATH")) 515 LoadLibPath(env, 8192); 516 else { 517 p = getenv(path); 518 if (!p) 519 break; 520 strcpy(env, p); 521 } 522 bstrip(env); 523 if (!*env) 524 break; 525 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s); 526 bstrip(s); 527 if (strlen(s) > 8192 - 5) { 528 Runtime_Error(pszSrcFile, __LINE__, "too big"); 529 break; 530 } 531 p = strrchr(s, '\\'); 532 if (p) 533 strcpy(simple, p + 1); 534 else if (*s) 535 strcpy(simple, s); 536 else 537 strcpy(simple, "*"); 538 if (!p) 539 *s = 0; 540 if (simple[strlen(simple) - 1] == ';') 541 simple[strlen(simple) - 1] = 0; 542 lLen = strlen(simple) + 1; 543 p = env; 544 while (p && *p) { 545 strncpy(path, p, CCHMAXPATH - 1); 546 path[CCHMAXPATH - 1] = 0; 547 t = strchr(path, ';'); 548 if (t) 549 *t = 0; 550 bstrip(path); 551 if (isalpha(*path) && path[1] == ':' && path[2] == '\\') { 552 if (strlen(s) > (8192 - lLen) - (strlen(path) + 1)) { 553 WinSetDlgItemText(hwnd, GREP_MASK, s); 554 break; 555 } 556 if (!*s || (*s && s[strlen(s) - 1] != ';')) { 557 if (*s) 558 strcat(s, ";"); 559 strcat(s, path); 560 lLen += strlen(path); 561 if (s[strlen(s) - 1] != '\\') { 562 lLen++; 563 strcat(s, "\\"); 564 } 565 rstrip(s); 566 if (*s) { 567 strcat(s, simple); 568 WinSetDlgItemText(hwnd, GREP_MASK, s); 569 WinSendDlgItemMsg(hwnd, 570 GREP_MASK, 571 EM_SETSEL, 572 MPFROM2SHORT(strlen(s) - (lLen - 1), 573 strlen(s)), MPVOID); 574 } 575 } 576 } 577 p = strchr(p, ';'); 578 if (p) 579 p++; 580 } 578 581 } 579 582 break; … … 583 586 bstrip(s); 584 587 if (strlen(s) > 8192 - 5) { 585 586 588 Runtime_Error(pszSrcFile, __LINE__, "too big"); 589 break; 587 590 } 588 591 *path = 0; 589 592 if (WinDlgBox(HWND_DESKTOP, 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 593 hwnd, 594 WalkAllDlgProc, 595 FM3ModHandle, WALK_FRAME, MPFROMP(path)) && *path) { 596 p = strrchr(s, '\\'); 597 if (p) 598 strcpy(simple, p + 1); 599 else if (*s) 600 strcpy(simple, s); 601 else 602 strcpy(simple, "*"); 603 if (!p) 604 *s = 0; 605 if (simple[strlen(simple) - 1] == ';') 606 simple[strlen(simple) - 1] = 0; 607 lLen = strlen(simple) + 1; 608 if (strlen(s) > (8192 - lLen) - (strlen(path) + 1)) { 609 Runtime_Error(pszSrcFile, __LINE__, "too big"); 610 WinSetDlgItemText(hwnd, GREP_MASK, s); 611 break; 612 } 613 if (!*s || (*s && s[strlen(s) - 1] != ';')) { 614 if (*s) 615 strcat(s, ";"); 616 strcat(s, path); 617 lLen += strlen(path); 618 if (s[strlen(s) - 1] != '\\') { 619 lLen++; 620 strcat(s, "\\"); 621 } 622 rstrip(s); 623 if (*s) { 624 strcat(s, simple); 625 WinSetDlgItemText(hwnd, GREP_MASK, s); 626 WinSendDlgItemMsg(hwnd, 627 GREP_MASK, 628 EM_SETSEL, 629 MPFROM2SHORT(strlen(s) - (lLen - 1), 630 strlen(s)), MPVOID); 631 } 632 } 630 633 } 631 634 break; … … 636 639 bstrip(s); 637 640 if (*s) { 638 639 640 641 642 643 644 645 646 647 648 649 641 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 642 GREP_LISTBOX, 643 LM_SEARCHSTRING, 644 MPFROM2SHORT(0, LIT_FIRST), 645 MPFROMP(s)); 646 if (sSelect < 0) { 647 WinSendDlgItemMsg(hwnd, 648 GREP_LISTBOX, 649 LM_INSERTITEM, 650 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s)); 651 changed = TRUE; 652 } 650 653 } 651 654 break; … … 653 656 case GREP_DELETE: 654 657 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 655 656 657 658 GREP_LISTBOX, 659 LM_QUERYSELECTION, 660 MPFROMSHORT(LIT_FIRST), MPVOID); 658 661 if (sSelect >= 0) { 659 660 661 662 662 WinSendDlgItemMsg(hwnd, 663 GREP_LISTBOX, 664 LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID); 665 changed = TRUE; 663 666 } 664 667 break; … … 702 705 case IDM_HELP: 703 706 if (hwndHelp) 704 705 706 707 WinSendMsg(hwndHelp, 708 HM_DISPLAY_HELP, 709 MPFROM2SHORT(HELP_GREP, 0), MPFROMSHORT(HM_RESOURCEID)); 707 710 break; 708 711 … … 711 714 case GREP_ALLHDS: 712 715 { 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 763 764 765 766 767 768 769 770 771 772 716 CHAR szDrive[] = " :\\"; 717 ULONG ulDriveNum; 718 ULONG ulDriveMap; 719 INT x; 720 BOOL incl; 721 722 CHAR new[8192]; 723 724 *s = 0; 725 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s); 726 s[8192 - 1] = 0; 727 p = strchr(s, ';'); 728 if (p) 729 *p = 0; 730 p = strrchr(s, '\\'); 731 if (!p) 732 p = strrchr(s, '/'); 733 if (!p) 734 p = strrchr(s, ':'); 735 if (p) 736 strcpy(s, p + 1); 737 if (!*s) 738 strcpy(s, "*"); 739 DosError(FERR_DISABLEHARDERR); 740 DosQCurDisk(&ulDriveNum, &ulDriveMap); 741 *new = 0; 742 for (x = 2; x < 26; x++) { 743 if (ulDriveMap & (1L << x)) { 744 incl = FALSE; 745 switch (SHORT1FROMMP(mp1)) { 746 case GREP_ALLHDS: 747 if (!(driveflags[x] & (DRIVE_REMOVABLE | DRIVE_IGNORE))) 748 incl = TRUE; 749 break; 750 case GREP_LOCALHDS: 751 if (!(driveflags[x] & 752 (DRIVE_REMOVABLE | DRIVE_IGNORE | DRIVE_REMOTE | 753 DRIVE_VIRTUAL))) 754 incl = TRUE; 755 break; 756 case GREP_REMOTEHDS: 757 if (!(driveflags[x] & 758 (DRIVE_REMOVABLE | DRIVE_IGNORE)) && 759 (driveflags[x] & DRIVE_REMOTE)) 760 incl = TRUE; 761 break; 762 } 763 } 764 if (incl) { 765 if (strlen(new) + strlen(s) + 5 < 8192 - 1) { 766 if (*new) 767 strcat(new, ";"); 768 *szDrive = x + 'A'; 769 strcat(new, szDrive); 770 strcat(new, s); 771 } 772 } 773 } 774 if (*new) 775 WinSetDlgItemText(hwnd, GREP_MASK, new); 773 776 } 774 777 break; … … 777 780 hwndCollect = WinQueryWindowULong(hwnd, QWL_USER); 778 781 if (!hwndCollect) 779 782 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 780 783 else { 781 782 static GREP g;// Passed to thread783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 784 // 07 Feb 08 SHL - fixme to malloc and free in thread 785 static GREP g; // Passed to thread 786 787 p = xmalloc(8192 + 512, pszSrcFile, __LINE__); 788 if (!p) 789 break; 790 memset(&g, 0, sizeof(GREP)); 791 g.size = sizeof(GREP); 792 recurse = WinQueryButtonCheckstate(hwnd, GREP_RECURSE) != 0; 793 absolute = WinQueryButtonCheckstate(hwnd, GREP_ABSOLUTE) != 0; 794 sensitive = WinQueryButtonCheckstate(hwnd, GREP_CASE) != 0; 795 sayfiles = WinQueryButtonCheckstate(hwnd, GREP_SAYFILES) != 0; 796 searchEAs = WinQueryButtonCheckstate(hwnd, GREP_SEARCHEAS) != 0; 797 searchFiles = WinQueryButtonCheckstate(hwnd, GREP_SEARCHFILES) != 0; 798 findifany = WinQueryButtonCheckstate(hwnd, GREP_FINDIFANY) != 0; 799 gRemember = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS); 800 if (gRemember) { 801 PrfWriteProfileData(fmprof, FM3Str, "Grep_Recurse", 802 (PVOID) & recurse, sizeof(BOOL)); 803 PrfWriteProfileData(fmprof, FM3Str, "Grep_Absolute", 804 (PVOID) & absolute, sizeof(BOOL)); 805 PrfWriteProfileData(fmprof, FM3Str, "Grep_Case", 806 (PVOID) & sensitive, sizeof(BOOL)); 807 PrfWriteProfileData(fmprof, FM3Str, "Grep_Sayfiles", 808 (PVOID) & sayfiles, sizeof(BOOL)); 809 PrfWriteProfileData(fmprof, FM3Str, "Grep_Searchfiles", 810 (PVOID) & searchFiles, sizeof(BOOL)); 811 PrfWriteProfileData(fmprof, FM3Str, "Grep_SearchfEAs", 812 (PVOID) & searchEAs, sizeof(BOOL)); 813 } 814 g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0; 815 if (g.finddupes) { 816 g.CRCdupes = WinQueryButtonCheckstate(hwnd, GREP_CRCDUPES) != 0; 817 g.nosizedupes = 818 WinQueryButtonCheckstate(hwnd, GREP_NOSIZEDUPES) != 0; 819 g.ignoreextdupes = 820 WinQueryButtonCheckstate(hwnd, GREP_IGNOREEXTDUPES) != 0; 821 } 822 // Parse file masks 823 *p = 0; 824 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, p); 825 bstrip(p); 826 if (!*p) { 827 DosBeep(50, 100); 828 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, GREP_MASK)); 829 free(p); 827 830 # ifdef FORTIFY 828 831 Fortify_LeaveScope(); 829 832 # endif 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 888 889 890 891 892 893 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 833 break; 834 } 835 strcpy(g.tosearch, p); 836 strcpy(lastmask, p); 837 // Parse search strings 838 *p = 0; 839 WinQueryWindowText(hwndMLE, 4096, p); 840 strcpy(lasttext, p); 841 { 842 CHAR *pszFrom; 843 CHAR *pszTo; 844 ULONG matched = 0; 845 846 pszTo = g.searchPattern; 847 pszFrom = p; 848 while (*pszFrom) { 849 if (*pszFrom == '\r') { 850 pszFrom++; 851 continue; 852 } 853 if (*pszFrom == '\n') { 854 if (*(pszFrom + 1)) 855 matched++; 856 *pszTo = 0; 857 } 858 else 859 *pszTo = *pszFrom; 860 pszTo++; 861 pszFrom++; 862 } 863 if (*g.searchPattern) 864 matched++; 865 *pszTo++ = 0; 866 *pszTo = 0; 867 g.numlines = matched; 868 if (matched) { 869 g.matched = xmalloc(g.numlines, pszSrcFile, __LINE__); 870 if (!g.matched) 871 g.numlines = 0; 872 } 873 } 874 *p = 0; 875 WinQueryDlgItemText(hwnd, GREP_GREATER, 34, p); 876 greater = atol(p); 877 *p = 0; 878 WinQueryDlgItemText(hwnd, GREP_LESSER, 34, p); 879 lesser = atol(p); 880 *p = 0; 881 WinQueryDlgItemText(hwnd, GREP_NEWER, 34, p); 882 newer = atoi(p); 883 *p = 0; 884 WinQueryDlgItemText(hwnd, GREP_OLDER, 34, p); 885 older = atoi(p); 886 if (older || newer) { 887 FDATE fdate; 888 FTIME ftime; 889 struct tm tm; 890 time_t t; 891 892 t = time(NULL); 893 tm = *localtime(&t); 894 fdate.day = tm.tm_mday; 895 fdate.month = tm.tm_mon + 1; 896 fdate.year = tm.tm_year - 80; 897 ftime.hours = tm.tm_hour; 898 ftime.minutes = tm.tm_min; 899 ftime.twosecs = tm.tm_sec / 2; 900 if (older) { 901 g.olderthan = SecsSince1980(&fdate, &ftime); 902 g.olderthan -= (older * (24L * 60L * 60L)); 903 } 904 if (newer) { 905 g.newerthan = SecsSince1980(&fdate, &ftime); 906 g.newerthan -= (newer * (24L * 60L * 60L)); 907 } 908 } 909 if (!newer) 910 g.newerthan = 0; 911 if (!older) 912 g.olderthan = 0; 913 g.greaterthan = greater; 914 g.lessthan = lesser; 915 g.absFlag = absolute; 916 g.caseFlag = sensitive; 917 g.dirFlag = recurse; 918 g.sayfiles = sayfiles; 919 g.searchEAs = searchEAs; 920 g.searchFiles = searchFiles; 921 g.findifany = findifany; 922 g.hwndFiles = hwndCollect; 923 g.hwnd = WinQueryWindow(hwndCollect, QW_PARENT); 924 g.hwndCurFile = WinWindowFromID(g.hwnd, DIR_SELECTED); 925 g.attrFile = ((DIRCNRDATA *)INSTDATA(hwndCollect))->mask.attrFile; 926 g.antiattr = ((DIRCNRDATA *)INSTDATA(hwndCollect))->mask.antiattr; 927 g.stopflag = &((DIRCNRDATA *)INSTDATA(hwndCollect))->stopflag; 928 if (_beginthread(GrepThread, NULL, 524280, (PVOID) & g) == -1) { 929 Runtime_Error(pszSrcFile, __LINE__, 930 GetPString(IDS_COULDNTSTARTTHREADTEXT)); 931 free(p); 929 932 # ifdef FORTIFY 930 933 Fortify_LeaveScope(); 931 934 # endif 932 933 934 935 936 935 WinDismissDlg(hwnd, 0); 936 break; 937 } 938 DosSleep(100); //05 Aug 07 GKY 128 939 free(p); 937 940 # ifdef FORTIFY 938 941 Fortify_LeaveScope(); … … 940 943 } 941 944 if (changed) { 942 943 944 945 946 947 948 945 // Grep mask list changed 946 SHORT x; 947 948 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 949 GREP_LISTBOX, 950 LM_QUERYITEMCOUNT, 951 MPVOID, MPVOID); 949 952 if (sSelect > 0) { 950 953 BldFullPathName(s, pFM2SaveDirectory, "GREPMASK.DAT"); 951 954 if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2) 952 955 break; //already gave error msg 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 956 fp = xfopen(s, "w", pszSrcFile, __LINE__); 957 if (fp) { 958 fputs(GetPString(IDS_GREPFILETEXT), fp); 959 for (x = 0; x < sSelect; x++) { 960 *s = 0; 961 WinSendDlgItemMsg(hwnd, 962 GREP_LISTBOX, 963 LM_QUERYITEMTEXT, 964 MPFROM2SHORT(x, 8192), MPFROMP(s)); 965 bstrip(s); 966 if (*s) 967 fprintf(fp, "%s\n", s); 968 } 969 fclose(fp); 970 } 971 } 969 972 } 970 973 WinDismissDlg(hwnd, 1);
Note:
See TracChangeset
for help on using the changeset viewer.