home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / LPAS / YG604W95.ZIP / YGREP.H < prev    next >
C/C++ Source or Header  |  1998-04-10  |  7KB  |  255 lines

  1. /*
  2. //    $Id: YGREP.H 1.17 1997/07/13 19:09:31 Y.Roumazeilles Exp $
  3. //
  4. //    (C) 1992-93-94-95-96-97-98 Yves Roumazeilles
  5. //
  6. //      Version 6.04
  7. */
  8.  
  9. #ifndef    __YGREP_H__
  10. #define    __YGREP_H__    
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15. #ifndef    EXPORT
  16. #define    EXPORT    
  17. #endif
  18.  
  19. #ifdef    WINVER
  20. # ifdef    WIN32
  21. #define    YGCALL    EXPORT WINAPI
  22. # else
  23. #define    YGCALL    EXPORT FAR PASCAL
  24. # endif
  25. #else
  26. #define    YGCALL    EXPORT
  27. #endif
  28.  
  29. WORD    YGCALL    YGrepVersion( void );
  30. BOOL    YGCALL    YGrepIsDebug( void );
  31. void    YGCALL    YGrepMessages( BOOL bMessagesAllowed );
  32.  
  33. #define    YO_EOLLF    0x0001L
  34. #define    YO_EOLCR    0x0002L
  35. #define    YO_EOLCRLF    YO_EOLCR|YO_EOLLF
  36. #define    YO_ERRMSG    0x0008L
  37. #define    YO_SHORTCLO    0x0010L
  38. long    YGCALL    YGrepOptions( long lOptions );
  39.  
  40.  
  41.  
  42.  
  43. /* YGrep Search Engine Error Codes */
  44. #define AGERR_UNKNOWN_TYPE        -1
  45. #define AGERR_NO_ERROR            0
  46. #define AGERR_STATE            1
  47. #define AGERR_ALLOC_MEM            2
  48. #define AGERR_TOO_SHORT            3
  49. #define AGERR_TOO_LONG            4
  50. #define AGERR_NO_PREVIOUS        5
  51. #define AGERR_NO_PATTERN        6
  52.  
  53. #define RGERR_MUNGED_AUTO        20
  54. #define RGERR_MISS_BRACKET        25
  55. #define RGERR_EMPTY_CL            26
  56. #define RGERR_ILLEGAL_CL        27
  57. #define RGERR_TOO_MANY_PAR        28
  58. #define RGERR_NULL_IN_PAR        29
  59. #define RGERR_UNMATCHED            30
  60. #define RGERR_NULL_IN_CRO        31
  61. #define RGERR_CYCLICAL_REF        32
  62. #define RGERR_UNDETERM_REF        33
  63. #define RGERR_UNMATCHED_PAR        34
  64. #define RGERR_TOO_MANY_BRA        35
  65.  
  66. #define    MATCH        0
  67. #define    MISMATCH    1
  68. #define    EXACTMATCH    2
  69. #define    MAXSYM        256    /* Size of the alphabet (in chars) */
  70. #define    WORD_SIZE    512    /* (in bits) */
  71. #define MAXTAG        10
  72.  
  73. #include    "bitlist.h"
  74.  
  75. typedef struct tagAGrepInfo {
  76.     int    iErrorCode;
  77.     char    cPat[WORD_SIZE];
  78.     LPSTR    TagStart[MAXTAG];
  79.     LPSTR    TagEnd[MAXTAG];
  80.     int    bMatchCase;
  81.     BLIST    uMask;        /* internal structures */
  82.     BLIST    uOvMask;
  83.     BLIST    uLimit;
  84.     BLIST    blState;    /* temporary AGrep() structures */
  85.     BLIST    blOverflow;
  86.     BLIST    blTemp;
  87.     BLIST    uTable[MAXSYM];    /* characteristic vector table */
  88.     int    iBitsPerState;
  89.     int    iWordSize;    /* actual word size of BLIST's */
  90.     int    iType;        /* MATCH, MISMATCH or EXACTMATCH */
  91.     char    cUPat[WORD_SIZE];
  92. } AGREPINFO;
  93. #ifdef    WINVER
  94. typedef    AGREPINFO*    PAGREPINFO;
  95. typedef    AGREPINFO FAR*    LPAGREPINFO;
  96. #else
  97. typedef    AGREPINFO*    PAGREPINFO;
  98. typedef    AGREPINFO*    LPAGREPINFO;
  99. #endif
  100.  
  101. int    YGCALL    CompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase, LPAGREPINFO pGI );
  102. int    YGCALL    AGrep( LPCSTR StringToSearch, LPAGREPINFO pGI );
  103. int    YGCALL    AGrepInit( LPAGREPINFO pGI );
  104. int    YGCALL    AGrepEmpty( LPAGREPINFO pGI );
  105. int    YGCALL    AGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPAGREPINFO pGI );
  106. int    YGCALL    AGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPAGREPINFO pGI );
  107. int    YGCALL    SCompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase );
  108. int    YGCALL    SAGrep( LPCSTR StringToSearch );
  109. int    YGCALL    SAGrepInit( void );
  110. int    YGCALL    SAGrepEmpty( void );
  111. int    YGCALL    SAGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  112. int    YGCALL    SAGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. #define    MAXDFA    2*WORD_SIZE+32    // It must be double in order to avoid any need for internal error checking
  120.  
  121. typedef struct tagRGrepInfo {
  122.     int    iErrorCode;
  123.     char    cPat[WORD_SIZE];
  124.     LPSTR    TagStart[MAXTAG];
  125.     LPSTR    TagEnd[MAXTAG];
  126.     int    bMatchCase;
  127.     char    cDFA[MAXDFA];        /* internal structures */
  128.     int    iBranches;
  129.     int    iMinLength;
  130.     char*    ap[MAXTAG];
  131. } RGREPINFO;
  132. #ifdef    WINVER
  133. typedef    RGREPINFO*    PRGREPINFO;
  134. typedef    RGREPINFO FAR*    LPRGREPINFO;
  135. #else
  136. typedef    RGREPINFO*    PRGREPINFO;
  137. typedef    RGREPINFO*    LPRGREPINFO;
  138. #endif
  139.  
  140. int    YGCALL    CompileRGrep( LPCSTR GrepString, BOOL bMatchCase, LPRGREPINFO pGI );
  141. int    YGCALL    RGrep( LPCSTR StringToSearch, LPRGREPINFO pGI );
  142. int    YGCALL    RGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPRGREPINFO pGI );
  143. int    YGCALL    RGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPRGREPINFO pGI );
  144. void    YGCALL    InitWordCharTable( void );
  145. void    YGCALL    AddWordChar( LPSTR s );
  146. void    YGCALL    RemoveWordChar( LPSTR s );
  147. int    YGCALL    SCompileRGrep( LPCSTR GrepString, BOOL bMatchCase );
  148. int    YGCALL    SRGrep( LPCSTR StringToSearch );
  149. int    YGCALL    SRGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  150. int    YGCALL    SRGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  151.  
  152.  
  153.  
  154.  
  155.  
  156. typedef struct tagSGrepInfo {
  157.     int    iErrorCode;
  158.     char    cPat[WORD_SIZE];
  159.     LPSTR    TagStart[MAXTAG];
  160.     LPSTR    TagEnd[MAXTAG];
  161.     int    bMatchCase;
  162.     char    cDFA[MAXDFA];        /* internal structures */
  163. } SGREPINFO;
  164. #ifdef    WINVER
  165. typedef    SGREPINFO*    PSGREPINFO;
  166. typedef    SGREPINFO FAR*    LPSGREPINFO;
  167. #else
  168. typedef    SGREPINFO*    PSGREPINFO;
  169. typedef    SGREPINFO*    LPSGREPINFO;
  170. #endif
  171.  
  172. int    YGCALL    CompileSGrep( LPCSTR GrepString, BOOL bMatchCase, LPSGREPINFO pGI );
  173. int    YGCALL    SGrep( LPCSTR StringToSearch, LPSGREPINFO pGI );
  174. int    YGCALL    SGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPSGREPINFO pGI );
  175. int    YGCALL    SGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize, LPSGREPINFO pGI );
  176. int    YGCALL    SCompileSGrep( LPCSTR GrepString, BOOL bMatchCase );
  177. int    YGCALL    SSGrep( LPCSTR StringToSearch );
  178. int    YGCALL    SSGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  179. int    YGCALL    SSGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, long lSize );
  180.  
  181.  
  182.  
  183.  
  184.  
  185. #define    OP_NOP    0
  186. #define    OP_NOT    1
  187. #define    OP_AND    2
  188. #define    OP_OR    3
  189. #define    OP_NAND    4
  190. #define    OP_NOR    5
  191. #define    OP_ADD    6
  192. #define    OP_SUB    7
  193. #define    OP_UCMP    8
  194. #define    OP_BAND    9
  195. #define    OP_BOR    10
  196. #define    OP_BXOR    11
  197. #define    OP_BNAND    12
  198. #define    OP_BNOR    13
  199.  
  200. typedef    struct tagYGrepInfo {
  201.     union {
  202.         int        opI;    /* One of OP_* values */
  203.         AGREPINFO    aGI;
  204.         RGREPINFO    rGI;
  205.         SGREPINFO    sGI;
  206.     } info;
  207. #ifdef    WINVER
  208.     struct tagYGrepInfo FAR*    pInfo;
  209. #else
  210.     struct tagYGrepInfo *       pInfo;
  211. #endif
  212.     int    iTypeOfInfo;    /* One of IT_* values */
  213. } YGREPINFO;
  214. #ifdef    WINVER
  215. typedef    YGREPINFO*    PYGREPINFO;
  216. typedef    YGREPINFO FAR*    LPYGREPINFO;
  217. #else
  218. typedef    YGREPINFO*    PYGREPINFO;
  219. typedef    YGREPINFO*    LPYGREPINFO;
  220. #endif
  221.  
  222. #define    IT_NONE    -1
  223. #define    IT_OP    0
  224. #define    IT_AG    1
  225. #define    IT_RG    2
  226. #define    IT_SG    3
  227.  
  228. int    YGCALL    PushYInfo( LPYGREPINFO pGI );
  229. int    YGCALL    YGrep( LPCSTR StringToSearch );
  230.  
  231.  
  232.  
  233. void    YGCALL    SFileSetFlags( BOOL bPrintFileName, BOOL bPrintBlockNumber, BOOL bPrintLineNumber, BOOL bCountsOnly, BOOL bNonMatching, BOOL bFileModeText );
  234. BOOL    YGCALL    SFileOpen( LPCSTR strFileName );
  235. LPSTR    YGCALL    SFileAGrep();
  236. LPSTR    YGCALL    SFileRGrep();
  237. LPSTR    YGCALL    SFileSGrep();
  238. LPSTR    YGCALL    SFileTextAGrep();
  239. LPSTR    YGCALL    SFileTextRGrep();
  240. LPSTR    YGCALL    SFileTextSGrep();
  241. LPSTR    YGCALL    SFileBinaryAGrep();
  242. LPSTR    YGCALL    SFileBinaryRGrep();
  243. LPSTR    YGCALL    SFileBinarySGrep();
  244. long    YGCALL    SFileClose();
  245.  
  246. int    YGCALL    YGrepGetError();
  247. int    YGCALL    YGrepSetError( int iError );
  248. int    YGCALL    YGrepResetError( int iError );
  249.  
  250.  
  251. #ifdef __cplusplus
  252. } /* extern "C" */
  253. #endif
  254. #endif    /* __YGREP_H__ */
  255.