Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

What is shwild?

Version 0.9.2

Introduction | License | C API | C++ API

Installing shwild | Building shwild | Linking to shwild | Contact & Feedback

Introduction

shwild is a simple, platform-independent, library that implements shell-compatible wildcard pattern matching.

It supports single-function matching, as in:

  // C or C++
  shwild_match("1?2",     "122", 0);                    // Returns 0 (matches)
  shwild_match("1[0-8]2", "122", 0);                    // Returns 0 (matches)
  shwild_match("1[0-8]2", "192", 0);                    // Returns 1 (does not match)
  shwild_match("1?2",     "1x1", 0);                    // Returns 1 (does not match)
  shwild_match("1[N-Z]2", "1x2", 0);                    // Returns 1 (does not match)
  shwild_match("1[N-Z]2", "1x2", SHWILD_F_IGNORE_CASE); // Returns 0 (matches)

and:

  // C++ only
  shwild::match("1?2", "122");    // Returns 0 (matches)
  shwild::match("1?2", "121", 0); // Returns 1 (does not match)

It also supports pattern pre-compilation, as in:

  // C or C++
  shwild_handle_t hCompiledPattern;

  if(shwild_compile_pattern("sh*.[cC]??", 0, &hCompiledPattern) >= 0)
  {
    shwild_match_pattern(hCompiledPattern, "shwild.cpp"); // Returns 0 (matches)
    shwild_match_pattern(hCompiledPattern, "shwild.hpp"); // Returns 1 (does not match)

    shwild_destroy_pattern(hCompiledPattern);
  }

and:

  // C++ only
  shwild::Pattern   pattern("sh*.[cC]??", 0);

  pattern.match("shwild.cpp"); // Returns true (matches)
  pattern.match("shwild.hpp"); // Returns false (does not match)

Recognised Patterns

shwild supports common (UNIX) shell parsing characters, as follows:

Suppressing characteristics or allowing more sophisticated behaviour is achieved by specifying one or more of the pattern control flags to the calls to shwild_match() and shwild_compile_pattern().

Languages

shwild is written in C and C++, and presents a C API along with C++ wrappers.

There is a COM mapping (written in C++, using ATL and STLSoft) called shwild.com, which is available separately from the website.

Authors

shwild is written by Matthew Wilson and Sean Kelly. Matthew is an author and development consultant. Sean is a UNIX expert and leading figure in the D Programming Language community.

License

shwild is released under the BSD license, which basically means its free for any use, but you can't claim it's yours.

Portability and Dependencies

shwild is written in standard C/C++, and should be compilable with any modern C/C++ compiler that provides an implementation of the C & C++ standard libraries. In addition, the Open Watcom compiler, which does not at this time support the standard library, is also compatible by dint of the use of some simple compatibility measures (see the vector_maker and shwild_string_t types).

The implementation of shwild is dependent on the following open-source libraries:

In addition, the following open-source libraries are required by one or more test programs supplied in the standard distribution:


shwild Library documentation © Matthew Wilson and Sean Kelly, 2004-2006 SourceForge.net Logo