2011-09-11 00:53:11 +02:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*
|
2011-10-25 22:19:38 +02:00
|
|
|
* i3 - an improved dynamic tiling window manager
|
2015-04-04 02:17:56 +02:00
|
|
|
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
|
2011-10-25 22:19:38 +02:00
|
|
|
*
|
|
|
|
* regex.c: Interface to libPCRE (perl compatible regular expressions).
|
|
|
|
*
|
2011-09-11 00:53:11 +02:00
|
|
|
*/
|
2013-12-29 03:11:50 +01:00
|
|
|
#pragma once
|
2011-09-11 00:53:11 +02:00
|
|
|
|
2016-10-11 09:13:35 +02:00
|
|
|
#include <config.h>
|
|
|
|
|
2011-09-11 00:53:11 +02: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-12 00:41:46 +02:00
|
|
|
/**
|
|
|
|
* Frees the given regular expression. It must not be used afterwards!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void regex_free(struct regex *regex);
|
|
|
|
|
2011-09-11 00:53:11 +02: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-22 00:16:52 +02:00
|
|
|
* be visible without debug logging.
|
2011-09-11 00:53:11 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool regex_matches(struct regex *regex, const char *input);
|