Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
9.3 KiB

  1. /**********************************************************************
  2. // FIND.H
  3. //
  4. // Copyright (c) 1992 - Microsoft Corp.
  5. // All rights reserved.
  6. // Microsoft Confidential
  7. //
  8. // Include file with #defines and prototypes for qgrep functions used
  9. // by the Jaguar search engine.
  10. **********************************************************************/
  11. #include <setjmp.h>
  12. //*********************************************************************
  13. // Constant definitions.
  14. //*********************************************************************
  15. #if 0
  16. typedef long (far pascal *FIND_CALLBACK)( int Func, unsigned uArg0,\
  17. void far *pArg1, void far *pArg2,\
  18. void far *pArg3 );
  19. #define FLG_FIND_NOMATCH 0x0001 // Display non-matching lines
  20. #define FLG_FIND_COUNT 0x0002 // Display on count of matching lines
  21. #define FLG_FIND_LINENO 0x0004 // Display line numbers on output
  22. #endif
  23. #define FIND_FILE 0x0100 // Only searching for a file (EXCLUSIVE)
  24. #define FIND_NOT 0x0200 // Searching for /NOT strings
  25. #define BUFLEN 256 // Temporary buffer length
  26. #define PATMAX 512 // Maximum parsed pattern length
  27. #define MAXSTRLEN 128 // Maximum search string length
  28. #define TRTABLEN 256 // Translation table length
  29. // Total bytes in StringList array
  30. #define STRING_LST_LEN ((TRTABLEN + 1) * sizeof(char *))
  31. // #ifndef NOASM
  32. // #define match exprmatch
  33. // #endif
  34. //*********************************************************************
  35. // Pattern token types.
  36. //*********************************************************************
  37. #define T_END 0 // End of expression
  38. #define T_STRING 1 // String to match
  39. #define T_SINGLE 2 // Single character to match
  40. #define T_CLASS 3 // Class to match
  41. #define T_ANY 4 // Match any character
  42. #define T_STAR 5 // *-expr
  43. //*********************************************************************
  44. //*********************************************************************
  45. typedef struct stringnode
  46. {
  47. struct stringnode *s_alt; // List of alternates
  48. struct stringnode *s_suf; // List of suffixes
  49. int s_must; // Length of portion that must match
  50. }
  51. STRINGNODE; // String node
  52. // Text field access macro
  53. #define s_text(x) ( ((char *)(x)) + (sizeof( STRINGNODE ) + ((x)->s_must & 1)) )
  54. //*********************************************************************
  55. // Type definitions.
  56. //*********************************************************************
  57. typedef struct exprnode
  58. {
  59. struct exprnode *ex_next; // Next node in list
  60. struct exprnode *ex_dummy; // Needed by freenode()
  61. char *ex_pattern; // Pointer to pattern to match
  62. }
  63. EXPR; // Expression node
  64. //*********************************************************************
  65. // QGREP function prototypes
  66. //*********************************************************************
  67. extern void (*addstr)( char *s, int n );
  68. extern char *(*find) ( char *buffer, char *bufend );
  69. extern void (*flush1)( void );
  70. extern int (*grep) ( char *startbuf, char *endbuf, char *name, int *first );
  71. extern void (*write1)( char *buffer, int buflen );
  72. int InitGrepInfo( char *pStrLst, char *pNotList, unsigned uOpts );
  73. int FreeGrepBufs( void );
  74. int InitGrepBufs( void );
  75. int FileFindGrep( int fHandle, unsigned fFlags,
  76. long (far pascal *AppCb)( int Func,
  77. unsigned uArg0,
  78. void far *pArg1,
  79. unsigned long ulArg2 ) );
  80. void addexpr ( char *e, int n );
  81. void addstring ( char *s, int n );
  82. int addstrings ( char *buffer, char *bufend, char *seplist, int *first );
  83. void addtoken ( char *e, int n );
  84. char *alloc ( unsigned size );
  85. void bitset ( unsigned char *bitvec, int first, int last, int bitval );
  86. int enumlist ( struct stringnode *node, int cchprev );
  87. int enumstrings ( void );
  88. int exprmatch ( char *s, char *p );
  89. char *exprparse ( char *p, int *NewBufLen );
  90. char *findall ( char *buffer, char *bufend );
  91. char *findlist ( char *buffer, char *bufend );
  92. char *findone ( char *buffer, char *bufend );
  93. void freenode ( struct stringnode *x );
  94. char *get1stcharset( char *e, unsigned char *bitvec );
  95. int isexpr ( char *s, int n );
  96. int istoken ( char *s, int n );
  97. void maketd1 ( unsigned char *pch, int cch, int cchstart );
  98. int match ( char *s, char *p );
  99. void matchstrings( char *s1, char *s2, int len, int *nmatched,
  100. int *leg );
  101. STRINGNODE *newnode ( char *s, int n );
  102. static int newstring ( unsigned char *s, int n );
  103. char *NextEol ( char *pchChar, char *EndBuf );
  104. int preveol ( char *s );
  105. STRINGNODE *reallocnode( register STRINGNODE *node, char *s, int n );
  106. char *simpleprefix( char *s, char **pp );
  107. int strncspn ( char *s, char *t, int n );
  108. int strnspn ( char *s, char *t, int n );
  109. char *strnupr ( char *pch, int cch );
  110. void SwapSrchTables( void );
  111. int cmpicase ( char * buf1, char * buf2, unsigned int count );
  112. char *findexpr ( char *buffer, char *bufend );
  113. //*********************************************************************
  114. // Bit flag definitions
  115. //*********************************************************************
  116. #define SHOWNAME 0x001 // Print filename
  117. #define NAMEONLY 0x002 // Print filename only
  118. #define LINENOS 0x004 // Print line numbers
  119. #define BEGLINE 0x008 // Match at beginning of line
  120. #define ENDLINE 0x010 // Match at end of line
  121. #define DEBUG 0x020 // Print debugging output
  122. #define TIMER 0x040 // Time execution
  123. #define SEEKOFF 0x080 // Print seek offsets
  124. #define ALLLINES 0x100 // Print all lines before/after match
  125. #define COLNOS 0x200 // Show column numbers (if LINENOS)
  126. #define CNTMATCH 0x400 // Show count of matching lines
  127. #define NEWDISP 0x800
  128. #ifndef TRUE
  129. #define TRUE 1
  130. #endif
  131. #ifndef FALSE
  132. #define FALSE 0
  133. #endif
  134. //*********************************************************************
  135. // Miscellaneous constants.
  136. //*********************************************************************
  137. #define EOS ('\r') // End of string character
  138. //*********************************************************************
  139. // Data shared among source files.
  140. //*********************************************************************
  141. extern char *Target; // Buffer for srch string being added
  142. extern int CaseSen; // Case-sensitivity flag
  143. extern int Flags; // Flags
  144. extern int StrCount; // String count
  145. extern jmp_buf ErrorJmp; // Storage location for setjmp()
  146. // All of the data below is located in DATA.ASM to allow swapping
  147. // blocks of search data with a single memmove() call.
  148. #define SWAP_LEN ((sizeof( int ) * 8) + (sizeof( char * ) * 4))
  149. #define INIT_LEN (sizeof( int ) * 8)
  150. // Storage for "string" search trees.
  151. extern int DummyFirst;
  152. extern int TblEntriesUsed; // Number of transtab entries used
  153. extern int ExprEntriesUsed; // Number of expression strings used
  154. extern int StrCount; // String count
  155. extern int TargetLen; // Length of last string added
  156. extern int MaxChar; // Max char value in srch string
  157. extern int MinChar; // Min char value in srch string
  158. extern int ShortStrLen; // Min string length added to list
  159. extern char **ExprStrList; // Array of ptrs to srch expressions
  160. extern STRINGNODE **StringList; // Array of ptrs to srch strings
  161. extern unsigned char *td1; // Ptr to TD1 shift table
  162. extern unsigned char *TransTable; // Allocated in grepmain()
  163. extern int nDummyFirst;
  164. extern int nTblEntriesUsed; // Number of transtab entries used
  165. extern int nExprEntriesUsed; // Number of expression strings used
  166. extern int nStrCount; // String count
  167. extern int nTargetLen; // Length of last string added
  168. extern unsigned nMaxChar; // Max char value in search string
  169. extern unsigned nMinChar; // Min char value in srch string
  170. extern int nShortStrLen; // Min string length added to list
  171. extern char **nExprStrList; // Array of ptrs to srch expressions
  172. extern STRINGNODE **nStringList; // Array of ptrs to srch strings
  173. extern unsigned char *ntd1; // Ptr to TD1 shift table
  174. extern unsigned char *nTransTable; // Allocated in grepmain()
  175. extern unsigned InitialSearchData; // First word in area containing
  176. // initial search values.
  177. extern char *ReadBuf; // Ptr to buffer for file reads
  178. extern char *Target; // Tmp buf for string being added
  179. extern unsigned char *achcol; // Ptr to collate table
  180. //*********************************************************************
  181. // Added for purposes of integrating the message subsysstem
  182. //*********************************************************************
  183. struct sublistx
  184. {
  185. unsigned char size; // sublist size
  186. unsigned char reserved; // reserved for future growth
  187. unsigned far *value; // pointer to replaceable parm
  188. unsigned char id; // type of replaceable parm
  189. unsigned char Flags; // how parm is to be displayed
  190. unsigned char max_width; // max width of replaceable field
  191. unsigned char min_width; // min width of replaceable field
  192. unsigned char pad_char; // pad character for replaceable field
  193. };