#ifndef _REGEX_H_
#define _REGEX_H_
#include "mb/pg_wchar.h"
typedef long regoff_t;
typedef struct
{
int re_magic;
size_t re_nsub;
long re_info;
#define REG_UBACKREF 000001
#define REG_ULOOKAROUND 000002
#define REG_UBOUNDS 000004
#define REG_UBRACES 000010
#define REG_UBSALNUM 000020
#define REG_UPBOTCH 000040
#define REG_UBBS 000100
#define REG_UNONPOSIX 000200
#define REG_UUNSPEC 000400
#define REG_UUNPORT 001000
#define REG_ULOCALE 002000
#define REG_UEMPTYMATCH 004000
#define REG_UIMPOSSIBLE 010000
#define REG_USHORTEST 020000
int re_csize;
char *re_endp;
Oid re_collation;
char *re_guts;
char *re_fns;
} regex_t;
typedef struct
{
regoff_t rm_so;
regoff_t rm_eo;
} regmatch_t;
typedef struct
{
regmatch_t rm_extend;
} rm_detail_t;
#define REG_BASIC 000000
#define REG_EXTENDED 000001
#define REG_ADVF 000002
#define REG_ADVANCED 000003
#define REG_QUOTE 000004
#define REG_NOSPEC REG_QUOTE
#define REG_ICASE 000010
#define REG_NOSUB 000020
#define REG_EXPANDED 000040
#define REG_NLSTOP 000100
#define REG_NLANCH 000200
#define REG_NEWLINE 000300
#define REG_PEND 000400
#define REG_EXPECT 001000
#define REG_BOSONLY 002000
#define REG_DUMP 004000
#define REG_FAKE 010000
#define REG_PROGRESS 020000
#define REG_NOTBOL 0001
#define REG_NOTEOL 0002
#define REG_STARTEND 0004
#define REG_FTRACE 0010
#define REG_MTRACE 0020
#define REG_SMALL 0040
#define REG_OKAY 0
#define REG_NOMATCH 1
#define REG_BADPAT 2
#define REG_ECOLLATE 3
#define REG_ECTYPE 4
#define REG_EESCAPE 5
#define REG_ESUBREG 6
#define REG_EBRACK 7
#define REG_EPAREN 8
#define REG_EBRACE 9
#define REG_BADBR 10
#define REG_ERANGE 11
#define REG_ESPACE 12
#define REG_BADRPT 13
#define REG_ASSERT 15
#define REG_INVARG 16
#define REG_MIXED 17
#define REG_BADOPT 18
#define REG_ETOOBIG 19
#define REG_ECOLORS 20
#define REG_CANCEL 21
#define REG_ATOI 101
#define REG_ITOA 102
#define REG_PREFIX (-1)
#define REG_EXACT (-2)
extern int pg_regcomp(regex_t *, const pg_wchar *, size_t, int, Oid);
extern int pg_regexec(regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t *, size_t, regmatch_t[], int);
extern int pg_regprefix(regex_t *, pg_wchar **, size_t *);
extern void pg_regfree(regex_t *);
extern size_t pg_regerror(int, const regex_t *, char *, size_t);
extern regex_t *RE_compile_and_cache(text *text_re, int cflags, Oid collation);
extern bool RE_compile_and_execute(text *text_re, char *dat, int dat_len,
int cflags, Oid collation,
int nmatch, regmatch_t *pmatch);
#endif