1 /* 2 * Copyright (c) 1998,1999,2000 3 * Traakan, Inc., Los Altos, CA 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 /* 30 * Project: NDMJOB 31 * Ident: $Id: $ 32 * 33 * Description: 34 * 35 */ 36 37 38 #include "ndmagents.h" 39 40 41 #ifndef GLOBAL 42 #define GLOBAL extern 43 #endif 44 45 GLOBAL char* progname; 46 47 GLOBAL struct ndm_session the_session; 48 GLOBAL struct ndm_session_param the_param; 49 50 GLOBAL int the_mode; 51 GLOBAL int d_debug; 52 GLOBAL char* L_log_file; 53 GLOBAL int n_noop; 54 GLOBAL int v_verbose; 55 GLOBAL int o_no_time_stamps; 56 GLOBAL char* o_config_file; 57 GLOBAL char* o_tape_tcp; 58 GLOBAL char* o_load_files_file; 59 60 GLOBAL FILE* log_fp; 61 62 extern void error_byebye(char* fmt, ...); 63 64 extern struct ndmp_enum_str_table mode_long_name_table[]; 65 66 extern int process_args(int argc, char* argv[]); 67 extern int handle_long_option(char* str); 68 extern void set_job_mode(int mode); 69 extern void usage(void); 70 extern void help(void); 71 extern void ndmjob_version_info(void); 72 extern void dump_settings(void); 73 74 extern int copy_args_expanding_macros(int argc, 75 char* argv[], 76 char* av[], 77 int max_ac); 78 extern int lookup_and_snarf(char* av[], char* name); 79 extern int snarf_macro(char* av[], char* val); 80 81 extern void ndmjob_log_deliver(struct ndmlog* log, 82 char* tag, 83 int lev, 84 char* msg); 85 86 extern void ndmjob_log(int level, char* fmt, ...); 87 88 89 #ifndef NDMOS_OPTION_NO_CONTROL_AGENT 90 91 #define MAX_EXCLUDE_PATTERN 100 92 #define MAX_FILE_ARG NDM_MAX_NLIST 93 94 GLOBAL char* B_bu_type; 95 GLOBAL int b_bsize; 96 GLOBAL char* C_chdir; 97 GLOBAL struct ndmagent D_data_agent; 98 GLOBAL struct ndm_env_table E_environment; 99 GLOBAL char* e_exclude_pattern[MAX_EXCLUDE_PATTERN]; 100 GLOBAL int n_e_exclude_pattern; 101 GLOBAL char* f_tape_device; 102 GLOBAL char* I_index_file; /* output */ 103 GLOBAL char* J_index_file; /* input */ 104 GLOBAL struct ndm_media_table m_media; 105 GLOBAL struct ndmagent R_robot_agent; 106 GLOBAL struct ndmscsi_target* r_robot_target; 107 GLOBAL struct ndmagent T_tape_agent; 108 GLOBAL char* U_user; 109 110 GLOBAL int o_time_limit; 111 GLOBAL int o_swap_connect; 112 GLOBAL int o_use_eject; 113 GLOBAL int o_tape_addr; 114 GLOBAL int o_from_addr; 115 GLOBAL int o_to_addr; 116 GLOBAL struct ndmscsi_target* o_tape_scsi; 117 GLOBAL int o_tape_timeout; 118 GLOBAL int o_robot_timeout; 119 GLOBAL char* o_rules; 120 GLOBAL off_t o_tape_limit; 121 GLOBAL int p_ndmp_port; 122 123 GLOBAL char* file_arg[MAX_FILE_ARG]; 124 GLOBAL char* file_arg_new[MAX_FILE_ARG]; 125 GLOBAL int n_file_arg; 126 127 /* The ji_ variables are set according to the -J input index */ 128 GLOBAL struct ndm_media_table ji_media; 129 GLOBAL struct ndm_env_table ji_environment; 130 131 GLOBAL ndmp9_name nlist[MAX_FILE_ARG]; /* parallels file_arg[] */ 132 133 GLOBAL FILE* index_fp; 134 135 GLOBAL struct ndm_job_param the_job; 136 137 #define AGENT_GIVEN(AGENT) (AGENT.conn_type != NDMCONN_TYPE_NONE) 138 #define ROBOT_GIVEN() (r_robot_target) 139 140 extern void ndmjob_ixlog_deliver(struct ndmlog* log, 141 char* tag, 142 int lev, 143 char* msg); 144 145 #endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */ 146 147 extern void ndmjob_register_callbacks(struct ndm_session* sess, 148 struct ndmlog* ixlog); 149 extern void ndmjob_unregister_callbacks(struct ndm_session* sess, 150 struct ndmlog* ixlog); 151 152 extern int ndmjobfhdb_add_file(struct ndmlog* ixlog, 153 int tagc, 154 char* raw_name, 155 ndmp9_file_stat* fstat); 156 extern int ndmjobfhdb_add_dir(struct ndmlog* ixlog, 157 int tagc, 158 char* raw_name, 159 ndmp9_u_quad dir_node, 160 ndmp9_u_quad node); 161 extern int ndmjobfhdb_add_node(struct ndmlog* ixlog, 162 int tagc, 163 ndmp9_u_quad node, 164 ndmp9_file_stat* fstat); 165 extern int ndmjobfhdb_add_dirnode_root(struct ndmlog* ixlog, 166 int tagc, 167 ndmp9_u_quad root_node); 168 169 #ifndef NDMOS_OPTION_NO_CONTROL_AGENT 170 extern int start_index_file(void); 171 extern int sort_index_file(void); 172 extern int build_job(void); 173 extern int args_to_job(void); 174 extern int args_to_job_backup_env(void); 175 extern int args_to_job_recover_env(void); 176 extern int args_to_job_recover_nlist(void); 177 extern int jndex_doit(void); 178 extern int jndex_tattle(void); 179 extern int jndex_merge_media(void); 180 extern int jndex_audit_not_found(void); 181 extern int jndex_merge_environment(void); 182 extern int jndex_fetch_post_backup_data_env(FILE* fp); 183 extern int jndex_fetch_post_backup_media(FILE* fp); 184 185 extern int apply_rules(struct ndm_job_param* job, char* rules); 186 extern int help_rules(void); 187 #endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */ 188