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