PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/amanda/tags/3_3_0beta1/client-src/client_util.h

#
C Header | 185 lines | 109 code | 21 blank | 55 comment | 0 complexity | e1e38f9a94a392eaca1404c9a34471eb MD5 | raw file
  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. #ifndef CLIENT_UTIL_H
  31. #define CLIENT_UTIL_H
  32. #include "amanda.h"
  33. #include "conffile.h"
  34. #include "amfeatures.h"
  35. #include "sl.h"
  36. #include "util.h" /* for bstrncmp() */
  37. #include "amandad.h" /* for g_option_t */
  38. #include "amxml.h" /* for dle_t */
  39. typedef enum {
  40. RECOVER_PATH_CWD = 0,
  41. RECOVER_PATH_REMOTE = 1,
  42. } recover_path_t;
  43. typedef struct backup_support_option_s {
  44. int config;
  45. int host;
  46. int disk;
  47. int max_level;
  48. int index_line;
  49. int index_xml;
  50. int message_line;
  51. int message_xml;
  52. int record;
  53. int include_file;
  54. int include_list;
  55. int include_list_glob;
  56. int include_optional;
  57. int exclude_file;
  58. int exclude_list;
  59. int exclude_list_glob;
  60. int exclude_optional;
  61. int collection;
  62. int calcsize;
  63. int client_estimate;
  64. int multi_estimate;
  65. int smb_recover_mode;
  66. int features;
  67. data_path_t data_path_set; /* bitfield of all allowed data-path */
  68. recover_path_t recover_path;
  69. } backup_support_option_t;
  70. typedef struct client_script_result_s {
  71. int exit_code;
  72. proplist_t proplist;
  73. GPtrArray *output;
  74. GPtrArray *err;
  75. } client_script_result_t;
  76. typedef enum {
  77. DMP_NORMAL, DMP_IGNORE, DMP_STRANGE, DMP_SIZE, DMP_ERROR
  78. } dmpline_t;
  79. typedef struct regex_s {
  80. char *regex;
  81. int srcline;
  82. int scale; /* only used for size lines */
  83. int field;
  84. dmpline_t typ;
  85. } amregex_t;
  86. #define AM_NORMAL_RE(re) {(re), __LINE__, 0, 0, DMP_NORMAL}
  87. #define AM_IGNORE_RE(re) {(re), __LINE__, 0, 0, DMP_IGNORE}
  88. #define AM_STRANGE_RE(re) {(re), __LINE__, 0, 0, DMP_STRANGE}
  89. #define AM_SIZE_RE(re,s,f) {(re), __LINE__, (s), (f), DMP_SIZE}
  90. #define AM_ERROR_RE(re) {(re), __LINE__, 0, 0, DMP_ERROR}
  91. char *build_exclude(dle_t *dle, int verbose);
  92. char *build_include(dle_t *dle, int verbose);
  93. void parse_options(char *str,
  94. dle_t *dle,
  95. am_feature_t *features,
  96. int verbose);
  97. /* Add all properties of an application for a dle to an ARGV.
  98. * include/exclude options are converted to properties.
  99. *
  100. * @param argv_ptr: the ARGV where to store properties.
  101. * @param dle: the dle.
  102. * @returns: Number of argument added to ARGV.
  103. */
  104. void application_property_add_to_argv(GPtrArray *argv_ptr,
  105. dle_t *dle,
  106. backup_support_option_t *bsu,
  107. am_feature_t *amfeatures);
  108. /* Merge properties from amanda-client.conf files to dles (application and scripts)
  109. *
  110. * @param dle: the dle list.
  111. * @returns: Return 1 on success
  112. * Return 0 on failure
  113. */
  114. int merge_dles_properties(dle_t *dles, int verbose);
  115. char *fixup_relative(char *name, char *device);
  116. backup_support_option_t *backup_support_option(char *program,
  117. g_option_t *g_options,
  118. char *disk,
  119. char *amdevice,
  120. GPtrArray **errarray);
  121. void run_client_script(script_t *script,
  122. execute_on_t execute_on,
  123. g_option_t *g_options,
  124. dle_t *dle);
  125. void run_client_scripts(execute_on_t execute_on,
  126. g_option_t *g_options,
  127. dle_t *dle,
  128. FILE *streamout);
  129. void run_calcsize(char *config, char *program, char *disk,
  130. char *dirname, GSList *levels,
  131. char *file_exclude, char *file_include);
  132. void check_access(char *filename, int mode);
  133. void check_file(char *filename, int mode);
  134. void check_dir(char *dirname, int mode);
  135. void check_suid(char *filename);
  136. double the_num(char * str, int pos);
  137. /* Convert a GSList returned from config_errors into an "ERROR "
  138. * line suitable for inclusion in a NAK or REP packet. Because we only
  139. * get one ERROR line per packet, this includes only the first
  140. * error, with an indication that there are more to follow.
  141. *
  142. * @param errlist: the list of errors from config_errors
  143. * @returns: newly allocated string containing the error messages
  144. */
  145. char *config_errors_to_error_string(GSList *errlist);
  146. amregex_t *build_re_table(amregex_t *orig_re_table,
  147. GSList *normal_message,
  148. GSList *ignore_message,
  149. GSList *strange_message);
  150. void add_type_table(dmpline_t typ,
  151. amregex_t **re_table, amregex_t *orig_re_table,
  152. GSList *normal_message, GSList *ignore_message,
  153. GSList *strange_message);
  154. void add_list_table(dmpline_t typ, amregex_t **re_table,
  155. GSList *message);
  156. /* Merge properties from conf_proplist to dle_proplist
  157. If verbose is 1, then dle->disk and name are used in output.
  158. * @returns: Return 1 on success
  159. * Return 0 on failure
  160. */
  161. int
  162. merge_properties(dle_t *dle, char *name, proplist_t dle_proplist,
  163. proplist_t conf_proplist, int verbose);
  164. #endif