OpenVAS Libraries  9.0.3
strutils.c File Reference
#include <ctype.h>
Include dependency graph for strutils.c:

Go to the source code of this file.

Functions

int str_match (const char *string, const char *pattern, int icase)
 

Function Documentation

◆ str_match()

int str_match ( const char *  string,
const char *  pattern,
int  icase 
)
Todo:
These functions are not necessarily nasl-specific and thus subject to be moved (e.g. to misc).
Todo:
In parts replacable by g_pattern_match function (when not icase)

Definition at line 29 of file strutils.c.

References str_match().

Referenced by nasl_match(), and str_match().

30 {
31  while (*pattern != '\0')
32  {
33  if (*pattern == '?')
34  {
35  if (*string == '\0')
36  return 0;
37  }
38  else if (*pattern == '*')
39  {
40  const char *p = string;
41  do
42  if (str_match (p, pattern + 1, icase))
43  return 1;
44  while (*p++ != '\0');
45  return 0;
46  }
47  else if ((icase && (tolower (*pattern) != tolower (*string)))
48  || (!icase && (*pattern != *string)))
49  return 0;
50  pattern++;
51  string++;
52  }
53  return *string == '\0';
54 }
int str_match(const char *string, const char *pattern, int icase)
Definition: strutils.c:29
gchar * string
Here is the call graph for this function:
Here is the caller graph for this function: