libite 2.6.1
strmatch.c File Reference
#include <errno.h>
#include <string.h>

Go to the source code of this file.

Functions

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

Detailed Description

Author
Joachim Wiberg
Date
2009-2021

Definition in file strmatch.c.

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.

Definition at line 74 of file strmatch.c.

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

Definition at line 43 of file strmatch.c.