Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

include/pcreposix.h

Go to the documentation of this file.
00001 /*************************************************
00002 *       Perl-Compatible Regular Expressions      *
00003 *************************************************/
00004 
00005 /* Copyright (c) 1997-2000 University of Cambridge */
00006 
00007 /**
00008  * @file include/pcreposix.h
00009  * @brief PCRE definitions
00010  */
00011 
00012 #ifndef _PCREPOSIX_H
00013 #define _PCREPOSIX_H
00014 
00015 /* This is the header for the POSIX wrapper interface to the PCRE Perl-
00016 Compatible Regular Expression library. It defines the things POSIX says should
00017 be there. I hope. */
00018 
00019 /* Have to include stdlib.h in order to ensure that size_t is defined. */
00020 
00021 #include <stdlib.h>
00022 
00023 /* Allow for C++ users */
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /* Options defined by POSIX. */
00030 
00031   /** Ignore case */
00032 #define REG_ICASE     0x01
00033   /** Don't match newlines with wildcards */
00034 #define REG_NEWLINE   0x02
00035   /** Don't match BOL */
00036 #define REG_NOTBOL    0x04
00037   /** Don't match EOL */
00038 #define REG_NOTEOL    0x08
00039 
00040 /* These are not used by PCRE, but by defining them we make it easier
00041 to slot PCRE into existing programs that make POSIX calls. */
00042 
00043   /** UNUSED! */
00044 #define REG_EXTENDED  0
00045   /** UNUSED! */
00046 #define REG_NOSUB     0
00047 
00048 /* Error values. Not all these are relevant or used by the wrapper. */
00049 
00050 enum {
00051   REG_ASSERT = 1,  /* internal error ? */
00052   REG_BADBR,       /* invalid repeat counts in {} */
00053   REG_BADPAT,      /* pattern error */
00054   REG_BADRPT,      /* ? * + invalid */
00055   REG_EBRACE,      /* unbalanced {} */
00056   REG_EBRACK,      /* unbalanced [] */
00057   REG_ECOLLATE,    /* collation error - not relevant */
00058   REG_ECTYPE,      /* bad class */
00059   REG_EESCAPE,     /* bad escape sequence */
00060   REG_EMPTY,       /* empty expression */
00061   REG_EPAREN,      /* unbalanced () */
00062   REG_ERANGE,      /* bad range inside [] */
00063   REG_ESIZE,       /* expression too big */
00064   REG_ESPACE,      /* failed to get memory */
00065   REG_ESUBREG,     /* bad back reference */
00066   REG_INVARG,      /* bad argument */
00067   REG_NOMATCH      /* match failed */
00068 };
00069 
00070 
00071 /* The structure representing a compiled regular expression. */
00072 
00073 typedef struct {
00074   void *re_pcre;
00075   size_t re_nsub;
00076   size_t re_erroffset;
00077 } regex_t;
00078 
00079 /* The structure in which a captured offset is returned. */
00080 
00081 typedef int regoff_t;
00082 
00083 typedef struct {
00084   regoff_t rm_so;
00085   regoff_t rm_eo;
00086 } regmatch_t;
00087 
00088 /* The functions */
00089 
00090 extern int regcomp(regex_t *, const char *, int);
00091 extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int);
00092 extern size_t regerror(int, const regex_t *, char *, size_t);
00093 extern void regfree(regex_t *);
00094 
00095 #ifdef __cplusplus
00096 }   /* extern "C" */
00097 #endif
00098 
00099 #endif /* End of pcreposix.h */