xref: /openbsd-src/usr.sbin/httpd/patterns.h (revision 5f2c5a1d59777b2f3ec11bd2d05e9fccff4086af)
1*5f2c5a1dSmmcc /*	$OpenBSD: patterns.h,v 1.3 2015/12/12 19:59:43 mmcc Exp $	*/
259355b5aSreyk 
359355b5aSreyk /*
459355b5aSreyk  * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
559355b5aSreyk  *
659355b5aSreyk  * Permission to use, copy, modify, and distribute this software for any
759355b5aSreyk  * purpose with or without fee is hereby granted, provided that the above
859355b5aSreyk  * copyright notice and this permission notice appear in all copies.
959355b5aSreyk  *
1059355b5aSreyk  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1159355b5aSreyk  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1259355b5aSreyk  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1359355b5aSreyk  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1459355b5aSreyk  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1559355b5aSreyk  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1659355b5aSreyk  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1759355b5aSreyk  */
1859355b5aSreyk 
1959355b5aSreyk #ifndef PATTERNS_H
2059355b5aSreyk #define PATTERNS_H
2159355b5aSreyk 
224d0a5e21Ssemarie #include <sys/types.h>
234d0a5e21Ssemarie 
2459355b5aSreyk #define MAXCAPTURES	32	/* Max no. of allowed captures in pattern */
2559355b5aSreyk #define MAXCCALLS	200	/* Max recusion depth in pattern matching */
2659355b5aSreyk #define MAXREPETITION	0xfffff	/* Max for repetition items */
2759355b5aSreyk 
2859355b5aSreyk struct str_find {
2959355b5aSreyk 	off_t		 sm_so;	/* start offset of match */
3059355b5aSreyk 	off_t		 sm_eo;	/* end offset of match */
3159355b5aSreyk };
3259355b5aSreyk 
3359355b5aSreyk struct str_match {
3459355b5aSreyk 	char		**sm_match; /* allocated array of matched strings */
3559355b5aSreyk 	unsigned int	 sm_nmatch; /* number of elements in array */
3659355b5aSreyk };
3759355b5aSreyk 
3859355b5aSreyk __BEGIN_DECLS
3959355b5aSreyk int	 str_find(const char *, const char *, struct str_find *, size_t,
4059355b5aSreyk 	    const char **);
4159355b5aSreyk int	 str_match(const char *, const char *, struct str_match *,
4259355b5aSreyk 	    const char **);
4359355b5aSreyk void	 str_match_free(struct str_match *);
4459355b5aSreyk __END_DECLS
4559355b5aSreyk 
4659355b5aSreyk #endif /* PATTERNS_H */
47