source: trunk/sys/dietlibc/include/regex.h @ 1

Last change on this file since 1 was 1, checked in by alain, 5 years ago

First import

File size: 2.0 KB
Line 
1#ifndef _REGEX_H
2#define _REGEX_H
3
4#include <stddef.h>
5#include <sys/types.h>
6
7typedef ptrdiff_t regoff_t;
8
9typedef struct {
10  regoff_t rm_so;
11  regoff_t rm_eo;
12} regmatch_t;
13
14#define REG_EXTENDED 1
15#define REG_ICASE 2
16#define REG_NOSUB 4
17#define REG_NEWLINE 8
18
19#define REG_NOTBOL 1
20#define REG_NOTEOL 2
21
22#define REG_NOMATCH -1
23
24#define RE_DUP_MAX 8192
25
26struct __regex_t;
27
28typedef int (*matcher)(void*,const char*,int ofs,struct __regex_t* t,int plus,int eflags);
29
30typedef struct __regex_t {
31  struct regex {
32    matcher m;
33    void* next;
34    int pieces;
35    int num;
36    struct branch* b;
37  } r;
38  int brackets,cflags;
39  regmatch_t* l;
40} regex_t;
41#define re_nsub r.pieces
42
43int regcomp(regex_t* preg, const char* regex, int cflags);
44int regexec(const regex_t* preg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags);
45size_t regerror(int errcode, const regex_t* preg, char* errbuf, size_t errbuf_size);
46void regfree(regex_t* preg);
47
48enum __regex_errors {
49  REG_NOERROR,
50  REG_BADRPT, /* Invalid use of repetition operators such as using `*' as the first character. */
51  REG_BADBR, /* Invalid use of back reference operator. */
52  REG_EBRACE, /* Un-matched brace interval operators. */
53  REG_EBRACK, /* Un-matched bracket list operators. */
54  REG_ERANGE, /* Invalid use of the range operator, eg. the ending point of the
55                 range occurs  prior  to  the  starting point. */
56  REG_ECTYPE, /* Unknown character class name. */
57  REG_ECOLLATE, /* Invalid collating element. */
58  REG_EPAREN, /* Un-matched parenthesis group operators. */
59  REG_ESUBREG, /* Invalid back reference to a subexpression. */
60  REG_EEND, /* Non specific error.  This is not defined by POSIX.2. */
61  REG_EESCAPE, /* Trailing backslash. */
62  REG_BADPAT, /* Invalid use of pattern operators such as group or list. */
63  REG_ESIZE, /* Compiled  regular  expression  requires  a  pattern  buffer
64                larger than 64Kb.  This is not defined by POSIX.2. */
65  REG_ESPACE /* regcomp ran out of space */
66};
67
68char* re_comp(char* regex);
69int re_exec(char* string);
70
71
72#endif
Note: See TracBrowser for help on using the repository browser.