/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/************************************************************
* File name: regex.h
: Note: CH regex.h header file wraper
************************************************************/
#ifndef _REGEX_H_
#define	_REGEX_H_

#include <sys/types.h>
#include <stddef.h>


typedef ssize_t regoff_t;

#include <ch/regex.h>

extern int regcomp(regex_t *, const char *, int);
extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
extern size_t regerror(int, const regex_t *, char *, size_t);
extern void regfree(regex_t *);

/* for 4.2 bsd compatibility with re_comp.h */
extern char *re_comp(const char *string);
extern int re_exec(const char *string);


#if defined(_CHDLL_)
#include <dlfcn.h>
void *_ChRegex_handle = dlopen("libregex.dl", RTLD_LAZY);
if(_ChRegex_handle == NULL) {
   fprintf(_stderr, "Error: dlopen(): %s\n", dlerror());
   fprintf(_stderr, "       cannot get _ChRegex_handle in regex.h\n");
   exit(-1);
}
void _dlclose_regex(void) {
   dlclose(_ChRegex_handle);
}
atexit(_dlclose_regex);
#endif

#endif /* _REGEX_H_ */
