home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / i18nv104.zip / INCLUDE / REGEX.H < prev    next >
C/C++ Source or Header  |  1996-02-13  |  4KB  |  97 lines

  1. /** regex.h National Language Support OS2 Include File
  2. *.
  3. *.      (C) COPYRIGHT International Business Machines Corp. 1985, 1990
  4. *.      All Rights Reserved
  5. *.      Licensed Materials - Property of IBM
  6. *.
  7. *.      US Government Users Restricted Rights - Use, duplication or
  8. *.      disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *.
  10. */
  11.  
  12. #ifndef __H_REGEX
  13.   #define __H_REGEX
  14.  
  15. #include <stddef.h>
  16.  
  17. #define _REG_SUBEXP_MAX    23   /* Maximum # of subexpressions          */
  18. #define REG_EXTENDED    0x001   /* Use Extended RE syntax rules         */
  19. #define REG_ICASE       0x002   /* Ignore case in match                 */
  20. #define REG_NOSUB       0x008   /* regexec() not report subexpressions  */
  21. #define REG_NEWLINE     0x004   /* Convert <backslash><n> to <newline>  */
  22.  
  23. #define REG_NOTBOL      0x100          /* First character not start of line */
  24. #define REG_NOTEOL      0x200   /* Last character not end of line       */
  25.  
  26. #define REG_NOMATCH     1       /* RE pattern not found                 */
  27. #define REG_BADPAT      2       /* Invalid Regular Expression           */
  28. #define REG_ECOLLATE    3       /* Invalid collating element            */
  29. #define REG_ECTYPE      4       /* Invalid character class              */
  30. #define REG_EESCAPE     5       /* Last character is \                  */
  31. #define REG_ESUBREG     6       /* Invalid number in \digit             */
  32. #define REG_EBRACK      7       /* [] imbalance                         */
  33. #define REG_EPAREN      8       /* \( \) or () imbalance                */
  34. #define REG_EBRACE      9       /* \{ \} or { } imbalance               */
  35. #define REG_BADBR       10      /* Invalid \{ \} range exp              */
  36. #define REG_ERANGE      11      /* Invalid range exp endpoint           */
  37. #define REG_ESPACE      12      /* Out of memory                        */
  38. #define REG_BADRPT      13      /* ?*+ not preceded by valid RE         */
  39. #define REG_ECHAR       14      /* invalid multibyte character          */
  40. #define REG_EBOL        15      /* ^ anchor and not BOL                 */
  41. #define REG_EEOL        16      /* $ anchor and not EOL                 */
  42.  
  43.  
  44. /* NOTE:  The size of regex_t must not change.  The size of the members
  45.  *      __re_lsub + __re_esub + __re_map + __maxsub + __unsed must be 
  46.  *      exactly 336 bytes, so if _REG_SUBEXP_MAX above changes, you'll
  47.  *      have to modify __unsed accordingly.
  48.  * ALSO:  See notes in __regexec_std.c regarding _REG_SUBEXP_MAX.
  49.  */
  50.  
  51. typedef struct {        /* regcomp() data saved for regexec()    */
  52.     size_t    re_nsub;    /* # of subexpressions in RE pattern    */
  53.     void    *re_comp;    /* compiled RE; freed by regfree()    */
  54.     int    re_cflags;    /* saved cflags for regexec()        */
  55.     size_t    re_erroff;    /* RE pattern error offset        */
  56.     size_t    re_len;        /* # wchar_t chars in compiled pattern    */
  57.     wchar_t    re_ucoll[2];    /* min/max unique collating values    */
  58.     void    *re_lsub[_REG_SUBEXP_MAX+1]; /* start subexp        */
  59.     void    *re_esub[_REG_SUBEXP_MAX+1]; /* end subexp        */
  60.     unsigned char *re_map;  /* map of valid pattern characters    */
  61.     int    __maxsub;    /* maximum number of subs in pattern.   */
  62.     void    *__unused[34];    /* Extra space if ever needed        */
  63. } regex_t;
  64.  
  65. #ifndef __off_t
  66.   typedef long  off_t;
  67.   #define __off_t
  68. #endif
  69.  
  70. typedef struct {            /* substring locations - from regexec() */
  71.     off_t   rm_so;          /* Byte offset from start of string to  */
  72.                             /*   start of substring                 */
  73.     off_t   rm_eo;          /* Byte offset from start of string of  */
  74.                             /*   first character after substring    */
  75.     } regmatch_t;
  76.  
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80.  
  81. int regcomp(regex_t *preg, const char *pattern, int cflags);
  82.  
  83. int regexec(const regex_t *preg, const char *string, 
  84.   size_t nmatch, regmatch_t pmatch[], int eflags);
  85.  
  86. size_t regerror(int errcode, const regex_t *preg, 
  87.   char *errbuf, size_t errbuf_size);
  88.  
  89. void regfree(regex_t *preg);
  90.  
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94.  
  95.  
  96. #endif
  97.