From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 10 00:58:50 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 174131065670 for ; Wed, 10 Feb 2010 00:58:50 +0000 (UTC) (envelope-from brampton@gmail.com) Received: from mail-fx0-f224.google.com (mail-fx0-f224.google.com [209.85.220.224]) by mx1.freebsd.org (Postfix) with ESMTP id 993608FC17 for ; Wed, 10 Feb 2010 00:58:49 +0000 (UTC) Received: by fxm24 with SMTP id 24so113591fxm.3 for ; Tue, 09 Feb 2010 16:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=ESNswRvgIkxDiBDQ/LM+veD2KXH1bYW8vlR/5luqm6E=; b=ByzU2RW5GWOR4hZ4ImS5MoT3H+JyEmR7SToK+JTsYt0VBYUpX41IbN6mKGZ6mUCaH0 6Dy/zo8lFy4bGUW6ZCp+7UZ4iLu1uVHhwQPIEJuA4h90PQVSt4kGehhNa5JMAkF2qTrT q7jFVeQB0t3c9ewrcb2Bd4LWzIwP4hgawdWAI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Xzk4rHLXHdEfAcell13B+dctH4rA3Pr9sUzHbP2wPRwSGuAy09dnZiXefoZzGee+R6 HoLeN9H9EcO5+3RZykloK3JTmbiW1iBZGzAeHClPOuvAJDCpuBxtS6Ek1UYl/q7ijwRR NdDIM8K8eY+kWxD+ju2c9WTZyxixbrKWwMTV4= MIME-Version: 1.0 Sender: brampton@gmail.com Received: by 10.223.3.135 with SMTP id 7mr8807419fan.21.1265763528528; Tue, 09 Feb 2010 16:58:48 -0800 (PST) In-Reply-To: <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com> References: <86tytqvwky.fsf@ds4.des.no> <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com> Date: Wed, 10 Feb 2010 00:58:48 +0000 X-Google-Sender-Auth: 7ac291aeda927e3f Message-ID: From: Andrew Brampton To: Garrett Cooper Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl with regex? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 00:58:50 -0000 On Wed, Feb 10, 2010 at 12:51 AM, Garrett Cooper wrote= : > =C2=A0 =C2=A0 =C2=A0 =C2=A0fnmatch is for matching filenames... I think t= here's a better way to do it with globs, but I'll have to take a quick peek= at python's glob module so I don't reinvent the wheel (using fnmatch(3) //= glob(3) to string match seems kind of stupid to do...). > I think fnmatch() is used to match filenames but reading its documentation I don't see why it has to be used only for filenames. It takes a pattern and a string and returns true if they match. Having a quick look in the FreeBSD source it is used in a few non-filesystem places, for example, contrib/binutils/ld/ldlang.c to match section names, sys/netinet/ipfw/ip_fw2.c to match interface names. I'm sure there are other examples. However, if you can find a better suited function then sure, I just don't like reinventing the wheel, even if this wheel is the wrong colour ;) Andrew