Thread View: comp.unix.programmer
8 messages
8 total messages
Started by Stephane Charette
Tue, 02 Apr 1996 20:15
Applying file masks in UNIX using C/C++
Author: Stephane Charette
Date: Tue, 02 Apr 1996 20:15
Date: Tue, 02 Apr 1996 20:15
17 lines
1224 bytes
1224 bytes
This is a long shot...but...does anyone know of the existence of public domain C/C++ code which will apply a file mask to an existing filename and return a TRUE or FALSE response? For example: if I have a mask of "a??01.text.*" and I have the files "abc01.text.old", "az01.text.new" and "az01.text", then it would return positive on the first two, but negative on the last. Does this make sense? What I hope, is that someone has already done all of this and put it up there on an FTP site. Thing is, I can't find it... WWW searches have turned up nothing so far either. (The fact that I have no idea what this would be called doesn't help.) Thanks for your help, Stephane Charette
Re: Applying file masks in UNIX using C/C++
Author: Erik Max Francis
Date: Wed, 03 Apr 1996 16:16
Date: Wed, 03 Apr 1996 16:16
15 lines
1361 bytes
1361 bytes
Stephane Charette wrote: > This is a long shot...but...does anyone know of the existence > of public domain C/C++ code which will apply a file mask to > an existing filename and return a TRUE or FALSE response? Nope. This sort of information is not available under the ANSI C standard. You should look on whatever programming group is appropriate for the operating system you're interested in (e.g., comp.os.msdos.programmer). -- Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max@alcyone.com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_
Re: Applying file masks in UNIX using C/C++
Author: Jeremy Nelson
Date: Wed, 03 Apr 1996 17:35
Date: Wed, 03 Apr 1996 17:35
13 lines
953 bytes
953 bytes
Stephane Charette wrote: : This is a long shot...but...does anyone know of the existence : of public domain C/C++ code which will apply a file mask to : an existing filename and return a TRUE or FALSE response? Erik Max Francis <max@alcyone.com> wrote: ! Nope. This sort of information is not available under the ANSI C standard. ! You should look on whatever programming group is appropriate for the ! operating system you're interested in (e.g., comp.os.msdos.programmer). FTR, 'fnmatch()' is defined by POSIX-2 and does this action. jfn
Re: Applying file masks in UNIX using C/C++
Author: Jacob Lorensen
Date: Thu, 04 Apr 1996 09:26
Date: Thu, 04 Apr 1996 09:26
45 lines
2079 bytes
2079 bytes
>>>>> "Stephane" == Stephane Charette <charrick@netrover.com> writes:
Stephane> This is a long shot...but...does anyone know of the
Stephane> existence of public domain C/C++ code which will apply a
Stephane> file mask to an existing filename and return a TRUE or
Stephane> FALSE response?
How about this?
WILDMAT(3) WILDMAT(3)
NAME
wildmat - perform shell-style wildcard matching
SYNOPSIS
int
wildmat(text, pattern)
char *text;
char *pattern;
DESCRIPTION
Wildmat compares the text against the pattern and returns
non-zero if the pattern matches the text. The pattern is
interpreted according to rules similar to shell filename
wildcards, and not as a full regular expression such as
those handled by the grep(1) family of programs or the
regex(3) or regexp(3) set of routines.
[...]
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> in 1986, and
posted to Usenet several times since then, most notably in
comp.sources.misc in March, 1991.
So I would suggest an archie search for wildmat or a search in
comp.sources.misc archives.
Hope this helps,
Jacob.
--
Jacob Lorensen; Mosebuen 33, 1.; DK-2820 Gentofte, Denmark; +45-31560401
PGP Key fingerprint = 1E 87 26 46 74 36 DC 4A 72 3B 66 78 C5 AD 9E 71
Public key available at the keyservers.
Re: Applying file masks in UNIX using C/C++
Author: Jean-Marc Delforge
Date: Fri, 05 Apr 1996 09:33
Date: Fri, 05 Apr 1996 09:33
75 lines
2112 bytes
2112 bytes
Stephane Charette <charrick@netrover.com> wrote:
>This is a long shot...but...does anyone know of the existence
>of public domain C/C++ code which will apply a file mask to
>an existing filename and return a TRUE or FALSE response?
>For example: if I have a mask of "a??01.text.*" and I have
>the files "abc01.text.old", "az01.text.new" and "az01.text",
>then it would return positive on the first two, but negative
>on the last. Does this make sense?
>What I hope, is that someone has already done all of this and
>put it up there on an FTP site. Thing is, I can't find it...
>WWW searches have turned up nothing so far either. (The fact
>that I have no idea what this would be called doesn't help.)
>Thanks for your help,
>Stephane Charette
Try This.
This is working like UNIX wildcards.
More best than DOS wildcards.
It's comminig from my mind.
It's working recusrively, and for strings of any size.
/*
** str_filter.c
** (c) smals 1992
** Delforge jm 2641
*/
#include <dos.h>
int StrFilter (char * str, char * mask)
{
char * pm, *ps;
pm = mask;
ps = str;
if (*pm == 0) return (1);
while (*pm != 0)
{
switch (*pm)
{
case '*' :
pm++;
if (*ps == 0) return (1);
while (*ps != 0)
{
if (StrFilter (ps, pm)) return (1);
ps++;
}
return (0);
case '?' :
if (*ps == 0) return (0);
ps++; pm++;
break;
default :
if (*pm != *ps) return (0);
pm++, ps++;
break;
}
}
if (*ps == 0) return (1);
else return (0);
}
/* eof */
Jean-Marc Delforge
Smals - Belgium - Brussels
101513.2141@compuserve.com
Re: Applying file masks in UNIX using C/C++
Author: Kazimir Kylheku
Date: Sun, 07 Apr 1996 05:04
Date: Sun, 07 Apr 1996 05:04
30 lines
1489 bytes
1489 bytes
In article <m1g2akuyph.fsf@pippin.jblhome.ping.dk>, Jacob Lorensen <jacob@jblhome.ping.dk> wrote: >>>>>> "Stephane" == Stephane Charette <charrick@netrover.com> writes: > > Stephane> This is a long shot...but...does anyone know of the > Stephane> existence of public domain C/C++ code which will apply a > Stephane> file mask to an existing filename and return a TRUE or > Stephane> FALSE response? > >How about this? > > WILDMAT(3) WILDMAT(3) > > > NAME > wildmat - perform shell-style wildcard matching > > SYNOPSIS > int > wildmat(text, pattern) > char *text; > char *pattern; FYI, there is a POSIX.2 standard function called glob() for doing this. I've never even heard of wildmat! I have checked three different major UNIX OS's and none of them have it in their man page roster. glob() and globfree() are also defined by the X/Open Portability Guide 4 (XPG4). --
Re: Applying file masks in UNIX using C/C++
Author: Tom Wheeley
Date: Sun, 07 Apr 1996 17:45
Date: Sun, 07 Apr 1996 17:45
17 lines
1329 bytes
1329 bytes
In article <4k7icoINNp4c@keats.ugrad.cs.ubc.ca>
c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
>
> FYI, there is a POSIX.2 standard function called glob() for doing this.
> I've never even heard of wildmat! I have checked three different major UNIX
> OS's and none of them have it in their man page roster.
I have the wildmat man page on my system (supposedly put there by Slackware --
I certainly didn't put it there) However, I don't have thew routine, so I
wrote my own in the end.
.splitbung
--
* TQ 1.0 * The 'Just So Quotes'.
"This is a one line proof...if we start sufficiently far to the left."
-- peter@cbmvax.cbm.commodore.com
Re: Applying file masks in UNIX using C/C++
Author: Jacob Lorensen
Date: Sat, 13 Apr 1996 18:50
Date: Sat, 13 Apr 1996 18:50
48 lines
2690 bytes
2690 bytes
>>>>> "Kazimir" == Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> writes:
Kazimir> In article <m1g2akuyph.fsf@pippin.jblhome.ping.dk>, Jacob
Kazimir> Lorensen <jacob@jblhome.ping.dk> wrote:
>>>>>>> "Stephane" == Stephane Charette <charrick@netrover.com>
>>>>>>> writes:
Stephane> This is a long shot...but...does anyone know of the
Stephane> existence of public domain C/C++ code which will apply a
Stephane> file mask to an existing filename and return a TRUE or
Stephane> FALSE response?
>> WILDMAT(3) WILDMAT(3)
>> NAME wildmat - perform shell-style wildcard matching
>> SYNOPSIS int wildmat(text, pattern) char *text; char *pattern;
Kazimir> I've never even heard of wildmat! I have checked three
Kazimir> different major UNIX OS's and none of them have it in
Kazimir> their man page roster.
No, I would not have thought so. That's also the reason I put a bit of
extra information in my article, namely (also from the manual page):
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> in 1986, and
posted to Usenet several times since then, most notably in
comp.sources.misc in March, 1991.
I.e., it appears to be a freely available library written by Rick Salz
and posted to Usenet. As the description of the routine's
functionality matches that requested by the original poster (Stephane
Charette), namely to match a set of file names against a shell-style
globbing pattern, I still think it may be a good idea to try and find
it. Glob() searches the directory itself and thus can _only_ be used
to find file names; wildmat() can be used to match arbitrary strings,
including filenames, against a pattern.
BTW, wildmat() is included in the INN distribution.
Jacob.
--
Jacob Lorensen; Mosebuen 33, 1.; DK-2820 Gentofte, Denmark; +45-31560401
PGP Key fingerprint = 1E 87 26 46 74 36 DC 4A 72 3B 66 78 C5 AD 9E 71
Public key available at the keyservers.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads