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