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