i3
regex.h File Reference
#include <config.h>
Include dependency graph for regex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct regexregex_new (const char *pattern)
 Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression.
 
void regex_free (struct regex *regex)
 Frees the given regular expression.
 
bool regex_matches (struct regex *regex, const char *input)
 Checks if the given regular expression matches the given input and returns true if it does.
 

Function Documentation

◆ regex_free()

void regex_free ( struct regex * regex)

Frees the given regular expression.

It must not be used afterwards!

Definition at line 47 of file regex.c.

References FREE, regex::pattern, and regex::regex.

Referenced by match_free(), match_parse_property(), and regex_new().

Here is the call graph for this function:

◆ regex_matches()

bool regex_matches ( struct regex * regex,
const char * input )

Checks if the given regular expression matches the given input and returns true if it does.

In either case, it logs the outcome using LOG(), so it will be visible without debug logging.

Definition at line 62 of file regex.c.

References ELOG, LOG, regex::pattern, and regex::regex.

Referenced by cmd_criteria_match_windows(), and match_matches_window().

Here is the call graph for this function:

◆ regex_new()

struct regex * regex_new ( const char * pattern)

Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression.

Also, calls pcre_study because this regex will most likely be used often (like for every new window and on every relevant property change of existing windows).

Returns NULL if the pattern could not be compiled into a regular expression (and ELOGs an appropriate error message).

Definition at line 22 of file regex.c.

References ELOG, regex::pattern, regex::regex, regex_free(), scalloc(), and sstrdup().

Referenced by json_string(), and match_parse_property().

Here is the call graph for this function: