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