source: trunk/dll/grep2.c@ 1707

Last change on this file since 1707 was 1707, checked in by Steven Levine, 12 years ago

Support git, svn, hg etc. version control metadata directory excludes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 32.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: grep2.c 1707 2014-02-08 20:14:08Z stevenhl $
5
6 grep dialog for collector
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004, 2014 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 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
22 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
23 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
24 10 Dec 08 SHL Integrate exception handler support
25 01 Jan 09 GKY Add Seek and Scan to drives & directory context menus pass drive/dir as search root
26 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
27 08 Mar 09 GKY Additional strings move to PCSZs in init.c
28 07 Oct 09 SHL Remember last search mask across runs
29 17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
30 08 Feb 14 SHL Support svn git hg CVS etc. metadata directory ignore
31
32 FIXME for more excess locals to be gone
33
34***********************************************************************/
35
36#include <stdlib.h>
37#include <string.h>
38#include <ctype.h>
39#include <share.h>
40#include <time.h>
41
42#define INCL_DOS
43#define INCL_WIN
44#define INCL_LONGLONG // dircnrs.h
45#define INCL_WINSTDCNR // makelist.h
46
47#include "fm3dll.h"
48#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
49#include "arccnrs.h" // Data declaration(s)
50#include "init.h" // Data declaration(s)
51#include "notebook.h" // Data declaration(s)
52#include "info.h" // Data declaration(s)
53#include "mainwnd.h" // Data declaration(s)
54#include "fm3dlg.h"
55#include "fm3str.h"
56#include "mle.h"
57#include "grep.h"
58#include "errutil.h" // Dos_Error...
59#include "strutil.h" // GetPString
60#include "pathutil.h" // BldFullPathName
61#include "walkem.h" // FillPathListBox
62#include "grep2.h"
63#include "wrappers.h" // xfgets
64#include "misc.h" // LoadLibPath
65#include "strips.h" // bstrip
66#include "dirs.h" // save_dir2
67#include "fortify.h"
68#include "excputil.h" // xbeginthread
69#include "valid.h" // IsFile
70
71#pragma data_seg(DATA1)
72
73static PSZ pszSrcFile = __FILE__;
74
75static PCSZ PSCZ_GREP_LASTMASK_SELECT = "Grep_LastMaskSelect";
76
77MRESULT EXPENTRY EnvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
78{
79 SHORT sSelect;
80 CHAR *p;
81 CHAR s[CCHMAXPATH];
82 CHAR szPath[CCHMAXPATH];
83
84 static CHAR lastenv[CCHMAXPATH] = "DPATH";
85
86 switch (msg) {
87 case WM_INITDLG:
88 if (mp2) {
89 WinSetWindowPtr(hwnd, QWL_USER, mp2);
90 *(CHAR *)mp2 = 0;
91 {
92 PCSZ p;
93 PSZ pp;
94
95 p = GetPString(IDS_ENVVARNAMES);
96 while (*p == ' ')
97 p++;
98 while (*p) {
99 *szPath = 0;
100 pp = szPath;
101 while (*p && *p != ' ')
102 *pp++ = *p++;
103 *pp = 0;
104 while (*p == ' ')
105 p++;
106 if (*szPath)
107 WinSendDlgItemMsg(hwnd,
108 ENV_LISTBOX,
109 LM_INSERTITEM,
110 MPFROM2SHORT(LIT_END, 0), MPFROMP(szPath));
111 }
112 }
113 WinSendDlgItemMsg(hwnd,
114 ENV_NAME,
115 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
116 WinSetDlgItemText(hwnd, ENV_NAME, lastenv);
117 WinSendDlgItemMsg(hwnd,
118 ENV_NAME,
119 EM_SETSEL, MPFROM2SHORT(0, CCHMAXPATH), MPVOID);
120 }
121 else
122 WinDismissDlg(hwnd, 0);
123 break;
124
125 case WM_CONTROL:
126 switch (SHORT1FROMMP(mp1)) {
127 case ENV_LISTBOX:
128 switch (SHORT2FROMMP(mp1)) {
129 case LN_SELECT:
130 {
131 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
132 ENV_LISTBOX,
133 LM_QUERYSELECTION,
134 MPFROMSHORT(LIT_FIRST), MPVOID);
135 if (sSelect >= 0) {
136 *s = 0;
137 WinSendDlgItemMsg(hwnd,
138 ENV_LISTBOX,
139 LM_QUERYITEMTEXT,
140 MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s));
141 bstrip(s);
142 if (*s)
143 WinSetDlgItemText(hwnd, ENV_NAME, s);
144 }
145 }
146 break;
147 case LN_ENTER:
148 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
149 break;
150 }
151 }
152 return 0;
153
154 case WM_COMMAND:
155 switch (SHORT1FROMMP(mp1)) {
156 case DID_CANCEL:
157 WinDismissDlg(hwnd, 0);
158 break;
159 case DID_OK:
160 p = WinQueryWindowPtr(hwnd, QWL_USER);
161 if (p) {
162 WinQueryDlgItemText(hwnd, ENV_NAME, CCHMAXPATH, p);
163 bstrip(p);
164 if (!*p) {
165 if (!fAlertBeepOff)
166 DosBeep(50, 100);
167 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ENV_NAME));
168 }
169 else {
170 strcpy(lastenv, p);
171 WinDismissDlg(hwnd, 1);
172 }
173 }
174 break;
175 case IDM_HELP:
176 if (hwndHelp)
177 WinSendMsg(hwndHelp,
178 HM_DISPLAY_HELP,
179 MPFROM2SHORT(HELP_ENV, 0), MPFROMSHORT(HM_RESOURCEID));
180 break;
181 }
182 return 0;
183 }
184 return WinDefDlgProc(hwnd, msg, mp1, mp2);
185}
186
187/**
188 * Add mask to mask list
189 * If mask contains both path an wildcard components if is just appended
190 * If mask contains only wildcard component, path is extracted from last mask in masks
191 * If mask contains only path components, wildcard is extracted from last mask in masks
192 * @param masks is semicolon separated mask string to be updated
193 * @param newMask is mask to append
194 * @note code limits mask length to 8192 to match GrepDlgProc
195 * @returns true if OK
196 */
197
198#if 0 // 2010-09-27 SHL FIXME to use
199
200static BOOL updateMaskString(CHAR masks[8192], PCSZ newMask)
201{
202 BOOL ok = TRUE;
203 BOOL isPath;
204 BOOL isWild;
205 UINT len;
206 CHAR mask[CCHMAXPATH + 2]; // 2 for semicolons
207 CHAR wildcard[CCHMAXPATH];
208 PSZ p;
209
210 // 2010-09-27 SHL FIXME to be globally available
211 #define CH_QMARK '?'
212 #define CH_STAR '*'
213 #define CH_BACKSLASH '\\'
214 #define CH_SEMICOLON ';'
215 static PCSZ PCSZ_SEMICOLON = ";"; // 2010-09-27 SHL FIXME to be globally available from init.c
216
217 // Extract last mask
218 len = strlen(masks);
219 if (!len)
220 *mask = 0;
221 else {
222 if (len < CCHMAXPATH + 2)
223 strcpy(mask, masks);
224 else {
225 strcpy(mask, masks + len - (CCHMAXPATH + 1));
226 len = strlen(mask);
227 }
228 }
229 if (len) {
230 p = mask + len - 1;
231 if (*p == CH_SEMICOLON)
232 *p = 0; // Chop trailing
233 p = strrchr(mask, CH_SEMICOLON); // Find last
234 if (p)
235 memmove(mask, p + 1, strlen(p + 1) + 1); // Move to front
236 }
237
238 isPath = strchr(newMask, CH_BACKSLASH) != NULL; // 2010-09-27 SHL FIXME if test too weak
239 // 2010-09-27 SHL FIXME to have function
240 isWild = strchr(newMask, CH_STAR) || strchr(newMask, CH_QMARK);
241
242 // Assume ready to do if both path and wildcard otherwise edit
243
244 if (isPath && !isWild) {
245 // Extract wildcard from old mask
246 p = strrchr(mask, CH_BACKSLASH);
247 if (!p)
248 strcpy(wildcard, mask);
249 else
250 strcpy(wildcard, p + 1);
251 // Append wildcard to path
252 strcpy(mask, newMask);
253 bstrip(mask);
254 len = strlen(mask);
255 if (len && mask[len - 1] != CH_BACKSLASH)
256 strcat(mask, PCSZ_BACKSLASH);
257 strcat(mask, wildcard);
258 }
259 else if (!isPath) {
260 // Use path from old mask
261 len = strlen(mask);
262 p = strrchr(mask, CH_BACKSLASH);
263 if (p)
264 *(p + 1) = 0;
265 else
266 *mask = 0; // Assume just wilcard
267 // Append new wildcard or filename
268 strcat(mask, newMask);
269 bstrip(mask);
270 }
271
272 if (strlen(masks) + strlen(mask) + 3 > sizeof(masks))
273 Runtime_Error(pszSrcFile, __LINE__, "too big");
274
275 // Append separator
276 if (masks[strlen(masks) - 1] != CH_SEMICOLON)
277 strcat(masks, PCSZ_SEMICOLON);
278 // Append mask to list
279 strcat(masks, mask);
280
281 return ok;
282}
283
284#endif // 2010-09-27 SHL FIXME to use
285
286MRESULT EXPENTRY GrepDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
287{
288 HWND hwndCollect;
289 HWND hwndMLE = WinWindowFromID(hwnd, GREP_SEARCH);
290 FILE *fp;
291 ULONG ul;
292 LONG lLen;
293 SHORT sSelect;
294 CHAR *p;
295 GREPINFO *GrepInfo;
296 ULONG size;
297 CHAR simple[8192];
298 CHAR path[CCHMAXPATH];
299 CHAR s[8192 + 14];
300 CHAR *moder = "r";
301
302 static BOOL fInitDone; // First time init done
303 // 07 Oct 09 SHL FIXME to not be static
304 // 07 Oct 09 SHL FIXME to save to profile?
305 // GREP_FRAME dialog buffers
306 static CHAR fileMasks[8192]; // ; separated
307 static CHAR searchText[4096]; // Structured
308 static BOOL recurse = TRUE;
309 static BOOL sensitive;
310 static BOOL absolute;
311 static BOOL sayfiles;
312 static BOOL searchEAs = TRUE;
313 static BOOL searchFiles = TRUE;
314 static BOOL findifany = TRUE;
315 static BOOL rememberSettings;
316 static UINT newer = 0;
317 static UINT older = 0;
318 static ULONG greaterthan = 0;
319 static ULONG lessthan = 0;
320 static BOOL ignoreSVN;
321
322 static BOOL maskListChanged;
323 static SHORT sLastMaskSelect = LIT_NONE;
324
325 switch (msg) {
326 case WM_INITDLG:
327 if (!mp2) {
328 WinDismissDlg(hwnd, 0);
329 break;
330 }
331 GrepInfo = mp2;
332 if (GrepInfo->szGrepPath && IsFile(GrepInfo->szGrepPath) == 0) {
333 BldFullPathName(fileMasks, GrepInfo->szGrepPath, "*"); // Directory passed
334 sLastMaskSelect = LIT_NONE;
335 fInitDone = TRUE;
336 }
337 else {//if (sLastMaskSelect == LIT_NONE) {
338 size = sizeof(sLastMaskSelect);
339 PrfQueryProfileData(fmprof, appname, (CHAR *) PSCZ_GREP_LASTMASK_SELECT, &sLastMaskSelect, &size);
340 if (sLastMaskSelect >= 0)
341 fInitDone = TRUE;
342 }
343 if (!fInitDone) {
344 fileMasks[0] = '*';
345 fileMasks[1] = 0;
346 }
347
348 WinSetWindowULong(hwnd, QWL_USER, *(HWND *) GrepInfo->hwnd);
349 WinSendDlgItemMsg(hwnd,
350 GREP_MASK,
351 EM_SETTEXTLIMIT, MPFROM2SHORT(8192, 0), MPVOID);
352 MLEsetlimit(hwndMLE, 4096);
353 MLEsetformat(hwndMLE, MLFIE_NOTRANS);
354 WinSendDlgItemMsg(hwnd,
355 GREP_NEWER,
356 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
357 WinSendDlgItemMsg(hwnd,
358 GREP_OLDER,
359 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
360 WinSendDlgItemMsg(hwnd,
361 GREP_GREATER,
362 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
363 WinSendDlgItemMsg(hwnd,
364 GREP_LESSER,
365 EM_SETTEXTLIMIT, MPFROM2SHORT(34, 0), MPVOID);
366 WinSetDlgItemText(hwnd, GREP_MASK, fileMasks);
367 WinSendDlgItemMsg(hwnd,
368 GREP_MASK, EM_SETSEL, MPFROM2SHORT(0, 8192), MPVOID);
369 size = sizeof(BOOL);
370 PrfQueryProfileData(fmprof, FM3Str, "RememberFlagsGrep",
371 (PVOID) & rememberSettings, &size);
372 WinCheckButton(hwnd, GREP_REMEMBERFLAGS, rememberSettings);
373 if (rememberSettings) {
374 size = sizeof(BOOL);
375 PrfQueryProfileData(fmprof, FM3Str, "Grep_Recurse",
376 (PVOID) & recurse, &size);
377 size = sizeof(BOOL);
378 PrfQueryProfileData(fmprof, FM3Str, "Grep_Absolute",
379 (PVOID) & absolute, &size);
380 size = sizeof(BOOL);
381 PrfQueryProfileData(fmprof, FM3Str, "Grep_Case",
382 (PVOID) & sensitive, &size);
383 size = sizeof(BOOL);
384 PrfQueryProfileData(fmprof, FM3Str, "Grep_Sayfiles",
385 (PVOID) & sayfiles, &size);
386 size = sizeof(BOOL);
387 PrfQueryProfileData(fmprof, FM3Str, "Grep_Searchfiles",
388 (PVOID) & searchFiles, &size);
389 size = sizeof(BOOL);
390 PrfQueryProfileData(fmprof, FM3Str, "Grep_SearchfEAs",
391 (PVOID) & searchEAs, &size);
392 }
393 if (!rememberSettings) {
394 recurse = TRUE;
395 sensitive = FALSE;
396 absolute = FALSE;
397 sayfiles = TRUE;
398 ignoreSVN = TRUE;
399 searchEAs = TRUE;
400 searchFiles = TRUE;
401 }
402 WinSetWindowText(hwndMLE, searchText);
403 if (*searchText) {
404 MLEsetcurpos(hwndMLE, 0);
405 MLEsetcurposa(hwndMLE, 4096);
406 if (!searchEAs)
407 searchFiles = TRUE;
408 }
409 WinCheckButton(hwnd, GREP_RECURSE, recurse);
410 WinCheckButton(hwnd, GREP_ABSOLUTE, absolute);
411 WinCheckButton(hwnd, GREP_CASE, sensitive);
412 WinCheckButton(hwnd, GREP_SAYFILES, sayfiles);
413 WinCheckButton(hwnd, GREP_SEARCHEAS, searchEAs);
414 WinCheckButton(hwnd, GREP_SEARCHFILES, searchFiles);
415 WinCheckButton(hwnd, GREP_FINDIFANY, findifany);
416 WinCheckButton(hwnd, GREP_IGNORESVN, ignoreSVN);
417
418 sprintf(s, "%lu", greaterthan);
419 WinSetDlgItemText(hwnd, GREP_GREATER, s);
420 sprintf(s, "%lu", lessthan);
421 WinSetDlgItemText(hwnd, GREP_LESSER, s);
422 sprintf(s, "%u", newer);
423 WinSetDlgItemText(hwnd, GREP_NEWER, s);
424 sprintf(s, "%u", older);
425 WinSetDlgItemText(hwnd, GREP_OLDER, s);
426
427 WinEnableWindow(WinWindowFromID(hwnd, GREP_IGNOREEXTDUPES), FALSE);
428 WinEnableWindow(WinWindowFromID(hwnd, GREP_CRCDUPES), FALSE);
429 WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), FALSE);
430
431 // Fill mask listbox
432 BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT);
433 fp = xfsopen(s, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
434 if (fp) {
435 while (!feof(fp)) {
436 if (!xfgets_bstripcr(s, 8192 + 4, fp, pszSrcFile, __LINE__))
437 break;
438 if (*s && *s != ';') {
439 WinSendDlgItemMsg(hwnd,
440 GREP_LISTBOX,
441 LM_INSERTITEM,
442 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s));
443 }
444 }
445 fclose(fp);
446 }
447 // 25 Sep 09 SHL Reselect last last used item
448 //if (sLastMaskSelect >= 0)
449 // WinSendDlgItemMsg(hwnd, GREP_LISTBOX, LM_SELECTITEM,
450 // MPFROMSHORT(sLastMaskSelect), MPFROMSHORT(TRUE));
451
452 FillPathListBox(hwnd,
453 WinWindowFromID(hwnd, GREP_DRIVELIST),
454 (HWND) 0, NULL, FALSE);
455 // 25 Sep 09 SHL FIXME select drive matching current container?
456 break;
457
458 case WM_ADJUSTWINDOWPOS:
459 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
460 break;
461
462 case UM_SETDIR:
463 PaintRecessedWindow(WinWindowFromID(hwnd, GREP_HELP),
464 (HPS) 0, FALSE, TRUE);
465 return 0;
466
467 case UM_FOCUSME:
468 // set focus to window hwnd in mp1
469 if (mp1)
470 WinSetFocus(HWND_DESKTOP, (HWND) mp1);
471 return 0;
472
473 case WM_CONTROL:
474 switch (SHORT1FROMMP(mp1)) {
475 case GREP_REMEMBERFLAGS:
476 {
477 BOOL rememberSettings = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS);
478
479 PrfWriteProfileData(fmprof, FM3Str, "RememberFlagsGrep",
480 (PVOID) & rememberSettings, sizeof(BOOL));
481 }
482 break;
483
484 case GREP_DRIVELIST:
485 switch (SHORT2FROMMP(mp1)) {
486 case LN_KILLFOCUS:
487 WinSetDlgItemText(hwnd,
488 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
489 break;
490 case LN_SETFOCUS:
491 WinSetDlgItemText(hwnd,
492 GREP_HELP, (CHAR *) GetPString(IDS_2CLICKADDDRVMASKTEXT));
493 break;
494 case LN_ENTER:
495 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
496 bstrip(s);
497 // Find last wildcard
498 p = strrchr(s, '\\');
499 if (p)
500 strcpy(simple, p);
501 else if (*s) {
502 strcpy(simple, PCSZ_BACKSLASH);
503 strcat(simple, s);
504 *s = 0;
505 }
506 else
507 strcpy(simple, "\\*");
508 if (simple[strlen(simple) - 1] == ';')
509 simple[strlen(simple) - 1] = 0; // Chop trailing semi
510 lLen = strlen(simple) + 1;
511 if (strlen(s) > 8192 - lLen) {
512 Runtime_Error(pszSrcFile, __LINE__, "too big");
513 WinSetDlgItemText(hwnd, GREP_MASK, s);
514 break;
515 }
516
517 // 19 Aug 10 SHL FIXME to honor append
518 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
519 GREP_DRIVELIST,
520 LM_QUERYSELECTION,
521 MPFROMSHORT(LIT_FIRST), MPVOID);
522 if (sSelect >= 0) {
523 if (*s && s[strlen(s) - 1] != ';')
524 strcat(s, ";");
525 WinSendDlgItemMsg(hwnd,
526 GREP_DRIVELIST,
527 LM_QUERYITEMTEXT,
528 MPFROM2SHORT(sSelect,
529 (8192 - strlen(s)) - lLen),
530 MPFROMP(&s[strlen(s)]));
531 rstrip(s);
532 if (*s) {
533 strcat(s, simple);
534 WinSetDlgItemText(hwnd, GREP_MASK, s);
535 WinSendDlgItemMsg(hwnd,
536 GREP_MASK,
537 EM_SETSEL,
538 MPFROM2SHORT(strlen(s) - (lLen + 1),
539 strlen(s)), MPVOID);
540 PostMsg(hwnd,
541 UM_FOCUSME,
542 MPFROMLONG(WinWindowFromID(hwnd, GREP_MASK)), MPVOID);
543 }
544 }
545 break; // LN_ENTER
546 } // switch
547 break; //GREP_DRIVELIST
548
549 case GREP_LISTBOX:
550 switch (SHORT2FROMMP(mp1)) {
551 case LN_KILLFOCUS:
552 WinSetDlgItemText(hwnd,
553 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
554 break;
555 case LN_SETFOCUS:
556 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_ADDSELDELMASKTEXT));
557 break;
558 case LN_ENTER:
559 case LN_SELECT:
560 // Enter checkbox controls whether or not notice is ignored
561 // If not checked, enter is ignored because select has already been processed
562 // If check, select is ignored and enter is processed
563 if ((SHORT2FROMMP(mp1) == LN_ENTER &&
564 !WinQueryButtonCheckstate(hwnd, GREP_APPEND)) ||
565 (SHORT2FROMMP(mp1) == LN_SELECT &&
566 WinQueryButtonCheckstate(hwnd, GREP_APPEND)))
567 break; // Ignore
568 {
569 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
570 GREP_LISTBOX,
571 LM_QUERYSELECTION,
572 MPFROMSHORT(LIT_FIRST), MPVOID);
573 if (sSelect >= 0) {
574 sLastMaskSelect = sSelect;
575 *s = 0;
576 if (WinQueryButtonCheckstate(hwnd, GREP_APPEND)) {
577 // Append to existing
578 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
579 bstrip(s);
580 if (*s && strlen(s) < 8190 && s[strlen(s) - 1] != ';')
581 strcat(s, ";");
582 }
583 // Append listbox item to mask string
584 WinSendDlgItemMsg(hwnd,
585 GREP_LISTBOX,
586 LM_QUERYITEMTEXT,
587 MPFROM2SHORT(sSelect, 8192 - strlen(s)),
588 MPFROMP(s + strlen(s)));
589 bstrip(s);
590 if (*s)
591 WinSetDlgItemText(hwnd, GREP_MASK, s);
592 }
593 }
594 break;
595 }
596 break; // GREP_LISTBOX
597
598 case GREP_MASK:
599 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
600 WinSetDlgItemText(hwnd,
601 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
602 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
603 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_MASKSFINDTEXT));
604 break;
605 case GREP_SEARCH:
606 if (SHORT2FROMMP(mp1) == MLN_KILLFOCUS)
607 WinSetDlgItemText(hwnd,
608 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
609 if (SHORT2FROMMP(mp1) == MLN_SETFOCUS)
610 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_TEXTFINDTEXT));
611 break;
612 case GREP_GREATER:
613 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
614 WinSetDlgItemText(hwnd,
615 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
616 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
617 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_MINSIZEFINDTEXT));
618 break;
619 case GREP_LESSER:
620 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
621 WinSetDlgItemText(hwnd,
622 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
623 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
624 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_MAXSIZEFINDTEXT));
625 break;
626 case GREP_NEWER:
627 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
628 WinSetDlgItemText(hwnd,
629 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
630 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
631 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_MAXAGEFINDTEXT));
632 break;
633 case GREP_OLDER:
634 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
635 WinSetDlgItemText(hwnd,
636 GREP_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
637 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
638 WinSetDlgItemText(hwnd, GREP_HELP, (CHAR *) GetPString(IDS_MINAGEFINDTEXT));
639 break;
640 case GREP_FINDDUPES:
641 {
642 BOOL finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES);
643
644 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCH), !finddupes);
645 WinEnableWindow(WinWindowFromID(hwnd, GREP_ABSOLUTE), !finddupes);
646 WinEnableWindow(WinWindowFromID(hwnd, GREP_CASE), !finddupes);
647 WinEnableWindow(WinWindowFromID(hwnd, GREP_CRCDUPES), finddupes);
648 WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), finddupes);
649 WinEnableWindow(WinWindowFromID(hwnd, GREP_IGNOREEXTDUPES),
650 finddupes);
651 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCHFILES), !finddupes);
652 WinEnableWindow(WinWindowFromID(hwnd, GREP_SEARCHEAS), !finddupes);
653 WinEnableWindow(WinWindowFromID(hwnd, GREP_GREATER), !finddupes);
654 WinEnableWindow(WinWindowFromID(hwnd, GREP_LESSER), !finddupes);
655 WinEnableWindow(WinWindowFromID(hwnd, GREP_NEWER), !finddupes);
656 WinEnableWindow(WinWindowFromID(hwnd, GREP_OLDER), !finddupes);
657 WinEnableWindow(WinWindowFromID(hwnd, GREP_FINDIFANY), !finddupes);
658 WinEnableWindow(WinWindowFromID(hwnd, GREP_GK), !finddupes);
659 WinEnableWindow(WinWindowFromID(hwnd, GREP_LK), !finddupes);
660 WinEnableWindow(WinWindowFromID(hwnd, GREP_NM), !finddupes);
661 WinEnableWindow(WinWindowFromID(hwnd, GREP_OM), !finddupes);
662 if (finddupes)
663 WinCheckButton(hwnd, GREP_RECURSE, TRUE);
664 }
665 }
666 return 0;
667
668 case WM_COMMAND:
669 switch (SHORT1FROMMP(mp1)) {
670 case GREP_ENV:
671 {
672 CHAR *t;
673 CHAR env[8192];
674
675 *path = 0;
676 if (!WinDlgBox(HWND_DESKTOP,
677 hwnd, EnvDlgProc, FM3ModHandle, ENV_FRAME, path)) {
678 break;
679 }
680 bstrip(path);
681 if (!*path)
682 break;
683 if (!stricmp(path, PCSZ_LIBPATH))
684 LoadLibPath(env, 8192);
685 else {
686 p = getenv(path);
687 if (!p)
688 break;
689 strcpy(env, p);
690 }
691 bstrip(env);
692 if (!*env)
693 break;
694 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
695 bstrip(s);
696 if (strlen(s) > 8192 - 5) {
697 Runtime_Error(pszSrcFile, __LINE__, "too big");
698 break;
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 lLen = strlen(simple) + 1;
712 p = env;
713 while (p && *p) {
714 strncpy(path, p, CCHMAXPATH - 1);
715 path[CCHMAXPATH - 1] = 0;
716 t = strchr(path, ';');
717 if (t)
718 *t = 0;
719 bstrip(path);
720 if (isalpha(*path) && path[1] == ':' && path[2] == '\\') {
721 if (strlen(s) > (8192 - lLen) - (strlen(path) + 1)) {
722 WinSetDlgItemText(hwnd, GREP_MASK, s);
723 break;
724 }
725 if (!*s || (*s && s[strlen(s) - 1] != ';')) {
726 if (*s)
727 strcat(s, ";");
728 strcat(s, path);
729 lLen += strlen(path);
730 if (s[strlen(s) - 1] != '\\') {
731 lLen++;
732 strcat(s, PCSZ_BACKSLASH);
733 }
734 rstrip(s);
735 if (*s) {
736 strcat(s, simple);
737 WinSetDlgItemText(hwnd, GREP_MASK, s);
738 // 19 Aug 10 SHL FIXME to honor append
739 WinSendDlgItemMsg(hwnd,
740 GREP_MASK,
741 EM_SETSEL,
742 MPFROM2SHORT(strlen(s) - (lLen - 1),
743 strlen(s)), MPVOID);
744 }
745 }
746 }
747 p = strchr(p, ';');
748 if (p)
749 p++;
750 }
751 }
752 break;
753
754 case GREP_WALK:
755 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
756 bstrip(s);
757 if (strlen(s) > 8192 - 5) {
758 Runtime_Error(pszSrcFile, __LINE__, "too big");
759 break;
760 }
761 *path = 0;
762 if (WinDlgBox(HWND_DESKTOP,
763 hwnd,
764 WalkAllDlgProc,
765 FM3ModHandle, WALK_FRAME, MPFROMP(path)) && *path) {
766 p = strrchr(s, '\\');
767 if (p)
768 strcpy(simple, p + 1);
769 else if (*s)
770 strcpy(simple, s);
771 else
772 strcpy(simple, "*");
773 if (!p)
774 *s = 0;
775 if (simple[strlen(simple) - 1] == ';')
776 simple[strlen(simple) - 1] = 0;
777 lLen = strlen(simple) + 1;
778 if (strlen(s) > (8192 - lLen) - (strlen(path) + 1)) {
779 Runtime_Error(pszSrcFile, __LINE__, "too big");
780 WinSetDlgItemText(hwnd, GREP_MASK, s);
781 break;
782 }
783 if (!*s || (*s && s[strlen(s) - 1] != ';')) {
784 if (*s)
785 strcat(s, ";");
786 strcat(s, path);
787 lLen += strlen(path);
788 if (s[strlen(s) - 1] != '\\') {
789 lLen++;
790 strcat(s, PCSZ_BACKSLASH);
791 }
792 rstrip(s);
793 // 25 Sep 09 SHL FIXME to honor append
794 if (*s) {
795 strcat(s, simple);
796 WinSetDlgItemText(hwnd, GREP_MASK, s);
797 WinSendDlgItemMsg(hwnd,
798 GREP_MASK,
799 EM_SETSEL,
800 MPFROM2SHORT(strlen(s) - (lLen - 1),
801 strlen(s)), MPVOID);
802 }
803 }
804 }
805 break;
806
807 case GREP_ADD:
808 *s = 0;
809 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
810 bstrip(s);
811 if (*s) {
812 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
813 GREP_LISTBOX,
814 LM_SEARCHSTRING,
815 MPFROM2SHORT(0, LIT_FIRST),
816 MPFROMP(s));
817 if (sSelect < 0) {
818 WinSendDlgItemMsg(hwnd,
819 GREP_LISTBOX,
820 LM_INSERTITEM,
821 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s));
822 maskListChanged = TRUE;
823 }
824 }
825 break;
826
827 case GREP_DELETE:
828 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
829 GREP_LISTBOX,
830 LM_QUERYSELECTION,
831 MPFROMSHORT(LIT_FIRST), MPVOID);
832 if (sSelect >= 0) {
833 WinSendDlgItemMsg(hwnd,
834 GREP_LISTBOX,
835 LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
836 if (sSelect >= sLastMaskSelect)
837 sLastMaskSelect--;
838 maskListChanged = TRUE;
839 }
840 break;
841
842 case GREP_OM:
843 *s = 0;
844 WinQueryDlgItemText(hwnd, GREP_OLDER, 34, s);
845 ul = atoi(s) * 30L;
846 sprintf(s, "%lu", ul);
847 WinSetDlgItemText(hwnd, GREP_OLDER, s);
848 break;
849
850 case GREP_NM:
851 *s = 0;
852 WinQueryDlgItemText(hwnd, GREP_NEWER, 34, s);
853 ul = atoi(s) * 30L;
854 sprintf(s, "%lu", ul);
855 WinSetDlgItemText(hwnd, GREP_NEWER, s);
856 break;
857
858 case GREP_GK:
859 *s = 0;
860 WinQueryDlgItemText(hwnd, GREP_GREATER, 34, s);
861 ul = atol(s) * 1024L;
862 sprintf(s, "%lu", ul);
863 WinSetDlgItemText(hwnd, GREP_GREATER, s);
864 break;
865
866 case GREP_LK:
867 *s = 0;
868 WinQueryDlgItemText(hwnd, GREP_LESSER, 34, s);
869 ul = atol(s) * 1024L;
870 sprintf(s, "%lu", ul);
871 WinSetDlgItemText(hwnd, GREP_LESSER, s);
872 break;
873
874 case DID_CANCEL:
875 WinDismissDlg(hwnd, 0);
876 break;
877
878 case IDM_HELP:
879 if (hwndHelp)
880 WinSendMsg(hwndHelp,
881 HM_DISPLAY_HELP,
882 MPFROM2SHORT(HELP_GREP, 0), MPFROMSHORT(HM_RESOURCEID));
883 break;
884
885 case GREP_LOCALHDS:
886 case GREP_REMOTEHDS:
887 case GREP_ALLHDS:
888 {
889 CHAR szDrive[] = " :\\";
890 ULONG ulDriveNum;
891 ULONG ulDriveMap;
892 INT x;
893 BOOL incl;
894 CHAR new[8192];
895
896 // Find first mask
897 *s = 0;
898 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, s);
899 s[8192 - 1] = 0;
900 p = strchr(s, ';');
901 if (p)
902 *p = 0;
903 p = strrchr(s, '\\');
904 if (!p)
905 p = strrchr(s, '/');
906 if (!p)
907 p = strrchr(s, ':');
908 if (p)
909 strcpy(s, p + 1);
910 if (!*s)
911 strcpy(s, "*");
912
913 DosError(FERR_DISABLEHARDERR);
914 DosQCurDisk(&ulDriveNum, &ulDriveMap);
915 *new = 0;
916 for (x = 2; x < 26; x++) {
917 incl = FALSE;
918 if (ulDriveMap & (1L << x)) {
919 switch (SHORT1FROMMP(mp1)) {
920 case GREP_ALLHDS:
921 if (!(driveflags[x] & (DRIVE_REMOVABLE | DRIVE_IGNORE | DRIVE_RAMDISK)))
922 incl = TRUE;
923 break;
924 case GREP_LOCALHDS:
925 // 06 Jun 10 SHL FIXME to work if drive not prescanned
926 if (!(driveflags[x] &
927 (DRIVE_REMOVABLE | DRIVE_IGNORE | DRIVE_REMOTE |
928 DRIVE_VIRTUAL | DRIVE_RAMDISK)))
929 incl = TRUE;
930 break;
931 case GREP_REMOTEHDS:
932 if (!(driveflags[x] & (DRIVE_REMOVABLE | DRIVE_IGNORE)) &&
933 (driveflags[x] & DRIVE_REMOTE))
934 incl = TRUE;
935 break;
936 }
937 }
938 if (incl) {
939 if (strlen(new) + strlen(s) + 5 < 8192 - 1) {
940 if (*new)
941 strcat(new, ";");
942 *szDrive = x + 'A';
943 strcat(new, szDrive);
944 strcat(new, s);
945 }
946 }
947 }
948 if (*new)
949 WinSetDlgItemText(hwnd, GREP_MASK, new);
950 }
951 break;
952
953 case DID_OK:
954 hwndCollect = WinQueryWindowULong(hwnd, QWL_USER);
955 if (!hwndCollect)
956 Runtime_Error(pszSrcFile, __LINE__, NULL);
957 else {
958 // 07 Feb 08 SHL - FIXME to malloc and free in thread
959 static GREP g; // Passed to thread
960 p = xmalloc(8192 + 512, pszSrcFile, __LINE__);
961 if (!p)
962 break; // Already complained
963 memset(&g, 0, sizeof(GREP));
964 g.size = sizeof(GREP);
965 recurse = WinQueryButtonCheckstate(hwnd, GREP_RECURSE) != 0;
966 absolute = WinQueryButtonCheckstate(hwnd, GREP_ABSOLUTE) != 0;
967 sensitive = WinQueryButtonCheckstate(hwnd, GREP_CASE) != 0;
968 sayfiles = WinQueryButtonCheckstate(hwnd, GREP_SAYFILES) != 0;
969 searchEAs = WinQueryButtonCheckstate(hwnd, GREP_SEARCHEAS) != 0;
970 searchFiles = WinQueryButtonCheckstate(hwnd, GREP_SEARCHFILES) != 0;
971 findifany = WinQueryButtonCheckstate(hwnd, GREP_FINDIFANY) != 0;
972 ignoreSVN = WinQueryButtonCheckstate(hwnd, GREP_IGNORESVN) != 0;
973 rememberSettings = WinQueryButtonCheckstate(hwnd, GREP_REMEMBERFLAGS);
974 if (rememberSettings) {
975 PrfWriteProfileData(fmprof, FM3Str, "Grep_Recurse",
976 (PVOID) & recurse, sizeof(BOOL));
977 PrfWriteProfileData(fmprof, FM3Str, "Grep_Absolute",
978 (PVOID) & absolute, sizeof(BOOL));
979 PrfWriteProfileData(fmprof, FM3Str, "Grep_Case",
980 (PVOID) & sensitive, sizeof(BOOL));
981 PrfWriteProfileData(fmprof, FM3Str, "Grep_Sayfiles",
982 (PVOID) & sayfiles, sizeof(BOOL));
983 PrfWriteProfileData(fmprof, FM3Str, "Grep_Searchfiles",
984 (PVOID) & searchFiles, sizeof(BOOL));
985 PrfWriteProfileData(fmprof, FM3Str, "Grep_SearchfEAs",
986 (PVOID) & searchEAs, sizeof(BOOL));
987 }
988 PrfWriteProfileData(fmprof, appname,
989 (CHAR *) PSCZ_GREP_LASTMASK_SELECT, &sLastMaskSelect, sizeof(sLastMaskSelect));
990 g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0;
991 if (g.finddupes) {
992 g.CRCdupes = WinQueryButtonCheckstate(hwnd, GREP_CRCDUPES) != 0;
993 g.nosizedupes =
994 WinQueryButtonCheckstate(hwnd, GREP_NOSIZEDUPES) != 0;
995 g.ignoreextdupes =
996 WinQueryButtonCheckstate(hwnd, GREP_IGNOREEXTDUPES) != 0;
997 }
998 // Parse file masks
999 *p = 0;
1000 WinQueryDlgItemText(hwnd, GREP_MASK, 8192, p);
1001 bstrip(p);
1002 if (!*p) {
1003 if (!fAlertBeepOff)
1004 DosBeep(50, 100);
1005 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, GREP_MASK));
1006 free(p);
1007# ifdef FORTIFY
1008 Fortify_LeaveScope();
1009# endif
1010 break;
1011 }
1012 strcpy(g.fileMasks, p);
1013 strcpy(fileMasks, p);
1014 // Parse search strings
1015 *p = 0;
1016 WinQueryWindowText(hwndMLE, 4096, p);
1017 strcpy(searchText, p);
1018 {
1019 CHAR *pszFrom;
1020 CHAR *pszTo;
1021 ULONG matched = 0;
1022
1023 pszTo = g.searchPattern;
1024 pszFrom = p;
1025 while (*pszFrom) {
1026 if (*pszFrom == '\r') {
1027 pszFrom++;
1028 continue;
1029 }
1030 if (*pszFrom == '\n') {
1031 if (*(pszFrom + 1))
1032 matched++;
1033 *pszTo = 0;
1034 }
1035 else
1036 *pszTo = *pszFrom;
1037 pszTo++;
1038 pszFrom++;
1039 }
1040 if (*g.searchPattern)
1041 matched++;
1042 *pszTo++ = 0;
1043 *pszTo = 0;
1044 g.numlines = matched;
1045 if (matched) {
1046 g.matched = xmalloc(g.numlines, pszSrcFile, __LINE__);
1047 if (!g.matched)
1048 g.numlines = 0;
1049 }
1050 }
1051 *p = 0;
1052 WinQueryDlgItemText(hwnd, GREP_GREATER, 34, p);
1053 greaterthan = atol(p);
1054 *p = 0;
1055 WinQueryDlgItemText(hwnd, GREP_LESSER, 34, p);
1056 lessthan = atol(p);
1057 *p = 0;
1058 WinQueryDlgItemText(hwnd, GREP_NEWER, 34, p);
1059 newer = atoi(p);
1060 *p = 0;
1061 WinQueryDlgItemText(hwnd, GREP_OLDER, 34, p);
1062 older = atoi(p);
1063 if (older || newer) {
1064 FDATE fdate;
1065 FTIME ftime;
1066 struct tm tm;
1067 time_t t;
1068
1069 t = time(NULL);
1070 tm = *localtime(&t);
1071 fdate.day = tm.tm_mday;
1072 fdate.month = tm.tm_mon + 1;
1073 fdate.year = tm.tm_year - 80;
1074 ftime.hours = tm.tm_hour;
1075 ftime.minutes = tm.tm_min;
1076 ftime.twosecs = tm.tm_sec / 2;
1077 if (older) {
1078 g.olderthan = SecsSince1980(&fdate, &ftime);
1079 g.olderthan -= (older * (24L * 60L * 60L));
1080 }
1081 if (newer) {
1082 g.newerthan = SecsSince1980(&fdate, &ftime);
1083 g.newerthan -= (newer * (24L * 60L * 60L));
1084 }
1085 }
1086 if (!newer)
1087 g.newerthan = 0;
1088 if (!older)
1089 g.olderthan = 0;
1090 g.greaterthan = greaterthan;
1091 g.lessthan = lessthan;
1092 g.absFlag = absolute;
1093 g.caseFlag = sensitive;
1094 g.dirFlag = recurse;
1095 g.sayfiles = sayfiles;
1096 g.searchEAs = searchEAs;
1097 g.searchFiles = searchFiles;
1098 g.findifany = findifany;
1099 g.ignoreSVN = ignoreSVN;
1100
1101 g.hwndFiles = hwndCollect;
1102 g.hwnd = WinQueryWindow(hwndCollect, QW_PARENT);
1103 g.hwndCurFile = WinWindowFromID(g.hwnd, DIR_SELECTED);
1104
1105 // Get settings from collector filter
1106 g.attrFile = ((DIRCNRDATA *)INSTDATA(hwndCollect))->mask.attrFile;
1107 g.antiattr = ((DIRCNRDATA *)INSTDATA(hwndCollect))->mask.antiattr;
1108 g.stopflag = &((DIRCNRDATA *)INSTDATA(hwndCollect))->stopflag;
1109
1110 if (rememberSettings) {
1111 PrfWriteProfileData(fmprof, FM3Str, "Grep_Recurse",
1112 (PVOID) & recurse, sizeof(BOOL));
1113 PrfWriteProfileData(fmprof, FM3Str, "Grep_Absolute",
1114 (PVOID) & absolute, sizeof(BOOL));
1115 PrfWriteProfileData(fmprof, FM3Str, "Grep_Case",
1116 (PVOID) & sensitive, sizeof(BOOL));
1117 PrfWriteProfileData(fmprof, FM3Str, "Grep_Sayfiles",
1118 (PVOID) & sayfiles, sizeof(BOOL));
1119 PrfWriteProfileData(fmprof, FM3Str, "Grep_Searchfiles",
1120 (PVOID) & searchFiles, sizeof(BOOL));
1121 PrfWriteProfileData(fmprof, FM3Str, "Grep_SearchfEAs",
1122 (PVOID) & searchEAs, sizeof(BOOL));
1123 }
1124
1125 if (xbeginthread(GrepThread,
1126 524280,
1127 &g,
1128 pszSrcFile,
1129 __LINE__) == -1)
1130 {
1131 free(p);
1132# ifdef FORTIFY
1133 Fortify_LeaveScope();
1134# endif
1135 WinDismissDlg(hwnd, 0);
1136 break;
1137 }
1138 DosSleep(100); //05 Aug 07 GKY 128
1139 free(p);
1140# ifdef FORTIFY
1141 Fortify_LeaveScope();
1142# endif
1143 }
1144 if (maskListChanged) {
1145 // Save modified mask list
1146 SHORT x;
1147
1148 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
1149 GREP_LISTBOX,
1150 LM_QUERYITEMCOUNT,
1151 MPVOID, MPVOID);
1152 // 07 Oct 09 SHL Rewrite if list empty
1153 if (sSelect >= 0) {
1154 CHAR *modew = "w";
1155
1156 BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT);
1157 if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
1158 break; //already gave error msg
1159 fp = xfopen(s, modew, pszSrcFile, __LINE__, FALSE);
1160 if (fp) {
1161 fputs(GetPString(IDS_GREPFILETEXT), fp);
1162 for (x = 0; x < sSelect; x++) {
1163 *s = 0;
1164 WinSendDlgItemMsg(hwnd,
1165 GREP_LISTBOX,
1166 LM_QUERYITEMTEXT,
1167 MPFROM2SHORT(x, 8192), MPFROMP(s));
1168 bstrip(s);
1169 if (*s)
1170 fprintf(fp, "%s\n", s);
1171 }
1172 fclose(fp);
1173 }
1174 }
1175 }
1176 WinDismissDlg(hwnd, 1);
1177 break;
1178 }
1179 return 0;
1180 }
1181 return WinDefDlgProc(hwnd, msg, mp1, mp2);
1182}
1183
1184#pragma alloc_text(GREP,GrepDlgProc,EnvDlgProc)
Note: See TracBrowser for help on using the repository browser.