xref: /netbsd/bin/pax/extern.h (revision c4a72b64)
1 /*	$NetBSD: extern.h,v 1.36 2002/12/08 01:35:12 mrg 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. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *	This product includes software developed by the University of
22  *	California, Berkeley and its contributors.
23  * 4. Neither the name of the University nor the names of its contributors
24  *    may be used to endorse or promote products derived from this software
25  *    without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  *
39  *	@(#)extern.h	8.2 (Berkeley) 4/18/94
40  */
41 
42 /*
43  * External references from each source file
44  */
45 
46 #include <sys/cdefs.h>
47 #include <err.h>
48 
49 /*
50  * ar_io.c
51  */
52 extern const char *arcname;
53 extern int curdirfd;
54 extern const char *gzip_program;
55 extern time_t starttime;
56 extern int force_one_volume;
57 extern char *chdname;
58 extern int forcelocal;
59 extern int secure;
60 
61 int ar_open(const char *);
62 void ar_close(void);
63 void ar_drain(void);
64 int ar_set_wr(void);
65 int ar_app_ok(void);
66 #ifdef SYS_NO_RESTART
67 int read_with_restart(int, void *, int);
68 int write_with_restart(int, void *, int);
69 #else
70 #define read_with_restart	read
71 #define write_with_restart	write
72 #endif
73 int xread(int, void *, int);
74 int xwrite(int, void *, int);
75 int ar_read(char *, int);
76 int ar_write(char *, int);
77 int ar_rdsync(void);
78 int ar_fow(off_t, off_t *);
79 int ar_rev(off_t );
80 int ar_next(void);
81 void ar_summary(int);
82 int ar_dochdir(char *);
83 
84 /*
85  * ar_subs.c
86  */
87 extern u_long flcnt;
88 extern ARCHD archd;
89 void list(void);
90 void extract(void);
91 void append(void);
92 void archive(void);
93 void copy(void);
94 
95 /*
96  * buf_subs.c
97  */
98 extern int blksz;
99 extern int wrblksz;
100 extern int maxflt;
101 extern int rdblksz;
102 extern off_t wrlimit;
103 extern off_t rdcnt;
104 extern off_t wrcnt;
105 int wr_start(void);
106 int rd_start(void);
107 void cp_start(void);
108 int appnd_start(off_t);
109 int rd_sync(void);
110 void pback(char *, int);
111 int rd_skip(off_t);
112 void wr_fin(void);
113 int wr_rdbuf(char *, int);
114 int rd_wrbuf(char *, int);
115 int wr_skip(off_t);
116 int wr_rdfile(ARCHD *, int, off_t *);
117 int rd_wrfile(ARCHD *, int, off_t *);
118 void cp_file(ARCHD *, int, int);
119 int buf_fill(void);
120 int buf_flush(int);
121 
122 /*
123  * cpio.c
124  */
125 extern int cpio_swp_head;
126 int cpio_strd(void);
127 int cpio_subtrail(ARCHD *);
128 int cpio_endwr(void);
129 int cpio_id(char *, int);
130 int cpio_rd(ARCHD *, char *);
131 off_t cpio_endrd(void);
132 int cpio_stwr(void);
133 int cpio_wr(ARCHD *);
134 int vcpio_id(char *, int);
135 int crc_id(char *, int);
136 int crc_strd(void);
137 int vcpio_rd(ARCHD *, char *);
138 off_t vcpio_endrd(void);
139 int crc_stwr(void);
140 int vcpio_wr(ARCHD *);
141 int bcpio_id(char *, int);
142 int bcpio_rd(ARCHD *, char *);
143 off_t bcpio_endrd(void);
144 int bcpio_wr(ARCHD *);
145 
146 /*
147  * file_subs.c
148  */
149 extern char *gnu_name_string, *gnu_link_string;
150 int file_creat(ARCHD *);
151 void file_close(ARCHD *, int);
152 int lnk_creat(ARCHD *);
153 int cross_lnk(ARCHD *);
154 int chk_same(ARCHD *);
155 int node_creat(ARCHD *);
156 int unlnk_exist(char *, int);
157 int chk_path(char *, uid_t, gid_t);
158 void set_ftime(char *fnm, time_t mtime, time_t atime, int frc);
159 int set_ids(char *, uid_t, gid_t);
160 void set_pmode(char *, mode_t);
161 void set_chflags(char *fnm, u_int32_t flags);
162 int file_write(int, char *, int, int *, int *, int, char *);
163 void file_flush(int, char *, int);
164 void rdfile_close(ARCHD *, int *);
165 int set_crc(ARCHD *, int);
166 
167 /*
168  * ftree.c
169  */
170 int ftree_start(void);
171 int ftree_add(char *, int);
172 void ftree_sel(ARCHD *);
173 void ftree_chk(void);
174 int next_file(ARCHD *);
175 
176 /*
177  * gen_subs.c
178  */
179 void ls_list(ARCHD *, time_t, FILE *);
180 void ls_tty(ARCHD *);
181 void safe_print(const char *, FILE *);
182 u_long asc_ul(char *, int, int);
183 int ul_asc(u_long, char *, int, int);
184 #if !defined(NET2_STAT) && !defined(_LP64)
185 unsigned long long asc_ull(char *, int, int);
186 int ull_asc(unsigned long long, char *, int, int);
187 #endif
188 int check_Aflag(void);
189 
190 /*
191  * getoldopt.c
192  */
193 struct option;
194 int getoldopt(int, char **, const char *, struct option *, int *);
195 
196 /*
197  * options.c
198  */
199 extern FSUB fsub[];
200 extern int ford[];
201 void options(int, char **);
202 OPLIST * opt_next(void);
203 int opt_add(const char *);
204 int bad_opt(void);
205 int mkpath(char *);
206 char *chdname;
207 
208 /*
209  * pat_rep.c
210  */
211 int rep_add(char *);
212 int pat_add(char *, char *);
213 void pat_chk(void);
214 int pat_sel(ARCHD *);
215 int pat_match(ARCHD *);
216 int mod_name(ARCHD *);
217 int set_dest(ARCHD *, char *, int);
218 
219 /*
220  * pax.c
221  */
222 extern int act;
223 extern FSUB *frmt;
224 extern int Aflag;
225 extern int cflag;
226 extern int cwdfd;
227 extern int dflag;
228 extern int iflag;
229 extern int kflag;
230 extern int lflag;
231 extern int nflag;
232 extern int tflag;
233 extern int uflag;
234 extern int vflag;
235 extern int zflag;
236 extern int Dflag;
237 extern int Hflag;
238 extern int Lflag;
239 extern int Mflag;
240 extern int Xflag;
241 extern int Yflag;
242 extern int Zflag;
243 extern int vfpart;
244 extern int patime;
245 extern int pmtime;
246 extern int nodirs;
247 extern int pfflags;
248 extern int pmode;
249 extern int pids;
250 extern int rmleadslash;
251 extern int exit_val;
252 extern int docrc;
253 extern char *dirptr;
254 extern char *ltmfrmt;
255 extern char *argv0;
256 extern FILE *listf;
257 extern char *tempfile;
258 extern char *tempbase;
259 
260 int main(int, char **);
261 void sig_cleanup(int);
262 
263 /*
264  * sel_subs.c
265  */
266 int sel_chk(ARCHD *);
267 int grp_add(char *);
268 int usr_add(char *);
269 int trng_add(char *);
270 
271 /*
272  * tables.c
273  */
274 int lnk_start(void);
275 int chk_lnk(ARCHD *);
276 void purg_lnk(ARCHD *);
277 void lnk_end(void);
278 int ftime_start(void);
279 int chk_ftime(ARCHD *);
280 int name_start(void);
281 int add_name(char *, int, char *);
282 void sub_name(char *, int *, size_t);
283 int dev_start(void);
284 int add_dev(ARCHD *);
285 int map_dev(ARCHD *, u_long, u_long);
286 int atdir_start(void);
287 void atdir_end(void);
288 void add_atdir(char *, dev_t, ino_t, time_t, time_t);
289 int get_atdir(dev_t, ino_t, time_t *, time_t *);
290 int dir_start(void);
291 void add_dir(char *, int, struct stat *, int);
292 void proc_dir(void);
293 u_int st_hash(char *, int, int);
294 
295 /*
296  * tar.c
297  */
298 extern int is_gnutar;
299 int tar_endwr(void);
300 off_t tar_endrd(void);
301 int tar_trail(char *, int, int *);
302 int tar_id(char *, int);
303 int tar_opt(void);
304 int tar_rd(ARCHD *, char *);
305 int tar_wr(ARCHD *);
306 int ustar_strd(void);
307 int ustar_stwr(void);
308 int ustar_id(char *, int);
309 int ustar_rd(ARCHD *, char *);
310 int ustar_wr(ARCHD *);
311 int tar_gnutar_X_compat(const char *);
312 int tar_gnutar_minus_minus_exclude(const char *);
313 
314 /*
315  * tty_subs.c
316  */
317 int tty_init(void);
318 void tty_prnt(const char *, ...)
319     __attribute__((format (printf, 1, 2)));
320 int tty_read(char *, int);
321 void tty_warn(int, const char *, ...)
322     __attribute__((format (printf, 2, 3)));
323 void syswarn(int, int, const char *, ...)
324     __attribute__((format (printf, 3, 4)));
325