Debian Codegraph @

share/libc/regex.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef _REGEX_H
24 #define _REGEX_H 1
25 #include "features.h"
26 __PUSH_FC_STDLIB
27 #include "__fc_define_size_t.h"
28 #include "__fc_define_ssize_t.h"
29 __BEGIN_DECLS
30
31 struct re_pattern_buffer {
32 struct re_dfa_t *buffer; // Non-POSIX
33 size_t allocated; // Non-POSIX
34 char *fastmap; // Non-POSIX
35 unsigned char *translate; // Non-POSIX
36 size_t re_nsub;
37 };
38
39 typedef struct re_pattern_buffer regex_t;
40
41 #define REG_EXTENDED 1
42 #define REG_ICASE 2
43 #define REG_NEWLINE 4
44 #define REG_NOSUB 8
45
46
47 /* Eflags */
48 #define REG_NOTBOL 1
49 #define REG_NOTEOL 2
50
51 /* Error codes */
52 typedef enum __fc_reg_errcode_t
53 {
54 REG_NOERROR = 0,
55 REG_NOMATCH,
56 REG_BADPAT,
57 REG_ECOLLATE,
58 REG_ECTYPE,
59 REG_EESCAPE,
60 REG_ESUBREG,
61 REG_EBRACK,
62 REG_EPAREN,
63 REG_EBRACE,
64 REG_BADBR,
65 REG_ERANGE,
66 REG_ESPACE,
67 REG_BADRPT,
68 REG_EEND,
69 REG_ESIZE,
70 REG_ERPAREN
71 } reg_errcode_t;
72
73 typedef ssize_t regoff_t;
74
75 // Non-POSIX
76 struct re_registers
77 {
78 size_t num_regs;
79 regoff_t *start;
80 regoff_t *end;
81 };
82
83 typedef struct __fc_regmatch_t
84 {
85 regoff_t rm_so;
86 regoff_t rm_eo;
87 } regmatch_t;
88
89 extern int regcomp(regex_t *, const char *, int);
90 extern int regexec(const regex_t *, const char *, size_t, regmatch_t[], int);
91 extern size_t regerror(int, const regex_t *, char *, size_t);
92 extern void regfree(regex_t *);
93
94 __END_DECLS
95
96 __POP_FC_STDLIB
97 #endif