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