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