home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.1 (Developer) [x86] / NeXT Step 3.1 Intel dev.cdr.dmg / NextDeveloper / Examples / IndexingKit / ToDoList / IXStringSearch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-16  |  2.8 KB  |  92 lines

  1. /*
  2. IXStringSearch.h - Copyright (c) 1992 NeXT Computer, Inc.
  3.  
  4. You may freely copy, distribute and reuse the code in this example.
  5. NeXT Computer, Inc. disclaims any warranty of any kind, expressed or implied, 
  6. as to its fitness for any particular use.
  7. */
  8.  
  9. #import <sys/stat.h>
  10.  
  11. // copied from <bsd/regex.h> to add extern for shlib.h
  12.  
  13. #define    ESIZE    512
  14. #define    NBRA    9
  15.  
  16. struct regex {
  17.     char    expbuf[ESIZE];
  18.     char    *braslist[NBRA];
  19.     char    *braelist[NBRA];
  20.     char    circf;
  21.     char    *start, *end; /* pointers to occurrence in 's' */
  22. };
  23.  
  24. extern char *re_comp (char *string);
  25. extern int re_exec (char *string);
  26. extern int recmp (char *pattern, char *target);
  27. extern struct regex *re_compile (char *string, int fold);
  28. extern int re_match (char *string, struct regex *r);
  29.  
  30. typedef struct regex regex;
  31.  
  32. #ifdef KANJI
  33. #define    ESIZEJ    (512*4)
  34.  
  35. struct regexJ {
  36.     wchar_t    expbuf[ESIZEJ];
  37.     char    *braslist[NBRA];
  38.     char    *braelist[NBRA];
  39.     char    circf;
  40.     char    *start, *end; /* pointers to occurrence in 's' */
  41. };
  42.  
  43. typedef struct regexJ regexJ;
  44. #endif KANJI
  45.  
  46. // regular expression searching
  47.  
  48. inline static regex * 
  49. IXRegexCompile(const char *s, char ignoreCase)
  50. {
  51.     return re_compile((char *) s, ignoreCase);
  52. }
  53.  
  54. extern char *IXFilenameToRegex(char *filename);
  55. extern const char *IXRegexMatch(const char *s, regex *r);
  56. extern const char *IXRegexMatchPrefix(const char *s, regex *r);
  57. extern const char *IXRegexMatchWord(const char *s, regex *r);
  58. extern const char *IXRegexMatchExactly(const char *s, regex *r);
  59.  
  60. #ifdef KANJI
  61. extern regexJ *IXRegexCompileJ(const char *s, char ignoreCase);
  62. extern const char *IXRegexMatchJ(const char *s, regexJ *r);
  63. extern const char *IXRegexMatchPrefixJ(const char *s, regexJ *r);
  64. extern const char *IXRegexMatchWordJ(const char *s, regexJ *r);
  65. extern const char *IXRegexMatchExactlyJ(const char *s, regexJ *r);
  66. #endif KANJI
  67.  
  68. #define IX_BMTABLESIZE        256
  69.  
  70. typedef struct            {
  71.     unsigned short        plength;
  72.     unsigned char        casemap[IX_BMTABLESIZE];
  73.     unsigned short        skiptab[IX_BMTABLESIZE];
  74.     unsigned char        pattern[0];
  75. } IXBMTable;
  76.  
  77. // Boyer Moore string searching
  78.  
  79. extern IXBMTable *IXBMCompile(const char *s, char ignoreCase);
  80. extern const char *IXBMMatch(const char *s, unsigned l, IXBMTable *t);
  81. extern const char *IXBMMatchPrefix(const char *s, unsigned l, IXBMTable *t);
  82. extern const char *IXBMMatchWord(const char *s, unsigned l, IXBMTable *t);
  83. extern const char *IXBMMatchExactly(const char *s, unsigned l, IXBMTable *t);
  84.  
  85. #ifdef KANJI
  86. extern IXBMTable *IXBMCompileJ(const char *s, char ignoreCase);
  87. extern const char *IXBMMatchJ(const char *s, unsigned l, IXBMTable *t);
  88. extern const char *IXBMMatchPrefixJ(const char *s, unsigned l, IXBMTable *t);
  89. extern const char *IXBMMatchWordJ(const char *s, unsigned l, IXBMTable *t);
  90. extern const char *IXBMMatchExactlyJ(const char *s, unsigned l, IXBMTable *t);
  91. #endif KANJI
  92.