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