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