1*6d07b400Sbouyer.\" $NetBSD: pmatch.9,v 1.3 2009/10/19 18:41:09 bouyer Exp $ 234173457Sbouyer.\" 334173457Sbouyer.\" Copyright (c) 2003 Manuel Bouyer. 434173457Sbouyer.\" 534173457Sbouyer.\" Redistribution and use in source and binary forms, with or without 634173457Sbouyer.\" modification, are permitted provided that the following conditions 734173457Sbouyer.\" are met: 834173457Sbouyer.\" 1. Redistributions of source code must retain the above copyright 934173457Sbouyer.\" notice, this list of conditions and the following disclaimer. 1034173457Sbouyer.\" 2. Redistributions in binary form must reproduce the above copyright 1134173457Sbouyer.\" notice, this list of conditions and the following disclaimer in the 1234173457Sbouyer.\" documentation and/or other materials provided with the distribution. 1334173457Sbouyer.\" 1434173457Sbouyer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1534173457Sbouyer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1634173457Sbouyer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1734173457Sbouyer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1834173457Sbouyer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1934173457Sbouyer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2034173457Sbouyer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2134173457Sbouyer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2234173457Sbouyer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2334173457Sbouyer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2434173457Sbouyer.\" 2534173457Sbouyer.\" 2634173457Sbouyer.Dd October 12, 2003 2734173457Sbouyer.Dt PMATCH 9 2834173457Sbouyer.Os 2934173457Sbouyer.Sh NAME 3034173457Sbouyer.Nm pmatch 3134173457Sbouyer.Nd performs pattern matching on strings 3234173457Sbouyer.Sh SYNOPSIS 3334173457Sbouyer.In sys/systm.h 3434173457Sbouyer.Ft int 3534173457Sbouyer.Fn pmatch "const char *string" "const char *pattern" "const char **estr" 3634173457Sbouyer.Sh DESCRIPTION 3734173457SbouyerExtract substring matching 3834173457Sbouyer.Fa pattern 3934173457Sbouyerfrom 4034173457Sbouyer.Fa string . 41d981fc9cSwizIf not 42d981fc9cSwiz.Dv NULL , 4334173457Sbouyer.Fa estr 4434173457Sbouyerpoints to the end of the longest exact or substring match. 4534173457Sbouyer.Pp 4634173457Sbouyer.Fn pmatch 4734173457Sbouyeruses the following metacharacters: 4834173457Sbouyer.Bl -tag -width Ds 49d981fc9cSwiz.It Li \&? 5034173457Sbouyermatch any single character. 5134173457Sbouyer.It Li * 5234173457Sbouyermatch any character 0 or more times. 53d981fc9cSwiz.It Li \&[ 5434173457Sbouyerdefine a range of characters that will match. 5534173457SbouyerThe range is defined by 2 characters separated by a 56d981fc9cSwiz.Sq Li \&- . 5734173457SbouyerThe range definition has to end with a 58d981fc9cSwiz.Sq Li \&] . 5934173457SbouyerA 60d981fc9cSwiz.Sq Li ^ 6134173457Sbouyerfollowing the 62d981fc9cSwiz.Sq Li \&[ 6334173457Sbouyerwill negate the range. 6434173457Sbouyer.El 6534173457Sbouyer.Sh RETURN VALUES 6634173457Sbouyer.Fn pmatch 6734173457Sbouyerwill return 2 for an exact match, 1 for a substring match, 0 for no match and 6834173457Sbouyer\-1 if an error occurs. 69