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