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