#ifndef _PG_REGEX_H_
#define _PG_REGEX_H_
#ifndef _WIN32
#include <regex.h>
#endif
#undef REG_UBACKREF
#undef REG_ULOOKAROUND
#undef REG_UBOUNDS
#undef REG_UBRACES
#undef REG_UBSALNUM
#undef REG_UPBOTCH
#undef REG_UBBS
#undef REG_UNONPOSIX
#undef REG_UUNSPEC
#undef REG_UUNPORT
#undef REG_ULOCALE
#undef REG_UEMPTYMATCH
#undef REG_UIMPOSSIBLE
#undef REG_USHORTEST
#undef REG_BASIC
#undef REG_EXTENDED
#undef REG_ADVF
#undef REG_ADVANCED
#undef REG_QUOTE
#undef REG_NOSPEC
#undef REG_ICASE
#undef REG_NOSUB
#undef REG_EXPANDED
#undef REG_NLSTOP
#undef REG_NLANCH
#undef REG_NEWLINE
#undef REG_PEND
#undef REG_EXPECT
#undef REG_BOSONLY
#undef REG_DUMP
#undef REG_FAKE
#undef REG_PROGRESS
#undef REG_NOTBOL
#undef REG_NOTEOL
#undef REG_STARTEND
#undef REG_FTRACE
#undef REG_MTRACE
#undef REG_SMALL
#undef REG_OKAY
#undef REG_NOMATCH
#undef REG_BADPAT
#undef REG_ECOLLATE
#undef REG_ECTYPE
#undef REG_EESCAPE
#undef REG_ESUBREG
#undef REG_EBRACK
#undef REG_EPAREN
#undef REG_EBRACE
#undef REG_BADBR
#undef REG_ERANGE
#undef REG_ESPACE
#undef REG_BADRPT
#undef REG_ASSERT
#undef REG_INVARG
#undef REG_MIXED
#undef REG_BADOPT
#undef REG_ETOOBIG
#undef REG_ECOLORS
#undef REG_ATOI
#undef REG_ITOA
#undef REG_PREFIX
#undef REG_EXACT
#include "mb/pg_wchar.h"
typedef long pg_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;
} pg_regex_t;
typedef struct
{
pg_regoff_t rm_so;
pg_regoff_t rm_eo;
} pg_regmatch_t;
typedef struct
{
pg_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_ATOI 101
#define REG_ITOA 102
#define REG_PREFIX (-1)
#define REG_EXACT (-2)
#define regoff_t pg_regoff_t
#define regex_t pg_regex_t
#define regmatch_t pg_regmatch_t
extern int pg_regcomp(regex_t *re, const pg_wchar *string, size_t len,
int flags, Oid collation);
extern int pg_regexec(regex_t *re, const pg_wchar *string, size_t len,
size_t search_start, rm_detail_t *details,
size_t nmatch, regmatch_t pmatch[], int flags);
extern int pg_regprefix(regex_t *re, pg_wchar **string, size_t *slength);
extern void pg_regfree(regex_t *re);
extern size_t pg_regerror(int errcode, const regex_t *preg, char *errbuf,
size_t errbuf_size);
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