lintian doesn't like orphan packages with uploaders...
[debian/amanda] / client-src / client_util.h
index b5ed362696bebe8ac1a5ce1cbd804e6b21a20f87..eae215cef5054e476de8a06ab3cf7deb685777ad 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  * Copyright (c) 1991-1998 University of Maryland at College Park
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  * All Rights Reserved.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
 #include "amanda.h"
 #include "conffile.h"
 #include "amfeatures.h"
-#include "sl.h"
+#include "am_sl.h"
 #include "util.h"              /* for bstrncmp() */
 #include "amandad.h"           /* for g_option_t */
+#include "amxml.h"             /* for dle_t      */
 
-typedef struct option_s {
-    char *str;
-    int compress;
-    int encrypt;
-    char *srvcompprog;
-    char *clntcompprog;
-    char *srv_encrypt;
-    char *clnt_encrypt;
-    char *srv_decrypt_opt;
-    char *clnt_decrypt_opt;
-    int no_record;
-    int createindex;
-    char *auth;
-    sl_t *exclude_file;
-    sl_t *exclude_list;
-    sl_t *include_file;
-    sl_t *include_list;
-    int exclude_optional;
-    int include_optional;
-    int kencrypt;
-} option_t;
+typedef enum {
+    RECOVER_PATH_CWD    = 0,
+    RECOVER_PATH_REMOTE = 1,
+} recover_path_t;
 
 typedef struct backup_support_option_s {
     int config;
@@ -72,26 +57,130 @@ typedef struct backup_support_option_s {
     int record;
     int include_file;
     int include_list;
+    int include_list_glob;
     int include_optional;
     int exclude_file;
     int exclude_list;
+    int exclude_list_glob;
     int exclude_optional;
     int collection;
+    int calcsize;
+    int client_estimate;
+    int multi_estimate;
+    int smb_recover_mode;
+    int features;
+    data_path_t data_path_set;  /* bitfield of all allowed data-path */
+    recover_path_t recover_path;
 } backup_support_option_t;
 
-char *build_exclude(char *disk, char *device, option_t *options, int verbose);
-char *build_include(char *disk, char *device, option_t *options, int verbose);
-void init_options(option_t *options);
-option_t *parse_options(char *str,
-                          char *disk,
-                          char *device,
-                          am_feature_t *features,
-                          int verbose);
-void output_tool_property(FILE *tool, option_t *options);
+typedef struct client_script_result_s {
+    int exit_code;
+    proplist_t proplist;
+    GPtrArray *output;
+    GPtrArray *err;
+} client_script_result_t;
+
+typedef enum {
+    DMP_NORMAL, DMP_IGNORE, DMP_STRANGE, DMP_SIZE, DMP_ERROR
+} dmpline_t;
+
+typedef struct regex_s {
+    char *regex;
+    int srcline;
+    int scale;                 /* only used for size lines */
+    int field;
+    dmpline_t typ;
+} amregex_t;
+
+#define AM_NORMAL_RE(re)       {(re), __LINE__, 0, 0, DMP_NORMAL}
+#define AM_IGNORE_RE(re)       {(re), __LINE__, 0, 0, DMP_IGNORE}
+#define AM_STRANGE_RE(re)      {(re), __LINE__, 0, 0, DMP_STRANGE}
+#define AM_SIZE_RE(re,s,f)     {(re), __LINE__, (s), (f), DMP_SIZE}
+#define AM_ERROR_RE(re)                {(re), __LINE__, 0, 0, DMP_ERROR}
+
+char *build_exclude(dle_t *dle, int verbose);
+char *build_include(dle_t *dle, int verbose);
+void parse_options(char *str,
+                  dle_t *dle,
+                  am_feature_t *features,
+                  int verbose);
+
+/* Add all properties of an application for a dle to an ARGV.
+ * include/exclude options are converted to properties.
+ *
+ * @param argv_ptr: the ARGV where to store properties.
+ * @param dle: the dle.
+ * @returns: Number of argument added to ARGV.
+ */
+void application_property_add_to_argv(GPtrArray *argv_ptr,
+                                     dle_t *dle,
+                                     backup_support_option_t *bsu,
+                                     am_feature_t *amfeatures);
+
+/* Merge properties from amanda-client.conf files to dles (application and scripts)
+ *
+ * @param dle: the dle list.
+ * @returns: Return 1 on success
+ *           Return 0 on failure
+ */
+int merge_dles_properties(dle_t *dles, int verbose);
+
 char *fixup_relative(char *name, char *device);
 backup_support_option_t *backup_support_option(char *program,
                                               g_option_t *g_options,
                                               char *disk,
-                                              char *amdevice);
+                                              char *amdevice,
+                                              GPtrArray **errarray);
+
+void run_client_script(script_t     *script,
+                      execute_on_t  execute_on,
+                      g_option_t   *g_options,
+                      dle_t        *dle);
+
+void run_client_scripts(execute_on_t  execute_on,
+                       g_option_t   *g_options,
+                       dle_t        *dle,
+                       FILE         *streamout);
+
+void run_calcsize(char *config, char *program, char *disk,
+                  char *dirname, GSList *levels,
+                  char *file_exclude, char *file_include);
+
+gboolean check_access(char *filename, int mode);
+gboolean check_file(char *filename, int mode);
+gboolean check_dir(char *dirname, int mode);
+gboolean check_suid(char *filename);
+double the_num(char * str, int pos);
+
+/* Convert a GSList returned from config_errors into an "ERROR "
+ * line suitable for inclusion in a NAK or REP packet.  Because we only
+ * get one ERROR line per packet, this includes only the first 
+ * error, with an indication that there are more to follow.
+ *
+ * @param errlist: the list of errors from config_errors
+ * @returns: newly allocated string containing the error messages
+ */
+char *config_errors_to_error_string(GSList *errlist);
+
+amregex_t *build_re_table(amregex_t *orig_re_table,
+                          GSList *normal_message,
+                          GSList *ignore_message,
+                          GSList *strange_message);
+void add_type_table(dmpline_t typ,
+                    amregex_t **re_table, amregex_t *orig_re_table,
+                    GSList *normal_message, GSList *ignore_message,
+                    GSList *strange_message);
+void add_list_table(dmpline_t typ, amregex_t **re_table,
+                    GSList *message);
+
+/* Merge properties from conf_proplist to dle_proplist
+   If verbose is 1, then dle->disk and name are used in output.
+ * @returns: Return 1 on success
+ *           Return 0 on failure
+ */
+int
+merge_properties(dle_t *dle, char *name, proplist_t dle_proplist,
+                proplist_t conf_proplist, int verbose);
 
 #endif
+