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