xref: /netbsd-src/share/man/man9/pmatch.9 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\" $NetBSD: pmatch.9,v 1.2 2003/10/14 06:49:51 wiz Exp $
2.\"
3.\" Copyright (c) 2003 Manuel Bouyer.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"	This product includes software developed by Manuel Bouyer.
16.\" 4. The name of the author may not be used to endorse or promote products
17.\"    derived from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\"
31.Dd October 12, 2003
32.Dt PMATCH 9
33.Os
34.Sh NAME
35.Nm pmatch
36.Nd performs pattern matching on strings
37.Sh SYNOPSIS
38.In sys/systm.h
39.Ft int
40.Fn pmatch "const char *string" "const char *pattern" "const char **estr"
41.Sh DESCRIPTION
42Extract substring matching
43.Fa pattern
44from
45.Fa string .
46If not
47.Dv NULL ,
48.Fa estr
49points to the end of the longest exact or substring match.
50.Pp
51.Fn pmatch
52uses the following metacharacters:
53.Bl -tag -width Ds
54.It Li \&?
55match any single character.
56.It Li *
57match any character 0 or more times.
58.It Li \&[
59define a range of characters that will match.
60The range is defined by 2 characters separated by a
61.Sq Li \&- .
62The range definition has to end with a
63.Sq Li \&] .
64A
65.Sq Li ^
66following the
67.Sq Li \&[
68will negate the range.
69.El
70.Sh RETURN VALUES
71.Fn pmatch
72will return 2 for an exact match, 1 for a substring match, 0 for no match and
73\-1 if an error occurs.
74