Date: Wed, 10 Feb 2010 00:58:48 +0000 From: Andrew Brampton <brampton+freebsd@gmail.com> To: Garrett Cooper <yanefbsd@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl with regex? Message-ID: <d41814901002091658l1e48848bn66a331690fc63608@mail.gmail.com> In-Reply-To: <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com> References: <d41814901002091308s7e894b55p880bde165bbbe703@mail.gmail.com> <86tytqvwky.fsf@ds4.des.no> <d41814901002091528i4884987cmb7347dfe4d50bdc5@mail.gmail.com> <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> <d41814901002091645w289aa894q4a06cbaed59eea05@mail.gmail.com> <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 10, 2010 at 12:51 AM, Garrett Cooper <yanefbsd@gmail.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d41814901002091658l1e48848bn66a331690fc63608>