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