extern.h revision 1.60
1/*	$NetBSD: extern.h,v 1.60 2020/04/03 16:13:32 joerg 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 */
48extern const char *arcname;
49extern int curdirfd;
50extern const char *gzip_program;
51extern time_t starttime;
52extern int force_one_volume;
53extern char *chdname;
54extern int forcelocal;
55extern int secure;
56
57int ar_open(const char *);
58void ar_close(void);
59void ar_drain(void);
60int ar_set_wr(void);
61int ar_app_ok(void);
62#ifdef SYS_NO_RESTART
63int read_with_restart(int, void *, int);
64int write_with_restart(int, void *, int);
65#else
66#define read_with_restart	read
67#define write_with_restart	write
68#endif
69int xread(int, void *, int);
70int xwrite(int, void *, int);
71int ar_read(char *, int);
72int ar_write(char *, int);
73int ar_rdsync(void);
74int ar_fow(off_t, off_t *);
75int ar_rev(off_t );
76int ar_next(void);
77void ar_summary(int);
78int ar_dochdir(const char *);
79
80/*
81 * ar_subs.c
82 */
83extern u_long flcnt;
84extern ARCHD archd;
85int updatepath(void);
86int dochdir(const char *);
87int fdochdir(int);
88int domkdir(const char *, mode_t);
89int list(void);
90int extract(void);
91int append(void);
92int archive(void);
93int copy(void);
94
95/*
96 * buf_subs.c
97 */
98extern int blksz;
99extern int wrblksz;
100extern int maxflt;
101extern int rdblksz;
102extern off_t wrlimit;
103extern off_t rdcnt;
104extern off_t wrcnt;
105int wr_start(void);
106int rd_start(void);
107void cp_start(void);
108int appnd_start(off_t);
109int rd_sync(void);
110void pback(char *, int);
111int rd_skip(off_t);
112void wr_fin(void);
113int wr_rdbuf(char *, int);
114int rd_wrbuf(char *, int);
115int wr_skip(off_t);
116int wr_rdfile(ARCHD *, int, off_t *);
117int rd_wrfile(ARCHD *, int, off_t *);
118void cp_file(ARCHD *, int, int);
119int buf_fill(void);
120int buf_flush(int);
121
122/*
123 * cpio.c
124 */
125extern int cpio_swp_head;
126int cpio_strd(void);
127int cpio_subtrail(ARCHD *);
128int cpio_endwr(void);
129int cpio_id(char *, int);
130int cpio_rd(ARCHD *, char *);
131off_t cpio_endrd(void);
132int cpio_stwr(void);
133int cpio_wr(ARCHD *);
134int vcpio_id(char *, int);
135int crc_id(char *, int);
136int crc_strd(void);
137int vcpio_rd(ARCHD *, char *);
138off_t vcpio_endrd(void);
139int crc_stwr(void);
140int vcpio_wr(ARCHD *);
141int bcpio_id(char *, int);
142int bcpio_rd(ARCHD *, char *);
143off_t bcpio_endrd(void);
144int bcpio_wr(ARCHD *);
145
146/*
147 * file_subs.c
148 */
149extern char *gnu_name_string, *gnu_link_string;
150extern size_t gnu_name_length, gnu_link_length;
151extern char *xtmp_name;
152int file_creat(ARCHD *, int);
153void file_close(ARCHD *, int);
154int lnk_creat(ARCHD *, int *);
155int cross_lnk(ARCHD *);
156int chk_same(ARCHD *);
157int node_creat(ARCHD *);
158int unlnk_exist(char *, int);
159int chk_path(char *, uid_t, gid_t);
160void set_ftime(char *fnm, time_t mtime, time_t atime, int frc, int slk);
161int set_ids(char *, uid_t, gid_t);
162void set_pmode(char *, mode_t);
163void set_chflags(char *fnm, u_int32_t flags);
164int file_write(int, char *, int, int *, int *, int, char *);
165void file_flush(int, char *, int);
166void rdfile_close(ARCHD *, int *);
167int set_crc(ARCHD *, int);
168
169/*
170 * ftree.c
171 */
172int ftree_start(void);
173int ftree_add(char *, int);
174void ftree_sel(ARCHD *);
175void ftree_chk(void);
176int next_file(ARCHD *);
177
178/*
179 * gen_subs.c
180 */
181void ls_list(ARCHD *, time_t, FILE *);
182void ls_tty(ARCHD *);
183void safe_print(const char *, FILE *);
184uint32_t asc_u32(char *, int, int);
185int u32_asc(uintmax_t, char *, int, int);
186uintmax_t asc_umax(char *, int, int);
187int umax_asc(uintmax_t, char *, int, int);
188int check_Aflag(void);
189
190/*
191 * getoldopt.c
192 */
193struct option;
194int getoldopt(int, char **, const char *, struct option *, int *);
195
196/*
197 * options.c
198 */
199extern FSUB fsub[];
200extern int ford[];
201extern int sep;
202extern int havechd;
203void options(int, char **);
204OPLIST * opt_next(void);
205int bad_opt(void);
206int mkpath(char *);
207#if !HAVE_NBTOOL_CONFIG_H
208extern int do_chroot;
209#endif
210
211/*
212 * pat_rep.c
213 */
214int rep_add(char *);
215int pat_add(char *, char *, int);
216void pat_chk(void);
217int pat_sel(ARCHD *);
218int pat_match(ARCHD *);
219int mod_name(ARCHD *, int);
220int set_dest(ARCHD *, char *, int);
221
222/*
223 * pax.c
224 */
225extern int act;
226extern FSUB *frmt;
227extern int Aflag;
228extern int cflag;
229extern int cwdfd;
230extern int dflag;
231extern int iflag;
232extern int kflag;
233extern int lflag;
234extern int nflag;
235extern int tflag;
236extern int uflag;
237extern int vflag;
238extern int Dflag;
239extern int Hflag;
240extern int Lflag;
241extern int Mflag;
242extern int Vflag;
243extern int Xflag;
244extern int Yflag;
245extern int Zflag;
246extern int vfpart;
247extern int patime;
248extern int pmtime;
249extern int nodirs;
250extern int pfflags;
251extern int pmode;
252extern int pids;
253extern int rmleadslash;
254extern int exit_val;
255extern int docrc;
256extern int to_stdout;
257extern char *dirptr;
258extern char *ltmfrmt;
259extern const char *argv0;
260extern FILE *listf;
261extern char *tempfile;
262extern char *tempbase;
263
264/*
265 * sel_subs.c
266 */
267int sel_chk(ARCHD *);
268int grp_add(char *);
269int usr_add(char *);
270int trng_add(char *);
271
272/*
273 * tables.c
274 */
275int lnk_start(void);
276int chk_lnk(ARCHD *);
277void purg_lnk(ARCHD *);
278void lnk_end(void);
279int ftime_start(void);
280int chk_ftime(ARCHD *);
281int name_start(void);
282int add_name(char *, int, char *);
283void sub_name(char *, int *, size_t);
284int dev_start(void);
285int add_dev(ARCHD *);
286int map_dev(ARCHD *, u_long, u_long);
287int atdir_start(void);
288void atdir_end(void);
289void add_atdir(char *, dev_t, ino_t, time_t, time_t);
290int get_atdir(dev_t, ino_t, time_t *, time_t *);
291int dir_start(void);
292void add_dir(char *, int, struct stat *, int);
293void proc_dir(void);
294u_int st_hash(char *, int, int);
295
296/*
297 * tar.c
298 */
299extern int is_gnutar;
300int tar_endwr(void);
301off_t tar_endrd(void);
302int tar_trail(char *, int, int *);
303int tar_id(char *, int);
304int tar_opt(void);
305int tar_rd(ARCHD *, char *);
306int tar_wr(ARCHD *);
307int ustar_strd(void);
308int ustar_stwr(void);
309int ustar_id(char *, int);
310int ustar_rd(ARCHD *, char *);
311int ustar_wr(ARCHD *);
312int tar_gnutar_X_compat(const char *);
313int tar_gnutar_minus_minus_exclude(const char *);
314
315/*
316 * tty_subs.c
317 */
318int tty_init(void);
319void tty_prnt(const char *, ...)
320    __attribute__((format (printf, 1, 2)));
321int tty_read(char *, int);
322void tty_warn(int, const char *, ...)
323    __attribute__((format (printf, 2, 3)));
324void syswarn(int, int, const char *, ...)
325    __attribute__((format (printf, 3, 4)));
326