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 42 #ifndef GLOBAL 43 #define GLOBAL extern 44 #endif 45 46 GLOBAL char * progname; 47 48 GLOBAL struct ndm_session the_session; 49 GLOBAL struct ndm_session_param the_param; 50 51 GLOBAL int the_mode; 52 GLOBAL int d_debug; 53 GLOBAL char * L_log_file; 54 GLOBAL int n_noop; 55 GLOBAL int v_verbose; 56 GLOBAL int o_no_time_stamps; 57 GLOBAL char * o_config_file; 58 GLOBAL char * o_tape_tcp; 59 GLOBAL char * o_load_files_file; 60 61 GLOBAL FILE * log_fp; 62 63 extern void error_byebye (char *fmt, ...); 64 65 extern struct ndmp_enum_str_table mode_long_name_table[]; 66 67 extern int process_args (int argc, char *argv[]); 68 extern int handle_long_option (char *str); 69 extern void set_job_mode (int mode); 70 extern void usage (void); 71 extern void help (void); 72 extern void ndmjob_version_info (void); 73 extern void dump_settings (void); 74 75 extern int copy_args_expanding_macros (int argc, char *argv[], 76 char *av[], int max_ac); 77 extern int lookup_and_snarf (char *av[], char *name); 78 extern int snarf_macro (char *av[], char *val); 79 80 extern void ndmjob_log_deliver(struct ndmlog *log, char *tag, 81 int lev, char *msg); 82 83 extern void ndmjob_log (int level, char *fmt, ...); 84 85 86 #ifndef NDMOS_OPTION_NO_CONTROL_AGENT 87 88 #define MAX_EXCLUDE_PATTERN 100 89 #define MAX_FILE_ARG NDM_MAX_NLIST 90 91 GLOBAL char * B_bu_type; 92 GLOBAL int b_bsize; 93 GLOBAL char * C_chdir; 94 GLOBAL struct ndmagent D_data_agent; 95 GLOBAL struct ndm_env_table E_environment; 96 GLOBAL char * e_exclude_pattern[MAX_EXCLUDE_PATTERN]; 97 GLOBAL int n_e_exclude_pattern; 98 GLOBAL char * f_tape_device; 99 GLOBAL char * I_index_file; /* output */ 100 GLOBAL char * J_index_file; /* input */ 101 GLOBAL struct ndm_media_table m_media; 102 GLOBAL struct ndmagent R_robot_agent; 103 GLOBAL struct ndmscsi_target * r_robot_target; 104 GLOBAL struct ndmagent T_tape_agent; 105 GLOBAL char * U_user; 106 107 GLOBAL int o_time_limit; 108 GLOBAL int o_swap_connect; 109 GLOBAL int o_use_eject; 110 GLOBAL int o_tape_addr; 111 GLOBAL int o_from_addr; 112 GLOBAL int o_to_addr; 113 GLOBAL struct ndmscsi_target * o_tape_scsi; 114 GLOBAL int o_tape_timeout; 115 GLOBAL int o_robot_timeout; 116 GLOBAL char * o_rules; 117 GLOBAL off_t o_tape_limit; 118 GLOBAL int p_ndmp_port; 119 120 GLOBAL char * file_arg[MAX_FILE_ARG]; 121 GLOBAL char * file_arg_new[MAX_FILE_ARG]; 122 GLOBAL int n_file_arg; 123 124 /* The ji_ variables are set according to the -J input index */ 125 GLOBAL struct ndm_media_table ji_media; 126 GLOBAL struct ndm_env_table ji_environment; 127 128 GLOBAL ndmp9_name nlist[MAX_FILE_ARG]; /* parallels file_arg[] */ 129 130 GLOBAL FILE * index_fp; 131 132 GLOBAL struct ndm_job_param the_job; 133 134 #define AGENT_GIVEN(AGENT) (AGENT.conn_type != NDMCONN_TYPE_NONE) 135 #define ROBOT_GIVEN() (r_robot_target) 136 137 extern void ndmjob_ixlog_deliver(struct ndmlog *log, char *tag, 138 int lev, char *msg); 139 140 #endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */ 141 142 extern void ndmjob_register_callbacks (struct ndm_session *sess, 143 struct ndmlog *ixlog); 144 extern void ndmjob_unregister_callbacks (struct ndm_session *sess, 145 struct ndmlog *ixlog); 146 147 extern int ndmjobfhdb_add_file (struct ndmlog *ixlog, int tagc, 148 char *raw_name, ndmp9_file_stat *fstat); 149 extern int ndmjobfhdb_add_dir (struct ndmlog *ixlog, int tagc, 150 char *raw_name, ndmp9_u_quad dir_node, ndmp9_u_quad node); 151 extern int ndmjobfhdb_add_node (struct ndmlog *ixlog, int tagc, 152 ndmp9_u_quad node, ndmp9_file_stat *fstat); 153 extern int ndmjobfhdb_add_dirnode_root (struct ndmlog *ixlog, int tagc, 154 ndmp9_u_quad root_node); 155 156 #ifndef NDMOS_OPTION_NO_CONTROL_AGENT 157 extern int start_index_file (void); 158 extern int sort_index_file (void); 159 extern int build_job (void); 160 extern int args_to_job (void); 161 extern int args_to_job_backup_env (void); 162 extern int args_to_job_recover_env (void); 163 extern int args_to_job_recover_nlist (void); 164 extern int jndex_doit (void); 165 extern int jndex_tattle (void); 166 extern int jndex_merge_media (void); 167 extern int jndex_audit_not_found (void); 168 extern int jndex_merge_environment (void); 169 extern int jndex_fetch_post_backup_data_env (FILE *fp); 170 extern int jndex_fetch_post_backup_media (FILE *fp); 171 172 extern int apply_rules (struct ndm_job_param *job, char *rules); 173 extern int help_rules (void); 174 #endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */ 175