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