libite
Functions
strmatch.c File Reference
#include <errno.h>
#include <string.h>
Include dependency graph for strmatch.c:

Functions

int strnmatch (const char *str, const char **list, size_t num)
 Finds matching strings from a finite list. More...
 
int strmatch (const char *str, const char **list)
 Finds matching strings from a list. More...
 

Detailed Description

Author
Joachim Wiberg
Date
2009-2021

Function Documentation

◆ strmatch()

int strmatch ( const char *  str,
const char **  list 
)

Finds matching strings from a list.

Parameters
strString to look for.
listNUL terminated list of strings to search.

This function searches the list of strings for str. If a (partial) match is found it returns the index in the list.

Please note, the list MUST be terminated by a NUL element. If that is not possible, we recommend using strnmatch() instead.

Returns
-1 on error, otherwise the index to the matching string.

◆ strnmatch()

int strnmatch ( const char *  str,
const char **  list,
size_t  num 
)

Finds matching strings from a finite list.

Parameters
strString to look for
listList of strings to search.
numNumber of entries in list.

This function searches the list of strings for str. If a (partial) match is found it returns the index in the list.

Very similar in function to strmatch(), but works for sets of strings that are not NUL terminated.

Returns
-1 on error, otherwise the index to the matching string.