home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / mmm_pkg.zip / mmmgrep.h < prev    next >
C/C++ Source or Header  |  1996-12-05  |  2KB  |  50 lines

  1. /**********************************************
  2. *   GREP include file for MMMX Editor         *
  3. *   Contains functions & classes for Search   *
  4. ***********************************************/
  5.  
  6. #ifndef __INCLUDED_MMMGREP__
  7. #define __INCLUDED_MMMGREP__
  8. #include "mmmx.h"
  9.  
  10. struct refs;
  11. //&<<&struct GrepTbl{
  12. struct GrepTbl{
  13.   int readyF;   // 0 for none, 1 for simple, 2 for grep
  14.   int lpt;      // len of CMask = (ncn/16)+1;
  15.   int ncn;      // number of conditions
  16.   int lpt0;     // allocated CMask
  17.   char *Ptrn,*Repl;
  18.   short *AMask;    // [256*lpt];
  19.   short *TMask;    // [ltm=ncn*lpt];
  20.   short *CMask;    // current  [lpt]
  21.   short *tMask;    // temp     [lpt]
  22.  
  23.   static int Dir(int dir,int flg){ return dir!=SEARCH_FORWARD && flg!=2 ? -1 : 1; }
  24.  
  25.   void ClrMask(short *a){ memset((char*)a,0,sizeof(short)*lpt); }
  26.   void SetBit(short *a,int n){ a[n>>4]|=1<<(n&15); }
  27.   int TstBit(short *a,int n){ return a[n>>4]&1<<(n&15); }
  28.   void OrMask(short *a,short *b){ for(int i=0;i<lpt;i++) *a++|=*b++; }
  29.   void AndMask(short *a,short *b){ for(int i=0;i<lpt;i++) *a++&=*b++; }
  30.   void AndMask(short *a,short *b,short *c){ for(int i=0;i<lpt;i++) *a++&=*b++|*c++; }
  31.   int EmptyMask(short *a){ for(int i=0;i<lpt;i++) if(*a++) return 0; return 1; }
  32.   int EmptyAndMask(short *a,short *b){ for(int i=0;i<lpt;i++) if(*a++&*b++) return 0; return 1; }
  33.  
  34.   GrepTbl():lpt0(0),AMask(0),TMask(0),CMask(0),tMask(0),Ptrn(0),Repl(0),readyF(0){}
  35.   void Set(char *ptrn);
  36.   int Find(char *str,int &len,int sflg,int r0,int dir);
  37.  
  38.   void SetASC(char s);
  39.   void GetASC(char *&s);
  40.   void ProcChar(char *&s,int &n,refs *R,int LastLb);
  41. };
  42. //&>>&1E 0 13 0
  43. extern GrepTbl SearchMasks;
  44. extern Fold *SearchFold;
  45.  
  46. extern void SwitchIntoSearchPage();
  47. extern void SearchReplaceTextFragment(int SearchDirection,int DoReplace=0);
  48. #endif
  49. //&>>&6 0 6 1A
  50.