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