source: trunk/dll/grep2.c@ 1880

Last change on this file since 1880 was 1880, checked in by Gregg Young, 10 years ago

Remove dead code and comments from remaining c files. #if 0 and #if NEVER were not addressed

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