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