| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: grep.c 517 2006-11-02 08:51:38Z root $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   grep tools
 | 
|---|
| 7 | 
 | 
|---|
| 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 9 |   Copyright (c) 2001, 2006 Steven H. Levine
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   12 Feb 03 SHL insert_grepfile: standardize EA math
 | 
|---|
| 12 |   12 Feb 03 SHL doonefile: standardize EA math
 | 
|---|
| 13 |   25 May 05 SHL Rework for ULONGLONG
 | 
|---|
| 14 |   25 May 05 SHL Rework for FillInRecordFromFFB
 | 
|---|
| 15 |   06 Jun 05 SHL Drop unused code
 | 
|---|
| 16 |   24 Oct 05 SHL dononefile: do not free EA list twice
 | 
|---|
| 17 |   22 Jul 06 SHL Use Runtime_Error
 | 
|---|
| 18 |   26 Jul 06 SHL Check more run time errors
 | 
|---|
| 19 |   19 Oct 06 SHL Correct . and .. detect
 | 
|---|
| 20 | 
 | 
|---|
| 21 | ***********************************************************************/
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #define INCL_DOS
 | 
|---|
| 24 | #define INCL_WIN
 | 
|---|
| 25 | #define INCL_LONGLONG
 | 
|---|
| 26 | #include <os2.h>
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include <stdlib.h>
 | 
|---|
| 29 | #include <string.h>
 | 
|---|
| 30 | #include <ctype.h>
 | 
|---|
| 31 | #include <stdio.h>
 | 
|---|
| 32 | #include <share.h>
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #include "fm3dll.h"
 | 
|---|
| 35 | #include "fm3str.h"
 | 
|---|
| 36 | #include "grep.h"
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #pragma data_seg(DATA2)
 | 
|---|
| 39 | 
 | 
|---|
| 40 | static PSZ pszSrcFile = __FILE__;
 | 
|---|
| 41 | 
 | 
|---|
| 42 | #pragma alloc_text(GREP,SecsSince1980,match,mmatch,dogrep)
 | 
|---|
| 43 | #pragma alloc_text(GREP,doallsubdirs,domatchingfiles)
 | 
|---|
| 44 | 
 | 
|---|
| 45 | /*****************************/
 | 
|---|
| 46 | /*   Function Prototypes     */
 | 
|---|
| 47 | /*****************************/
 | 
|---|
| 48 | 
 | 
|---|
| 49 | static VOID  doallsubdirs    (GREP *grep,CHAR *searchPath,BOOL recursing,
 | 
|---|
| 50 |                               char **fle,int numfls);
 | 
|---|
| 51 | static INT   domatchingfiles (GREP *grep,CHAR *path,char **fle,int numfls);
 | 
|---|
| 52 | static BOOL  doonefile       (GREP *grep,CHAR *fileName,FILEFINDBUF4 *f);
 | 
|---|
| 53 | static BOOL  doinsertion     (GREP *grep);
 | 
|---|
| 54 | static BOOL  InsertDupe      (GREP *grep,CHAR *dir,FILEFINDBUF4 *f);
 | 
|---|
| 55 | static VOID  FillDupes       (GREP *g);
 | 
|---|
| 56 | static VOID  FreeDupes       (GREP *g);
 | 
|---|
| 57 | 
 | 
|---|
| 58 | #define GREPCHARS "*?[] \\"
 | 
|---|
| 59 | 
 | 
|---|
| 60 | #define isleap(year) ((((year%4)==0) && ((year%100)!=0)) || \
 | 
|---|
| 61 |         ((year%400)==0))
 | 
|---|
| 62 | 
 | 
|---|
| 63 | 
 | 
|---|
| 64 | static INT monthdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
 | 
|---|
| 65 | 
 | 
|---|
| 66 | 
 | 
|---|
| 67 | ULONG SecsSince1980 (FDATE *date,FTIME *time)
 | 
|---|
| 68 | {
 | 
|---|
| 69 |   ULONG        total = 0L;
 | 
|---|
| 70 |   register int x;
 | 
|---|
| 71 | 
 | 
|---|
| 72 |   for(x = 1980;x < date->year + 1980;x++) {
 | 
|---|
| 73 |     if(isleap(x))
 | 
|---|
| 74 |       total += (366L * (24L * 60L * 60L));
 | 
|---|
| 75 |     else
 | 
|---|
| 76 |       total += (365L * (24L * 60L * 60L));
 | 
|---|
| 77 |   }
 | 
|---|
| 78 |   for(x = 1;x < date->month;x++) {
 | 
|---|
| 79 |     if(x == 2 && isleap(date->year + 1980))
 | 
|---|
| 80 |       total += (29L * (24L * 60L * 60L));
 | 
|---|
| 81 |     else
 | 
|---|
| 82 |       total += ((long)monthdays[x - 1] * (24L * 60L * 60L));
 | 
|---|
| 83 |   }
 | 
|---|
| 84 |   total += (((long)date->day - 1L) * (24L * 60L * 60L));
 | 
|---|
| 85 |   total += ((long)time->hours * (60L * 60L));
 | 
|---|
| 86 |   total += ((long)time->minutes * 60L);
 | 
|---|
| 87 |   total += ((long)time->twosecs * 2L);
 | 
|---|
| 88 |   return total;
 | 
|---|
| 89 | }
 | 
|---|
| 90 | 
 | 
|---|
| 91 | 
 | 
|---|
| 92 | /*
 | 
|---|
| 93 |  * this function originally from C_ECHO's Snippets -- modified
 | 
|---|
| 94 |  * brute force methodology
 | 
|---|
| 95 |  */
 | 
|---|
| 96 | 
 | 
|---|
| 97 | static BOOL m_match (CHAR *string, CHAR *pattern, BOOL absolute, BOOL ignore,
 | 
|---|
| 98 |                      LONG len) {
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   /* return TRUE if pattern found in string */
 | 
|---|
| 101 | 
 | 
|---|
| 102 |   register CHAR *tn = pattern;
 | 
|---|
| 103 |   register LONG  len2 = 0;
 | 
|---|
| 104 |   LONG           lastlen = 0;
 | 
|---|
| 105 |   CHAR           lo,hi;
 | 
|---|
| 106 | 
 | 
|---|
| 107 |   if(len && string && pattern) {
 | 
|---|
| 108 |     if(absolute)                  /* no pattern matching */
 | 
|---|
| 109 |       return(findstring(pattern,strlen(pattern),string,len,
 | 
|---|
| 110 |                         (ignore == FALSE)) != NULL);
 | 
|---|
| 111 | 
 | 
|---|
| 112 |     while(*tn && len2 < len) {
 | 
|---|
| 113 |       switch(*tn) {
 | 
|---|
| 114 |         case ' ':
 | 
|---|
| 115 |           while(*tn == ' ')
 | 
|---|
| 116 |             tn++;
 | 
|---|
| 117 |           while(len2 < len && isspace(string[len2]))
 | 
|---|
| 118 |             len2++;
 | 
|---|
| 119 |           break;
 | 
|---|
| 120 | 
 | 
|---|
| 121 |         case '*':
 | 
|---|
| 122 |           while(*tn == '*' || *tn == '?')
 | 
|---|
| 123 |             tn++;
 | 
|---|
| 124 |           if(!*tn)
 | 
|---|
| 125 |             return TRUE;
 | 
|---|
| 126 |           if(ignore) {
 | 
|---|
| 127 |             while(len2 < len && string[len2] != *tn)
 | 
|---|
| 128 |               len2++;
 | 
|---|
| 129 |           }
 | 
|---|
| 130 |           else {
 | 
|---|
| 131 |             while(len2 < len && toupper(string[len2] != *tn))
 | 
|---|
| 132 |               len2++;
 | 
|---|
| 133 |           }
 | 
|---|
| 134 |           break;
 | 
|---|
| 135 | 
 | 
|---|
| 136 |         case '[':
 | 
|---|
| 137 |           tn++;
 | 
|---|
| 138 |           if(!*tn)
 | 
|---|
| 139 |             return FALSE;
 | 
|---|
| 140 |           lo = *tn;
 | 
|---|
| 141 |           tn++;
 | 
|---|
| 142 |           if(*tn != '-')
 | 
|---|
| 143 |             return FALSE;
 | 
|---|
| 144 |           tn++;
 | 
|---|
| 145 |           if(!*tn)
 | 
|---|
| 146 |             return FALSE;
 | 
|---|
| 147 |           hi = *tn;
 | 
|---|
| 148 |           tn++;
 | 
|---|
| 149 |           if (*tn != ']')
 | 
|---|
| 150 |             return FALSE;
 | 
|---|
| 151 |           tn++;
 | 
|---|
| 152 |           if(ignore) {
 | 
|---|
| 153 |             if ((toupper(string[len2]) >= toupper(lo)) &&
 | 
|---|
| 154 |                 (toupper(string[len2]) <= toupper(hi)))
 | 
|---|
| 155 |               len2++;
 | 
|---|
| 156 |             else {
 | 
|---|
| 157 |               tn = pattern;
 | 
|---|
| 158 |               len2 = lastlen = lastlen + 1;
 | 
|---|
| 159 |             }
 | 
|---|
| 160 |           }
 | 
|---|
| 161 |           else {
 | 
|---|
| 162 |             if ((string[len2] >= lo) && (string[len2] <= hi))
 | 
|---|
| 163 |               len2++;
 | 
|---|
| 164 |             else {
 | 
|---|
| 165 |               tn = pattern;
 | 
|---|
| 166 |               len2 = lastlen = lastlen + 1;
 | 
|---|
| 167 |             }
 | 
|---|
| 168 |           }
 | 
|---|
| 169 |           break;
 | 
|---|
| 170 | 
 | 
|---|
| 171 |         case '?':
 | 
|---|
| 172 |           tn++;
 | 
|---|
| 173 |           len2++;
 | 
|---|
| 174 |           break;
 | 
|---|
| 175 | 
 | 
|---|
| 176 |         case '\\':
 | 
|---|
| 177 |           tn++;
 | 
|---|
| 178 |           if(!*tn)
 | 
|---|
| 179 |             return FALSE;
 | 
|---|
| 180 |           /* else intentional fallthru */
 | 
|---|
| 181 |         default:
 | 
|---|
| 182 |           if(ignore) {
 | 
|---|
| 183 |             if(toupper(*tn) == toupper(string[len2])) {
 | 
|---|
| 184 |               tn++;
 | 
|---|
| 185 |               len2++;
 | 
|---|
| 186 |             }
 | 
|---|
| 187 |             else {
 | 
|---|
| 188 |               tn = pattern;
 | 
|---|
| 189 |               len2 = lastlen = lastlen + 1;
 | 
|---|
| 190 |             }
 | 
|---|
| 191 |           }
 | 
|---|
| 192 |           else {
 | 
|---|
| 193 |             if(*tn == string[len2]) {
 | 
|---|
| 194 |               tn++;
 | 
|---|
| 195 |               len2++;
 | 
|---|
| 196 |             }
 | 
|---|
| 197 |             else {
 | 
|---|
| 198 |               tn = pattern;
 | 
|---|
| 199 |               len2 = lastlen = lastlen + 1;
 | 
|---|
| 200 |             }
 | 
|---|
| 201 |           }
 | 
|---|
| 202 |           break;
 | 
|---|
| 203 |       }
 | 
|---|
| 204 |     }
 | 
|---|
| 205 |     while(*tn == '*')
 | 
|---|
| 206 |       tn++;
 | 
|---|
| 207 | 
 | 
|---|
| 208 |     if (!*tn)
 | 
|---|
| 209 |       return TRUE;
 | 
|---|
| 210 |   }
 | 
|---|
| 211 |   return FALSE;
 | 
|---|
| 212 | }
 | 
|---|
| 213 | 
 | 
|---|
| 214 | 
 | 
|---|
| 215 | static BOOL match (CHAR *string,CHAR *patterns,BOOL absolute,BOOL ignore,
 | 
|---|
| 216 |                    LONG len,ULONG numlines,CHAR *matched,BOOL matchall) {
 | 
|---|
| 217 | 
 | 
|---|
| 218 |   BOOL           ret = FALSE;
 | 
|---|
| 219 |   register CHAR *p;
 | 
|---|
| 220 |   register ULONG x = 0;
 | 
|---|
| 221 | 
 | 
|---|
| 222 |   p = patterns;
 | 
|---|
| 223 |   while(!ret && *p) {
 | 
|---|
| 224 |     ret = m_match(string,p,absolute,ignore,len);
 | 
|---|
| 225 |     if(matchall && ret)
 | 
|---|
| 226 |       break;
 | 
|---|
| 227 |     if(matched && ret && x < numlines)
 | 
|---|
| 228 |       matched[x] = 1;
 | 
|---|
| 229 |     p += strlen(p); /* check each pattern in 0-terminated list */
 | 
|---|
| 230 |     p++;
 | 
|---|
| 231 |     x++;
 | 
|---|
| 232 |   }
 | 
|---|
| 233 |   return ret;
 | 
|---|
| 234 | }
 | 
|---|
| 235 | 
 | 
|---|
| 236 | 
 | 
|---|
| 237 | VOID dogrep (VOID *arg)
 | 
|---|
| 238 | {
 | 
|---|
| 239 |   HAB           ghab;
 | 
|---|
| 240 |   HMQ           ghmq;
 | 
|---|
| 241 |   GREP          grep;
 | 
|---|
| 242 |   register INT  x,numfls;
 | 
|---|
| 243 |   static CHAR  *fle[512];
 | 
|---|
| 244 |   CHAR         *p,*pp,searchPath[CCHMAXPATH * 2];
 | 
|---|
| 245 | 
 | 
|---|
| 246 |   if(!arg)
 | 
|---|
| 247 |     return;
 | 
|---|
| 248 |   grep = *(GREP *)arg;
 | 
|---|
| 249 |   *grep.stopflag = 0;  /* reset thread-killing flag */
 | 
|---|
| 250 |   grep.FilesToGet = (grep.dirFlag) ? min(FilesToGet,128) : FilesToGet;
 | 
|---|
| 251 |   DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 252 |   priority_normal();
 | 
|---|
| 253 | 
 | 
|---|
| 254 |   ghab = WinInitialize(0);
 | 
|---|
| 255 |   if(ghab) {
 | 
|---|
| 256 |     grep.ghab = ghab;
 | 
|---|
| 257 |     ghmq = WinCreateMsgQueue(ghab,0);
 | 
|---|
| 258 |     if(ghmq) {
 | 
|---|
| 259 |       WinCancelShutdown(ghmq,TRUE);
 | 
|---|
| 260 |       DosSleep(128L);
 | 
|---|
| 261 |       WinSetWindowText(grep.hwndCurFile,
 | 
|---|
| 262 |                        GetPString((grep.finddupes) ?
 | 
|---|
| 263 |                                   IDS_GREPDUPETEXT : IDS_GREPSCANTEXT));
 | 
|---|
| 264 | 
 | 
|---|
| 265 |       pp = grep.searchPattern;
 | 
|---|
| 266 |       while(*pp) {
 | 
|---|
| 267 |         if(!grep.absFlag) {
 | 
|---|
| 268 |           p = GREPCHARS;  /* see if any sense in pattern matching */
 | 
|---|
| 269 |           while(*p) {
 | 
|---|
| 270 |             if(strchr(pp,*p))
 | 
|---|
| 271 |               break;
 | 
|---|
| 272 |             p++;
 | 
|---|
| 273 |           }
 | 
|---|
| 274 |           if(!*p) /* nope, turn it off */
 | 
|---|
| 275 |             grep.absFlag = TRUE;
 | 
|---|
| 276 |         }
 | 
|---|
| 277 |         pp = pp + strlen(pp) + 1;
 | 
|---|
| 278 |       }
 | 
|---|
| 279 | 
 | 
|---|
| 280 |       grep.attrFile &= (~FILE_DIRECTORY);
 | 
|---|
| 281 |       grep.antiattr &= (~FILE_DIRECTORY);
 | 
|---|
| 282 |       if(grep.antiattr & FILE_READONLY)
 | 
|---|
| 283 |         grep.antiattr |= MUST_HAVE_READONLY;
 | 
|---|
| 284 |       if(grep.antiattr & FILE_HIDDEN)
 | 
|---|
| 285 |         grep.antiattr |= MUST_HAVE_HIDDEN;
 | 
|---|
| 286 |       if(grep.antiattr & FILE_SYSTEM)
 | 
|---|
| 287 |         grep.antiattr |= MUST_HAVE_SYSTEM;
 | 
|---|
| 288 |       if(grep.antiattr & FILE_ARCHIVED)
 | 
|---|
| 289 |         grep.antiattr |= MUST_HAVE_ARCHIVED;
 | 
|---|
| 290 | 
 | 
|---|
| 291 |       grep.anyexcludes = FALSE;
 | 
|---|
| 292 |       numfls = x = 0;
 | 
|---|
| 293 |       fle[numfls++] = strtok(grep.tosearch,";");
 | 
|---|
| 294 |       while((fle[numfls] = strtok(NULL,";")) != NULL && numfls < 511) {
 | 
|---|
| 295 |         if(*fle[numfls] == '/')
 | 
|---|
| 296 |           grep.anyexcludes = TRUE;
 | 
|---|
| 297 |         numfls++;
 | 
|---|
| 298 |       }
 | 
|---|
| 299 | 
 | 
|---|
| 300 |       while(x < numfls) { /* loop through search masks */
 | 
|---|
| 301 | 
 | 
|---|
| 302 |         if(*fle[x] == '/')  /* is an exclude mask only */
 | 
|---|
| 303 |           goto ExcludeSkip;
 | 
|---|
| 304 | 
 | 
|---|
| 305 |         /* first, separate any path from mask */
 | 
|---|
| 306 | 
 | 
|---|
| 307 |         p = (char *)(fle[x] + (strlen(fle[x]) - 1));
 | 
|---|
| 308 |         while(*p != '\\' && *p != ':' && p != fle[x])
 | 
|---|
| 309 |           --p;
 | 
|---|
| 310 | 
 | 
|---|
| 311 |         if(p == fle[x]) {  /* no path */
 | 
|---|
| 312 |           strcpy(searchPath,grep.curdir);
 | 
|---|
| 313 |           strncpy(grep.fileMask,fle[x],CCHMAXPATH);
 | 
|---|
| 314 |           grep.fileMask[CCHMAXPATH - 1] = 0;
 | 
|---|
| 315 |         }
 | 
|---|
| 316 |         else {  /* got to deal with a path */
 | 
|---|
| 317 |           if(*p == ':') { /* just a drive, start in root dir */
 | 
|---|
| 318 |             *p = 0;
 | 
|---|
| 319 |             p++;
 | 
|---|
| 320 |             strncpy(searchPath,fle[x],CCHMAXPATH - 2);
 | 
|---|
| 321 |             searchPath[CCHMAXPATH - 3] = 0;
 | 
|---|
| 322 |             strcat(searchPath,":\\");
 | 
|---|
| 323 |             strcpy(grep.fileMask,p);
 | 
|---|
| 324 |           }
 | 
|---|
| 325 |           if(*p == '\\') {  /* got a 'full' path */
 | 
|---|
| 326 | 
 | 
|---|
| 327 |             CHAR temp;
 | 
|---|
| 328 | 
 | 
|---|
| 329 |             p++;
 | 
|---|
| 330 |             temp = *p;
 | 
|---|
| 331 |             *p = 0;
 | 
|---|
| 332 |             strncpy(searchPath,fle[x],CCHMAXPATH);
 | 
|---|
| 333 |             searchPath[CCHMAXPATH - 1] = 0;
 | 
|---|
| 334 |             *p = temp;
 | 
|---|
| 335 |             strcpy(grep.fileMask,p);
 | 
|---|
| 336 |           }
 | 
|---|
| 337 |           if(!*grep.fileMask)
 | 
|---|
| 338 |             strcpy(grep.fileMask,"*");
 | 
|---|
| 339 |         }
 | 
|---|
| 340 |         if(*grep.stopflag)
 | 
|---|
| 341 |           break;
 | 
|---|
| 342 |         /* do single directory */
 | 
|---|
| 343 |         domatchingfiles(&grep,searchPath,fle,numfls);
 | 
|---|
| 344 |         if(grep.dirFlag)  /* do subdirs */
 | 
|---|
| 345 |           doallsubdirs(&grep,searchPath,FALSE,fle,numfls);
 | 
|---|
| 346 | ExcludeSkip:
 | 
|---|
| 347 |         if(*grep.stopflag)
 | 
|---|
| 348 |           break;
 | 
|---|
| 349 |         x++ ;
 | 
|---|
| 350 |         if(WinIsWindow(grep.ghab,grep.hwndFiles))
 | 
|---|
| 351 |           doinsertion(&grep); /* insert any remaining objects */
 | 
|---|
| 352 |       }
 | 
|---|
| 353 | 
 | 
|---|
| 354 | ShutDownThread:  /* kill pm connection, end thread */
 | 
|---|
| 355 | 
 | 
|---|
| 356 |       if(WinIsWindow(grep.ghab,grep.hwndFiles))
 | 
|---|
| 357 |         doinsertion(&grep); /* insert any remaining objects */
 | 
|---|
| 358 | 
 | 
|---|
| 359 |       if(WinIsWindow(grep.ghab,grep.hwndFiles) && grep.finddupes &&
 | 
|---|
| 360 |          !*grep.stopflag)
 | 
|---|
| 361 |         FillDupes(&grep);
 | 
|---|
| 362 | 
 | 
|---|
| 363 |       if(!PostMsg(grep.hwndFiles,
 | 
|---|
| 364 |                   UM_CONTAINER_FILLED,
 | 
|---|
| 365 |                   MPVOID,
 | 
|---|
| 366 |                   MPVOID)) /* tell window we're done */
 | 
|---|
| 367 |         WinSendMsg(grep.hwndFiles,
 | 
|---|
| 368 |                    UM_CONTAINER_FILLED,
 | 
|---|
| 369 |                    MPVOID,
 | 
|---|
| 370 |                    MPVOID);
 | 
|---|
| 371 |       WinDestroyMsgQueue(ghmq);
 | 
|---|
| 372 |     }
 | 
|---|
| 373 |     WinTerminate(ghab);
 | 
|---|
| 374 |   }
 | 
|---|
| 375 |   if(!ghmq || !ghab)
 | 
|---|
| 376 |     WinPostMsg(grep.hwndFiles,
 | 
|---|
| 377 |                UM_CONTAINER_FILLED,
 | 
|---|
| 378 |                MPVOID,
 | 
|---|
| 379 |                MPVOID);
 | 
|---|
| 380 |   if(grep.dupehead)
 | 
|---|
| 381 |     FreeDupes(&grep);
 | 
|---|
| 382 |   if(grep.numlines &&
 | 
|---|
| 383 |      grep.matched)
 | 
|---|
| 384 |     free(grep.matched);
 | 
|---|
| 385 |   DosPostEventSem(CompactSem);
 | 
|---|
| 386 | }
 | 
|---|
| 387 | 
 | 
|---|
| 388 | 
 | 
|---|
| 389 | static BOOL IsExcluded (char *name,char **fle,int numfls)
 | 
|---|
| 390 | {
 | 
|---|
| 391 |   register int x;
 | 
|---|
| 392 |   char        *n;
 | 
|---|
| 393 | 
 | 
|---|
| 394 |   n = strrchr(name,'\\');
 | 
|---|
| 395 |   if(!n)
 | 
|---|
| 396 |     n = strrchr(name,':');
 | 
|---|
| 397 |   if(n)
 | 
|---|
| 398 |     n++;
 | 
|---|
| 399 |   else
 | 
|---|
| 400 |     n = name;
 | 
|---|
| 401 |   for(x = 0;x < numfls;x++) {
 | 
|---|
| 402 |     if(*fle[x] == '/' &&
 | 
|---|
| 403 |        wildcard((strchr(fle[x],'\\') ||
 | 
|---|
| 404 |                  strchr(fle[x],':')) ?
 | 
|---|
| 405 |                 name : n,fle[x] + 1,FALSE))
 | 
|---|
| 406 |       return TRUE;
 | 
|---|
| 407 |   }
 | 
|---|
| 408 |   return FALSE;
 | 
|---|
| 409 | }
 | 
|---|
| 410 | 
 | 
|---|
| 411 | 
 | 
|---|
| 412 | static VOID doallsubdirs (GREP *grep,CHAR *searchPath,BOOL recursing,
 | 
|---|
| 413 |                           char **fle,int numfls) {
 | 
|---|
| 414 | 
 | 
|---|
| 415 |   /* process all subdirectories */
 | 
|---|
| 416 | 
 | 
|---|
| 417 |   FILEFINDBUF4 findBuffer;
 | 
|---|
| 418 |   HDIR         findHandle  = HDIR_CREATE;
 | 
|---|
| 419 |   LONG         findCount   = 1L;
 | 
|---|
| 420 |   CHAR         *p = NULL;
 | 
|---|
| 421 | 
 | 
|---|
| 422 |   /* add a mask to search path */
 | 
|---|
| 423 |   if(searchPath[strlen(searchPath) - 1] != '\\')
 | 
|---|
| 424 |     strcat(searchPath,"\\");
 | 
|---|
| 425 |   strcat(searchPath,"*");
 | 
|---|
| 426 |   /* step through all subdirectories */
 | 
|---|
| 427 |   DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 428 |   if(!DosFindFirst(searchPath,&findHandle,(MUST_HAVE_DIRECTORY |
 | 
|---|
| 429 |                   FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY),
 | 
|---|
| 430 |                   &findBuffer,
 | 
|---|
| 431 |                   (ULONG)sizeof(findBuffer),
 | 
|---|
| 432 |                   (PULONG)&findCount,
 | 
|---|
| 433 |                   FIL_QUERYEASIZE)) {
 | 
|---|
| 434 | 
 | 
|---|
| 435 |     /* get rid of mask portion, save end-of-directory */
 | 
|---|
| 436 | 
 | 
|---|
| 437 |     p = strrchr(searchPath,'\\');
 | 
|---|
| 438 |     if(p)
 | 
|---|
| 439 |       p++;
 | 
|---|
| 440 |     else
 | 
|---|
| 441 |       p = searchPath;
 | 
|---|
| 442 |     do {   /* Process each directory that matches the mask */
 | 
|---|
| 443 |       priority_normal();
 | 
|---|
| 444 |       if(*grep->stopflag)
 | 
|---|
| 445 |         break;
 | 
|---|
| 446 |       // Skip . and ..
 | 
|---|
| 447 |       if (findBuffer.achName[0] != '.' ||
 | 
|---|
| 448 |           (findBuffer.achName[1] &&
 | 
|---|
| 449 |            (findBuffer.achName[1] != '.' || findBuffer.achName[2]))) {
 | 
|---|
| 450 |         strcpy(p,findBuffer.achName) ;
 | 
|---|
| 451 |         if(!grep->anyexcludes || !IsExcluded(searchPath,fle,numfls)) {
 | 
|---|
| 452 |           domatchingfiles(grep,searchPath,fle,numfls) ;
 | 
|---|
| 453 |           doallsubdirs(grep,searchPath,TRUE,fle,numfls);
 | 
|---|
| 454 |           DosSleep(0L);
 | 
|---|
| 455 |         }
 | 
|---|
| 456 |       }
 | 
|---|
| 457 |       findCount = 1L;
 | 
|---|
| 458 |     } while(!DosFindNext(findHandle,
 | 
|---|
| 459 |                          &findBuffer,
 | 
|---|
| 460 |                          sizeof(findBuffer),
 | 
|---|
| 461 |                          (PULONG)&findCount));
 | 
|---|
| 462 |     DosFindClose(findHandle);
 | 
|---|
| 463 |     priority_normal();
 | 
|---|
| 464 |   }
 | 
|---|
| 465 |   if(p)    /* strip off last directory addition */
 | 
|---|
| 466 |     *p = 0;
 | 
|---|
| 467 | }
 | 
|---|
| 468 | 
 | 
|---|
| 469 | 
 | 
|---|
| 470 | static INT domatchingfiles (GREP *grep,CHAR *path,char **fle,int numfls)
 | 
|---|
| 471 | {
 | 
|---|
| 472 |   /* process all matching files in a directory */
 | 
|---|
| 473 | 
 | 
|---|
| 474 |   PFILEFINDBUF4  findBuffer;
 | 
|---|
| 475 |   PFILEFINDBUF4  pffbFile;
 | 
|---|
| 476 |   register PBYTE fb;
 | 
|---|
| 477 |   register ULONG x;
 | 
|---|
| 478 |   HDIR           findHandle  = HDIR_CREATE;
 | 
|---|
| 479 |   ULONG          findCount = grep->FilesToGet;
 | 
|---|
| 480 |   CHAR           newPath[CCHMAXPATH],*p;
 | 
|---|
| 481 |   APIRET         rc;
 | 
|---|
| 482 | 
 | 
|---|
| 483 |   findBuffer = xmalloc(grep->FilesToGet * sizeof(FILEFINDBUF4),pszSrcFile,__LINE__);
 | 
|---|
| 484 |   if(!findBuffer)
 | 
|---|
| 485 |     return 0;
 | 
|---|
| 486 | 
 | 
|---|
| 487 |   /* build filemask */
 | 
|---|
| 488 | 
 | 
|---|
| 489 |   sprintf(newPath,
 | 
|---|
| 490 |           "%s%s%s",
 | 
|---|
| 491 |           path,
 | 
|---|
| 492 |           (path[strlen(path) - 1] == '\\') ?
 | 
|---|
| 493 |            NullStr : "\\",
 | 
|---|
| 494 |           grep->fileMask);
 | 
|---|
| 495 | 
 | 
|---|
| 496 |   MakeFullName(newPath);
 | 
|---|
| 497 | 
 | 
|---|
| 498 |   /* find and save end-of-dir position */
 | 
|---|
| 499 |   p = strrchr(newPath,'\\');
 | 
|---|
| 500 |   if(p)
 | 
|---|
| 501 |     p++;
 | 
|---|
| 502 |   else
 | 
|---|
| 503 |     p = newPath;
 | 
|---|
| 504 | 
 | 
|---|
| 505 |   /* step through matching files */
 | 
|---|
| 506 |   DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 507 |   if(!DosFindFirst(newPath,
 | 
|---|
| 508 |                   &findHandle,
 | 
|---|
| 509 |                   (FILE_NORMAL | grep->attrFile | grep->antiattr),
 | 
|---|
| 510 |                   findBuffer,
 | 
|---|
| 511 |                   (ULONG)(grep->FilesToGet * sizeof(FILEFINDBUF4)),
 | 
|---|
| 512 |                   (PULONG)&findCount,
 | 
|---|
| 513 |                   FIL_QUERYEASIZE)) {
 | 
|---|
| 514 | 
 | 
|---|
| 515 |     do {   /* Process each file that matches the mask */
 | 
|---|
| 516 |       priority_normal();
 | 
|---|
| 517 |       fb = (PBYTE)findBuffer;
 | 
|---|
| 518 |       for(x = 0L;x < findCount;x++) {
 | 
|---|
| 519 |         pffbFile = (PFILEFINDBUF4)fb;
 | 
|---|
| 520 |         if(*grep->stopflag)
 | 
|---|
| 521 |           break;
 | 
|---|
| 522 |         if(*pffbFile->achName != '.' ||
 | 
|---|
| 523 |            (pffbFile->achName[1] && pffbFile->achName[1] != '.')) {
 | 
|---|
| 524 |           strcpy(p,pffbFile->achName);  /* build filename */
 | 
|---|
| 525 |           if(!grep->anyexcludes ||
 | 
|---|
| 526 |              !IsExcluded(newPath,fle,numfls)) {
 | 
|---|
| 527 |             if(!grep->finddupes)
 | 
|---|
| 528 |               doonefile(grep,
 | 
|---|
| 529 |                         newPath,
 | 
|---|
| 530 |                         pffbFile);
 | 
|---|
| 531 |             else if(!InsertDupe(grep,
 | 
|---|
| 532 |                                 newPath,
 | 
|---|
| 533 |                                 pffbFile)) {
 | 
|---|
| 534 |               DosFindClose(findHandle);
 | 
|---|
| 535 |               free(findBuffer);
 | 
|---|
| 536 |               return 1;
 | 
|---|
| 537 |             }
 | 
|---|
| 538 |           }
 | 
|---|
| 539 |         }
 | 
|---|
| 540 |         if(!pffbFile->oNextEntryOffset)
 | 
|---|
| 541 |           break;
 | 
|---|
| 542 |         fb += pffbFile->oNextEntryOffset;
 | 
|---|
| 543 |       }
 | 
|---|
| 544 |       findCount = grep->FilesToGet;
 | 
|---|
| 545 |       rc = DosFindNext(findHandle,
 | 
|---|
| 546 |                        findBuffer,
 | 
|---|
| 547 |                        (ULONG)(grep->FilesToGet * sizeof(FILEFINDBUF4)),
 | 
|---|
| 548 |                        (PULONG)&findCount);
 | 
|---|
| 549 |       if(!rc)
 | 
|---|
| 550 |         DosSleep(1L);
 | 
|---|
| 551 |     } while(!rc);
 | 
|---|
| 552 |     DosFindClose(findHandle);
 | 
|---|
| 553 |     priority_normal();
 | 
|---|
| 554 |   }
 | 
|---|
| 555 |   free(findBuffer);
 | 
|---|
| 556 |   return 0 ;
 | 
|---|
| 557 | }
 | 
|---|
| 558 | 
 | 
|---|
| 559 | #pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist)
 | 
|---|
| 560 | 
 | 
|---|
| 561 | 
 | 
|---|
| 562 | static VOID freegreplist (GREP *grep)
 | 
|---|
| 563 | {
 | 
|---|
| 564 |   register INT x;
 | 
|---|
| 565 | 
 | 
|---|
| 566 |   if(grep) {
 | 
|---|
| 567 |     if(grep->insertffb) {
 | 
|---|
| 568 |       for(x = 0;grep->insertffb[x];x++)
 | 
|---|
| 569 |         free(grep->insertffb[x]);
 | 
|---|
| 570 |       free(grep->insertffb);
 | 
|---|
| 571 |     }
 | 
|---|
| 572 |     if(grep->dir) {
 | 
|---|
| 573 |       for(x = 0;grep->dir[x];x++)
 | 
|---|
| 574 |         free(grep->dir[x]);
 | 
|---|
| 575 |       free(grep->dir);
 | 
|---|
| 576 |     }
 | 
|---|
| 577 |     grep->dir = NULL;
 | 
|---|
| 578 |     grep->insertffb = NULL;
 | 
|---|
| 579 |     grep->toinsert = 0L;
 | 
|---|
| 580 |     grep->insertedbytes = 0L;
 | 
|---|
| 581 |   }
 | 
|---|
| 582 | }
 | 
|---|
| 583 | 
 | 
|---|
| 584 | 
 | 
|---|
| 585 | static BOOL doinsertion (GREP *grep)
 | 
|---|
| 586 | {
 | 
|---|
| 587 |   RECORDINSERT ri;
 | 
|---|
| 588 |   DIRCNRDATA  *dcd;
 | 
|---|
| 589 |   PCNRITEM     pci,pciFirst;
 | 
|---|
| 590 |   INT          x;
 | 
|---|
| 591 | 
 | 
|---|
| 592 |   if(!grep ||
 | 
|---|
| 593 |      !grep->toinsert ||
 | 
|---|
| 594 |      !grep->insertffb ||
 | 
|---|
| 595 |      !grep->dir)
 | 
|---|
| 596 |     return FALSE;
 | 
|---|
| 597 |   pci = WinSendMsg(grep->hwndFiles,
 | 
|---|
| 598 |                    CM_ALLOCRECORD,
 | 
|---|
| 599 |                    MPFROMLONG(EXTRA_RECORD_BYTES),
 | 
|---|
| 600 |                    MPFROMLONG(grep->toinsert));
 | 
|---|
| 601 |   if(pci) {
 | 
|---|
| 602 |     if(grep->sayfiles)
 | 
|---|
| 603 |       WinSetWindowText(grep->hwndCurFile,
 | 
|---|
| 604 |                        GetPString(IDS_GREPINSERTINGTEXT));
 | 
|---|
| 605 |     pciFirst = pci;
 | 
|---|
| 606 |     dcd = INSTDATA(grep->hwndFiles);
 | 
|---|
| 607 |     for(x = 0; grep->insertffb[x]; x++) {
 | 
|---|
| 608 |       FillInRecordFromFFB(grep->hwndFiles,
 | 
|---|
| 609 |                           pci,
 | 
|---|
| 610 |                           grep->dir[x],
 | 
|---|
| 611 |                           grep->insertffb[x],
 | 
|---|
| 612 |                           FALSE,
 | 
|---|
| 613 |                           dcd);
 | 
|---|
| 614 |       pci = (PCNRITEM) pci->rc.preccNextRecord;
 | 
|---|
| 615 |     }
 | 
|---|
| 616 |     memset(&ri,0,sizeof(RECORDINSERT));
 | 
|---|
| 617 |     ri.cb                 = sizeof(RECORDINSERT);
 | 
|---|
| 618 |     ri.pRecordOrder       = (PRECORDCORE) CMA_END;
 | 
|---|
| 619 |     ri.pRecordParent      = (PRECORDCORE)NULL;
 | 
|---|
| 620 |     ri.zOrder             = (USHORT) CMA_TOP;
 | 
|---|
| 621 |     ri.cRecordsInsert     = grep->toinsert;
 | 
|---|
| 622 |     ri.fInvalidateRecord  = TRUE;
 | 
|---|
| 623 |     WinSendMsg(grep->hwndFiles,
 | 
|---|
| 624 |                CM_INSERTRECORD,
 | 
|---|
| 625 |                MPFROMP(pciFirst),
 | 
|---|
| 626 |                MPFROMP(&ri));
 | 
|---|
| 627 |     if(dcd) {
 | 
|---|
| 628 |       DosEnterCritSec();
 | 
|---|
| 629 |        dcd->ullTotalBytes += grep->insertedbytes;
 | 
|---|
| 630 |       DosExitCritSec();
 | 
|---|
| 631 |     }
 | 
|---|
| 632 |     if(grep->toinsert == grep->FilesToGet)
 | 
|---|
| 633 |       DosSleep(1L);
 | 
|---|
| 634 |     freegreplist(grep);
 | 
|---|
| 635 |     PostMsg(grep->hwndFiles,
 | 
|---|
| 636 |             UM_RESCAN,
 | 
|---|
| 637 |             MPVOID,
 | 
|---|
| 638 |             MPVOID);
 | 
|---|
| 639 |     return TRUE;
 | 
|---|
| 640 |   }
 | 
|---|
| 641 |   freegreplist(grep);
 | 
|---|
| 642 |   return FALSE;
 | 
|---|
| 643 | }
 | 
|---|
| 644 | 
 | 
|---|
| 645 | 
 | 
|---|
| 646 | static BOOL insert_grepfile (GREP *grep,CHAR *filename,FILEFINDBUF4 *f)
 | 
|---|
| 647 | {
 | 
|---|
| 648 |   CHAR        *p,szDirectory[CCHMAXPATH];
 | 
|---|
| 649 | 
 | 
|---|
| 650 |   if(WinIsWindow(grep->ghab,grep->hwndFiles)) {
 | 
|---|
| 651 |     grep->numfiles++;
 | 
|---|
| 652 |     strcpy(szDirectory,filename);
 | 
|---|
| 653 |     p = strrchr(szDirectory,'\\');
 | 
|---|
| 654 |     if(p) {
 | 
|---|
| 655 |       if(p < szDirectory + 4)
 | 
|---|
| 656 |         p++;
 | 
|---|
| 657 |       *p = 0;
 | 
|---|
| 658 |       if(!grep->insertffb) {
 | 
|---|
| 659 |         grep->insertffb = xmallocz(sizeof(FILEFINDBUF4 *) *
 | 
|---|
| 660 |                                    (grep->FilesToGet + 1),pszSrcFile,__LINE__);
 | 
|---|
| 661 |         if(!grep->insertffb)
 | 
|---|
| 662 |           return FALSE;
 | 
|---|
| 663 |         grep->dir = xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1),pszSrcFile,__LINE__);
 | 
|---|
| 664 |         if(!grep->dir) {
 | 
|---|
| 665 |           free(grep->insertffb);
 | 
|---|
| 666 |           return FALSE;
 | 
|---|
| 667 |         }
 | 
|---|
| 668 |       }
 | 
|---|
| 669 |       grep->insertffb[grep->toinsert] = xmalloc(sizeof(FILEFINDBUF4),pszSrcFile,__LINE__);
 | 
|---|
| 670 |       if(!grep->insertffb[grep->toinsert])
 | 
|---|
| 671 |         return FALSE;
 | 
|---|
| 672 |       memcpy(grep->insertffb[grep->toinsert],f,sizeof(FILEFINDBUF4));
 | 
|---|
| 673 |       grep->dir[grep->toinsert] = xstrdup(szDirectory,pszSrcFile,__LINE__);
 | 
|---|
| 674 |       if(!grep->dir) {
 | 
|---|
| 675 |         free(grep->insertffb[grep->toinsert]);
 | 
|---|
| 676 |         return FALSE;
 | 
|---|
| 677 |       }
 | 
|---|
| 678 |       grep->insertedbytes += f->cbFile + CBLIST_TO_EASIZE(f->cbList);
 | 
|---|
| 679 |       grep->toinsert++;
 | 
|---|
| 680 |       if(grep->toinsert == grep->FilesToGet)
 | 
|---|
| 681 |         return doinsertion(grep);
 | 
|---|
| 682 |       return TRUE;
 | 
|---|
| 683 |     }
 | 
|---|
| 684 |   }
 | 
|---|
| 685 |   else
 | 
|---|
| 686 |     freegreplist(grep);
 | 
|---|
| 687 |   return FALSE;
 | 
|---|
| 688 | }
 | 
|---|
| 689 | 
 | 
|---|
| 690 | 
 | 
|---|
| 691 | static BOOL doonefile (GREP *grep,CHAR *filename,FILEFINDBUF4 *f)
 | 
|---|
| 692 | {
 | 
|---|
| 693 |   /* process a single file */
 | 
|---|
| 694 | 
 | 
|---|
| 695 |   CHAR           *input;
 | 
|---|
| 696 |   FILE           *inputFile;
 | 
|---|
| 697 |   ULONG           pos;
 | 
|---|
| 698 |   BOOL            ret = FALSE,strmatch = FALSE;
 | 
|---|
| 699 | 
 | 
|---|
| 700 |   grep->fileCount++;
 | 
|---|
| 701 |   if(grep->sayfiles)
 | 
|---|
| 702 |     WinSetWindowText(grep->hwndCurFile,
 | 
|---|
| 703 |                      filename);
 | 
|---|
| 704 | 
 | 
|---|
| 705 |   if(grep->greaterthan || grep->lessthan) {
 | 
|---|
| 706 | 
 | 
|---|
| 707 |     BOOL  keep = TRUE;
 | 
|---|
| 708 |     ULONG adjsize;
 | 
|---|
| 709 | 
 | 
|---|
| 710 |     adjsize = f->cbFile +
 | 
|---|
| 711 |               (grep->searchEAs ? CBLIST_TO_EASIZE(f->cbList) : 0);
 | 
|---|
| 712 |     if(grep->greaterthan) {
 | 
|---|
| 713 |       if(adjsize < grep->greaterthan)
 | 
|---|
| 714 |         keep = FALSE;
 | 
|---|
| 715 |     }
 | 
|---|
| 716 |     if(keep && grep->lessthan) {
 | 
|---|
| 717 |       if(adjsize > grep->lessthan)
 | 
|---|
| 718 |         keep = FALSE;
 | 
|---|
| 719 |     }
 | 
|---|
| 720 |     if(!keep)
 | 
|---|
| 721 |       return ret;
 | 
|---|
| 722 |   }
 | 
|---|
| 723 | 
 | 
|---|
| 724 |   if(grep->newerthan || grep->olderthan) {
 | 
|---|
| 725 | 
 | 
|---|
| 726 |     BOOL  keep = TRUE;
 | 
|---|
| 727 |     ULONG numsecs;
 | 
|---|
| 728 | 
 | 
|---|
| 729 |     numsecs = SecsSince1980(&f->fdateLastWrite,
 | 
|---|
| 730 |                             &f->ftimeLastWrite);
 | 
|---|
| 731 |     if(grep->newerthan) {
 | 
|---|
| 732 |       if(numsecs < grep->newerthan)
 | 
|---|
| 733 |         keep = FALSE;
 | 
|---|
| 734 |     }
 | 
|---|
| 735 |     if(keep && grep->olderthan) {
 | 
|---|
| 736 |       if(numsecs > grep->olderthan)
 | 
|---|
| 737 |         keep = FALSE;
 | 
|---|
| 738 |     }
 | 
|---|
| 739 |     if(!keep)
 | 
|---|
| 740 |       return ret;
 | 
|---|
| 741 |   }
 | 
|---|
| 742 | 
 | 
|---|
| 743 |   if((!grep->searchEAs && !grep->searchFiles) ||
 | 
|---|
| 744 |       !*grep->searchPattern)    /* just a find */
 | 
|---|
| 745 |     return insert_grepfile(grep,filename,f);
 | 
|---|
| 746 | 
 | 
|---|
| 747 |   if(grep->searchEAs) {
 | 
|---|
| 748 | 
 | 
|---|
| 749 |     HOLDFEA *head,*info;
 | 
|---|
| 750 |     USHORT  type,len;
 | 
|---|
| 751 |     BOOL    alltext;
 | 
|---|
| 752 |     CHAR    *data,temp;
 | 
|---|
| 753 | 
 | 
|---|
| 754 |     head = GetFileEAs(filename,FALSE,TRUE);
 | 
|---|
| 755 |     if(head) {
 | 
|---|
| 756 |       info = head;
 | 
|---|
| 757 |       while(info && !strmatch) {
 | 
|---|
| 758 |         alltext = TRUE;
 | 
|---|
| 759 |         switch(*(USHORT *)info->value) {
 | 
|---|
| 760 |           case EAT_ASCII:
 | 
|---|
| 761 |             if(match(info->value + (sizeof(USHORT) * 2),
 | 
|---|
| 762 |                      grep->searchPattern,grep->absFlag,
 | 
|---|
| 763 |                      (grep->caseFlag == FALSE),
 | 
|---|
| 764 |                      info->cbValue - (sizeof(USHORT) * 2),
 | 
|---|
| 765 |                      grep->numlines,
 | 
|---|
| 766 |                      grep->matched,
 | 
|---|
| 767 |                      !grep->findifany)) {
 | 
|---|
| 768 |               strmatch = TRUE;
 | 
|---|
| 769 |             }
 | 
|---|
| 770 |             break;
 | 
|---|
| 771 |           case EAT_MVST:
 | 
|---|
| 772 |             type = *(USHORT *)(info->value + (sizeof(USHORT) * 3));
 | 
|---|
| 773 |             if(type == EAT_ASCII) {
 | 
|---|
| 774 |               data = info->value + (sizeof(USHORT) * 4);
 | 
|---|
| 775 |               len = *(USHORT *)data;
 | 
|---|
| 776 |               data += sizeof(USHORT);
 | 
|---|
| 777 |               while((data - info->value) + len <=
 | 
|---|
| 778 |                     info->cbValue) {
 | 
|---|
| 779 |                 temp = *(data + len);
 | 
|---|
| 780 |                 *(data + len) = 0;
 | 
|---|
| 781 |                 if(match(data,
 | 
|---|
| 782 |                          grep->searchPattern,
 | 
|---|
| 783 |                          grep->absFlag,
 | 
|---|
| 784 |                          (grep->caseFlag == FALSE),
 | 
|---|
| 785 |                          len,
 | 
|---|
| 786 |                          grep->numlines,
 | 
|---|
| 787 |                          grep->matched,
 | 
|---|
| 788 |                          !grep->findifany)) {
 | 
|---|
| 789 |                   strmatch = TRUE;
 | 
|---|
| 790 |                   break;
 | 
|---|
| 791 |                 }
 | 
|---|
| 792 |                 data += len;
 | 
|---|
| 793 |                 if(data - info->value >= info->cbValue)
 | 
|---|
| 794 |                   break;
 | 
|---|
| 795 |                 *data = temp;
 | 
|---|
| 796 |                 len = *(USHORT *)data;
 | 
|---|
| 797 |                 data += sizeof(USHORT);
 | 
|---|
| 798 |               }
 | 
|---|
| 799 |             }
 | 
|---|
| 800 |             break;
 | 
|---|
| 801 |           case EAT_MVMT:
 | 
|---|
| 802 |             data = info->value + (sizeof(USHORT) * 3);
 | 
|---|
| 803 |             type = *(USHORT *)data;
 | 
|---|
| 804 |             data += sizeof(USHORT);
 | 
|---|
| 805 |             len = *(USHORT *)data;
 | 
|---|
| 806 |             data += sizeof(USHORT);
 | 
|---|
| 807 |             while((data - info->value) - len <=
 | 
|---|
| 808 |                   info->cbValue) {
 | 
|---|
| 809 |               if(type != EAT_ASCII) {
 | 
|---|
| 810 |                 alltext = FALSE;
 | 
|---|
| 811 |                 break;
 | 
|---|
| 812 |               }
 | 
|---|
| 813 |               data += len;
 | 
|---|
| 814 |               if(data - info->value >= info->cbValue)
 | 
|---|
| 815 |                 break;
 | 
|---|
| 816 |               type = *(USHORT *)data;
 | 
|---|
| 817 |               data += sizeof(USHORT);
 | 
|---|
| 818 |               len = *(USHORT *)data;
 | 
|---|
| 819 |               data += sizeof(USHORT);
 | 
|---|
| 820 |             }
 | 
|---|
| 821 |             if(alltext) {
 | 
|---|
| 822 |               data = info->value + (sizeof(USHORT) * 3);
 | 
|---|
| 823 |               type = *(USHORT *)data;
 | 
|---|
| 824 |               data += sizeof(USHORT);
 | 
|---|
| 825 |               len = *(USHORT *)data;
 | 
|---|
| 826 |               data += sizeof(USHORT);
 | 
|---|
| 827 |               while((data - info->value) - len <=
 | 
|---|
| 828 |                     info->cbValue) {
 | 
|---|
| 829 |                 temp = *(data + len);
 | 
|---|
| 830 |                 *(data + len) = 0;
 | 
|---|
| 831 |                 if(match(data,
 | 
|---|
| 832 |                          grep->searchPattern,
 | 
|---|
| 833 |                          grep->absFlag,
 | 
|---|
| 834 |                          (grep->caseFlag == FALSE),
 | 
|---|
| 835 |                          len,
 | 
|---|
| 836 |                          grep->numlines,
 | 
|---|
| 837 |                          grep->matched,
 | 
|---|
| 838 |                          !grep->findifany)) {
 | 
|---|
| 839 |                   strmatch = TRUE;
 | 
|---|
| 840 |                   break;
 | 
|---|
| 841 |                 }
 | 
|---|
| 842 |                 data += len;
 | 
|---|
| 843 |                 *data = temp;
 | 
|---|
| 844 |                 if(data - info->value >= info->cbValue)
 | 
|---|
| 845 |                   break;
 | 
|---|
| 846 |                 type = *(USHORT *)data;
 | 
|---|
| 847 |                 data += sizeof(USHORT);
 | 
|---|
| 848 |                 len = *(USHORT *)data;
 | 
|---|
| 849 |                 data += sizeof(USHORT);
 | 
|---|
| 850 |               }
 | 
|---|
| 851 |             }
 | 
|---|
| 852 |             break;
 | 
|---|
| 853 |           default:
 | 
|---|
| 854 |             break;
 | 
|---|
| 855 |         }
 | 
|---|
| 856 |         info = info->next;
 | 
|---|
| 857 |       } // while
 | 
|---|
| 858 |       Free_FEAList(head);
 | 
|---|
| 859 |       DosSleep(1L);
 | 
|---|
| 860 |     }
 | 
|---|
| 861 |   }
 | 
|---|
| 862 | 
 | 
|---|
| 863 |   if(grep->searchFiles) {
 | 
|---|
| 864 |     input = xmalloc(65537,pszSrcFile,__LINE__);
 | 
|---|
| 865 |     if(input) {
 | 
|---|
| 866 |       LONG len;
 | 
|---|
| 867 |       inputFile = _fsopen(filename,"rb",SH_DENYNO);
 | 
|---|
| 868 |       if (inputFile) {
 | 
|---|
| 869 |         pos = ftell(inputFile);
 | 
|---|
| 870 |         while(!feof(inputFile)) {
 | 
|---|
| 871 |           if(pos)
 | 
|---|
| 872 |             fseek(inputFile,pos - 1024,SEEK_SET);
 | 
|---|
| 873 |           len = fread(input,1,65536,inputFile);
 | 
|---|
| 874 |           if(len >= 0) {
 | 
|---|
| 875 |             if(*grep->stopflag)
 | 
|---|
| 876 |               break;
 | 
|---|
| 877 |             if(match(input,
 | 
|---|
| 878 |                      grep->searchPattern,
 | 
|---|
| 879 |                      grep->absFlag,
 | 
|---|
| 880 |                      (grep->caseFlag == FALSE),
 | 
|---|
| 881 |                      len,
 | 
|---|
| 882 |                      grep->numlines,
 | 
|---|
| 883 |                      grep->matched,
 | 
|---|
| 884 |                      !grep->findifany)) {
 | 
|---|
| 885 |               strmatch = TRUE;
 | 
|---|
| 886 |               break;
 | 
|---|
| 887 |             }
 | 
|---|
| 888 |           }
 | 
|---|
| 889 |           else
 | 
|---|
| 890 |             break;
 | 
|---|
| 891 |         }
 | 
|---|
| 892 |         fclose(inputFile) ;
 | 
|---|
| 893 |       }
 | 
|---|
| 894 |       free(input);
 | 
|---|
| 895 |       DosSleep(1L);
 | 
|---|
| 896 |     }
 | 
|---|
| 897 |   }
 | 
|---|
| 898 | 
 | 
|---|
| 899 | Match:
 | 
|---|
| 900 | 
 | 
|---|
| 901 |   if(strmatch)
 | 
|---|
| 902 |     ret = insert_grepfile(grep,
 | 
|---|
| 903 |                           filename,
 | 
|---|
| 904 |                           f);
 | 
|---|
| 905 |   return ret;
 | 
|---|
| 906 | }
 | 
|---|
| 907 | 
 | 
|---|
| 908 | 
 | 
|---|
| 909 | #pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock)
 | 
|---|
| 910 | #pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb)
 | 
|---|
| 911 | #pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb)
 | 
|---|
| 912 | 
 | 
|---|
| 913 | static LONG cr3tab[] = {    /* CRC polynomial 0xEDB88320 */
 | 
|---|
| 914 | 
 | 
|---|
| 915 |   0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
 | 
|---|
| 916 |   0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
 | 
|---|
| 917 |   0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
 | 
|---|
| 918 |   0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
 | 
|---|
| 919 |   0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
 | 
|---|
| 920 |   0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
 | 
|---|
| 921 |   0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
 | 
|---|
| 922 |   0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
 | 
|---|
| 923 |   0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
 | 
|---|
| 924 |   0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
 | 
|---|
| 925 |   0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
 | 
|---|
| 926 |   0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
 | 
|---|
| 927 |   0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
 | 
|---|
| 928 |   0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
 | 
|---|
| 929 |   0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
 | 
|---|
| 930 |   0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
 | 
|---|
| 931 |   0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
 | 
|---|
| 932 |   0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
 | 
|---|
| 933 |   0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
 | 
|---|
| 934 |   0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
 | 
|---|
| 935 |   0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
 | 
|---|
| 936 |   0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
 | 
|---|
| 937 |   0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
 | 
|---|
| 938 |   0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
 | 
|---|
| 939 |   0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
 | 
|---|
| 940 |   0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
 | 
|---|
| 941 |   0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
 | 
|---|
| 942 |   0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
 | 
|---|
| 943 |   0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
 | 
|---|
| 944 |   0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
 | 
|---|
| 945 |   0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
 | 
|---|
| 946 |   0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
 | 
|---|
| 947 |   0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
 | 
|---|
| 948 |   0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
 | 
|---|
| 949 |   0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
 | 
|---|
| 950 |   0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
 | 
|---|
| 951 |   0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
 | 
|---|
| 952 |   0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
 | 
|---|
| 953 |   0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
 | 
|---|
| 954 |   0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
 | 
|---|
| 955 |   0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
 | 
|---|
| 956 |   0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
 | 
|---|
| 957 |   0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
 | 
|---|
| 958 |   0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
 | 
|---|
| 959 |   0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
 | 
|---|
| 960 |   0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
 | 
|---|
| 961 |   0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
 | 
|---|
| 962 |   0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
 | 
|---|
| 963 |   0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
 | 
|---|
| 964 |   0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
 | 
|---|
| 965 |   0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
 | 
|---|
| 966 |   0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
 | 
|---|
| 967 |   0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
 | 
|---|
| 968 |   0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
 | 
|---|
| 969 |   0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
 | 
|---|
| 970 |   0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
 | 
|---|
| 971 |   0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
 | 
|---|
| 972 |   0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
 | 
|---|
| 973 |   0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
 | 
|---|
| 974 |   0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
 | 
|---|
| 975 |   0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
 | 
|---|
| 976 |   0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
 | 
|---|
| 977 |   0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
 | 
|---|
| 978 |   0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
 | 
|---|
| 979 | };
 | 
|---|
| 980 | 
 | 
|---|
| 981 | 
 | 
|---|
| 982 | LONG CRCBlock (register CHAR *str, register INT blklen, register LONG crc)
 | 
|---|
| 983 | {
 | 
|---|
| 984 |   while (blklen--) {
 | 
|---|
| 985 |     crc = cr3tab[((INT) crc ^ *str) & 0xff] ^ (((ULONG)crc >> 8) & 0x00FFFFFF);
 | 
|---|
| 986 |     str++;
 | 
|---|
| 987 |   }
 | 
|---|
| 988 |   return crc;
 | 
|---|
| 989 | }
 | 
|---|
| 990 | 
 | 
|---|
| 991 | 
 | 
|---|
| 992 | LONG CRCFile (CHAR *filename,INT *error)
 | 
|---|
| 993 | {
 | 
|---|
| 994 |   LONG CRC = -1L,len;
 | 
|---|
| 995 |   FILE *fp;
 | 
|---|
| 996 |   CHAR *buffer;
 | 
|---|
| 997 | 
 | 
|---|
| 998 |   *error = 0;
 | 
|---|
| 999 |   buffer = xmalloc(65535,pszSrcFile,__LINE__);
 | 
|---|
| 1000 |   if (!buffer)
 | 
|---|
| 1001 |     *error = -1;
 | 
|---|
| 1002 |   else {
 | 
|---|
| 1003 |     fp = _fsopen(filename,"rb",SH_DENYNO);
 | 
|---|
| 1004 |     if (!fp)
 | 
|---|
| 1005 |       *error = -2;
 | 
|---|
| 1006 |     else {
 | 
|---|
| 1007 |       while(!feof(fp)) {
 | 
|---|
| 1008 |         len = fread(buffer,1,65535,fp);
 | 
|---|
| 1009 |         if(len && len < 65536L)
 | 
|---|
| 1010 |           CRC = CRCBlock(buffer,len,CRC);
 | 
|---|
| 1011 |         else
 | 
|---|
| 1012 |           break;
 | 
|---|
| 1013 |         DosSleep(0L);
 | 
|---|
| 1014 |       }
 | 
|---|
| 1015 |       fclose(fp);
 | 
|---|
| 1016 |       DosSleep(1L);
 | 
|---|
| 1017 |     }
 | 
|---|
| 1018 |     free(buffer);
 | 
|---|
| 1019 |   }
 | 
|---|
| 1020 |   return CRC;
 | 
|---|
| 1021 | }
 | 
|---|
| 1022 | 
 | 
|---|
| 1023 | 
 | 
|---|
| 1024 | static VOID FreeDupes (GREP *g)
 | 
|---|
| 1025 | {
 | 
|---|
| 1026 |   DUPES *i,*next;
 | 
|---|
| 1027 | 
 | 
|---|
| 1028 |   i = g->dupehead;
 | 
|---|
| 1029 |   while(i) {
 | 
|---|
| 1030 |     next = i->next;
 | 
|---|
| 1031 |     if(i->name)
 | 
|---|
| 1032 |       free(i->name);
 | 
|---|
| 1033 |     free(i);
 | 
|---|
| 1034 |     i = next;
 | 
|---|
| 1035 |   }
 | 
|---|
| 1036 |   g->dupehead = g->dupelast = NULL;
 | 
|---|
| 1037 |   if(g->dupenames)
 | 
|---|
| 1038 |     free(g->dupenames);
 | 
|---|
| 1039 |   if(g->dupesizes)
 | 
|---|
| 1040 |     free(g->dupesizes);
 | 
|---|
| 1041 |   g->dupesizes = g->dupenames = NULL;
 | 
|---|
| 1042 | }
 | 
|---|
| 1043 | 
 | 
|---|
| 1044 | 
 | 
|---|
| 1045 | int comparenamesq (const void *v1,const void *v2)
 | 
|---|
| 1046 | {
 | 
|---|
| 1047 |   DUPES *d1 = *(DUPES **)v1;
 | 
|---|
| 1048 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1049 |   CHAR  *p1,*p2;
 | 
|---|
| 1050 | 
 | 
|---|
| 1051 |   p1 = strrchr(d1->name,'\\');
 | 
|---|
| 1052 |   if(p1)
 | 
|---|
| 1053 |     p1++;
 | 
|---|
| 1054 |   else
 | 
|---|
| 1055 |     p1 = d1->name;
 | 
|---|
| 1056 |   p2 = strrchr(d2->name,'\\');
 | 
|---|
| 1057 |   if(p2)
 | 
|---|
| 1058 |     p2++;
 | 
|---|
| 1059 |   else
 | 
|---|
| 1060 |     p2 = d2->name;
 | 
|---|
| 1061 |   return stricmp(p1,p2);
 | 
|---|
| 1062 | }
 | 
|---|
| 1063 | 
 | 
|---|
| 1064 | 
 | 
|---|
| 1065 | int comparenamesqe (const void *v1,const void *v2)
 | 
|---|
| 1066 | {
 | 
|---|
| 1067 |   DUPES *d1 = *(DUPES **)v1;
 | 
|---|
| 1068 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1069 |   CHAR  *p1,*p2,*p1e,*p2e,e1,e2;
 | 
|---|
| 1070 |   int    ret;
 | 
|---|
| 1071 | 
 | 
|---|
| 1072 |   p1 = strrchr(d1->name,'\\');
 | 
|---|
| 1073 |   if(p1)
 | 
|---|
| 1074 |     p1++;
 | 
|---|
| 1075 |   else
 | 
|---|
| 1076 |     p1 = d1->name;
 | 
|---|
| 1077 |   p1e = strrchr(p1,'.');
 | 
|---|
| 1078 |   if(p1e) {
 | 
|---|
| 1079 |     e1 = *p1e;
 | 
|---|
| 1080 |     *p1e = 0;
 | 
|---|
| 1081 |   }
 | 
|---|
| 1082 |   p2 = strrchr(d2->name,'\\');
 | 
|---|
| 1083 |   if(p2)
 | 
|---|
| 1084 |     p2++;
 | 
|---|
| 1085 |   else
 | 
|---|
| 1086 |     p2 = d2->name;
 | 
|---|
| 1087 |   p2e = strrchr(p2,'.');
 | 
|---|
| 1088 |   if(p2e) {
 | 
|---|
| 1089 |     e2 = *p2e;
 | 
|---|
| 1090 |     *p2e = 0;
 | 
|---|
| 1091 |   }
 | 
|---|
| 1092 |   ret = stricmp(p1,p2);
 | 
|---|
| 1093 |   if(p1e)
 | 
|---|
| 1094 |     *p1e = e1;
 | 
|---|
| 1095 |   if(p2e)
 | 
|---|
| 1096 |     *p2e = e2;
 | 
|---|
| 1097 |   return ret;
 | 
|---|
| 1098 | }
 | 
|---|
| 1099 | 
 | 
|---|
| 1100 | 
 | 
|---|
| 1101 | int comparesizesq (const void *v1,const void *v2)
 | 
|---|
| 1102 | {
 | 
|---|
| 1103 |   DUPES *d1 = *(DUPES **)v1;
 | 
|---|
| 1104 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1105 | 
 | 
|---|
| 1106 |   return (d1->size > d2->size) ? 1 : (d1->size == d2->size) ? 0 : -1;
 | 
|---|
| 1107 | }
 | 
|---|
| 1108 | 
 | 
|---|
| 1109 | 
 | 
|---|
| 1110 | int comparenamesb (const void *v1,const void *v2)
 | 
|---|
| 1111 | {
 | 
|---|
| 1112 |   DUPES *d1 = (DUPES *)v1;
 | 
|---|
| 1113 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1114 |   CHAR  *p1,*p2;
 | 
|---|
| 1115 | 
 | 
|---|
| 1116 |   p1 = strrchr(d1->name,'\\');
 | 
|---|
| 1117 |   if(p1)
 | 
|---|
| 1118 |     p1++;
 | 
|---|
| 1119 |   else
 | 
|---|
| 1120 |     p1 = d1->name;
 | 
|---|
| 1121 |   p2 = strrchr(d2->name,'\\');
 | 
|---|
| 1122 |   if(p2)
 | 
|---|
| 1123 |     p2++;
 | 
|---|
| 1124 |   else
 | 
|---|
| 1125 |     p2 = d2->name;
 | 
|---|
| 1126 |   return stricmp(p1,p2);
 | 
|---|
| 1127 | }
 | 
|---|
| 1128 | 
 | 
|---|
| 1129 | 
 | 
|---|
| 1130 | int comparenamesbe (const void *v1,const void *v2)
 | 
|---|
| 1131 | {
 | 
|---|
| 1132 |   DUPES *d1 = (DUPES *)v1;
 | 
|---|
| 1133 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1134 |   CHAR  *p1,*p2,*p1e,*p2e,e1,e2;
 | 
|---|
| 1135 |   int    ret;
 | 
|---|
| 1136 | 
 | 
|---|
| 1137 |   p1 = strrchr(d1->name,'\\');
 | 
|---|
| 1138 |   if(p1)
 | 
|---|
| 1139 |     p1++;
 | 
|---|
| 1140 |   else
 | 
|---|
| 1141 |     p1 = d1->name;
 | 
|---|
| 1142 |   p1e = strrchr(p1,'.');
 | 
|---|
| 1143 |   if(p1e) {
 | 
|---|
| 1144 |     e1 = *p1e;
 | 
|---|
| 1145 |     *p1e = 0;
 | 
|---|
| 1146 |   }
 | 
|---|
| 1147 |   p2 = strrchr(d2->name,'\\');
 | 
|---|
| 1148 |   if(p2)
 | 
|---|
| 1149 |     p2++;
 | 
|---|
| 1150 |   else
 | 
|---|
| 1151 |     p2 = d2->name;
 | 
|---|
| 1152 |   p2e = strrchr(p2,'.');
 | 
|---|
| 1153 |   if(p2e) {
 | 
|---|
| 1154 |     e2 = *p2e;
 | 
|---|
| 1155 |     *p2e = 0;
 | 
|---|
| 1156 |   }
 | 
|---|
| 1157 |   ret = stricmp(p1,p2);
 | 
|---|
| 1158 |   if(p1e)
 | 
|---|
| 1159 |     *p1e = e1;
 | 
|---|
| 1160 |   if(p2e)
 | 
|---|
| 1161 |     *p2e = e2;
 | 
|---|
| 1162 |   return ret;
 | 
|---|
| 1163 | }
 | 
|---|
| 1164 | 
 | 
|---|
| 1165 | 
 | 
|---|
| 1166 | int comparesizesb (const void *v1,const void *v2)
 | 
|---|
| 1167 | {
 | 
|---|
| 1168 |   DUPES *d1 = (DUPES *)v1;
 | 
|---|
| 1169 |   DUPES *d2 = *(DUPES **)v2;
 | 
|---|
| 1170 | 
 | 
|---|
| 1171 |   return (d1->size > d2->size) ? 1 : (d1->size == d2->size) ? 0 : -1;
 | 
|---|
| 1172 | }
 | 
|---|
| 1173 | 
 | 
|---|
| 1174 | 
 | 
|---|
| 1175 | static VOID FillDupes (GREP *g)
 | 
|---|
| 1176 | {
 | 
|---|
| 1177 |   DUPES         *c,*i,**r;
 | 
|---|
| 1178 |   register CHAR *pc,*pi;
 | 
|---|
| 1179 |   CHAR         **list = NULL;
 | 
|---|
| 1180 |   INT            numfiles = 0,numalloced = 0,error;
 | 
|---|
| 1181 |   register ULONG x = 0L,y = 0L;
 | 
|---|
| 1182 |   ULONG          cntr = 100;
 | 
|---|
| 1183 | 
 | 
|---|
| 1184 |   if(g->CRCdupes)
 | 
|---|
| 1185 |     cntr = 50;
 | 
|---|
| 1186 |   i = g->dupehead;
 | 
|---|
| 1187 |   while (i) {
 | 
|---|
| 1188 |     x++;
 | 
|---|
| 1189 |     i = i->next;
 | 
|---|
| 1190 |   }
 | 
|---|
| 1191 |   if (x) {
 | 
|---|
| 1192 |     WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1193 |                      GetPString(IDS_GREPDUPESORTINGTEXT));
 | 
|---|
| 1194 |     DosSleep(1L);
 | 
|---|
| 1195 |     g->dupenames = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
 | 
|---|
| 1196 |     if (!g->nosizedupes)
 | 
|---|
| 1197 |       g->dupesizes = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
 | 
|---|
| 1198 |     if (g->dupenames && (g->nosizedupes || g->dupesizes)) {
 | 
|---|
| 1199 |       i = g->dupehead;
 | 
|---|
| 1200 |       while(i) {
 | 
|---|
| 1201 |         g->dupenames[y] = i;
 | 
|---|
| 1202 |         if(!g->nosizedupes)
 | 
|---|
| 1203 |           g->dupesizes[y] = i;
 | 
|---|
| 1204 |         i = i->next;
 | 
|---|
| 1205 |         y++;
 | 
|---|
| 1206 |       }
 | 
|---|
| 1207 |       g->dupenames[y] = NULL;
 | 
|---|
| 1208 |       if (!g->nosizedupes)
 | 
|---|
| 1209 |         g->dupesizes[y] = NULL;
 | 
|---|
| 1210 |       DosSleep(1L);
 | 
|---|
| 1211 |       qsort(g->dupenames,
 | 
|---|
| 1212 |             x,
 | 
|---|
| 1213 |             sizeof(DUPES *),
 | 
|---|
| 1214 |             ((g->ignoreextdupes) ?
 | 
|---|
| 1215 |              comparenamesqe :
 | 
|---|
| 1216 |              comparenamesq));
 | 
|---|
| 1217 |       DosSleep(1L);
 | 
|---|
| 1218 |       if (!g->nosizedupes) {
 | 
|---|
| 1219 |         qsort(g->dupesizes,
 | 
|---|
| 1220 |               x,
 | 
|---|
| 1221 |               sizeof(DUPES *),
 | 
|---|
| 1222 |               comparesizesq);
 | 
|---|
| 1223 |         DosSleep(1L);
 | 
|---|
| 1224 |       }
 | 
|---|
| 1225 |       WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1226 |                        GetPString(IDS_GREPDUPECOMPARINGTEXT));
 | 
|---|
| 1227 | 
 | 
|---|
| 1228 |       i = g->dupehead;
 | 
|---|
| 1229 |       y = 0L;
 | 
|---|
| 1230 |       while(i) {
 | 
|---|
| 1231 |         if(*g->stopflag)
 | 
|---|
| 1232 |           break;
 | 
|---|
| 1233 |         if(!(i->flags & GF_SKIPME)) {
 | 
|---|
| 1234 |           r = (DUPES **)bsearch(i,g->dupenames,x,sizeof(DUPES *),
 | 
|---|
| 1235 |                                 ((g->ignoreextdupes) ? comparenamesbe :
 | 
|---|
| 1236 |                                  comparenamesb));
 | 
|---|
| 1237 |           if(r) {
 | 
|---|
| 1238 |             while(r > g->dupenames && ((g->ignoreextdupes) ?
 | 
|---|
| 1239 |                   !comparenamesqe((r - 1),&i) :
 | 
|---|
| 1240 |                   !comparenamesq((r - 1),&i)))
 | 
|---|
| 1241 |               r--;
 | 
|---|
| 1242 |             while(*r && ((g->ignoreextdupes) ?
 | 
|---|
| 1243 |                          !comparenamesqe(r,&i) :
 | 
|---|
| 1244 |                          !comparenamesq(r,&i))) {
 | 
|---|
| 1245 |               if(*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME))) {
 | 
|---|
| 1246 |                 r++;
 | 
|---|
| 1247 |                 continue;
 | 
|---|
| 1248 |               }
 | 
|---|
| 1249 |               if(g->CRCdupes) {
 | 
|---|
| 1250 |                 if((*r)->CRC == -1L) {
 | 
|---|
| 1251 |                   (*r)->CRC = CRCFile((*r)->name,&error);
 | 
|---|
| 1252 |                   if(error)
 | 
|---|
| 1253 |                     (*r)->CRC = -1L;
 | 
|---|
| 1254 |                   else if((*r)->CRC == -1L)
 | 
|---|
| 1255 |                     (*r)->CRC = 0L;
 | 
|---|
| 1256 |                 }
 | 
|---|
| 1257 |                 if(i->CRC == -1L) {
 | 
|---|
| 1258 |                   i->CRC = CRCFile(i->name,&error);
 | 
|---|
| 1259 |                   if(error)
 | 
|---|
| 1260 |                     i->CRC = -1L;
 | 
|---|
| 1261 |                   else if(i->CRC == -1L)
 | 
|---|
| 1262 |                     i->CRC = 0L;
 | 
|---|
| 1263 |                 }
 | 
|---|
| 1264 |                 if(((*r)->size != i->size) || ((*r)->CRC != -1L &&
 | 
|---|
| 1265 |                    i->CRC != -1L && (*r)->CRC != i->CRC)) {
 | 
|---|
| 1266 |                   r++;
 | 
|---|
| 1267 |                   continue;
 | 
|---|
| 1268 |                 }
 | 
|---|
| 1269 |               }
 | 
|---|
| 1270 |               if(!AddToList((*r)->name,
 | 
|---|
| 1271 |                             &list,
 | 
|---|
| 1272 |                             &numfiles,
 | 
|---|
| 1273 |                             &numalloced)) {
 | 
|---|
| 1274 |                 (*r)->flags |= GF_INSERTED;
 | 
|---|
| 1275 |                 if(g->sayfiles)
 | 
|---|
| 1276 |                   WinSetWindowText(g->hwndFiles,
 | 
|---|
| 1277 |                                    (*r)->name);
 | 
|---|
| 1278 |                 if((*r)->size == i->size &&
 | 
|---|
| 1279 |                    (i->date.year == (*r)->date.year &&
 | 
|---|
| 1280 |                     i->date.month == (*r)->date.month &&
 | 
|---|
| 1281 |                     i->date.day == (*r)->date.day &&
 | 
|---|
| 1282 |                     i->time.hours == (*r)->time.hours &&
 | 
|---|
| 1283 |                     i->time.minutes == (*r)->time.minutes &&
 | 
|---|
| 1284 |                     i->time.twosecs == (*r)->time.twosecs))
 | 
|---|
| 1285 |                   (*r)->flags |= GF_SKIPME;
 | 
|---|
| 1286 |               }
 | 
|---|
| 1287 |               if(!(i->flags & (GF_INSERTED | GF_SKIPME))) {
 | 
|---|
| 1288 |                 if(!AddToList(i->name,
 | 
|---|
| 1289 |                               &list,
 | 
|---|
| 1290 |                               &numfiles,
 | 
|---|
| 1291 |                               &numalloced)) {
 | 
|---|
| 1292 |                   i->flags |= GF_INSERTED;
 | 
|---|
| 1293 |                   if((*r)->flags & GF_SKIPME)
 | 
|---|
| 1294 |                     i->flags |= GF_SKIPME;
 | 
|---|
| 1295 |                 }
 | 
|---|
| 1296 |               }
 | 
|---|
| 1297 |               r++;
 | 
|---|
| 1298 |             }
 | 
|---|
| 1299 |           }
 | 
|---|
| 1300 |           if(!g->nosizedupes) {
 | 
|---|
| 1301 |             r = (DUPES **)bsearch(i,
 | 
|---|
| 1302 |                                   g->dupesizes,
 | 
|---|
| 1303 |                                   x,
 | 
|---|
| 1304 |                                   sizeof(DUPES *),
 | 
|---|
| 1305 |                                   comparesizesb);
 | 
|---|
| 1306 |             if(r) {
 | 
|---|
| 1307 |               while(r > g->dupesizes && !comparesizesq((r - 1),&i))
 | 
|---|
| 1308 |                 r--;
 | 
|---|
| 1309 |               while(*r && !comparesizesq(r,&i)) {
 | 
|---|
| 1310 |                 if(*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME)) ||
 | 
|---|
| 1311 |                    (i->date.year != (*r)->date.year ||
 | 
|---|
| 1312 |                     i->date.month != (*r)->date.month ||
 | 
|---|
| 1313 |                     i->date.day != (*r)->date.day ||
 | 
|---|
| 1314 |                     i->time.hours != (*r)->time.hours ||
 | 
|---|
| 1315 |                     i->time.minutes != (*r)->time.minutes ||
 | 
|---|
| 1316 |                     i->time.twosecs != (*r)->time.twosecs)) {
 | 
|---|
| 1317 |                   r++;
 | 
|---|
| 1318 |                   continue;
 | 
|---|
| 1319 |                 }
 | 
|---|
| 1320 |                 if(g->CRCdupes) {
 | 
|---|
| 1321 |                   if((*r)->CRC == -1L) {
 | 
|---|
| 1322 |                     (*r)->CRC = CRCFile((*r)->name,&error);
 | 
|---|
| 1323 |                     if(error)
 | 
|---|
| 1324 |                       (*r)->CRC = -1L;
 | 
|---|
| 1325 |                     else if((*r)->CRC == -1L)
 | 
|---|
| 1326 |                       (*r)->CRC = 0L;
 | 
|---|
| 1327 |                   }
 | 
|---|
| 1328 |                   if(i->CRC == -1L) {
 | 
|---|
| 1329 |                     i->CRC = CRCFile(i->name,&error);
 | 
|---|
| 1330 |                     if(error)
 | 
|---|
| 1331 |                       i->CRC = -1L;
 | 
|---|
| 1332 |                     else if(i->CRC == -1L)
 | 
|---|
| 1333 |                       i->CRC = 0L;
 | 
|---|
| 1334 |                   }
 | 
|---|
| 1335 |                   if((*r)->CRC != -1L && i->CRC != -1L &&
 | 
|---|
| 1336 |                      (*r)->CRC != i->CRC) {
 | 
|---|
| 1337 |                     *r++;
 | 
|---|
| 1338 |                     continue;
 | 
|---|
| 1339 |                   }
 | 
|---|
| 1340 |                 }
 | 
|---|
| 1341 |                 if(!AddToList((*r)->name,
 | 
|---|
| 1342 |                               &list,
 | 
|---|
| 1343 |                               &numfiles,
 | 
|---|
| 1344 |                               &numalloced)) {
 | 
|---|
| 1345 |                   if(g->sayfiles)
 | 
|---|
| 1346 |                     WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1347 |                                      (*r)->name);
 | 
|---|
| 1348 |                   (*r)->flags |= GF_INSERTED;
 | 
|---|
| 1349 |                   if(((g->ignoreextdupes) ?
 | 
|---|
| 1350 |                       comparenamesqe(r,&i) :
 | 
|---|
| 1351 |                       comparenamesq(r,&i)))
 | 
|---|
| 1352 |                     (*r)->flags |= GF_SKIPME;
 | 
|---|
| 1353 |                 }
 | 
|---|
| 1354 |                 if(!(i->flags & (GF_INSERTED | GF_SKIPME))) {
 | 
|---|
| 1355 |                   if(!AddToList(i->name,
 | 
|---|
| 1356 |                                 &list,
 | 
|---|
| 1357 |                                 &numfiles,
 | 
|---|
| 1358 |                                 &numalloced)) {
 | 
|---|
| 1359 |                     i->flags |= GF_INSERTED;
 | 
|---|
| 1360 |                     if((*r)->flags & GF_SKIPME)
 | 
|---|
| 1361 |                       i->flags |= GF_SKIPME;
 | 
|---|
| 1362 |                   }
 | 
|---|
| 1363 |                 }
 | 
|---|
| 1364 |                 r++;
 | 
|---|
| 1365 |               }
 | 
|---|
| 1366 |             }
 | 
|---|
| 1367 |           }
 | 
|---|
| 1368 |         }
 | 
|---|
| 1369 |         i = i->next;
 | 
|---|
| 1370 |         y++;
 | 
|---|
| 1371 |         if(!(y % cntr)) {
 | 
|---|
| 1372 | 
 | 
|---|
| 1373 |           CHAR s[44];
 | 
|---|
| 1374 | 
 | 
|---|
| 1375 |           sprintf(s,
 | 
|---|
| 1376 |                   GetPString(IDS_GREPDUPECHECKPROGTEXT),
 | 
|---|
| 1377 |                   y,
 | 
|---|
| 1378 |                   g->numfiles);
 | 
|---|
| 1379 |           WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1380 |                            s);
 | 
|---|
| 1381 |           DosSleep(128L);
 | 
|---|
| 1382 |         }
 | 
|---|
| 1383 |         DosSleep(y % 2);
 | 
|---|
| 1384 |       }
 | 
|---|
| 1385 |     }
 | 
|---|
| 1386 |     else {
 | 
|---|
| 1387 |       // Insufficient memory - fall back
 | 
|---|
| 1388 |       DosBeep(50,100);
 | 
|---|
| 1389 |       WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1390 |                        GetPString(IDS_GREPDUPECOMPARINGTEXT));
 | 
|---|
| 1391 |       x = y = 0L;
 | 
|---|
| 1392 |       if(g->dupenames) {
 | 
|---|
| 1393 |         free(g->dupenames);
 | 
|---|
| 1394 |         g->dupenames = NULL;
 | 
|---|
| 1395 |       }
 | 
|---|
| 1396 |       if(g->dupesizes) {
 | 
|---|
| 1397 |         free(g->dupesizes);
 | 
|---|
| 1398 |         g->dupesizes = NULL;
 | 
|---|
| 1399 |       }
 | 
|---|
| 1400 |       i = g->dupehead;
 | 
|---|
| 1401 |       while(i) {
 | 
|---|
| 1402 |         if(*g->stopflag)
 | 
|---|
| 1403 |           break;
 | 
|---|
| 1404 |         if(!(i->flags & GF_SKIPME)) {
 | 
|---|
| 1405 |           if(!(y % cntr)) {
 | 
|---|
| 1406 | 
 | 
|---|
| 1407 |             CHAR s[44];
 | 
|---|
| 1408 | 
 | 
|---|
| 1409 |             sprintf(s,
 | 
|---|
| 1410 |                     GetPString(IDS_GREPDUPECHECKPROGTEXT),
 | 
|---|
| 1411 |                     y,
 | 
|---|
| 1412 |                     g->numfiles);
 | 
|---|
| 1413 |             WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1414 |                              s);
 | 
|---|
| 1415 |             DosSleep(0L);
 | 
|---|
| 1416 |           }
 | 
|---|
| 1417 |           y++;
 | 
|---|
| 1418 |           pi = strrchr(i->name,'\\');
 | 
|---|
| 1419 |           if(pi)
 | 
|---|
| 1420 |             *pi++;
 | 
|---|
| 1421 |           else
 | 
|---|
| 1422 |             pi = i->name;
 | 
|---|
| 1423 |           c = g->dupehead;
 | 
|---|
| 1424 |           while(c) {
 | 
|---|
| 1425 |             if(*g->stopflag)
 | 
|---|
| 1426 |               break;
 | 
|---|
| 1427 |             if(c != i && !(c->flags & (GF_INSERTED | GF_SKIPME))) {
 | 
|---|
| 1428 |               x++;
 | 
|---|
| 1429 |               pc = strrchr(c->name,'\\');
 | 
|---|
| 1430 |               if(pc)
 | 
|---|
| 1431 |                 pc++;
 | 
|---|
| 1432 |               else
 | 
|---|
| 1433 |                 pc = c->name;
 | 
|---|
| 1434 |               if((!g->nosizedupes && i->size == c->size &&
 | 
|---|
| 1435 |                   i->date.year == c->date.year &&
 | 
|---|
| 1436 |                   i->date.month == c->date.month &&
 | 
|---|
| 1437 |                   i->date.day == c->date.day &&
 | 
|---|
| 1438 |                   i->time.hours == c->time.hours &&
 | 
|---|
| 1439 |                   i->time.minutes == c->time.minutes &&
 | 
|---|
| 1440 |                   i->time.twosecs == c->time.twosecs) ||
 | 
|---|
| 1441 |                  !stricmp(pc,pi)) {         /* potential dupe */
 | 
|---|
| 1442 |                 if(g->CRCdupes) {
 | 
|---|
| 1443 |                   if(g->CRCdupes) {
 | 
|---|
| 1444 |                     if(c->CRC == -1L) {
 | 
|---|
| 1445 |                       c->CRC = CRCFile(c->name,&error);
 | 
|---|
| 1446 |                       if(error)
 | 
|---|
| 1447 |                         c->CRC = -1L;
 | 
|---|
| 1448 |                       else if(c->CRC == -1L)
 | 
|---|
| 1449 |                         c->CRC = 0L;
 | 
|---|
| 1450 |                     }
 | 
|---|
| 1451 |                     if(i->CRC == -1L) {
 | 
|---|
| 1452 |                       i->CRC = CRCFile(i->name,&error);
 | 
|---|
| 1453 |                       if(error)
 | 
|---|
| 1454 |                         i->CRC = -1L;
 | 
|---|
| 1455 |                       else if(i->CRC == -1L)
 | 
|---|
| 1456 |                           i->CRC = 0L;
 | 
|---|
| 1457 |                     }
 | 
|---|
| 1458 |                     if((c->size != i->size) || (c->CRC != -1L &&
 | 
|---|
| 1459 |                        i->CRC != -1L && c->CRC != i->CRC)) {
 | 
|---|
| 1460 |                       c = c->next;
 | 
|---|
| 1461 |                       continue;
 | 
|---|
| 1462 |                     }
 | 
|---|
| 1463 |                   }
 | 
|---|
| 1464 |                 }
 | 
|---|
| 1465 |                 if(AddToList(c->name,
 | 
|---|
| 1466 |                              &list,
 | 
|---|
| 1467 |                              &numfiles,
 | 
|---|
| 1468 |                              &numalloced))
 | 
|---|
| 1469 |                   goto BreakOut;                // Failed
 | 
|---|
| 1470 |                 if(!(i->flags & GF_INSERTED)) {
 | 
|---|
| 1471 |                   if(AddToList(i->name,
 | 
|---|
| 1472 |                                &list,
 | 
|---|
| 1473 |                                &numfiles,
 | 
|---|
| 1474 |                                &numalloced))
 | 
|---|
| 1475 |                     goto BreakOut;              // Failed
 | 
|---|
| 1476 |                 }
 | 
|---|
| 1477 |                 if(g->sayfiles)
 | 
|---|
| 1478 |                   WinSetWindowText(g->hwndCurFile,
 | 
|---|
| 1479 |                                    pc);
 | 
|---|
| 1480 |                 c->flags |= GF_INSERTED;
 | 
|---|
| 1481 |                 i->flags |= GF_INSERTED;
 | 
|---|
| 1482 |                 if(!stricmp(pc,pi)) {
 | 
|---|
| 1483 |                   c->flags |= GF_SKIPME;
 | 
|---|
| 1484 |                   i->flags |= GF_SKIPME;
 | 
|---|
| 1485 |                 }
 | 
|---|
| 1486 |               }
 | 
|---|
| 1487 |               else if(!(x % 100L))
 | 
|---|
| 1488 |                 DosSleep(1L);
 | 
|---|
| 1489 |             }
 | 
|---|
| 1490 |             c = c->next;
 | 
|---|
| 1491 |           }
 | 
|---|
| 1492 |         }
 | 
|---|
| 1493 |         i = i->next;
 | 
|---|
| 1494 |       }
 | 
|---|
| 1495 |     }
 | 
|---|
| 1496 |   }
 | 
|---|
| 1497 | BreakOut:
 | 
|---|
| 1498 |   FreeDupes(g);
 | 
|---|
| 1499 |   if(numfiles && list) {
 | 
|---|
| 1500 |     if(!PostMsg(g->hwndFiles,
 | 
|---|
| 1501 |                 WM_COMMAND,
 | 
|---|
| 1502 |                 MPFROM2SHORT(IDM_COLLECTOR,0),
 | 
|---|
| 1503 |                 MPFROMP(list)))
 | 
|---|
| 1504 |       FreeList(list);
 | 
|---|
| 1505 |   }
 | 
|---|
| 1506 |   else
 | 
|---|
| 1507 |     DosPostEventSem(CompactSem);
 | 
|---|
| 1508 | }
 | 
|---|
| 1509 | 
 | 
|---|
| 1510 | 
 | 
|---|
| 1511 | static BOOL InsertDupe (GREP *g,CHAR *dir,FILEFINDBUF4 *f)
 | 
|---|
| 1512 | {
 | 
|---|
| 1513 |   DUPES *info;
 | 
|---|
| 1514 | 
 | 
|---|
| 1515 |   if (*dir) {
 | 
|---|
| 1516 |     info = xmallocz(sizeof(DUPES),pszSrcFile,__LINE__);
 | 
|---|
| 1517 |     if (!info)
 | 
|---|
| 1518 |       return FALSE;
 | 
|---|
| 1519 |     else {
 | 
|---|
| 1520 |       info->name = xstrdup(dir,pszSrcFile,__LINE__);
 | 
|---|
| 1521 |       if (!info->name) {
 | 
|---|
| 1522 |         free(info);
 | 
|---|
| 1523 |         return FALSE;
 | 
|---|
| 1524 |       }
 | 
|---|
| 1525 |       else {
 | 
|---|
| 1526 |         info->size = f->cbFile;
 | 
|---|
| 1527 |         info->date = f->fdateLastWrite;
 | 
|---|
| 1528 |         info->time = f->ftimeLastWrite;
 | 
|---|
| 1529 |         info->CRC = -1L;
 | 
|---|
| 1530 |         g->numfiles++;
 | 
|---|
| 1531 |         if (!g->dupehead)
 | 
|---|
| 1532 |           g->dupehead = info;
 | 
|---|
| 1533 |         if (g->dupelast)
 | 
|---|
| 1534 |           g->dupelast->next = info;
 | 
|---|
| 1535 |         g->dupelast = info;
 | 
|---|
| 1536 |         info->next = NULL;
 | 
|---|
| 1537 |       }
 | 
|---|
| 1538 |     }
 | 
|---|
| 1539 |   }
 | 
|---|
| 1540 |   return TRUE;
 | 
|---|
| 1541 | }
 | 
|---|