home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / libc / regex.h < prev    next >
Text File  |  1999-03-15  |  5KB  |  127 lines

  1. #if __IBMC__ || __IBMCPP__
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __H_REGEX
  10.   #define __H_REGEX
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef  _LNK_CONV
  17.       #if __IBMC__ || __IBMCPP__ || defined(_OPTLINK_SUPPORTED)
  18.          #define _LNK_CONV   _Optlink
  19.       #else
  20.          #define _LNK_CONV
  21.       #endif
  22.    #endif
  23.  
  24.    #ifndef _IMPORT
  25.       #ifdef __IMPORTLIB__
  26.          #define _IMPORT _Import
  27.       #else
  28.          #define _IMPORT
  29.       #endif
  30.    #endif
  31.  
  32.    /********************************************************************/
  33.    /*  <regex.h> header file                                           */
  34.    /*                                                                  */
  35.    /*  (C) Copyright IBM Corp. 1991, 1995.                             */
  36.    /*  - Licensed Material - Program-Property of IBM                   */
  37.    /*  - All rights reserved                                           */
  38.    /*                                                                  */
  39.    /********************************************************************/
  40.  
  41.    #include <stddef.h>
  42.  
  43.    #define _REG_SUBEXP_MAX    23   /* Maximum # of subexpressions          */
  44.    #define REG_EXTENDED    0x001   /* Use Extended RE syntax rules         */
  45.    #define REG_ICASE       0x002   /* Ignore case in match                 */
  46.    #define REG_NOSUB       0x008   /* regexec() not report subexpressions  */
  47.    #define REG_NEWLINE     0x004   /* Convert <backslash><n> to <newline>  */
  48.  
  49.    #define REG_NOTBOL      0x100   /* First character not start of line    */
  50.    #define REG_NOTEOL      0x200   /* Last character not end of line       */
  51.  
  52.    #define REG_NOMATCH     1       /* RE pattern not found                 */
  53.    #define REG_BADPAT      2       /* Invalid Regular Expression           */
  54.    #define REG_ECOLLATE    3       /* Invalid collating element            */
  55.    #define REG_ECTYPE      4       /* Invalid character class              */
  56.    #define REG_EESCAPE     5       /* Last character is \                  */
  57.    #define REG_ESUBREG     6       /* Invalid number in \digit             */
  58.    #define REG_EBRACK      7       /* [] imbalance                         */
  59.    #define REG_EPAREN      8       /* \( \) or () imbalance                */
  60.    #define REG_EBRACE      9       /* \{ \} or { } imbalance               */
  61.    #define REG_BADBR       10      /* Invalid \{ \} range exp              */
  62.    #define REG_ERANGE      11      /* Invalid range exp endpoint           */
  63.    #define REG_ESPACE      12      /* Out of memory                        */
  64.    #define REG_BADRPT      13      /* ?*+ not preceded by valid RE         */
  65.    #define REG_ECHAR       14      /* invalid multibyte character          */
  66.    #define REG_EBOL        15      /* ^ anchor and not BOL                 */
  67.    #define REG_EEOL        16      /* $ anchor and not EOL                 */
  68.  
  69.  
  70.    /* NOTE:  The size of regex_t must not change.  The size of the members
  71.     *        __re_lsub + __re_esub + __re_map + __maxsub + __unsed must be
  72.     *        exactly 336 bytes, so if _REG_SUBEXP_MAX above changes, you'll
  73.     *        have to modify __unsed accordingly.
  74.     */
  75.  
  76.    typedef struct {             /* regcomp() data saved for regexec()   */
  77.         size_t  re_nsub;        /* # of subexpressions in RE pattern    */
  78.         void    *re_comp;       /* compiled RE; freed by regfree()      */
  79.         int     re_cflags;      /* saved cflags for regexec()           */
  80.         size_t  re_erroff;      /* RE pattern error offset              */
  81.         size_t  re_len;         /* # wchar_t chars in compiled pattern  */
  82.         wchar_t re_ucoll[2];    /* min/max unique collating values      */
  83.  
  84.         void    *re_lsub[_REG_SUBEXP_MAX+1]; /* start subexp            */
  85.         void    *re_esub[_REG_SUBEXP_MAX+1]; /* end subexp              */
  86.         unsigned char *re_map;  /* map of valid pattern characters      */
  87.         int     __maxsub;       /* maximum number of subs in pattern.   */
  88.         void    *__unused[34];  /* Extra space if ever needed           */
  89.    } regex_t;
  90.  
  91.    #ifndef __off_t
  92.       typedef long  off_t;
  93.       #define __off_t
  94.    #endif
  95.  
  96.    typedef struct {             /* substring locations - from regexec() */
  97.         off_t   rm_so;          /* Byte offset from start of string to  */
  98.                                 /*   start of substring                 */
  99.         off_t   rm_eo;          /* Byte offset from start of string of  */
  100.                                 /*   first character after substring    */
  101.     } regmatch_t;
  102.  
  103.    extern int _IMPORT _LNK_CONV regcomp(regex_t *preg, const char *pattern, int cflags);
  104.  
  105.    extern int _IMPORT _LNK_CONV regexec(const regex_t *preg, const char *string,
  106.      size_t nmatch, regmatch_t pmatch[], int eflags);
  107.  
  108.    extern size_t _IMPORT _LNK_CONV regerror(int errcode, const regex_t *preg,
  109.      char *errbuf, size_t errbuf_size);
  110.  
  111.    extern void _IMPORT _LNK_CONV regfree(regex_t *preg);
  112.  
  113.    #ifdef __cplusplus
  114.       }
  115.    #endif
  116.  
  117. #endif
  118.  
  119. #if __IBMC__ || __IBMCPP__
  120. #pragma info( none )
  121. #ifndef __CHKHDR__
  122.    #pragma info( restore )
  123. #endif
  124. #pragma info( restore )
  125. #endif
  126.  
  127.