ed686c6e5cc17edaa88c990b9d00df3240d4bf61
[debian/amanda] / client-src / client_util.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
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.
15  *
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.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /* 
27  * $Id: client_util.h,v 1.14 2006/05/25 01:47:11 johnfranks Exp $
28  *
29  */
30
31 #ifndef CLIENT_UTIL_H
32 #define CLIENT_UTIL_H
33
34 #include "amanda.h"
35 #include "conffile.h"
36 #include "amfeatures.h"
37 #include "sl.h"
38 #include "util.h"               /* for bstrncmp() */
39 #include "amandad.h"            /* for g_option_t */
40 #include "amxml.h"              /* for dle_t      */
41
42 typedef struct backup_support_option_s {
43     int config;
44     int host;
45     int disk;
46     int max_level;
47     int index_line;
48     int index_xml;
49     int message_line;
50     int message_xml;
51     int record;
52     int include_file;
53     int include_list;
54     int include_optional;
55     int exclude_file;
56     int exclude_list;
57     int exclude_optional;
58     int collection;
59     int calcsize;
60     int multi_estimate;
61     int smb_recover_mode;
62 } backup_support_option_t;
63
64 typedef struct client_script_result_s {
65     int exit_code;
66     proplist_t proplist;
67     GPtrArray *output;
68     GPtrArray *err;
69 } client_script_result_t;
70
71 char *build_exclude(dle_t *dle, int verbose);
72 char *build_include(dle_t *dle, int verbose);
73 void parse_options(char *str,
74                    dle_t *dle,
75                    am_feature_t *features,
76                    int verbose);
77
78 /* Count the size of an ARGV to store all properties of an application for
79  * a dle. include/exclude options are converted to properties.
80  *
81  * @param dle: the dle
82  * @returns: size of an ARGV needed.
83  */
84 int application_property_argv_size(dle_t *dle);
85
86 /* Add all properties of an application for a dle to an ARGV.
87  * include/exclude options are converted to properties.
88  *
89  * @param argvchild: the ARGV where to store properties.
90  * @param dle: the dle.
91  * @returns: Number of argument added to ARGV.
92  */
93 int application_property_add_to_argv(char **argvchild,
94                                      dle_t *dle,
95                                      backup_support_option_t *bsu);
96
97 char *fixup_relative(char *name, char *device);
98 backup_support_option_t *backup_support_option(char *program,
99                                                g_option_t *g_options,
100                                                char *disk,
101                                                char *amdevice,
102                                                GPtrArray **errarray);
103
104 void run_client_script(script_t     *script,
105                        execute_on_t  execute_on,
106                        g_option_t   *g_options,
107                        dle_t        *dle);
108
109 void run_client_scripts(execute_on_t  execute_on,
110                         g_option_t   *g_options,
111                         dle_t        *dle,
112                         FILE         *streamout);
113
114 void run_calcsize(char *config, char *program, char *disk,
115                   char *dirname, GSList *levels,
116                   char *file_exclude, char *file_include);
117
118 void check_access(char *filename, int mode);
119 void check_file(char *filename, int mode);
120 void check_dir(char *dirname, int mode);
121 void check_suid(char *filename);
122 double the_num(char * str, int pos);
123
124 /* Convert a GSList returned from config_errors into an "ERROR "
125  * line suitable for inclusion in a NAK or REP packet.  Because we only
126  * get one ERROR line per packet, this includes only the first 
127  * error, with an indication that there are more to follow.
128  *
129  * @param errlist: the list of errors from config_errors
130  * @returns: newly allocated string containing the error messages
131  */
132 char *config_errors_to_error_string(GSList *errlist);
133
134 #endif