1 /* regextype.h -- Decode the name of a regular expression syntax.
2
3 Copyright (C) 2005-2022 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 /* Written by James Youngman <jay@gnu.org>.
19 */
20 #ifndef REGEXTPE_H
21 # define REGEXTPE_H
22
23 /* Translate a regular expression type name into an option mask.
24 * This could convert "grep" into RE_SYNTAX_GREP, for example.
25 * Return -1 if there is no match.
26 */
27 int get_regex_type(const char *s);
28
29 enum {
30 CONTEXT_FINDUTILS = 1u,
31 CONTEXT_GENERIC = 2u,
32 CONTEXT_ALL = CONTEXT_GENERIC|CONTEXT_FINDUTILS,
33 };
34
35
36
37 /* Returns the regex type name corresponding to index IX.
38 * Indexes start at 0. Returns NULL if IX is too large.
39 */
40 const char * get_regex_type_name(unsigned int ix);
41
42
43 /* Returns the option mask name corresponding to regular expresion
44 * type index IX. Indexes start at 0. Behaviour is undefined if IX
45 * has a value which would cause get_regex_type_name to return NULL.
46 */
47 int get_regex_type_flags(unsigned int ix);
48
49 /* If regular expression type IX (which is a regular expression type
50 * index) has one or more synonyms which is interesting in context
51 * CONTEXT, return the index of one of them. Otherwise, return -1.
52 */
53 int get_regex_type_synonym(unsigned int ix, unsigned int context);
54
55 /* Returns one of CONTEXT_FINDUTILS, CONTEXT_GENERIC or CONTEXT_ALL.
56 * This identifies whether this regular expression type index is relevant for,
57 * respectively, findutils, general callers, or all callers.
58 */
59 unsigned int get_regex_type_context(unsigned int ix);
60
61 #endif