Imported Upstream version 3.1.0
[debian/amanda] / common-src / match.h
1 /*
2  * Copyright (c) 2010 Zmanda, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16  *
17  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 #ifndef MATCH_H
22 #define MATCH_H
23
24 #include <glib.h>
25
26 char *  validate_regexp(const char *regex);
27
28 /* quote any non-alphanumeric characters in str, so that the result will only
29  * match the original string.  If anchor is true, then add ^ and $ to make sure
30  * that substrings will not match.  Note that the resulting regular expression
31  * will not work with match_host, match_disk, etc., since those do not technically
32  * support quoting metacharacters */
33 char *  clean_regex(const char *str, gboolean anchor);
34
35 /* Make an Amanda host expression that will match the given string exactly. */
36 char *  make_exact_host_expression(const char *host);
37
38 /* Make an Amanda disk expression that will match the given string exactly. */
39 char *  make_exact_disk_expression(const char *disk);
40
41 int     match(const char *regex, const char *str);
42
43 int     match_no_newline(const char *regex, const char *str);
44
45 char *  validate_glob(const char *glob);
46
47 char *  glob_to_regex(const char *glob);
48
49 int     match_glob(const char *glob, const char *str);
50
51 int     match_tar(const char *glob, const char *str);
52
53 int     match_host(const char *glob, const char *host);
54
55 int     match_datestamp(const char *dateexp, const char *datestamp);
56
57 int     match_level(const char *levelexp, const char *level);
58
59 int     match_disk(const char *glob, const char *disk);
60
61 #endif /* MATCH_H */
62