2 * Copyright (c) 2010 Zmanda, Inc. All Rights Reserved.
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.
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
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
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
30 /* The regular expressions used here are POSIX extended regular expressions;
31 * see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html
34 /* validate that REGEX is a valid POSIX regular expression by calling regcomp.
35 * Returns a statically allocated error message on failure or NULL on success. */
36 char * validate_regexp(const char *regex);
38 /* Match STR against POSIX regular expression REGEX by calling regexec. This uses
39 * the REG_NEWLINE flag, meaning that . does not match a newline and $ and ^ are
40 * relative to lines as well as the beginning and end of STR. */
41 int match(const char *regex, const char *str);
43 /* Like match(), but without REG_NEWLINE, so a newline is treated like any other
45 int match_no_newline(const char *regex, const char *str);
47 /* quote any non-alphanumeric characters in str, so that the result will only
48 * match the original string. If anchor is true, then add ^ and $ to make sure
49 * that substrings will not match. */
50 char * clean_regex(const char *str, gboolean anchor);
57 * A "glob expression" is similar to shell globs; it supports metacharacters
58 * "*" and "?", as well as character classes like "[...]" and "[!...]"
59 * (negated). The "*" and "?" do not match filename separators ("/"). The
60 * entire expression is anchored, so it must match the string, not just a single
64 /* Validate that GLOB is a legal GLOB expression. Returns a statically
65 * allocated error message on failure, or NULL on success. */
66 char * validate_glob(const char *glob);
68 /* Convert a GLOB expression into a dynamically allocated regular expression */
69 char * glob_to_regex(const char *glob);
71 /* Like match(), but with a glob expression */
72 int match_glob(const char *glob, const char *str);
78 /* A "tar expression" is almost the same as a glob, except that "*" can match a
79 * filename separator ("?" cannot). It is used by calcsize to emulate tar's exclude
80 * list patterns, which are actually significantly more complicated than this.
83 /* Like match(), but with a tar expression */
84 int match_tar(const char *glob, const char *str);
90 /* Host expressions are described in amanda(8). */
92 /* Make an Amanda host expression that will match the given string exactly.
93 * There is a little bit of fuzz here involving leading and trailing "."
94 * chararacters, (so "host.org", "host.org.", and ".host.org" will all match
95 * the same expressions) but DNS considers them equivalent, too. */
96 char * make_exact_host_expression(const char *host);
98 /* Like match(), but using a host expression */
99 int match_host(const char *glob, const char *host);
105 /* Disk expressions are described in amanda(8) */
107 /* Make an Amanda disk expression that will match the given string exactly. */
108 char * make_exact_disk_expression(const char *disk);
110 /* Like match(), but using a disk expression */
111 int match_disk(const char *glob, const char *disk);
114 * Datestamp expressions
117 /* Datestamp expressions are described in amanda(8) */
119 int match_datestamp(const char *dateexp, const char *datestamp);
125 /* Level expressions are either prefix matches e.g., "1", which matches "1", "10", and "123",
126 * absolute matches e.g., "3$" which only matches "3", or a range e.g., "3-5" which only
127 * matches levels 3, 4, and 5. */
129 /* Like match(), but using a level expression */
130 int match_level(const char *levelexp, const char *level);