xref: /freebsd/bin/pax/extern.h (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
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 
36 /*
37  * External references from each source file
38  */
39 
40 #include <sys/cdefs.h>
41 
42 /*
43  * ar_io.c
44  */
45 extern const char *arcname;
46 extern const char *gzip_program;
47 int ar_open(const char *);
48 void ar_close(void);
49 void ar_drain(void);
50 int ar_set_wr(void);
51 int ar_app_ok(void);
52 int ar_read(char *, int);
53 int ar_write(char *, int);
54 int ar_rdsync(void);
55 int ar_fow(off_t, off_t *);
56 int ar_rev(off_t );
57 int ar_next(void);
58 
59 /*
60  * ar_subs.c
61  */
62 extern u_long flcnt;
63 void list(void);
64 void extract(void);
65 void append(void);
66 void archive(void);
67 void copy(void);
68 
69 /*
70  * buf_subs.c
71  */
72 extern int blksz;
73 extern int wrblksz;
74 extern int maxflt;
75 extern int rdblksz;
76 extern off_t wrlimit;
77 extern off_t rdcnt;
78 extern off_t wrcnt;
79 int wr_start(void);
80 int rd_start(void);
81 void cp_start(void);
82 int appnd_start(off_t);
83 int rd_sync(void);
84 void pback(char *, int);
85 int rd_skip(off_t);
86 void wr_fin(void);
87 int wr_rdbuf(char *, int);
88 int rd_wrbuf(char *, int);
89 int wr_skip(off_t);
90 int wr_rdfile(ARCHD *, int, off_t *);
91 int rd_wrfile(ARCHD *, int, off_t *);
92 void cp_file(ARCHD *, int, int);
93 int buf_fill(void);
94 int buf_flush(int);
95 
96 /*
97  * cache.c
98  */
99 int uidtb_start(void);
100 int gidtb_start(void);
101 int usrtb_start(void);
102 int grptb_start(void);
103 const char * name_uid(uid_t, int);
104 const char * name_gid(gid_t, int);
105 int uid_name(char *, uid_t *);
106 int gid_name(char *, gid_t *);
107 
108 /*
109  * cpio.c
110  */
111 int cpio_strd(void);
112 int cpio_trail(ARCHD *);
113 int cpio_endwr(void);
114 int cpio_id(char *, int);
115 int cpio_rd(ARCHD *, char *);
116 off_t cpio_endrd(void);
117 int cpio_stwr(void);
118 int cpio_wr(ARCHD *);
119 int vcpio_id(char *, int);
120 int crc_id(char *, int);
121 int crc_strd(void);
122 int vcpio_rd(ARCHD *, char *);
123 off_t vcpio_endrd(void);
124 int crc_stwr(void);
125 int vcpio_wr(ARCHD *);
126 int bcpio_id(char *, int);
127 int bcpio_rd(ARCHD *, char *);
128 off_t bcpio_endrd(void);
129 int bcpio_wr(ARCHD *);
130 
131 /*
132  * file_subs.c
133  */
134 int file_creat(ARCHD *);
135 void file_close(ARCHD *, int);
136 int lnk_creat(ARCHD *);
137 int cross_lnk(ARCHD *);
138 int chk_same(ARCHD *);
139 int node_creat(ARCHD *);
140 int unlnk_exist(char *, int);
141 int chk_path(char *, uid_t, gid_t);
142 void set_ftime(char *fnm, time_t mtime, time_t atime, int frc);
143 int set_ids(char *, uid_t, gid_t);
144 int set_lids(char *, uid_t, gid_t);
145 void set_pmode(char *, mode_t);
146 int file_write(int, char *, int, int *, int *, int, char *);
147 void file_flush(int, char *, int);
148 void rdfile_close(ARCHD *, int *);
149 int set_crc(ARCHD *, int);
150 
151 /*
152  * ftree.c
153  */
154 int ftree_start(void);
155 int ftree_add(char *, int);
156 void ftree_sel(ARCHD *);
157 void ftree_notsel(void);
158 void ftree_chk(void);
159 int next_file(ARCHD *);
160 
161 /*
162  * gen_subs.c
163  */
164 void ls_list(ARCHD *, time_t, FILE *);
165 void ls_tty(ARCHD *);
166 int l_strncpy(char *, const char *, int);
167 u_long asc_ul(char *, int, int);
168 int ul_asc(u_long, char *, int, int);
169 u_quad_t asc_uqd(char *, int, int);
170 int uqd_asc(u_quad_t, char *, int, int);
171 
172 /*
173  * getoldopt.c
174  */
175 int getoldopt(int, char **, const char *);
176 
177 /*
178  * options.c
179  */
180 extern FSUB fsub[];
181 extern int ford[];
182 void options(int, char **);
183 OPLIST * opt_next(void);
184 int opt_add(const char *);
185 int bad_opt(void);
186 extern char *chdname;
187 
188 /*
189  * pat_rep.c
190  */
191 int rep_add(char *);
192 int pat_add(char *, char *);
193 void pat_chk(void);
194 int pat_sel(ARCHD *);
195 int pat_match(ARCHD *);
196 int mod_name(ARCHD *);
197 int set_dest(ARCHD *, char *, int);
198 
199 /*
200  * pax.c
201  */
202 extern int act;
203 extern FSUB *frmt;
204 extern int cflag;
205 extern int cwdfd;
206 extern int dflag;
207 extern int iflag;
208 extern int kflag;
209 extern int lflag;
210 extern int nflag;
211 extern int tflag;
212 extern int uflag;
213 extern int vflag;
214 extern int Dflag;
215 extern int Hflag;
216 extern int Lflag;
217 extern int Oflag;
218 extern int Xflag;
219 extern int Yflag;
220 extern int Zflag;
221 extern int vfpart;
222 extern int patime;
223 extern int pmtime;
224 extern int nodirs;
225 extern int pmode;
226 extern int pids;
227 extern int rmleadslash;
228 extern int exit_val;
229 extern int docrc;
230 extern char *dirptr;
231 extern const char *argv0;
232 extern sigset_t s_mask;
233 extern FILE *listf;
234 extern char *tempfile;
235 extern char *tempbase;
236 
237 void sig_cleanup(int);
238 
239 /*
240  * sel_subs.c
241  */
242 int sel_chk(ARCHD *);
243 int grp_add(char *);
244 int usr_add(char *);
245 int trng_add(char *);
246 
247 /*
248  * tables.c
249  */
250 int lnk_start(void);
251 int chk_lnk(ARCHD *);
252 void purg_lnk(ARCHD *);
253 void lnk_end(void);
254 int ftime_start(void);
255 int chk_ftime(ARCHD *);
256 int name_start(void);
257 int add_name(char *, int, char *);
258 void sub_name(char *, int *, size_t);
259 int dev_start(void);
260 int add_dev(ARCHD *);
261 int map_dev(ARCHD *, u_long, u_long);
262 int atdir_start(void);
263 void atdir_end(void);
264 void add_atdir(char *, dev_t, ino_t, time_t, time_t);
265 int get_atdir(dev_t, ino_t, time_t *, time_t *);
266 int dir_start(void);
267 void add_dir(char *, int, struct stat *, int);
268 void proc_dir(void);
269 u_int st_hash(char *, int, int);
270 
271 /*
272  * tar.c
273  */
274 int tar_endwr(void);
275 off_t tar_endrd(void);
276 int tar_trail(char *, int, int *);
277 int tar_id(char *, int);
278 int tar_opt(void);
279 int tar_rd(ARCHD *, char *);
280 int tar_wr(ARCHD *);
281 int ustar_strd(void);
282 int ustar_stwr(void);
283 int ustar_id(char *, int);
284 int ustar_rd(ARCHD *, char *);
285 int ustar_wr(ARCHD *);
286 
287 /*
288  * tty_subs.c
289  */
290 int tty_init(void);
291 void tty_prnt(const char *, ...) __printflike(1, 2);
292 int tty_read(char *, int);
293 void paxwarn(int, const char *, ...) __printflike(2, 3);
294 void syswarn(int, int, const char *, ...) __printflike(3, 4);
295