Applying file masks in UNIX using C/C++ 
Author Message
 Applying file masks in UNIX using C/C++

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



Sat, 19 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++

Quote:

> 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).
--

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 {*filter*}/his soul went to seek/the doom of the just." -- _Beowulf_


Sun, 20 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++
: 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).

FTR, 'fnmatch()' is defined by POSIX-2 and does this action.

jfn



Sun, 20 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++

    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

          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.



Mon, 21 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++

Quote:

>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);

Quote:
}

/* eof */

Jean-Marc Delforge
Smals - Belgium - Brussels



Tue, 22 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++


 >
 >    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).
--



Wed, 23 Sep 1998 03:00:00 GMT  
 Applying file masks in UNIX using C/C++


Quote:

> 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."



Thu, 24 Sep 1998 04:00:00 GMT  
 Applying file masks in UNIX using C/C++




    >>>>>>> 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

          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.



Wed, 30 Sep 1998 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Two CS files (using namespaces)

3. resx files needed for cs - files ??

4. CS files display in VS6 like CPP files ?

5. Compile CS source code using ICodeCompiler

6. Survey on using C as intro CS langauge (?)

7. Survey on using C as intro CS langa

8. Include code in other Cs files

9. Reuse of cs files, namespace, arch advice pls

10. How to Generate .cs file at Runtime

11. My .cs files were deleted!?

12. manipulating server controls in the Codebehind .cs file

 

 
Powered by phpBB® Forum Software