1 /* $NetBSD: extern.h,v 1.30 2002/01/31 22:43:35 tv 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. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)extern.h 8.2 (Berkeley) 4/18/94 40 */ 41 42 /* 43 * External references from each source file 44 */ 45 46 #include <sys/cdefs.h> 47 #include <err.h> 48 49 /* 50 * ar_io.c 51 */ 52 extern const char *arcname; 53 extern int curdirfd; 54 extern const char *gzip_program; 55 extern time_t starttime; 56 extern int force_one_volume; 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(char *); 79 80 /* 81 * ar_subs.c 82 */ 83 extern u_long flcnt; 84 extern ARCHD archd; 85 void list(void); 86 void extract(void); 87 void append(void); 88 void archive(void); 89 void copy(void); 90 91 /* 92 * buf_subs.c 93 */ 94 extern int blksz; 95 extern int wrblksz; 96 extern int maxflt; 97 extern int rdblksz; 98 extern off_t wrlimit; 99 extern off_t rdcnt; 100 extern off_t wrcnt; 101 int wr_start(void); 102 int rd_start(void); 103 void cp_start(void); 104 int appnd_start(off_t); 105 int rd_sync(void); 106 void pback(char *, int); 107 int rd_skip(off_t); 108 void wr_fin(void); 109 int wr_rdbuf(char *, int); 110 int rd_wrbuf(char *, int); 111 int wr_skip(off_t); 112 int wr_rdfile(ARCHD *, int, off_t *); 113 int rd_wrfile(ARCHD *, int, off_t *); 114 void cp_file(ARCHD *, int, int); 115 int buf_fill(void); 116 int buf_flush(int); 117 118 /* 119 * cpio.c 120 */ 121 extern int cpio_swp_head; 122 int cpio_strd(void); 123 int cpio_subtrail(ARCHD *); 124 int cpio_endwr(void); 125 int cpio_id(char *, int); 126 int cpio_rd(ARCHD *, char *); 127 off_t cpio_endrd(void); 128 int cpio_stwr(void); 129 int cpio_wr(ARCHD *); 130 int vcpio_id(char *, int); 131 int crc_id(char *, int); 132 int crc_strd(void); 133 int vcpio_rd(ARCHD *, char *); 134 off_t vcpio_endrd(void); 135 int crc_stwr(void); 136 int vcpio_wr(ARCHD *); 137 int bcpio_id(char *, int); 138 int bcpio_rd(ARCHD *, char *); 139 off_t bcpio_endrd(void); 140 int bcpio_wr(ARCHD *); 141 142 /* 143 * file_subs.c 144 */ 145 extern char *gnu_hack_string; 146 int file_creat(ARCHD *); 147 void file_close(ARCHD *, int); 148 int lnk_creat(ARCHD *); 149 int cross_lnk(ARCHD *); 150 int chk_same(ARCHD *); 151 int node_creat(ARCHD *); 152 int unlnk_exist(char *, int); 153 int chk_path(char *, uid_t, gid_t); 154 void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); 155 int set_ids(char *, uid_t, gid_t); 156 void set_pmode(char *, mode_t); 157 void set_chflags(char *fnm, u_int32_t flags); 158 int file_write(int, char *, int, int *, int *, int, char *); 159 void file_flush(int, char *, int); 160 void rdfile_close(ARCHD *, int *); 161 int set_crc(ARCHD *, int); 162 163 /* 164 * ftree.c 165 */ 166 int ftree_start(void); 167 int ftree_add(char *, int); 168 void ftree_sel(ARCHD *); 169 void ftree_chk(void); 170 int next_file(ARCHD *); 171 172 /* 173 * gen_subs.c 174 */ 175 void ls_list(ARCHD *, time_t); 176 void ls_tty(ARCHD *); 177 void zf_strncpy(char *, const char *, int); 178 int l_strncpy(char *, const char *, int); 179 u_long asc_ul(char *, int, int); 180 int ul_asc(u_long, char *, int, int); 181 #ifndef NET2_STAT 182 unsigned long long asc_ull(char *, int, int); 183 int ull_asc(unsigned long long, char *, int, int); 184 #endif 185 int check_Aflag(void); 186 187 /* 188 * getoldopt.c 189 */ 190 struct option; 191 int getoldopt(int, char **, const char *, struct option *, int *); 192 193 /* 194 * options.c 195 */ 196 extern FSUB fsub[]; 197 extern int ford[]; 198 extern int cpio_mode; 199 void options(int, char **); 200 OPLIST * opt_next(void); 201 int opt_add(const char *); 202 int opt_chdir(char *); 203 int bad_opt(void); 204 205 /* 206 * pat_rep.c 207 */ 208 int rep_add(char *); 209 int pat_add(char *, int); 210 void pat_chk(void); 211 int pat_sel(ARCHD *); 212 int pat_match(ARCHD *); 213 int mod_name(ARCHD *); 214 int set_dest(ARCHD *, char *, int); 215 216 /* 217 * pax.c 218 */ 219 extern int act; 220 extern FSUB *frmt; 221 extern int Aflag; 222 extern int cflag; 223 extern int dflag; 224 extern int iflag; 225 extern int kflag; 226 extern int lflag; 227 extern int nflag; 228 extern int tflag; 229 extern int uflag; 230 extern int vflag; 231 extern int zflag; 232 extern int Dflag; 233 extern int Hflag; 234 extern int Lflag; 235 extern int Mflag; 236 extern int Xflag; 237 extern int Yflag; 238 extern int Zflag; 239 extern int vfpart; 240 extern int patime; 241 extern int pmtime; 242 extern int pfflags; 243 extern int pmode; 244 extern int pids; 245 extern int exit_val; 246 extern int docrc; 247 extern char *dirptr; 248 extern char *argv0; 249 int main(int, char **); 250 void sig_cleanup(int); 251 252 /* 253 * sel_subs.c 254 */ 255 int sel_chk(ARCHD *); 256 int grp_add(char *); 257 int usr_add(char *); 258 int trng_add(char *); 259 260 /* 261 * tables.c 262 */ 263 int lnk_start(void); 264 int chk_lnk(ARCHD *); 265 void purg_lnk(ARCHD *); 266 void lnk_end(void); 267 int ftime_start(void); 268 int chk_ftime(ARCHD *); 269 int name_start(void); 270 int add_name(char *, int, char *); 271 void sub_name(char *, int *); 272 int dev_start(void); 273 int add_dev(ARCHD *); 274 int map_dev(ARCHD *, u_long, u_long); 275 int atdir_start(void); 276 void atdir_end(void); 277 void add_atdir(char *, dev_t, ino_t, time_t, time_t); 278 int get_atdir(dev_t, ino_t, time_t *, time_t *); 279 int dir_start(void); 280 void add_dir(char *, int, struct stat *, int); 281 void proc_dir(void); 282 u_int st_hash(char *, int, int); 283 284 /* 285 * tar.c 286 */ 287 extern int is_oldgnutar; 288 int tar_endwr(void); 289 off_t tar_endrd(void); 290 int tar_trail(char *, int, int *); 291 int tar_id(char *, int); 292 int tar_opt(void); 293 int tar_rd(ARCHD *, char *); 294 int tar_wr(ARCHD *); 295 int ustar_strd(void); 296 int ustar_stwr(void); 297 int ustar_id(char *, int); 298 int ustar_rd(ARCHD *, char *); 299 int ustar_wr(ARCHD *); 300 int tar_gnutar_X_compat(const char *); 301 302 /* 303 * tty_subs.c 304 */ 305 int tty_init(void); 306 void tty_prnt(const char *, ...) 307 __attribute__((format (printf, 1, 2))); 308 int tty_read(char *, int); 309 void tty_warn(int, const char *, ...) 310 __attribute__((format (printf, 2, 3))); 311 void syswarn(int, int, const char *, ...) 312 __attribute__((format (printf, 3, 4))); 313