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