jcs's openbsd hax
openbsd
1/* $OpenBSD: patterns.h,v 1.3 2015/12/12 19:59:43 mmcc Exp $ */
2
3/*
4 * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef PATTERNS_H
20#define PATTERNS_H
21
22#include <sys/types.h>
23
24#define MAXCAPTURES 32 /* Max no. of allowed captures in pattern */
25#define MAXCCALLS 200 /* Max recusion depth in pattern matching */
26#define MAXREPETITION 0xfffff /* Max for repetition items */
27
28struct str_find {
29 off_t sm_so; /* start offset of match */
30 off_t sm_eo; /* end offset of match */
31};
32
33struct str_match {
34 char **sm_match; /* allocated array of matched strings */
35 unsigned int sm_nmatch; /* number of elements in array */
36};
37
38__BEGIN_DECLS
39int str_find(const char *, const char *, struct str_find *, size_t,
40 const char **);
41int str_match(const char *, const char *, struct str_match *,
42 const char **);
43void str_match_free(struct str_match *);
44__END_DECLS
45
46#endif /* PATTERNS_H */