i3
Functions
regex.c File Reference
#include "all.h"
Include dependency graph for regex.c:

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. More...
 
void regex_free (struct regex *regex)
 Frees the given regular expression. More...
 
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. More...
 

Function Documentation

void regex_free ( struct regex regex)

Frees the given regular expression.

It must not be used afterwards!

Definition at line 59 of file regex.c.

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

Referenced by match_free().

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 any debug loglevel.

Definition at line 73 of file regex.c.

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

Referenced by cmd_criteria_match_windows(), and match_matches_window().

struct regex* regex_new ( const char *  pattern)
read

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::extra, regex::pattern, regex::regex, scalloc(), and sstrdup().

Referenced by cmd_criteria_add(), and yyparse().

Here is the call graph for this function: