]> git.sur5r.net Git - i3/i3/blob - include/regex.h
Merge pull request #2507 from stapelberg/autotools
[i3/i3] / include / regex.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * regex.c: Interface to libPCRE (perl compatible regular expressions).
8  *
9  */
10 #pragma once
11
12 #include <config.h>
13
14 /**
15  * Creates a new 'regex' struct containing the given pattern and a PCRE
16  * compiled regular expression. Also, calls pcre_study because this regex will
17  * most likely be used often (like for every new window and on every relevant
18  * property change of existing windows).
19  *
20  * Returns NULL if the pattern could not be compiled into a regular expression
21  * (and ELOGs an appropriate error message).
22  *
23  */
24 struct regex *regex_new(const char *pattern);
25
26 /**
27  * Frees the given regular expression. It must not be used afterwards!
28  *
29  */
30 void regex_free(struct regex *regex);
31
32 /**
33  * Checks if the given regular expression matches the given input and returns
34  * true if it does. In either case, it logs the outcome using LOG(), so it will
35  * be visible without debug logging.
36  *
37  */
38 bool regex_matches(struct regex *regex, const char *input);