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