#ifndef _REGEX_H_
#define _REGEX_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <wchar.h>
#include <xlocale.h>
#define tre_regcomp regcomp
#define tre_regcomp_l regcomp_l
#define tre_regexec regexec
#define tre_regerror regerror
#define tre_regfree regfree
#define tre_regncomp regncomp
#define tre_regncomp_l regncomp_l
#define tre_regnexec regnexec
#define tre_regwcomp regwcomp
#define tre_regwcomp_l regwcomp_l
#define tre_regwexec regwexec
#define tre_regwncomp regwncomp
#define tre_regwncomp_l regwncomp_l
#define tre_regwnexec regwnexec
typedef enum {
#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
REG_ENOSYS = -1,
#endif
REG_OK = 0,
REG_NOMATCH,
REG_BADPAT,
REG_ECOLLATE,
REG_ECTYPE,
REG_EESCAPE,
REG_ESUBREG,
REG_EBRACK,
REG_EPAREN,
REG_EBRACE,
REG_BADBR,
REG_ERANGE,
REG_ESPACE,
REG_BADRPT,
REG_EMPTY,
REG_INVARG,
REG_ILLSEQ
} reg_errcode_t;
enum {
TRE_CONFIG_APPROX,
TRE_CONFIG_WCHAR,
TRE_CONFIG_MULTIBYTE,
TRE_CONFIG_SYSTEM_ABI,
TRE_CONFIG_VERSION
};
typedef int regoff_t;
typedef wchar_t tre_char_t;
typedef struct {
int re_magic;
size_t re_nsub;
const void *re_endp;
void *value;
} regex_t;
typedef struct {
regoff_t rm_so;
regoff_t rm_eo;
} regmatch_t;
typedef struct {
int cost_ins;
int cost_del;
int cost_subst;
int max_cost;
int max_ins;
int max_del;
int max_subst;
int max_err;
} regaparams_t;
typedef struct {
size_t nmatch;
regmatch_t *pmatch;
int cost;
int num_ins;
int num_del;
int num_subst;
} regamatch_t;
typedef struct {
int (*get_next_char)(tre_char_t *c, unsigned int *pos_add, void *context);
void (*rewind)(size_t pos, void *context);
int (*compare)(size_t pos1, size_t pos2, size_t len, void *context);
void *context;
} tre_str_source;
#define REG_EXTENDED 1
#define REG_ICASE (REG_EXTENDED << 1)
#define REG_NEWLINE (REG_ICASE << 1)
#define REG_NOSUB (REG_NEWLINE << 1)
#define REG_BASIC 0
#define REG_LITERAL (REG_NOSUB << 1)
#define REG_RIGHT_ASSOC (REG_LITERAL << 1)
#define REG_UNGREEDY (REG_RIGHT_ASSOC << 1)
#define REG_PEND (REG_UNGREEDY << 1)
#define REG_ENHANCED (REG_PEND << 1)
#define REG_NOSPEC REG_LITERAL
#define REG_MINIMAL REG_UNGREEDY
#define REG_NOTBOL 1
#define REG_NOTEOL (REG_NOTBOL << 1)
#define REG_STARTEND (REG_NOTEOL << 1)
#define REG_BACKR (REG_STARTEND << 1)
#define REG_APPROX_MATCHER (REG_NOTEOL << 1)
#define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1)
#define RE_DUP_MAX 255
#define _REG_nexec 1
__BEGIN_DECLS
int
tre_regcomp(regex_t * __restrict preg, const char * __restrict regex,
int cflags);
int
tre_regexec(const regex_t * __restrict preg, const char * __restrict string,
size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags);
size_t
tre_regerror(int errcode, const regex_t * __restrict preg,
char * __restrict errbuf, size_t errbuf_size);
void
tre_regfree(regex_t *preg);
int
tre_regwcomp(regex_t *preg, const wchar_t *regex, int cflags);
int
tre_regwexec(const regex_t *preg, const wchar_t *string,
size_t nmatch, regmatch_t pmatch[], int eflags);
int
tre_regncomp(regex_t *preg, const char *regex, size_t len, int cflags);
int
tre_regnexec(const regex_t *preg, const char *string, size_t len,
size_t nmatch, regmatch_t pmatch[], int eflags);
int
tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t len, int cflags);
int
tre_regwnexec(const regex_t *preg, const wchar_t *string, size_t len,
size_t nmatch, regmatch_t pmatch[], int eflags);
char *
tre_version(void);
int
tre_config(int query, void *result);
int
tre_have_backrefs(const regex_t *preg);
int
tre_have_approx(const regex_t *preg);
__END_DECLS
int
tre_regcomp_l(regex_t *preg, const char *regex, int cflags, locale_t locale);
int
tre_regncomp_l(regex_t *preg, const char *regex, size_t len, int cflags,
locale_t locale);
int
tre_regwcomp_l(regex_t *preg, const wchar_t *regex, int cflags,
locale_t locale);
int
tre_regwncomp_l(regex_t *preg, const wchar_t *regex, size_t len, int cflags,
locale_t locale);
#endif