1 /* $NetBSD: extern.h,v 1.49 2005/09/16 16:48:18 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 1992 Keith Muller. 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Keith Muller of the University of California, San Diego. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)extern.h 8.2 (Berkeley) 4/18/94 36 */ 37 38 /* 39 * External references from each source file 40 */ 41 42 #include <sys/cdefs.h> 43 #include <err.h> 44 45 /* 46 * ar_io.c 47 */ 48 extern const char *arcname; 49 extern int curdirfd; 50 extern const char *gzip_program; 51 extern time_t starttime; 52 extern int force_one_volume; 53 extern char *chdname; 54 extern int forcelocal; 55 extern int secure; 56 57 int ar_open(const char *); 58 void ar_close(void); 59 void ar_drain(void); 60 int ar_set_wr(void); 61 int ar_app_ok(void); 62 #ifdef SYS_NO_RESTART 63 int read_with_restart(int, void *, int); 64 int write_with_restart(int, void *, int); 65 #else 66 #define read_with_restart read 67 #define write_with_restart write 68 #endif 69 int xread(int, void *, int); 70 int xwrite(int, void *, int); 71 int ar_read(char *, int); 72 int ar_write(char *, int); 73 int ar_rdsync(void); 74 int ar_fow(off_t, off_t *); 75 int ar_rev(off_t ); 76 int ar_next(void); 77 void ar_summary(int); 78 int ar_dochdir(const char *); 79 80 /* 81 * ar_subs.c 82 */ 83 extern u_long flcnt; 84 extern ARCHD archd; 85 int updatepath(void); 86 int dochdir(const char *); 87 int fdochdir(int); 88 int domkdir(const char *, mode_t); 89 void list(void); 90 void extract(void); 91 void append(void); 92 void archive(void); 93 void copy(void); 94 95 /* 96 * buf_subs.c 97 */ 98 extern int blksz; 99 extern int wrblksz; 100 extern int maxflt; 101 extern int rdblksz; 102 extern off_t wrlimit; 103 extern off_t rdcnt; 104 extern off_t wrcnt; 105 int wr_start(void); 106 int rd_start(void); 107 void cp_start(void); 108 int appnd_start(off_t); 109 int rd_sync(void); 110 void pback(char *, int); 111 int rd_skip(off_t); 112 void wr_fin(void); 113 int wr_rdbuf(char *, int); 114 int rd_wrbuf(char *, int); 115 int wr_skip(off_t); 116 int wr_rdfile(ARCHD *, int, off_t *); 117 int rd_wrfile(ARCHD *, int, off_t *); 118 void cp_file(ARCHD *, int, int); 119 int buf_fill(void); 120 int buf_flush(int); 121 122 /* 123 * cpio.c 124 */ 125 extern int cpio_swp_head; 126 int cpio_strd(void); 127 int cpio_subtrail(ARCHD *); 128 int cpio_endwr(void); 129 int cpio_id(char *, int); 130 int cpio_rd(ARCHD *, char *); 131 off_t cpio_endrd(void); 132 int cpio_stwr(void); 133 int cpio_wr(ARCHD *); 134 int vcpio_id(char *, int); 135 int crc_id(char *, int); 136 int crc_strd(void); 137 int vcpio_rd(ARCHD *, char *); 138 off_t vcpio_endrd(void); 139 int crc_stwr(void); 140 int vcpio_wr(ARCHD *); 141 int bcpio_id(char *, int); 142 int bcpio_rd(ARCHD *, char *); 143 off_t bcpio_endrd(void); 144 int bcpio_wr(ARCHD *); 145 146 /* 147 * file_subs.c 148 */ 149 extern char *gnu_name_string, *gnu_link_string; 150 extern size_t gnu_name_length, gnu_link_length; 151 extern char *xtmp_name; 152 int file_creat(ARCHD *, int); 153 void file_close(ARCHD *, int); 154 int lnk_creat(ARCHD *, int *); 155 int cross_lnk(ARCHD *); 156 int chk_same(ARCHD *); 157 int node_creat(ARCHD *); 158 int unlnk_exist(char *, int); 159 int chk_path(char *, uid_t, gid_t); 160 void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); 161 int set_ids(char *, uid_t, gid_t); 162 void set_pmode(char *, mode_t); 163 void set_chflags(char *fnm, u_int32_t flags); 164 int file_write(int, char *, int, int *, int *, int, char *); 165 void file_flush(int, char *, int); 166 void rdfile_close(ARCHD *, int *); 167 int set_crc(ARCHD *, int); 168 169 /* 170 * ftree.c 171 */ 172 int ftree_start(void); 173 int ftree_add(char *, int); 174 void ftree_sel(ARCHD *); 175 void ftree_chk(void); 176 int next_file(ARCHD *); 177 178 /* 179 * gen_subs.c 180 */ 181 void ls_list(ARCHD *, time_t, FILE *); 182 void ls_tty(ARCHD *); 183 void safe_print(const char *, FILE *); 184 u_long asc_ul(char *, int, int); 185 int ul_asc(u_long, char *, int, int); 186 #if !defined(NET2_STAT) && !defined(_LP64) 187 unsigned long long asc_ull(char *, int, int); 188 int ull_asc(unsigned long long, char *, int, int); 189 #endif 190 int check_Aflag(void); 191 192 /* 193 * getoldopt.c 194 */ 195 struct option; 196 int getoldopt(int, char **, const char *, struct option *, int *); 197 198 /* 199 * options.c 200 */ 201 extern FSUB fsub[]; 202 extern int ford[]; 203 extern int sep; 204 void options(int, char **); 205 OPLIST * opt_next(void); 206 int opt_add(const char *); 207 int bad_opt(void); 208 int mkpath(char *); 209 char *chdname; 210 #if !HAVE_NBTOOL_CONFIG_H 211 int do_chroot; 212 #endif 213 214 /* 215 * pat_rep.c 216 */ 217 int rep_add(char *); 218 int pat_add(char *, char *); 219 void pat_chk(void); 220 int pat_sel(ARCHD *); 221 int pat_match(ARCHD *); 222 int mod_name(ARCHD *); 223 int set_dest(ARCHD *, char *, int); 224 225 /* 226 * pax.c 227 */ 228 extern int act; 229 extern FSUB *frmt; 230 extern int Aflag; 231 extern int cflag; 232 extern int cwdfd; 233 extern int dflag; 234 extern int iflag; 235 extern int jflag; 236 extern int kflag; 237 extern int lflag; 238 extern int nflag; 239 extern int tflag; 240 extern int uflag; 241 extern int vflag; 242 extern int zflag; 243 extern int Dflag; 244 extern int Hflag; 245 extern int Lflag; 246 extern int Mflag; 247 extern int Xflag; 248 extern int Yflag; 249 extern int Zflag; 250 extern int vfpart; 251 extern int patime; 252 extern int pmtime; 253 extern int nodirs; 254 extern int pfflags; 255 extern int pmode; 256 extern int pids; 257 extern int rmleadslash; 258 extern int exit_val; 259 extern int docrc; 260 extern int to_stdout; 261 extern char *dirptr; 262 extern char *ltmfrmt; 263 extern const char *argv0; 264 extern FILE *listf; 265 extern char *tempfile; 266 extern char *tempbase; 267 268 int main(int, char **); 269 void sig_cleanup(int); 270 271 /* 272 * sel_subs.c 273 */ 274 int sel_chk(ARCHD *); 275 int grp_add(char *); 276 int usr_add(char *); 277 int trng_add(char *); 278 279 /* 280 * tables.c 281 */ 282 int lnk_start(void); 283 int chk_lnk(ARCHD *); 284 void purg_lnk(ARCHD *); 285 void lnk_end(void); 286 int ftime_start(void); 287 int chk_ftime(ARCHD *); 288 int name_start(void); 289 int add_name(char *, int, char *); 290 void sub_name(char *, int *, size_t); 291 int dev_start(void); 292 int add_dev(ARCHD *); 293 int map_dev(ARCHD *, u_long, u_long); 294 int atdir_start(void); 295 void atdir_end(void); 296 void add_atdir(char *, dev_t, ino_t, time_t, time_t); 297 int get_atdir(dev_t, ino_t, time_t *, time_t *); 298 int dir_start(void); 299 void add_dir(char *, int, struct stat *, int); 300 void proc_dir(void); 301 u_int st_hash(char *, int, int); 302 303 /* 304 * tar.c 305 */ 306 extern int is_gnutar; 307 int tar_endwr(void); 308 off_t tar_endrd(void); 309 int tar_trail(char *, int, int *); 310 int tar_id(char *, int); 311 int tar_opt(void); 312 int tar_rd(ARCHD *, char *); 313 int tar_wr(ARCHD *); 314 int ustar_strd(void); 315 int ustar_stwr(void); 316 int ustar_id(char *, int); 317 int ustar_rd(ARCHD *, char *); 318 int ustar_wr(ARCHD *); 319 int tar_gnutar_X_compat(const char *); 320 int tar_gnutar_minus_minus_exclude(const char *); 321 322 /* 323 * tty_subs.c 324 */ 325 int tty_init(void); 326 void tty_prnt(const char *, ...) 327 __attribute__((format (printf, 1, 2))); 328 int tty_read(char *, int); 329 void tty_warn(int, const char *, ...) 330 __attribute__((format (printf, 2, 3))); 331 void syswarn(int, int, const char *, ...) 332 __attribute__((format (printf, 3, 4))); 333