home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / uccs / root.14 / udk / usr / include / regex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-19  |  4.7 KB  |  133 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. #ifndef _REGEX_H
  12. #define _REGEX_H
  13. #ident    "@(#)sgs-head:common/head/regex.h    1.8"
  14.  
  15. #ifndef _SIZE_T
  16. #   define _SIZE_T
  17.     typedef unsigned int    size_t;
  18. #endif
  19.  
  20. #ifndef _SSIZE_T
  21. #   define _SSIZE_T
  22.     typedef int    ssize_t;
  23. #endif
  24.  
  25.     /*
  26.     * Official regexec() flags.
  27.     */
  28. #define REG_NOTBOL    0x000001 /* start of string does not match ^ */
  29. #define REG_NOTEOL    0x000002 /* end of string does not match $ */
  30.  
  31.     /*
  32.     * Additional regexec() flags.
  33.     */
  34. #define REG_NONEMPTY    0x000004 /* do not match empty at start of string */
  35.  
  36.     /*
  37.     * Extensions to provide individual control over each
  38.     * of the differences between basic and extended REs.
  39.     */
  40. #define REG_OR        0x000001 /* enable | operator */
  41. #define REG_PLUS    0x000002 /* enable + operator */
  42. #define REG_QUEST    0x000004 /* enable ? operator */
  43. #define REG_BRACES    0x000008 /* use {m,n} (instead of \{m,n\}) */
  44. #define REG_PARENS    0x000010 /* use (...) [instead of \(...\)] */
  45. #define REG_ANCHORS    0x000020 /* ^ and $ are anchors anywhere */
  46. #define REG_NOBACKREF    0x000040 /* disable \digit */
  47. #define REG_NOAUTOQUOTE    0x000080 /* no automatic quoting of REG_BADRPTs */
  48.  
  49.     /*
  50.     * Official regcomp() flags.
  51.     */
  52. #define REG_EXTENDED    (REG_OR | REG_PLUS | REG_QUEST | REG_BRACES | \
  53.                 REG_PARENS | REG_ANCHORS | \
  54.                 REG_NOBACKREF | REG_NOAUTOQUOTE)
  55. #define REG_ICASE    0x000100 /* ignore case */
  56. #define REG_NOSUB    0x000200 /* only success/fail for regexec() */
  57. #define REG_NEWLINE    0x000400 /* take \n as line separator for ^ and $ */
  58.  
  59.     /*
  60.     * Additional regcomp() flags.
  61.     * Some of these assume that int is >16 bits!
  62.     */
  63. #define REG_ONESUB    0x000800 /* regexec() only needs pmatch[0] */
  64. #define REG_MTPARENFAIL    0x001000 /* take empty \(\) or () as match failure */
  65. #define REG_MTPARENBAD    0x002000 /* disallow empty \(\) or () */
  66. #define REG_BADRANGE    0x004000 /* accept [m-a] ranges as [ma] */
  67. #define REG_SEPRANGE    0x008000 /* disallow [a-m-z] style ranges */
  68. #define REG_BKTQUOTE    0x010000 /* allow \ in []s to quote \, -, ^ or ] */
  69. #define REG_BKTEMPTY    0x020000 /* allow empty []s (w/BKTQUOTE, BKTESCAPE) */
  70. #define REG_ANGLES    0x040000 /* enable \<, \> operators */
  71. #define REG_ESCNL    0x080000 /* take \n as newline character */
  72. #define REG_NLALT    0x100000 /* take newline as alternation */
  73. #define REG_ESCSEQ    0x200000 /* otherwise, take \ as start of C escapes */
  74. #define REG_BKTESCAPE    0x400000 /* allow \ in []s to quote next anything */
  75. #define REG_OLDBRE    (REG_BADRANGE | REG_ANGLES | REG_ESCNL)
  76.  
  77.     /*
  78.     * Error return values.
  79.     */
  80. #define REG_ENOSYS    (-1)    /* unsupported */
  81. #define    REG_NOMATCH    1    /* regexec() failed to match */
  82. #define    REG_BADPAT    2    /* invalid regular expression */
  83. #define    REG_ECOLLATE    3    /* invalid collating element construct */
  84. #define    REG_ECTYPE    4    /* invalid character class construct */
  85. #define REG_EEQUIV    5    /* invalid equivalence class construct */
  86. #define REG_EBKTCHAR    6    /* invalid character in [] construct */
  87. #define    REG_EESCAPE    7    /* trailing \ in pattern */
  88. #define    REG_ESUBREG    8    /* number in \digit invalid or in error */
  89. #define    REG_EBRACK    9    /* [] imbalance */
  90. #define REG_EMPTYSUBBKT    10    /* empty sub-bracket construct */
  91. #define REG_EMPTYPAREN    11    /* empty \(\) or () [REG_MTPARENBAD] */
  92. #define REG_NOPAT    12    /* no (empty) pattern */
  93. #define    REG_EPAREN    13    /* \(\) or () imbalance */
  94. #define    REG_EBRACE    14    /* \{\} or {} imbalance */
  95. #define    REG_BADBR    15    /* contents of \{\} or {} invalid */
  96. #define    REG_ERANGE    16    /* invalid endpoint in expression */
  97. #define    REG_ESPACE    17    /* out of memory */
  98. #define    REG_BADRPT    18    /* *,+,?,\{\} or {} not after r.e. */
  99. #define REG_BADESC    19    /* invalid escape sequence (e.g. \0) */
  100.  
  101. typedef struct
  102. {
  103.     size_t        re_nsub;    /* only advertised member */
  104.     unsigned long    re_flags;    /* augmented regcomp() flags */
  105.     struct re_dfa_    *re_dfa;    /* DFA engine */
  106.     struct re_nfa_    *re_nfa;    /* NFA engine */
  107.     struct re_coll_    *re_col;    /* current collation info */
  108.     void        *re_more;    /* just in case... */
  109. } regex_t;
  110.  
  111. typedef ssize_t regoff_t;
  112.  
  113. typedef struct
  114. {
  115.     regoff_t    rm_so;
  116.     regoff_t    rm_eo;
  117. } regmatch_t;
  118.  
  119. #ifdef __cplusplus
  120. extern "C" {
  121. #endif
  122.  
  123. int    regcomp(regex_t *, const char *, int);
  124. int    regexec(const regex_t *, const char *, size_t, regmatch_t *, int);
  125. size_t    regerror(int, const regex_t *, char *, size_t);
  126. void    regfree(regex_t *);
  127.  
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131.  
  132. #endif /*_REGEX_H*/
  133.