home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / regex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  6.0 KB  |  134 lines

  1. #if (defined(__IBMC__) || defined(__IBMCPP__))
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __regex_h
  10.    #define __regex_h
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef  _LNK_CONV
  17.      #ifdef _M_I386
  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.    /*  VisualAge for C++ for Windows, Version 3.5                      */
  36.    /*    Licensed Material - Property of IBM                           */
  37.    /*                                                                  */
  38.    /*  5801-ARR and Other Materials                                    */
  39.    /*                                                                  */
  40.    /*  (c) Copyright IBM Corp 1991, 1996. All rights reserved.         */
  41.    /*                                                                  */
  42.    /********************************************************************/
  43.  
  44.    #include <stddef.h>           /* size_t, wchar_t definition required */
  45.  
  46.    #define __REG_SUBEXP_MAX        9        /* Maximum # of subexpressions                */
  47.  
  48.    /* regcomp() cflags */
  49.  
  50.    #define REG_EXTENDED        0x001        /* Use Extended RE syntax rules               */
  51.    #define REG_ICASE           0x002        /* Ignore case in match                       */
  52.    #define REG_NEWLINE         0x004        /* Convert <backslash><n> to <newline>        */
  53.    #define REG_NOSUB           0x008        /* regexec() not report subexpressions        */
  54.  
  55.  
  56.    /* regexec() eflags */
  57.  
  58.    #define REG_NOTBOL          0x100        /* First character not start of line          */
  59.    #define REG_NOTEOL          0x200        /* Last character not end of line             */
  60.  
  61.  
  62.    /* Regular Expression error codes */
  63.  
  64.    #define REG_NOMATCH             1        /* RE pattern not found                       */
  65.    #define REG_BADPAT              2        /* Invalid Regular Expression                 */
  66.    #define REG_ECOLLATE            3        /* Invalid collating element                  */
  67.    #define REG_ECTYPE              4        /* Invalid character class                    */
  68.    #define REG_EESCAPE             5        /* Last character is \                        */
  69.    #define REG_ESUBREG             6        /* Invalid number in \digit                   */
  70.    #define REG_EBRACK              7        /* [] imbalance                               */
  71.    #define REG_EPAREN              8        /* \( \) or () imbalance                      */
  72.    #define REG_EBRACE              9        /* \{ \} or { } imbalance                     */
  73.    #define REG_BADBR              10        /* Invalid \{ \} range exp                    */
  74.    #define REG_ERANGE             11        /* Invalid range exp endpoint                 */
  75.    #define REG_ESPACE             12        /* Out of memory                              */
  76.    #define REG_BADRPT             13        /* ?*+ not preceded by valid RE               */
  77.    #define REG_ECHAR              14        /* invalid multibyte character                */
  78.    #define REG_EBOL               15        /* ¬ anchor and not BOL                       */
  79.    #define REG_EEOL               16        /* $ anchor and not EOL                       */
  80.  
  81.    #ifndef __mbstate_t
  82.       #define __mbstate_t
  83.       typedef short      mbstate_t;
  84.    #endif
  85.  
  86.    typedef struct {                         /* regcomp() data saved for regexec()         */
  87.            size_t  re_nsub;                 /* # of subexpressions in RE pattern          */
  88.            void    *re_comp;                /* compiled RE; freed by regfree()            */
  89.            int     re_cflags;               /* saved cflags for regexec()                 */
  90.            size_t  re_erroff;               /* RE pattern error offset                    */
  91.            size_t  re_len;                  /* # wchar_t chars in compiled pattern        */
  92.            wchar_t re_ucoll[2];             /* min/max unique collating values            */
  93.            void    *re_lsub[__REG_SUBEXP_MAX+1]; /* start subexp                          */
  94.            void    *re_esub[__REG_SUBEXP_MAX+1]; /* end subexp                            */
  95.            unsigned char re_map[256];       /* map of valid pattern characters            */
  96.            mbstate_t     re_shift;          /* Saved shift state                          */
  97.            short         re_dbcs;           /* May start with DBCS character              */
  98.    } regex_t;
  99.  
  100.    #ifndef __off_t
  101.      typedef long  off_t;                /* file offset */
  102.      #define __off_t
  103.    #endif
  104.  
  105.    typedef struct {                      /* substring locations - from regexec()          */
  106.            off_t   rm_so;                /* offset of substring                           */
  107.            off_t   rm_eo;                /* offset of first char after substring          */
  108.            mbstate_t rm_ss;              /* Shift state at start of substring             */
  109.            mbstate_t rm_es;              /* Shift state at end of substring               */
  110.    } regmatch_t;
  111.  
  112.  
  113.    /* Regular Expression function prototypes */
  114.  
  115.    extern int      _LNK_CONV regcomp(regex_t *, const char *, int);
  116.    extern int      _LNK_CONV regexec(const regex_t *, const char *, size_t, regmatch_t *, int);
  117.    extern size_t   _LNK_CONV regerror(int, const regex_t *, char *, size_t);
  118.    extern void     _LNK_CONV regfree(regex_t *);
  119.  
  120.    #ifdef __cplusplus
  121.       }
  122.    #endif
  123.  
  124. #endif
  125.  
  126. #if (defined(__IBMC__) || defined(__IBMCPP__))
  127. #pragma info( none )
  128. #ifndef __CHKHDR__
  129.    #pragma info( restore )
  130. #endif
  131. #pragma info( restore )
  132. #endif
  133.  
  134.