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