file_cmds-220.4.tar.gz
[apple/file_cmds.git] / pax / extern.h
1 /* $OpenBSD: extern.h,v 1.33 2008/05/06 06:54:28 henning 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 #include <sys/cdefs.h>
44
45 /*
46 * ar_io.c
47 */
48 extern const char *arcname;
49 extern const char *gzip_program;
50 extern int force_one_volume;
51 int ar_open(const char *);
52 void ar_close(void);
53 void ar_drain(void);
54 int ar_set_wr(void);
55 int ar_app_ok(void);
56 int ar_read(char *, int);
57 int ar_write(char *, int);
58 int ar_rdsync(void);
59 int ar_fow(off_t, off_t *);
60 int ar_rev(off_t );
61 int ar_next(void);
62
63 /*
64 * ar_subs.c
65 */
66 extern u_long flcnt;
67 int updatepath(void);
68 int dochdir(const char *);
69 int fdochdir(int);
70 void list(void);
71 void extract(void);
72 void append(void);
73 void archive(void);
74 void copy(void);
75
76 /*
77 * buf_subs.c
78 */
79 extern int blksz;
80 extern int wrblksz;
81 extern int maxflt;
82 extern int rdblksz;
83 extern off_t wrlimit;
84 extern off_t rdcnt;
85 extern off_t wrcnt;
86 int wr_start(void);
87 int rd_start(void);
88 void cp_start(void);
89 int appnd_start(off_t);
90 int rd_sync(void);
91 void pback(char *, int);
92 int rd_skip(off_t);
93 void wr_fin(void);
94 int wr_rdbuf(char *, int);
95 int rd_wrbuf(char *, int);
96 int wr_skip(off_t);
97 int wr_rdfile(ARCHD *, int, off_t *);
98 int rd_wrfile(ARCHD *, int, off_t *);
99 void cp_file(ARCHD *, int, int);
100 int buf_fill(void);
101 int buf_flush(int);
102
103 /*
104 * cache.c
105 */
106 int uidtb_start(void);
107 int gidtb_start(void);
108 int usrtb_start(void);
109 int grptb_start(void);
110 char * name_uid(uid_t, int);
111 char * name_gid(gid_t, int);
112 int uid_name(char *, uid_t *);
113 int gid_name(char *, gid_t *);
114
115 /*
116 * cpio.c
117 */
118 int cpio_strd(void);
119 int cpio_trail(ARCHD *, char *, int, int *);
120 int cpio_endwr(void);
121 int cpio_id(char *, int);
122 int cpio_rd(ARCHD *, char *);
123 off_t cpio_endrd(void);
124 int cpio_stwr(void);
125 int cpio_wr(ARCHD *);
126 int vcpio_id(char *, int);
127 int crc_id(char *, int);
128 int crc_strd(void);
129 int vcpio_rd(ARCHD *, char *);
130 off_t vcpio_endrd(void);
131 int crc_stwr(void);
132 int vcpio_wr(ARCHD *);
133 int bcpio_id(char *, int);
134 int bcpio_rd(ARCHD *, char *);
135 off_t bcpio_endrd(void);
136 int bcpio_wr(ARCHD *);
137
138 /*
139 * file_subs.c
140 */
141 extern char *gnu_name_string, *gnu_link_string;
142 int file_creat(ARCHD *);
143 void file_close(ARCHD *, int);
144 int lnk_creat(ARCHD *);
145 int cross_lnk(ARCHD *);
146 int chk_same(ARCHD *);
147 int node_creat(ARCHD *);
148 int unlnk_exist(char *, int);
149 int chk_path(char *, uid_t, gid_t, char **);
150 void set_ftime(char *fnm, time_t mtime, time_t atime, int frc);
151 void fset_ftime(char *fnm, int, time_t mtime, time_t atime, int frc);
152 int set_ids(char *, uid_t, gid_t);
153 int fset_ids(char *, int, uid_t, gid_t);
154 int set_lids(char *, uid_t, gid_t);
155 void set_pmode(char *, mode_t);
156 void fset_pmode(char *, int, mode_t);
157 int file_write(int, char *, int, int *, int *, int, char *);
158 void file_flush(int, char *, int);
159 void rdfile_close(ARCHD *, int *);
160 int set_crc(ARCHD *, int);
161
162 /*
163 * ftree.c
164 */
165 int ftree_start(void);
166 int ftree_add(char *, int);
167 void ftree_sel(ARCHD *);
168 void ftree_notsel(void);
169 void ftree_skipped_newer(ARCHD *);
170 void ftree_chk(void);
171 int next_file(ARCHD *);
172
173 /*
174 * gen_subs.c
175 */
176 void ls_list(ARCHD *, time_t, FILE *);
177 void ls_tty(ARCHD *);
178 void safe_print(const char *, FILE *);
179 u_long asc_ul(char *, int, int);
180 int ul_asc(u_long, char *, int, int);
181 #ifndef LONG_OFF_T
182 u_quad_t asc_uqd(char *, int, int);
183 int uqd_asc(u_quad_t, char *, int, int);
184 #endif
185 size_t fieldcpy(char *, size_t, const char *, size_t);
186
187 /*
188 * getoldopt.c
189 */
190 int getoldopt(int, char **, const char *);
191
192 /*
193 * options.c
194 */
195 extern FSUB fsub[];
196 extern int ford[];
197 void options(int, char **);
198 OPLIST * opt_next(void);
199 int opt_add(const char *);
200 int bad_opt(void);
201 int pax_format_opt_add(char *);
202 int pax_opt(void);
203 char *chdname;
204
205 /*
206 * pat_rep.c
207 */
208 int rep_add(char *);
209 int pat_add(char *, char *);
210 void pat_chk(void);
211 int pat_sel(ARCHD *);
212 int pat_match(ARCHD *);
213 int mod_name(ARCHD *);
214 int set_dest(ARCHD *, char *, int);
215
216 /*
217 * pax.c
218 */
219 extern int act;
220 extern FSUB *frmt;
221 extern int cflag;
222 extern int cwdfd;
223 extern int dflag;
224 extern int iflag;
225 extern int kflag;
226 extern int lflag;
227 extern int nflag;
228 extern int tflag;
229 extern int uflag;
230 extern int vflag;
231 extern int Dflag;
232 extern int Hflag;
233 extern int Lflag;
234 extern int Xflag;
235 extern int Yflag;
236 extern int Zflag;
237 extern int zeroflag;
238 extern int vfpart;
239 extern int patime;
240 extern int pmtime;
241 extern int nodirs;
242 extern int pmode;
243 extern int pids;
244 extern int rmleadslash;
245 extern int secure;
246 extern int exit_val;
247 extern int docrc;
248 extern char *dirptr;
249 extern char *ltmfrmt;
250 extern char *argv0;
251 extern FILE *listf;
252 extern char *tempfile;
253 extern char *tempbase;
254 extern int havechd;
255
256 int main(int, char **);
257 void sig_cleanup(int);
258
259 /*
260 * sel_subs.c
261 */
262 int sel_chk(ARCHD *);
263 int grp_add(char *);
264 int usr_add(char *);
265 int trng_add(char *);
266
267 /*
268 * tables.c
269 */
270 int lnk_start(void);
271 int chk_lnk(ARCHD *);
272 void purg_lnk(ARCHD *);
273 void lnk_end(void);
274 int ftime_start(void);
275 int chk_ftime(ARCHD *);
276 int name_start(void);
277 int add_name(char *, int, char *);
278 void sub_name(char *, int *, size_t);
279 int dev_start(void);
280 int add_dev(ARCHD *);
281 int map_dev(ARCHD *, u_long, u_long);
282 int atdir_start(void);
283 void atdir_end(void);
284 void add_atdir(char *, dev_t, ino_t, time_t, time_t);
285 int get_atdir(dev_t, ino_t, time_t *, time_t *);
286 int dir_start(void);
287 void add_dir(char *, size_t, struct stat *, int);
288 void proc_dir(void);
289 u_int st_hash(char *, int, int);
290
291 /*
292 * tar.c
293 */
294 extern char *gnu_hack_string;
295 int tar_endwr(void);
296 off_t tar_endrd(void);
297 int tar_trail(ARCHD *, char *, int, int *);
298 int tar_id(char *, int);
299 int tar_opt(void);
300 int tar_rd(ARCHD *, char *);
301 int tar_wr(ARCHD *);
302 int ustar_strd(void);
303 int ustar_stwr(void);
304 int ustar_id(char *, int);
305 int ustar_rd(ARCHD *, char *);
306 int ustar_wr(ARCHD *);
307
308 /*
309 * pax_format.c
310 */
311 extern char *header_name_g;
312 extern int pax_read_or_list_mode;
313 #define PAX_INVALID_ACTION_BYPASS 1
314 #define PAX_INVALID_ACTION_RENAME 2
315 #define PAX_INVALID_ACTION_UTF8 3
316 #define PAX_INVALID_ACTION_WRITE 4
317 extern int want_linkdata;
318 extern int pax_invalid_action;
319 extern char * pax_list_opt_format;
320 extern char * pax_invalid_action_write_path;
321 extern char * pax_invalid_action_write_cwd;
322 void pax_format_list_output(ARCHD *, time_t, FILE *, int);
323 void cleanup_pax_invalid_action(void);
324 void record_pax_invalid_action_results(ARCHD *, char *);
325 int perform_pax_invalid_action(ARCHD *, int);
326 void adjust_copy_for_pax_options(ARCHD *);
327 /*
328 int pax_strd(void);
329 int pax_stwr(void);
330 */
331 int pax_id(char *, int);
332 int pax_rd(ARCHD *, char *);
333 int pax_wr(ARCHD *);
334
335 /*
336 * tty_subs.c
337 */
338 int tty_init(void);
339 void tty_prnt(const char *, ...);
340 int tty_read(char *, int);
341 void paxwarn(int, const char *, ...);
342 void syswarn(int, int, const char *, ...);