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