SDDSlib
|
Wildcard matching and string utility functions. More...
#include <ctype.h>
#include "mdb.h"
Go to the source code of this file.
Macros | |
#define | MATCH_INVERT '^' |
#define | MATCH_MANY '*' |
#define | MATCH_SET1 '[' |
#define | MATCH_SET2 ']' |
#define | ESCAPE_CHAR '\\' |
#define | SET_MATCH_INVERT '^' |
#define | MATCH_ONE '?' |
Functions | |
int | wild_match (char *string, char *template) |
Determine whether one string is a wildcard match for another. | |
int | wild_match_ci (char *string, char *template) |
Determine whether one string is a case-insensitive wildcard match for another. | |
int | strcmp_ci (const char *s, const char *t) |
Compare two strings case-insensitively. | |
char * | strchr_ci (char *s, char c) |
char * | expand_ranges (char *template) |
Expand range specifiers in a wildcard template into explicit character lists. | |
int | has_wildcards (char *template) |
Check if a template string contains any wildcard characters. | |
char * | unescape_wildcards (char *template) |
Remove escape characters from wildcard characters in a template string. | |
int | strcmp_nh (const char *s1, const char *s2) |
Compare two strings with a custom non-hierarchical ranking. | |
Wildcard matching and string utility functions.
This file provides functions to perform wildcard pattern matching, expand range specifiers within templates, check for the presence of wildcard characters, and manipulate strings with respect to wildcard handling.
Definition in file wild_match.c.
#define ESCAPE_CHAR '\\' |
Definition at line 29 of file wild_match.c.
#define MATCH_INVERT '^' |
Definition at line 25 of file wild_match.c.
#define MATCH_MANY '*' |
Definition at line 26 of file wild_match.c.
#define MATCH_ONE '?' |
Definition at line 35 of file wild_match.c.
#define MATCH_SET1 '[' |
Definition at line 27 of file wild_match.c.
#define MATCH_SET2 ']' |
Definition at line 28 of file wild_match.c.
#define SET_MATCH_INVERT '^' |
Definition at line 30 of file wild_match.c.
char * expand_ranges | ( | char * | template | ) |
Expand range specifiers in a wildcard template into explicit character lists.
Processes a wildcard template containing range specifiers (e.g., [a-e0-5]
) and expands them into explicit lists of characters (e.g., [abcde012345]
). This function should be called before performing wildcard matching with wild_match()
.
template | The wildcard template containing range specifiers. |
Definition at line 429 of file wild_match.c.
int has_wildcards | ( | char * | template | ) |
Check if a template string contains any wildcard characters.
Scans the input template string to determine if it includes any wildcard characters such as '*', '?', or character sets defined within brackets. Escaped wildcard characters (preceded by a backslash) are ignored.
template | The string to check for wildcard characters. |
Definition at line 498 of file wild_match.c.
char * strchr_ci | ( | char * | s, |
char | c ) |
Definition at line 409 of file wild_match.c.
int strcmp_ci | ( | const char * | s, |
const char * | t ) |
Compare two strings case-insensitively.
Performs a case-insensitive comparison between two strings. Returns 0 if the strings are equal, a negative value if the first non-matching character in s1
is lower than that in s2
, and a positive value if it is greater.
s | The first string to compare. |
t | The second string to compare. |
s1
< s2
, 0 if s1
== s2
, 1 if s1
> s2
. Definition at line 396 of file wild_match.c.
int strcmp_nh | ( | const char * | s1, |
const char * | s2 ) |
Compare two strings with a custom non-hierarchical ranking.
Compares two strings where non-numeric characters are ranked before numeric characters. Numeric characters are compared based on their length, with single-digit numbers ranked before multi-digit numbers. The comparison returns -1, 0, or 1 depending on whether the first string is less than, equal to, or greater than the second string.
s1 | The first string to compare. |
s2 | The second string to compare. |
s1
< s2
, 0 if s1
== s2
, 1 if s1
> s2
. Definition at line 583 of file wild_match.c.
char * unescape_wildcards | ( | char * | template | ) |
Remove escape characters from wildcard characters in a template string.
Processes the input template string and removes backslashes preceding wildcard characters ('*', '?', '[', ']'). This function modifies the string in place.
template | The wildcard template string to unescape. |
Definition at line 534 of file wild_match.c.
int wild_match | ( | char * | string, |
char * | template ) |
Determine whether one string is a wildcard match for another.
Compares the input string against a template that may include wildcard characters such as '*', '?', and character sets defined within brackets. Supports inversion of match results using the '^' character.
string | The string to be matched. |
template | The wildcard pattern to match against. |
Definition at line 49 of file wild_match.c.
int wild_match_ci | ( | char * | string, |
char * | template ) |
Determine whether one string is a case-insensitive wildcard match for another.
Similar to wild_match
, but performs case-insensitive comparisons between the input string and the template. Handles wildcard characters and supports inversion of match results.
string | The string to be matched, case-insensitively. |
template | The wildcard pattern to match against, case-insensitively. |
Definition at line 220 of file wild_match.c.