xref: /openbsd-src/bin/pax/extern.h (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1 /*	$OpenBSD: extern.h,v 1.54 2016/01/01 15:56:03 tedu Exp $	*/
2 /*	$NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $	*/
3 
4 /*-
5  * Copyright (c) 1992 Keith Muller.
6  * Copyright (c) 1992, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  *
9  * This code is derived from software contributed to Berkeley by
10  * Keith Muller of the University of California, San Diego.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	@(#)extern.h	8.2 (Berkeley) 4/18/94
37  */
38 
39 /*
40  * External references from each source file
41  */
42 
43 /*
44  * ar_io.c
45  */
46 extern const char *arcname;
47 extern const char *gzip_program;
48 extern int force_one_volume;
49 int ar_open(const char *);
50 void ar_close(int _in_sig);
51 void ar_drain(void);
52 int ar_set_wr(void);
53 int ar_app_ok(void);
54 int ar_read(char *, int);
55 int ar_write(char *, int);
56 int ar_rdsync(void);
57 int ar_fow(off_t, off_t *);
58 int ar_rev(off_t );
59 int ar_next(void);
60 
61 /*
62  * ar_subs.c
63  */
64 extern u_long flcnt;
65 void list(void);
66 void extract(void);
67 void append(void);
68 void archive(void);
69 void copy(void);
70 
71 /*
72  * buf_subs.c
73  */
74 extern int blksz;
75 extern int wrblksz;
76 extern int maxflt;
77 extern int rdblksz;
78 extern off_t wrlimit;
79 extern off_t rdcnt;
80 extern off_t wrcnt;
81 int wr_start(void);
82 int rd_start(void);
83 void cp_start(void);
84 int appnd_start(off_t);
85 int rd_sync(void);
86 void pback(char *, int);
87 int rd_skip(off_t);
88 void wr_fin(void);
89 int wr_rdbuf(char *, int);
90 int rd_wrbuf(char *, int);
91 int wr_skip(off_t);
92 int wr_rdfile(ARCHD *, int, off_t *);
93 int rd_wrfile(ARCHD *, int, off_t *);
94 void cp_file(ARCHD *, int, int);
95 int buf_fill(void);
96 int buf_flush(int);
97 
98 /*
99  * cache.c
100  */
101 int uidtb_start(void);
102 int gidtb_start(void);
103 int usrtb_start(void);
104 int grptb_start(void);
105 char * name_uid(uid_t, int);
106 char * name_gid(gid_t, int);
107 int uid_name(char *, uid_t *);
108 int gid_name(char *, gid_t *);
109 
110 /*
111  * cpio.c
112  */
113 int cpio_strd(void);
114 int cpio_trail(ARCHD *, char *, int, int *);
115 int cpio_endwr(void);
116 int cpio_id(char *, int);
117 int cpio_rd(ARCHD *, char *);
118 off_t cpio_endrd(void);
119 int cpio_stwr(void);
120 int cpio_wr(ARCHD *);
121 int vcpio_id(char *, int);
122 int crc_id(char *, int);
123 int crc_strd(void);
124 int vcpio_rd(ARCHD *, char *);
125 off_t vcpio_endrd(void);
126 int crc_stwr(void);
127 int vcpio_wr(ARCHD *);
128 int bcpio_id(char *, int);
129 int bcpio_rd(ARCHD *, char *);
130 off_t bcpio_endrd(void);
131 int bcpio_wr(ARCHD *);
132 
133 /*
134  * file_subs.c
135  */
136 int file_creat(ARCHD *);
137 void file_close(ARCHD *, int);
138 int lnk_creat(ARCHD *);
139 int cross_lnk(ARCHD *);
140 int chk_same(ARCHD *);
141 int node_creat(ARCHD *);
142 int unlnk_exist(char *, int);
143 int chk_path(char *, uid_t, gid_t);
144 void set_ftime(const char *, const struct timespec *,
145     const struct timespec *, int);
146 void fset_ftime(const char *, int, const struct timespec *,
147     const struct timespec *, int);
148 int set_ids(char *, uid_t, gid_t);
149 int fset_ids(char *, int, uid_t, gid_t);
150 void set_pmode(char *, mode_t);
151 void fset_pmode(char *, int, mode_t);
152 int set_attr(const struct file_times *, int _force_times, mode_t, int _do_mode,
153     int _in_sig);
154 int file_write(int, char *, int, int *, int *, int, char *);
155 void file_flush(int, char *, int);
156 void rdfile_close(ARCHD *, int *);
157 int set_crc(ARCHD *, int);
158 
159 /*
160  * ftree.c
161  */
162 int ftree_start(void);
163 int ftree_add(char *, int);
164 void ftree_sel(ARCHD *);
165 void ftree_skipped_newer(ARCHD *);
166 void ftree_chk(void);
167 int next_file(ARCHD *);
168 
169 /*
170  * gen_subs.c
171  */
172 void ls_list(ARCHD *, time_t, FILE *);
173 void ls_tty(ARCHD *);
174 void safe_print(const char *, FILE *);
175 u_long asc_ul(char *, int, int);
176 int ul_asc(u_long, char *, int, int);
177 u_quad_t asc_uqd(char *, int, int);
178 int uqd_asc(u_quad_t, char *, int, int);
179 size_t fieldcpy(char *, size_t, const char *, size_t);
180 
181 /*
182  * getoldopt.c
183  */
184 int getoldopt(int, char **, const char *);
185 
186 /*
187  * options.c
188  */
189 extern FSUB fsub[];
190 extern int ford[];
191 void options(int, char **);
192 OPLIST * opt_next(void);
193 int opt_add(const char *);
194 int bad_opt(void);
195 extern char *chdname;
196 
197 /*
198  * pat_rep.c
199  */
200 int rep_add(char *);
201 int pat_add(char *, char *);
202 void pat_chk(void);
203 int pat_sel(ARCHD *);
204 int pat_match(ARCHD *);
205 int mod_name(ARCHD *);
206 int set_dest(ARCHD *, char *, int);
207 int has_dotdot(const char *);
208 
209 /*
210  * pax.c
211  */
212 extern int act;
213 extern FSUB *frmt;
214 extern int cflag;
215 extern int cwdfd;
216 extern int dflag;
217 extern int iflag;
218 extern int kflag;
219 extern int lflag;
220 extern int nflag;
221 extern int tflag;
222 extern int uflag;
223 extern int vflag;
224 extern int Dflag;
225 extern int Hflag;
226 extern int Lflag;
227 extern int Nflag;
228 extern int Xflag;
229 extern int Yflag;
230 extern int Zflag;
231 extern int zeroflag;
232 extern int vfpart;
233 extern int patime;
234 extern int pmtime;
235 extern int nodirs;
236 extern int pmode;
237 extern int pids;
238 extern int rmleadslash;
239 extern int exit_val;
240 extern int docrc;
241 extern char *dirptr;
242 extern char *argv0;
243 extern FILE *listf;
244 extern int listfd;
245 extern char *tempfile;
246 extern char *tempbase;
247 extern int havechd;
248 
249 void sig_cleanup(int);
250 
251 /*
252  * sel_subs.c
253  */
254 int sel_chk(ARCHD *);
255 int grp_add(char *);
256 int usr_add(char *);
257 int trng_add(char *);
258 
259 /*
260  * tables.c
261  */
262 int lnk_start(void);
263 int chk_lnk(ARCHD *);
264 void purg_lnk(ARCHD *);
265 void lnk_end(void);
266 int ftime_start(void);
267 int chk_ftime(ARCHD *);
268 int sltab_start(void);
269 int sltab_add_sym(const char *_path, const char *_value, mode_t _mode);
270 int sltab_add_link(const char *, const struct stat *);
271 void sltab_process(int _in_sig);
272 int name_start(void);
273 int add_name(char *, int, char *);
274 void sub_name(char *, int *, size_t);
275 #ifndef NOCPIO
276 int dev_start(void);
277 int add_dev(ARCHD *);
278 int map_dev(ARCHD *, u_long, u_long);
279 #else
280 # define dev_start()	0
281 # define add_dev(x)	0
282 # define map_dev(x,y,z)	0
283 #endif /* NOCPIO */
284 int atdir_start(void);
285 void atdir_end(void);
286 void add_atdir(char *, dev_t, ino_t, const struct timespec *,
287     const struct timespec *);
288 int do_atdir(const char *, dev_t, ino_t);
289 int dir_start(void);
290 void add_dir(char *, struct stat *, int);
291 void delete_dir(dev_t, ino_t);
292 void proc_dir(int _in_sig);
293 u_int st_hash(const char *, int, int);
294 
295 /*
296  * tar.c
297  */
298 extern int tar_nodir;
299 extern char *gnu_name_string, *gnu_link_string;
300 int tar_endwr(void);
301 off_t tar_endrd(void);
302 int tar_trail(ARCHD *, char *, int, int *);
303 int tar_id(char *, int);
304 int tar_opt(void);
305 int tar_rd(ARCHD *, char *);
306 int tar_wr(ARCHD *);
307 int ustar_strd(void);
308 int ustar_stwr(void);
309 int ustar_id(char *, int);
310 int ustar_rd(ARCHD *, char *);
311 int ustar_wr(ARCHD *);
312 
313 /*
314  * tty_subs.c
315  */
316 int tty_init(void);
317 void tty_prnt(const char *, ...)
318     __attribute__((nonnull(1), format(printf, 1, 2)));
319 int tty_read(char *, int);
320 void paxwarn(int, const char *, ...)
321     __attribute__((nonnull(2), format(printf, 2, 3)));
322 void syswarn(int, int, const char *, ...)
323     __attribute__((nonnull(3), format(printf, 3, 4)));
324