NetBSD/share/man/man9/pmatch.9

74 lines
2.6 KiB
Groff
Raw Normal View History

2003-10-14 10:49:51 +04:00
.\" $NetBSD: pmatch.9,v 1.2 2003/10/14 06:49:51 wiz Exp $
2003-10-13 23:52:58 +04:00
.\"
.\" Copyright (c) 2003 Manuel Bouyer.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Manuel Bouyer.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
.Dd October 12, 2003
.Dt PMATCH 9
.Os
.Sh NAME
.Nm pmatch
.Nd performs pattern matching on strings
.Sh SYNOPSIS
.In sys/systm.h
.Ft int
.Fn pmatch "const char *string" "const char *pattern" "const char **estr"
.Sh DESCRIPTION
Extract substring matching
.Fa pattern
from
.Fa string .
2003-10-14 10:49:51 +04:00
If not
.Dv NULL ,
2003-10-13 23:52:58 +04:00
.Fa estr
points to the end of the longest exact or substring match.
.Pp
.Fn pmatch
uses the following metacharacters:
.Bl -tag -width Ds
2003-10-14 10:49:51 +04:00
.It Li \&?
2003-10-13 23:52:58 +04:00
match any single character.
.It Li *
match any character 0 or more times.
2003-10-14 10:49:51 +04:00
.It Li \&[
2003-10-13 23:52:58 +04:00
define a range of characters that will match.
The range is defined by 2 characters separated by a
2003-10-14 10:49:51 +04:00
.Sq Li \&- .
2003-10-13 23:52:58 +04:00
The range definition has to end with a
2003-10-14 10:49:51 +04:00
.Sq Li \&] .
2003-10-13 23:52:58 +04:00
A
2003-10-14 10:49:51 +04:00
.Sq Li ^
2003-10-13 23:52:58 +04:00
following the
2003-10-14 10:49:51 +04:00
.Sq Li \&[
2003-10-13 23:52:58 +04:00
will negate the range.
.El
.Sh RETURN VALUES
.Fn pmatch
will return 2 for an exact match, 1 for a substring match, 0 for no match and
\-1 if an error occurs.