#define MAXCHAR 256
enum {T_CHAR,T_MASK,T_ANY,T_OR,T_OR_TOP,T_START,T_END,T_NOT,T_GROUP,T_BOUNDARY,T_NBOUNDARY,T_BEGIN_WORD,T_END_WORD};
static char *rtype[]={"CHAR","MASK","ANY","OR","OR_TOP","STARTOFLINE","EOL","NOT","GROUP","BOUNDARY","NBOUNDARY","BEGIN_WORD","END_WORD"};
#define REG_EXTENDED 1
#define REG_ICASE 2
#define REG_NOSUB 4
#define REG_NEWLINE 8

typedef struct OBJ {
	char type; unsigned char c; 
	int min; int max; unsigned char *mask; 
	int icase;
	struct OBJ *next;
	struct OBJ *or;
} Obj;
typedef struct REGEX_T {Obj *list;} regex_t;

int regcomp(regex_t *reg, char *in, int flags);
Obj *reg_newobj(void);
char *reg_error(void);
int reg_setdebug(int x);

Obj *r_comp_all(unsigned char **in);
int regerror(int e, regex_t *reg, char *bf, int bfsz);
int regfree(regex_t *reg);
int regexec(regex_t *reg, char *in, int xx, char *yy, int zz);
int r_comp_modifier(Obj *o, unsigned char **in);
Obj *r_comp_any(unsigned char **in);
int r_comp_set(Obj *o,unsigned char **in);
void reg_show(Obj *o);
void reg_show_obj(Obj *o);
int rfail(const char * arg_list, ...);
void reg_freeobj(Obj *o);
int reg_match_one(unsigned char **in, Obj **o);
int reg_match_list(unsigned char **in, Obj **o);
int reg_match(unsigned char **in,Obj **o);

char *reg_find(char *in, regex_t *r);
int reg_find_start(char *in, regex_t *r);
