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