| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: grep2.c 793 2007-08-21 02:53:38Z gyoung $
|
|---|
| 5 |
|
|---|
| 6 | Grep dialog for collector
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2004, 2006 Steven H. Levine
|
|---|
| 10 |
|
|---|
| 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
|---|
| 12 | 23 May 05 SHL Use QWL_USER
|
|---|
| 13 | 06 Jun 05 SHL Indent -i2
|
|---|
| 14 | 06 Jun 05 SHL Rework for VAC3.65 compat, lose excess statics
|
|---|
| 15 | 17 Jul 06 SHL Use Runtime_Error
|
|---|
| 16 | 28 Jul 06 SHL Avoid 0 length malloc, optimize option checks
|
|---|
| 17 | 29 Jul 06 SHL Use xfgets
|
|---|
| 18 | 22 Oct 06 GKY Switch say files on as default so you can tell that seek and scan files is doing something
|
|---|
| 19 | 07 Jan 07 GKY Add remember search flags to seek and scan
|
|---|
| 20 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
|---|
| 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | fixme for more excess locals to be gone
|
|---|
| 25 |
|
|---|
| 26 | ***********************************************************************/
|
|---|
| 27 |
|
|---|
| 28 | #define INCL_DOS
|
|---|
| 29 | #define INCL_WIN
|
|---|
| 30 | #define INCL_GPI
|
|---|
| 31 | #define INCL_DOSERRORS
|
|---|
| 32 | #include <os2.h>
|
|---|
| 33 |
|
|---|
| 34 | #include <stdarg.h>
|
|---|
| 35 | #include <stdio.h>
|
|---|
| 36 | #include <stdlib.h>
|
|---|
| 37 | #include <string.h>
|
|---|
| 38 | #include <ctype.h>
|
|---|
| 39 | #include <time.h>
|
|---|
| 40 | #include <share.h>
|
|---|
| 41 | #include <limits.h>
|
|---|
| 42 | #include <process.h> // _beginthread
|
|---|
| 43 |
|
|---|
| 44 | #include "fm3dll.h"
|
|---|
| 45 | #include "fm3dlg.h"
|
|---|
| 46 | #include "fm3str.h"
|
|---|
| 47 | #include "mle.h"
|
|---|
| 48 | #include "grep.h"
|
|---|
| 49 |
|
|---|
| 50 | #pragma data_seg(DATA1)
|
|---|
| 51 |
|
|---|
| 52 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 53 |
|
|---|
| 54 | MRESULT EXPENTRY EnvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 55 | {
|
|---|
| 56 | SHORT sSelect;
|
|---|
| 57 | CHAR *p;
|
|---|
| 58 | CHAR s[CCHMAXPATH];
|
|---|
| 59 | CHAR szPath[CCHMAXPATH];
|
|---|
| 60 |
|
|---|
| 61 | static CHAR lastenv[CCHMAXPATH] = "DPATH";
|
|---|
| 62 |
|
|---|
| 63 | switch (msg) {
|
|---|
| 64 | case WM_INITDLG:
|
|---|
| 65 | if (mp2) {
|
|---|
| 66 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
|---|
| 67 | *(CHAR *) mp2 = 0;
|
|---|
| 68 | {
|
|---|
| 69 | CHAR *p;
|
|---|
| 70 | CHAR *pp;
|
|---|
| 71 |
|
|---|
| 72 | p = GetPString(IDS_ENVVARNAMES);
|
|---|
| 73 | while (*p == ' ')
|
|---|
| 74 | p++;
|
|---|
| 75 | while (*p) {
|
|---|
| 76 | *szPath = 0;
|
|---|
| 77 | pp = szPath;
|
|---|
| 78 | while (*p && *p != ' ')
|
|---|
| 79 | *pp++ = *p++;
|
|---|
| 80 | *pp = 0;
|
|---|
| 81 | while (*p == ' ')
|
|---|
| 82 | p++;
|
|---|
| 83 | if (*szPath)
|
|---|
| 84 | WinSendDlgItemMsg(hwnd,
|
|---|
| 85 | ENV_LISTBOX,
|
|---|
| 86 | LM_INSERTITEM,
|
|---|
| 87 | MPFROM2SHORT(LIT_END, 0), MPFROMP(szPath));
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 | WinSendDlgItemMsg(hwnd,
|
|---|
| 91 | ENV_NAME,
|
|---|
| 92 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 93 | WinSetDlgItemText(hwnd, ENV_NAME, lastenv);
|
|---|
| 94 | WinSendDlgItemMsg(hwnd,
|
|---|
| 95 | ENV_NAME,
|
|---|
| 96 | EM_SETSEL, MPFROM2SHORT(0, CCHMAXPATH), MPVOID);
|
|---|
| 97 | }
|
|---|
| 98 | else
|
|---|
| 99 | WinDismissDlg(hwnd, 0);
|
|---|
| 100 | break;
|
|---|
| 101 |
|
|---|
| 102 | case WM_CONTROL:
|
|---|
| 103 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 104 | case ENV_LISTBOX:
|
|---|
| 105 | switch (SHORT2FROMMP(mp1)) {
|
|---|
| 106 | case LN_SELECT:
|
|---|
| 107 | {
|
|---|
| 108 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 109 | ENV_LISTBOX,
|
|---|
| 110 | LM_QUERYSELECTION,
|
|---|
| 111 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 112 | if (sSelect >= 0) {
|
|---|
| 113 | *s = 0;
|
|---|
| 114 | WinSendDlgItemMsg(hwnd,
|
|---|
| 115 | ENV_LISTBOX,
|
|---|
| 116 | LM_QUERYITEMTEXT,
|
|---|
| 117 | MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s));
|
|---|
| 118 | bstrip(s);
|
|---|
| 119 | if (*s)
|
|---|
| 120 | WinSetDlgItemText(hwnd, ENV_NAME, s);
|
|---|
| 121 | }
|
|---|
| 122 | }
|
|---|
| 123 | break;
|
|---|
| 124 | case LN_ENTER:
|
|---|
| 125 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 126 | break;
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 | return 0;
|
|---|
| 130 |
|
|---|
| 131 | case WM_COMMAND:
|
|---|
| 132 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 133 | case DID_CANCEL:
|
|---|
| 134 | WinDismissDlg(hwnd, 0);
|
|---|
| 135 | break;
|
|---|
| 136 | case DID_OK:
|
|---|
| 137 | p = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 138 | if (p) {
|
|---|
| 139 | WinQueryDlgItemText(hwnd, ENV_NAME, CCHMAXPATH, p);
|
|---|
| 140 | bstrip(p);
|
|---|
| 141 | if (!*p) {
|
|---|
| 142 | DosBeep(50, 100);
|
|---|
| 143 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ENV_NAME));
|
|---|
| 144 | }
|
|---|
| 145 | else {
|
|---|
| 146 | strcpy(lastenv, p);
|
|---|
| 147 | WinDismissDlg(hwnd, 1);
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | break;
|
|---|
| 151 | case IDM_HELP:
|
|---|
| 152 | if (hwndHelp)
|
|---|
| 153 | WinSendMsg(hwndHelp,
|
|---|
| 154 | HM_DISPLAY_HELP,
|
|---|
| 155 | MPFROM2SHORT(HELP_ENV, 0), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 156 | break;
|
|---|
| 157 | }
|
|---|
| 158 | return 0;
|
|---|
| 159 | }
|
|---|
| 160 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | MRESULT EXPENTRY GrepDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 164 | {
|
|---|
| 165 | HWND hwndCollect;
|
|---|
| 166 | HWND hwndMLE = WinWindowFromID(hwnd, GREP_SEARCH);
|
|---|
| 167 | FILE *fp;
|
|---|
| 168 | ULONG ul;
|
|---|
| 169 | LONG lLen;
|
|---|
| 170 | SHORT sSelect;
|
|---|
| 171 | CHAR *p;
|
|---|
| 172 | CHAR s[8192 + 14];
|
|---|
| 173 | CHAR simple[8192];
|
|---|
| 174 | CHAR path[CCHMAXPATH];
|
|---|
| 175 |
|
|---|
| 176 | static CHAR lastmask[8192] = "*";
|
|---|
| 177 | static CHAR lasttext[4096] = "";
|
|---|
| 178 | static BOOL recurse = TRUE;
|
|---|
| 179 | static BOOL sensitive = FALSE;
|
|---|
| 180 | static BOOL absolute = FALSE;
|
|---|
| 181 | static BOOL sayfiles = TRUE;
|
|---|
| 182 | static BOOL searchEAs = TRUE;
|
|---|
| 183 | static BOOL searchFiles = TRUE;
|
|---|
| 184 | static BOOL changed = FALSE;
|
|---|
| 185 | static BOOL findifany = TRUE;
|
|---|
| 186 | static BOOL gRemember = FALSE;
|
|---|
| 187 | ULONG size = sizeof(BOOL);
|
|---|
| 188 | static UINT newer = 0;
|
|---|
| 189 | static UINT older = 0;
|
|---|
| 190 | static ULONG greater = 0;
|
|---|
| 191 | static ULONG lesser = 0;
|
|---|
| 192 |
|
|---|
| 193 | switch (msg) {
|
|---|
| 194 | case WM_INITDLG:
|
|---|
| 195 | if (!mp2) {
|
|---|
| 196 | WinDismissDlg(hwnd, 0);
|
|---|
| 197 | break;
|
|---|
| 198 | }
|
|---|
| 199 | WinSetWindowULong(hwnd, QWL_USER, *(HWND *) mp2);
|
|---|
| 200 | WinSendDlgItemMsg(hwnd,
|
|---|
| 201 | GREP_MASK,
|
|---|
| 202 | EM_SETTEXTLIMIT, MPFROM2SHORT(8192, 0), MPVOID);
|
|---|
| 203 | MLEsetlimit(hwndMLE, 4096);
|
|---|
| 204 | MLEsetformat(hwndMLE, MLFIE_NOTRANS);
|
|---|
| 205 | WinSendDlgItemMsg(hwnd,
|
|---|
| 206 | GREP_NEWER,
|
|---|
| 207 | EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
|
|---|
| 208 | WinSendDlgItemMsg(hwnd,
|
|---|
| 209 | GREP_OLDER,
|
|---|
| 210 | EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
|
|---|
| 211 | WinSendDlgItemMsg(hwnd,
|
|---|
| 212 | GREP_GREATER,
|
|---|
| 213 | EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
|
|---|
| 214 | WinSendDlgItemMsg(hwnd,
|
|---|
| 215 | GREP_LESSER,
|
|---|
| 216 | EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
|
|---|
| 217 | WinSetDlgItemText(hwnd, GREP_MASK, lastmask);
|
|---|
| 218 | WinSendDlgItemMsg(hwnd,
|
|---|
| 219 | GREP_MASK, EM_SETSEL, MPFROM2SHORT(0, 8192), MPVOID);
|
|---|
| 220 | PrfQueryProfileData(fmprof, FM3Str, "RememberFlagsGrep",
|
|---|
| 221 | (PVOID) & gRemember, &size);
|
|---|
| 222 | WinCheckButton(hwnd, GREP_REMEMBERFLAGS, gRemember);
|
|---|
| 223 | if (gRemember) {
|
|---|
| 224 | PrfQueryProfileData(fmprof, FM3Str, "Grep_Recurse",
|
|---|
| 225 | (PVOID) & recurse, &size);
|
|---|
| 226 | PrfQueryProfileData(fmprof, FM3Str, "Grep_Absolute",
|
|---|
| 227 | (PVOID) & absolute, &size);
|
|---|
| 228 | PrfQueryProfileData(fmprof, FM3Str, "Grep_Case",
|
|---|
| 229 | (PVOID) & sensitive, &size);
|
|---|
| 230 | PrfQueryProfileData(fmprof, FM3Str, "Grep_Sayfiles",
|
|---|
| 231 | (PVOID) & sayfiles, &size);
|
|---|
| 232 | PrfQueryProfileData(fmprof, FM3Str, "Grep_Searchfiles",
|
|---|
| 233 | (PVOID) & searchFiles, &size);
|
|---|
| 234 | PrfQueryProfileData(fmprof, FM3Str, "Grep_SearchfEAs",
|
|---|
| 235 | (PVOID) & searchEAs, &size);
|
|---|
| 236 | }
|
|---|
| 237 | if (!gRemember) {
|
|---|
| 238 | recurse = TRUE;
|
|---|
| 239 | sensitive = FALSE;
|
|---|
| 240 | absolute = FALSE;
|
|---|
| 241 | sayfiles = TRUE;
|
|---|
| 242 | searchEAs = TRUE;
|
|---|
| 243 | searchFiles = TRUE;
|
|---|
| 244 | }
|
|---|
| 245 | WinSetWindowText(hwndMLE, lasttext);
|
|---|
| 246 | if (*lasttext) {
|
|---|
| 247 | MLEsetcurpos(hwndMLE, 0);
|
|---|
| 248 | MLEsetcurposa(hwndMLE, 4096);
|
|---|
| 249 | if (!searchEAs)
|
|---|
| 250 | searchFiles = TRUE;
|
|---|
| 251 | }
|
|---|
| 252 | WinCheckButton(hwnd, GREP_RECURSE, recurse);
|
|---|
| 253 | WinCheckButton(hwnd, GREP_ABSOLUTE, absolute);
|
|---|
| 254 | WinCheckButton(hwnd, GREP_CASE, sensitive);
|
|---|
| 255 | WinCheckButton(hwnd, GREP_SAYFILES, sayfiles);
|
|---|
| 256 | WinCheckButton(hwnd, GREP_SEARCHEAS, searchEAs);
|
|---|
| 257 | WinCheckButton(hwnd, GREP_SEARCHFILES, searchFiles);
|
|---|
| 258 | WinCheckButton(hwnd, GREP_FINDIFANY, findifany);
|
|---|
| 259 |
|
|---|
| 260 | sprintf(s, "%lu", greater);
|
|---|
| 261 | WinSetDlgItemText(hwnd, GREP_GREATER, s);
|
|---|
| 262 | sprintf(s, "%lu", lesser);
|
|---|
| 263 | WinSetDlgItemText(hwnd, GREP_LESSER, s);
|
|---|
| 264 | sprintf(s, "%u", newer);
|
|---|
| 265 | WinSetDlgItemText(hwnd, GREP_NEWER, s);
|
|---|
| 266 | sprintf(s, "%u", older);
|
|---|
| 267 | WinSetDlgItemText(hwnd, GREP_OLDER, s);
|
|---|
| 268 |
|
|---|
| 269 | WinEnableWindow(WinWindowFromID(hwnd, GREP_IGNOREEXTDUPES), FALSE);
|
|---|
| 270 | WinEnableWindow(WinWindowFromID(hwnd, GREP_CRCDUPES), FALSE);
|
|---|
| 271 | WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), FALSE);
|
|---|
| 272 |
|
|---|
| 273 | save_dir2(s);
|
|---|
| 274 | if (s[strlen(s) - 1] != '\\')
|
|---|
| 275 | strcat(s, "\\");
|
|---|
| 276 | strcat(s, "GREPMASK.DAT");
|
|---|
| 277 | fp = _fsopen(s, "r", SH_DENYWR);
|
|---|
| 278 | if (fp) {
|
|---|
| 279 | while (!feof(fp)) {
|
|---|
| 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 | }
|
|---|
| 288 | }
|
|---|
| 289 | fclose(fp);
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | FillPathListBox(hwnd,
|
|---|
| 293 | WinWindowFromID(hwnd, GREP_DRIVELIST),
|
|---|
| 294 | (HWND) 0, NULL, FALSE);
|
|---|
| 295 | break;
|
|---|
| 296 |
|
|---|
| 297 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 298 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
|---|
| 299 | break;
|
|---|
| 300 |
|
|---|
| 301 | case UM_SETDIR:
|
|---|
| 302 | PaintRecessedWindow(WinWindowFromID(hwnd, GREP_HELP),
|
|---|
| 303 | (HPS) 0, FALSE, TRUE);
|
|---|
| 304 | return 0;
|
|---|
| 305 |
|
|---|
| 306 | case UM_FOCUSME:
|
|---|
| 307 | /* set focus to window hwnd in mp1 */
|
|---|
| 308 | if (mp1)
|
|---|
| 309 | WinSetFocus(HWND_DESKTOP, (HWND) mp1);
|
|---|
| 310 | return 0;
|
|---|
| 311 |
|
|---|
| 312 | case WM_CONTROL:
|
|---|
| 313 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 314 | case GREP_REMEMBERFLAGS:
|
|---|
| 315 | {
|
|---|
| 316 | BOOL gRemember = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS);
|
|---|
| 317 |
|
|---|
| 318 | PrfWriteProfileData(fmprof, FM3Str, "RememberFlagsGrep",
|
|---|
| 319 | (PVOID) & gRemember, sizeof(BOOL));
|
|---|
| 320 | }
|
|---|
| 321 | break;
|
|---|
| 322 |
|
|---|
| 323 | case GREP_DRIVELIST:
|
|---|
| 324 | switch (SHORT2FROMMP(mp1)) {
|
|---|
| 325 | case LN_KILLFOCUS:
|
|---|
| 326 | WinSetDlgItemText(hwnd,
|
|---|
| 327 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 328 | break;
|
|---|
| 329 | case LN_SETFOCUS:
|
|---|
| 330 | WinSetDlgItemText(hwnd,
|
|---|
| 331 | GREP_HELP, GetPString(IDS_2CLICKADDDRVMASKTEXT));
|
|---|
| 332 | break;
|
|---|
| 333 | case LN_ENTER:
|
|---|
| 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
|
|---|
| 384 | break;
|
|---|
| 385 |
|
|---|
| 386 | case GREP_LISTBOX:
|
|---|
| 387 | switch (SHORT2FROMMP(mp1)) {
|
|---|
| 388 | case LN_KILLFOCUS:
|
|---|
| 389 | WinSetDlgItemText(hwnd,
|
|---|
| 390 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 391 | break;
|
|---|
| 392 | case LN_SETFOCUS:
|
|---|
| 393 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_ADDSELDELMASKTEXT));
|
|---|
| 394 | break;
|
|---|
| 395 | case LN_ENTER:
|
|---|
| 396 | case LN_SELECT:
|
|---|
| 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;
|
|---|
| 426 | }
|
|---|
| 427 | break;
|
|---|
| 428 |
|
|---|
| 429 | case GREP_MASK:
|
|---|
| 430 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 431 | WinSetDlgItemText(hwnd,
|
|---|
| 432 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 433 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 434 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MASKSFINDTEXT));
|
|---|
| 435 | break;
|
|---|
| 436 | case GREP_SEARCH:
|
|---|
| 437 | if (SHORT2FROMMP(mp1) == MLN_KILLFOCUS)
|
|---|
| 438 | WinSetDlgItemText(hwnd,
|
|---|
| 439 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 440 | if (SHORT2FROMMP(mp1) == MLN_SETFOCUS)
|
|---|
| 441 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_TEXTFINDTEXT));
|
|---|
| 442 | break;
|
|---|
| 443 | case GREP_GREATER:
|
|---|
| 444 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 445 | WinSetDlgItemText(hwnd,
|
|---|
| 446 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 447 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 448 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MINSIZEFINDTEXT));
|
|---|
| 449 | break;
|
|---|
| 450 | case GREP_LESSER:
|
|---|
| 451 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 452 | WinSetDlgItemText(hwnd,
|
|---|
| 453 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 454 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 455 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MAXSIZEFINDTEXT));
|
|---|
| 456 | break;
|
|---|
| 457 | case GREP_NEWER:
|
|---|
| 458 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 459 | WinSetDlgItemText(hwnd,
|
|---|
| 460 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 461 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 462 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MAXAGEFINDTEXT));
|
|---|
| 463 | break;
|
|---|
| 464 | case GREP_OLDER:
|
|---|
| 465 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 466 | WinSetDlgItemText(hwnd,
|
|---|
| 467 | GREP_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
|---|
| 468 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 469 | WinSetDlgItemText(hwnd, GREP_HELP, GetPString(IDS_MINAGEFINDTEXT));
|
|---|
| 470 | break;
|
|---|
| 471 | case GREP_FINDDUPES:
|
|---|
| 472 | {
|
|---|
| 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);
|
|---|
| 495 | }
|
|---|
| 496 | }
|
|---|
| 497 | return 0;
|
|---|
| 498 |
|
|---|
| 499 | case WM_COMMAND:
|
|---|
| 500 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 501 | case GREP_ENV:
|
|---|
| 502 | {
|
|---|
| 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 | }
|
|---|
| 581 | }
|
|---|
| 582 | break;
|
|---|
| 583 |
|
|---|
| 584 | case GREP_WALK:
|
|---|
| 585 | WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
|
|---|
| 586 | bstrip(s);
|
|---|
| 587 | if (strlen(s) > 8192 - 5) {
|
|---|
| 588 | Runtime_Error(pszSrcFile, __LINE__, "too big");
|
|---|
| 589 | break;
|
|---|
| 590 | }
|
|---|
| 591 | *path = 0;
|
|---|
| 592 | if (WinDlgBox(HWND_DESKTOP,
|
|---|
| 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 | }
|
|---|
| 633 | }
|
|---|
| 634 | break;
|
|---|
| 635 |
|
|---|
| 636 | case GREP_ADD:
|
|---|
| 637 | *s = 0;
|
|---|
| 638 | WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
|
|---|
| 639 | bstrip(s);
|
|---|
| 640 | if (*s) {
|
|---|
| 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 | }
|
|---|
| 653 | }
|
|---|
| 654 | break;
|
|---|
| 655 |
|
|---|
| 656 | case GREP_DELETE:
|
|---|
| 657 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 658 | GREP_LISTBOX,
|
|---|
| 659 | LM_QUERYSELECTION,
|
|---|
| 660 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 661 | if (sSelect >= 0) {
|
|---|
| 662 | WinSendDlgItemMsg(hwnd,
|
|---|
| 663 | GREP_LISTBOX,
|
|---|
| 664 | LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
|
|---|
| 665 | changed = TRUE;
|
|---|
| 666 | }
|
|---|
| 667 | break;
|
|---|
| 668 |
|
|---|
| 669 | case GREP_OM:
|
|---|
| 670 | *s = 0;
|
|---|
| 671 | WinQueryDlgItemText(hwnd, GREP_OLDER, 34, s);
|
|---|
| 672 | ul = atoi(s) * 30L;
|
|---|
| 673 | sprintf(s, "%lu", ul);
|
|---|
| 674 | WinSetDlgItemText(hwnd, GREP_OLDER, s);
|
|---|
| 675 | break;
|
|---|
| 676 |
|
|---|
| 677 | case GREP_NM:
|
|---|
| 678 | *s = 0;
|
|---|
| 679 | WinQueryDlgItemText(hwnd, GREP_NEWER, 34, s);
|
|---|
| 680 | ul = atoi(s) * 30L;
|
|---|
| 681 | sprintf(s, "%lu", ul);
|
|---|
| 682 | WinSetDlgItemText(hwnd, GREP_NEWER, s);
|
|---|
| 683 | break;
|
|---|
| 684 |
|
|---|
| 685 | case GREP_GK:
|
|---|
| 686 | *s = 0;
|
|---|
| 687 | WinQueryDlgItemText(hwnd, GREP_GREATER, 34, s);
|
|---|
| 688 | ul = atol(s) * 1024L;
|
|---|
| 689 | sprintf(s, "%lu", ul);
|
|---|
| 690 | WinSetDlgItemText(hwnd, GREP_GREATER, s);
|
|---|
| 691 | break;
|
|---|
| 692 |
|
|---|
| 693 | case GREP_LK:
|
|---|
| 694 | *s = 0;
|
|---|
| 695 | WinQueryDlgItemText(hwnd, GREP_LESSER, 34, s);
|
|---|
| 696 | ul = atol(s) * 1024L;
|
|---|
| 697 | sprintf(s, "%lu", ul);
|
|---|
| 698 | WinSetDlgItemText(hwnd, GREP_LESSER, s);
|
|---|
| 699 | break;
|
|---|
| 700 |
|
|---|
| 701 | case DID_CANCEL:
|
|---|
| 702 | WinDismissDlg(hwnd, 0);
|
|---|
| 703 | break;
|
|---|
| 704 |
|
|---|
| 705 | case IDM_HELP:
|
|---|
| 706 | if (hwndHelp)
|
|---|
| 707 | WinSendMsg(hwndHelp,
|
|---|
| 708 | HM_DISPLAY_HELP,
|
|---|
| 709 | MPFROM2SHORT(HELP_GREP, 0), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 710 | break;
|
|---|
| 711 |
|
|---|
| 712 | case GREP_LOCALHDS:
|
|---|
| 713 | case GREP_REMOTEHDS:
|
|---|
| 714 | case GREP_ALLHDS:
|
|---|
| 715 | {
|
|---|
| 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);
|
|---|
| 776 | }
|
|---|
| 777 | break;
|
|---|
| 778 |
|
|---|
| 779 | case DID_OK:
|
|---|
| 780 | hwndCollect = WinQueryWindowULong(hwnd, QWL_USER);
|
|---|
| 781 | if (!hwndCollect)
|
|---|
| 782 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
|---|
| 783 | else {
|
|---|
| 784 | static GREP g; // Passed to thread
|
|---|
| 785 |
|
|---|
| 786 | p = xmalloc(8192 + 512, pszSrcFile, __LINE__);
|
|---|
| 787 | if (!p)
|
|---|
| 788 | break;
|
|---|
| 789 | memset(&g, 0, sizeof(GREP));
|
|---|
| 790 | g.size = sizeof(GREP);
|
|---|
| 791 | recurse = WinQueryButtonCheckstate(hwnd, GREP_RECURSE) != 0;
|
|---|
| 792 | absolute = WinQueryButtonCheckstate(hwnd, GREP_ABSOLUTE) != 0;
|
|---|
| 793 | sensitive = WinQueryButtonCheckstate(hwnd, GREP_CASE) != 0;
|
|---|
| 794 | sayfiles = WinQueryButtonCheckstate(hwnd, GREP_SAYFILES) != 0;
|
|---|
| 795 | searchEAs = WinQueryButtonCheckstate(hwnd, GREP_SEARCHEAS) != 0;
|
|---|
| 796 | searchFiles = WinQueryButtonCheckstate(hwnd, GREP_SEARCHFILES) != 0;
|
|---|
| 797 | findifany = WinQueryButtonCheckstate(hwnd, GREP_FINDIFANY) != 0;
|
|---|
| 798 | gRemember = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS);
|
|---|
| 799 | if (gRemember) {
|
|---|
| 800 | PrfWriteProfileData(fmprof, FM3Str, "Grep_Recurse",
|
|---|
| 801 | (PVOID) & recurse, sizeof(BOOL));
|
|---|
| 802 | PrfWriteProfileData(fmprof, FM3Str, "Grep_Absolute",
|
|---|
| 803 | (PVOID) & absolute, sizeof(BOOL));
|
|---|
| 804 | PrfWriteProfileData(fmprof, FM3Str, "Grep_Case",
|
|---|
| 805 | (PVOID) & sensitive, sizeof(BOOL));
|
|---|
| 806 | PrfWriteProfileData(fmprof, FM3Str, "Grep_Sayfiles",
|
|---|
| 807 | (PVOID) & sayfiles, sizeof(BOOL));
|
|---|
| 808 | PrfWriteProfileData(fmprof, FM3Str, "Grep_Searchfiles",
|
|---|
| 809 | (PVOID) & searchFiles, sizeof(BOOL));
|
|---|
| 810 | PrfWriteProfileData(fmprof, FM3Str, "Grep_SearchfEAs",
|
|---|
| 811 | (PVOID) & searchEAs, sizeof(BOOL));
|
|---|
| 812 | }
|
|---|
| 813 | g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0;
|
|---|
| 814 | if (g.finddupes) {
|
|---|
| 815 | g.CRCdupes = WinQueryButtonCheckstate(hwnd, GREP_CRCDUPES) != 0;
|
|---|
| 816 | g.nosizedupes =
|
|---|
| 817 | WinQueryButtonCheckstate(hwnd, GREP_NOSIZEDUPES) != 0;
|
|---|
| 818 | g.ignoreextdupes =
|
|---|
| 819 | WinQueryButtonCheckstate(hwnd, GREP_IGNOREEXTDUPES) != 0;
|
|---|
| 820 | }
|
|---|
| 821 | // Parse file masks
|
|---|
| 822 | *p = 0;
|
|---|
| 823 | WinQueryDlgItemText(hwnd, GREP_MASK, 8192, p);
|
|---|
| 824 | bstrip(p);
|
|---|
| 825 | if (!*p) {
|
|---|
| 826 | DosBeep(50, 100);
|
|---|
| 827 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, GREP_MASK));
|
|---|
| 828 | free(p);
|
|---|
| 829 | break;
|
|---|
| 830 | }
|
|---|
| 831 | strcpy(g.tosearch, p);
|
|---|
| 832 | strcpy(lastmask, p);
|
|---|
| 833 | // Parse search strings
|
|---|
| 834 | *p = 0;
|
|---|
| 835 | WinQueryWindowText(hwndMLE, 4096, p);
|
|---|
| 836 | strcpy(lasttext, p);
|
|---|
| 837 | {
|
|---|
| 838 | CHAR *pszFrom;
|
|---|
| 839 | CHAR *pszTo;
|
|---|
| 840 | ULONG matched = 0;
|
|---|
| 841 |
|
|---|
| 842 | pszTo = g.searchPattern;
|
|---|
| 843 | pszFrom = p;
|
|---|
| 844 | while (*pszFrom) {
|
|---|
| 845 | if (*pszFrom == '\r') {
|
|---|
| 846 | pszFrom++;
|
|---|
| 847 | continue;
|
|---|
| 848 | }
|
|---|
| 849 | if (*pszFrom == '\n') {
|
|---|
| 850 | if (*(pszFrom + 1))
|
|---|
| 851 | matched++;
|
|---|
| 852 | *pszTo = 0;
|
|---|
| 853 | }
|
|---|
| 854 | else
|
|---|
| 855 | *pszTo = *pszFrom;
|
|---|
| 856 | pszTo++;
|
|---|
| 857 | pszFrom++;
|
|---|
| 858 | }
|
|---|
| 859 | if (*g.searchPattern)
|
|---|
| 860 | matched++;
|
|---|
| 861 | *pszTo++ = 0;
|
|---|
| 862 | *pszTo = 0;
|
|---|
| 863 | g.numlines = matched;
|
|---|
| 864 | if (matched) {
|
|---|
| 865 | g.matched = xmalloc(g.numlines, pszSrcFile, __LINE__);
|
|---|
| 866 | if (!g.matched)
|
|---|
| 867 | g.numlines = 0;
|
|---|
| 868 | }
|
|---|
| 869 | }
|
|---|
| 870 | *p = 0;
|
|---|
| 871 | WinQueryDlgItemText(hwnd, GREP_GREATER, 34, p);
|
|---|
| 872 | greater = atol(p);
|
|---|
| 873 | *p = 0;
|
|---|
| 874 | WinQueryDlgItemText(hwnd, GREP_LESSER, 34, p);
|
|---|
| 875 | lesser = atol(p);
|
|---|
| 876 | *p = 0;
|
|---|
| 877 | WinQueryDlgItemText(hwnd, GREP_NEWER, 34, p);
|
|---|
| 878 | newer = atoi(p);
|
|---|
| 879 | *p = 0;
|
|---|
| 880 | WinQueryDlgItemText(hwnd, GREP_OLDER, 34, p);
|
|---|
| 881 | older = atoi(p);
|
|---|
| 882 | if (older || newer) {
|
|---|
| 883 | FDATE fdate;
|
|---|
| 884 | FTIME ftime;
|
|---|
| 885 | struct tm tm;
|
|---|
| 886 | time_t t;
|
|---|
| 887 |
|
|---|
| 888 | t = time(NULL);
|
|---|
| 889 | tm = *localtime(&t);
|
|---|
| 890 | fdate.day = tm.tm_mday;
|
|---|
| 891 | fdate.month = tm.tm_mon + 1;
|
|---|
| 892 | fdate.year = tm.tm_year - 80;
|
|---|
| 893 | ftime.hours = tm.tm_hour;
|
|---|
| 894 | ftime.minutes = tm.tm_min;
|
|---|
| 895 | ftime.twosecs = tm.tm_sec / 2;
|
|---|
| 896 | if (older) {
|
|---|
| 897 | g.olderthan = SecsSince1980(&fdate, &ftime);
|
|---|
| 898 | g.olderthan -= (older * (24L * 60L * 60L));
|
|---|
| 899 | }
|
|---|
| 900 | if (newer) {
|
|---|
| 901 | g.newerthan = SecsSince1980(&fdate, &ftime);
|
|---|
| 902 | g.newerthan -= (newer * (24L * 60L * 60L));
|
|---|
| 903 | }
|
|---|
| 904 | }
|
|---|
| 905 | if (!newer)
|
|---|
| 906 | g.newerthan = 0;
|
|---|
| 907 | if (!older)
|
|---|
| 908 | g.olderthan = 0;
|
|---|
| 909 | g.greaterthan = greater;
|
|---|
| 910 | g.lessthan = lesser;
|
|---|
| 911 | g.absFlag = absolute;
|
|---|
| 912 | g.caseFlag = sensitive;
|
|---|
| 913 | g.dirFlag = recurse;
|
|---|
| 914 | g.sayfiles = sayfiles;
|
|---|
| 915 | g.searchEAs = searchEAs;
|
|---|
| 916 | g.searchFiles = searchFiles;
|
|---|
| 917 | g.findifany = findifany;
|
|---|
| 918 | g.hwndFiles = hwndCollect;
|
|---|
| 919 | g.hwnd = WinQueryWindow(hwndCollect, QW_PARENT);
|
|---|
| 920 | g.hwndCurFile = WinWindowFromID(g.hwnd, DIR_SELECTED);
|
|---|
| 921 | g.attrFile = ((DIRCNRDATA *) INSTDATA(hwndCollect))->mask.attrFile;
|
|---|
| 922 | g.antiattr = ((DIRCNRDATA *) INSTDATA(hwndCollect))->mask.antiattr;
|
|---|
| 923 | g.stopflag = &((DIRCNRDATA *) INSTDATA(hwndCollect))->stopflag;
|
|---|
| 924 | if (_beginthread(GrepThread, NULL, 524280, (PVOID) & g) == -1) {
|
|---|
| 925 | Runtime_Error(pszSrcFile, __LINE__,
|
|---|
| 926 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
|---|
| 927 | free(p);
|
|---|
| 928 | WinDismissDlg(hwnd, 0);
|
|---|
| 929 | break;
|
|---|
| 930 | }
|
|---|
| 931 | else
|
|---|
| 932 | DosSleep(100); //05 Aug 07 GKY 128
|
|---|
| 933 | free(p);
|
|---|
| 934 | }
|
|---|
| 935 | if (changed) {
|
|---|
| 936 | SHORT x;
|
|---|
| 937 |
|
|---|
| 938 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 939 | GREP_LISTBOX,
|
|---|
| 940 | LM_QUERYITEMCOUNT,
|
|---|
| 941 | MPVOID, MPVOID);
|
|---|
| 942 | if (sSelect > 0) {
|
|---|
| 943 | save_dir2(s);
|
|---|
| 944 | if (s[strlen(s) - 1] != '\\')
|
|---|
| 945 | strcat(s, "\\");
|
|---|
| 946 | strcat(s, "GREPMASK.DAT");
|
|---|
| 947 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
|---|
| 948 | if (fp) {
|
|---|
| 949 | fputs(GetPString(IDS_GREPFILETEXT), fp);
|
|---|
| 950 | for (x = 0; x < sSelect; x++) {
|
|---|
| 951 | *s = 0;
|
|---|
| 952 | WinSendDlgItemMsg(hwnd,
|
|---|
| 953 | GREP_LISTBOX,
|
|---|
| 954 | LM_QUERYITEMTEXT,
|
|---|
| 955 | MPFROM2SHORT(x, 8192), MPFROMP(s));
|
|---|
| 956 | bstrip(s);
|
|---|
| 957 | if (*s)
|
|---|
| 958 | fprintf(fp, "%s\n", s);
|
|---|
| 959 | }
|
|---|
| 960 | fclose(fp);
|
|---|
| 961 | }
|
|---|
| 962 | }
|
|---|
| 963 | }
|
|---|
| 964 | WinDismissDlg(hwnd, 1);
|
|---|
| 965 | break;
|
|---|
| 966 | }
|
|---|
| 967 | return 0;
|
|---|
| 968 | }
|
|---|
| 969 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 970 | }
|
|---|
| 971 |
|
|---|
| 972 | #pragma alloc_text(GREP,GrepDlgProc,EnvDlgProc)
|
|---|