2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: the Amanda Development Team. Its members are listed in a
25 * file named AUTHORS, in the root directory of this distribution.
28 * $Id: client_util.h,v 1.14 2006/05/25 01:47:11 johnfranks Exp $
37 #include "amfeatures.h"
39 #include "util.h" /* for bstrncmp() */
40 #include "amandad.h" /* for g_option_t */
41 #include "amxml.h" /* for dle_t */
45 RECOVER_PATH_REMOTE = 1,
48 typedef struct backup_support_option_s {
60 int include_list_glob;
64 int exclude_list_glob;
72 data_path_t data_path_set; /* bitfield of all allowed data-path */
73 recover_path_t recover_path;
74 } backup_support_option_t;
76 typedef struct client_script_result_s {
81 } client_script_result_t;
84 DMP_NORMAL, DMP_IGNORE, DMP_STRANGE, DMP_SIZE, DMP_ERROR
87 typedef struct regex_s {
90 int scale; /* only used for size lines */
95 #define AM_NORMAL_RE(re) {(re), __LINE__, 0, 0, DMP_NORMAL}
96 #define AM_IGNORE_RE(re) {(re), __LINE__, 0, 0, DMP_IGNORE}
97 #define AM_STRANGE_RE(re) {(re), __LINE__, 0, 0, DMP_STRANGE}
98 #define AM_SIZE_RE(re,s,f) {(re), __LINE__, (s), (f), DMP_SIZE}
99 #define AM_ERROR_RE(re) {(re), __LINE__, 0, 0, DMP_ERROR}
101 char *build_exclude(dle_t *dle, int verbose);
102 char *build_include(dle_t *dle, int verbose);
103 void parse_options(char *str,
105 am_feature_t *features,
108 /* Add all properties of an application for a dle to an ARGV.
109 * include/exclude options are converted to properties.
111 * @param argv_ptr: the ARGV where to store properties.
112 * @param dle: the dle.
113 * @returns: Number of argument added to ARGV.
115 void application_property_add_to_argv(GPtrArray *argv_ptr,
117 backup_support_option_t *bsu,
118 am_feature_t *amfeatures);
120 /* Merge properties from amanda-client.conf files to dles (application and scripts)
122 * @param dle: the dle list.
123 * @returns: Return 1 on success
124 * Return 0 on failure
126 int merge_dles_properties(dle_t *dles, int verbose);
128 char *fixup_relative(char *name, char *device);
129 backup_support_option_t *backup_support_option(char *program,
130 g_option_t *g_options,
133 GPtrArray **errarray);
135 void run_client_script(script_t *script,
136 execute_on_t execute_on,
137 g_option_t *g_options,
140 void run_client_scripts(execute_on_t execute_on,
141 g_option_t *g_options,
145 void run_calcsize(char *config, char *program, char *disk,
146 char *dirname, GSList *levels,
147 char *file_exclude, char *file_include);
149 gboolean check_access(char *filename, int mode);
150 gboolean check_file(char *filename, int mode);
151 gboolean check_dir(char *dirname, int mode);
152 gboolean check_suid(char *filename);
153 double the_num(char * str, int pos);
155 /* Convert a GSList returned from config_errors into an "ERROR "
156 * line suitable for inclusion in a NAK or REP packet. Because we only
157 * get one ERROR line per packet, this includes only the first
158 * error, with an indication that there are more to follow.
160 * @param errlist: the list of errors from config_errors
161 * @returns: newly allocated string containing the error messages
163 char *config_errors_to_error_string(GSList *errlist);
165 amregex_t *build_re_table(amregex_t *orig_re_table,
166 GSList *normal_message,
167 GSList *ignore_message,
168 GSList *strange_message);
169 void add_type_table(dmpline_t typ,
170 amregex_t **re_table, amregex_t *orig_re_table,
171 GSList *normal_message, GSList *ignore_message,
172 GSList *strange_message);
173 void add_list_table(dmpline_t typ, amregex_t **re_table,
176 /* Merge properties from conf_proplist to dle_proplist
177 If verbose is 1, then dle->disk and name are used in output.
178 * @returns: Return 1 on success
179 * Return 0 on failure
182 merge_properties(dle_t *dle, char *name, proplist_t dle_proplist,
183 proplist_t conf_proplist, int verbose);