2011-09-10 18:53:11 -04:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*
|
2011-10-25 16:19:38 -04:00
|
|
|
* i3 - an improved dynamic tiling window manager
|
|
|
|
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
|
|
|
|
*
|
|
|
|
* regex.c: Interface to libPCRE (perl compatible regular expressions).
|
|
|
|
*
|
2011-09-10 18:53:11 -04:00
|
|
|
*/
|
2013-12-28 21:11:50 -05:00
|
|
|
#pragma once
|
2011-09-10 18:53:11 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct regex *regex_new(const char *pattern);
|
|
|
|
|
2011-09-11 18:41:46 -04:00
|
|
|
/**
|
|
|
|
* Frees the given regular expression. It must not be used afterwards!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void regex_free(struct regex *regex);
|
|
|
|
|
2011-09-10 18:53:11 -04:00
|
|
|
/**
|
|
|
|
* 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
|
2012-07-21 18:16:52 -04:00
|
|
|
* be visible without debug logging.
|
2011-09-10 18:53:11 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool regex_matches(struct regex *regex, const char *input);
|