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