]> CyberLeo.Net >> Repos - FreeBSD/releng/8.0.git/blob - contrib/cpio/src/extern.h
Adjust to reflect 8.0-RELEASE.
[FreeBSD/releng/8.0.git] / contrib / cpio / src / extern.h
1 /* extern.h - External declarations for cpio.  Requires system.h.
2    Copyright (C) 1990, 1991, 1992, 2001, 2006 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public
15    License along with this program; if not, write to the Free
16    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17    Boston, MA 02110-1301 USA.  */
18
19 #include "paxlib.h"
20 #include "quotearg.h"
21 #include "quote.h"
22
23 enum archive_format
24 {
25   arf_unknown, arf_binary, arf_oldascii, arf_newascii, arf_crcascii,
26   arf_tar, arf_ustar, arf_hpoldascii, arf_hpbinary
27 };
28
29 extern enum archive_format archive_format;
30 extern int reset_time_flag;
31 extern int io_block_size;
32 extern int create_dir_flag;
33 extern int rename_flag;
34 extern char *rename_batch_file;
35 extern int table_flag;
36 extern int unconditional_flag;
37 extern int verbose_flag;
38 extern int dot_flag;
39 extern int link_flag;
40 extern int retain_time_flag;
41 extern int crc_i_flag;
42 extern int append_flag;
43 extern int swap_bytes_flag;
44 extern int swap_halfwords_flag;
45 extern int swapping_bytes;
46 extern int swapping_halfwords;
47 extern int set_owner_flag;
48 extern uid_t set_owner;
49 extern int set_group_flag;
50 extern gid_t set_group;
51 extern int no_chown_flag;
52 extern int sparse_flag;
53 extern int quiet_flag;
54 extern int only_verify_crc_flag;
55 extern int abs_paths_flag;
56 extern unsigned int warn_option;
57
58 /* Values for warn_option */
59 #define CPIO_WARN_NONE     0
60 #define CPIO_WARN_TRUNCATE 0x01
61 #define CPIO_WARN_ALL      (unsigned int)-1
62
63 extern bool to_stdout_option;
64
65 extern int last_header_start;
66 extern int copy_matching_files;
67 extern int numeric_uid;
68 extern char *pattern_file_name;
69 extern char *new_media_message;
70 extern char *new_media_message_with_number;
71 extern char *new_media_message_after_number;
72 extern int archive_des;
73 extern char *archive_name;
74 extern char *rsh_command_option;
75 extern unsigned int crc;
76 extern int delayed_seek_count;
77 #ifdef DEBUG_CPIO
78 extern int debug_flag;
79 #endif
80
81 extern char *input_buffer, *output_buffer;
82 extern char *in_buff, *out_buff;
83 extern long input_buffer_size;
84 extern long input_size, output_size;
85 #ifdef __GNUC__
86 extern long long input_bytes, output_bytes;
87 #else
88 extern long input_bytes, output_bytes;
89 #endif
90 extern char *directory_name;
91 extern char **save_patterns;
92 extern int num_patterns;
93 extern char name_end;
94 extern char input_is_special;
95 extern char output_is_special;
96 extern char input_is_seekable;
97 extern char output_is_seekable;
98 extern char *program_name;
99 extern int (*xstat) ();
100 extern void (*copy_function) ();
101 \f
102
103 /* copyin.c */
104 void warn_junk_bytes (long bytes_skipped);
105 /* FIXME: make read_* static in copyin.c */
106 void read_in_header (struct cpio_file_stat *file_hdr, int in_des);
107 void read_in_old_ascii (struct cpio_file_stat *file_hdr, int in_des);
108 void read_in_new_ascii (struct cpio_file_stat *file_hdr, int in_des);
109 void read_in_binary (struct cpio_file_stat *file_hdr,
110                      struct old_cpio_header *short_hdr, int in_des);
111 void swab_array (char *arg, int count);
112 void process_copy_in (void);
113 void long_format (struct cpio_file_stat *file_hdr, char *link_name);
114 void print_name_with_quoting (char *p);
115
116 /* copyout.c */
117 int write_out_header (struct cpio_file_stat *file_hdr, int out_des);
118 void process_copy_out (void);
119
120 /* copypass.c */
121 void process_copy_pass (void);
122 int link_to_maj_min_ino (char *file_name, int st_dev_maj, 
123                          int st_dev_min, int st_ino);
124 int link_to_name (char *link_name, char *link_target);
125
126 /* dirname.c */
127 char *dirname (char *path);
128
129 /* filemode.c */
130 void mode_string (unsigned int mode, char *str);
131
132 /* idcache.c */
133 #ifndef __MSDOS__
134 char *getgroup ();
135 char *getuser ();
136 uid_t *getuidbyname ();
137 gid_t *getgidbyname ();
138 #endif
139
140 /* main.c */
141 void process_args (int argc, char *argv[]);
142 void initialize_buffers (void);
143
144 /* makepath.c */
145 int make_path (char *argpath, int mode, int parent_mode,
146                uid_t owner, gid_t group, char *verbose_fmt_string);
147
148 /* tar.c */
149 void write_out_tar_header (struct cpio_file_stat *file_hdr, int out_des);
150 int null_block (long *block, int size);
151 void read_in_tar_header (struct cpio_file_stat *file_hdr, int in_des);
152 int otoa (char *s, unsigned long *n);
153 int is_tar_header (char *buf);
154 int is_tar_filename_too_long (char *name);
155
156 /* userspec.c */
157 #ifndef __MSDOS__
158 char *parse_user_spec (char *name, uid_t *uid, gid_t *gid,
159                        char **username, char **groupname);
160 #endif
161
162 /* util.c */
163 void tape_empty_output_buffer (int out_des);
164 void disk_empty_output_buffer (int out_des);
165 void swahw_array (char *ptr, int count);
166 void tape_buffered_write (char *in_buf, int out_des, off_t num_bytes);
167 void tape_buffered_read (char *in_buf, int in_des, off_t num_bytes);
168 int tape_buffered_peek (char *peek_buf, int in_des, int num_bytes);
169 void tape_toss_input (int in_des, off_t num_bytes);
170 void copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes);
171 void copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, char *filename);
172 void copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, char *filename);
173 void warn_if_file_changed (char *file_name, unsigned long old_file_size,
174                            off_t old_file_mtime);
175 void create_all_directories (char *name);
176 void prepare_append (int out_file_des);
177 char *find_inode_file (unsigned long node_num,
178                        unsigned long major_num, unsigned long minor_num);
179 void add_inode (unsigned long node_num, char *file_name,
180                 unsigned long major_num, unsigned long minor_num);
181 int open_archive (char *file);
182 void tape_offline (int tape_des);
183 void get_next_reel (int tape_des);
184 void set_new_media_message (char *message);
185 #if defined(__MSDOS__) && !defined(__GNUC__)
186 int chown (char *path, int owner, int group);
187 #endif
188 #ifdef __TURBOC__
189 int utime (char *filename, struct utimbuf *utb);
190 #endif
191 #ifdef HPUX_CDF
192 char *add_cdf_double_slashes (char *filename);
193 #endif
194 void write_nuls_to_file (off_t num_bytes, int out_des, 
195                          void (*writer) (char *in_buf,
196                                          int out_des, off_t num_bytes));
197 #define DISK_IO_BLOCK_SIZE      512
198
199 /* FIXME: Move to system.h? */
200 #ifndef SYMLINK_USES_UMASK
201 # define UMASKED_SYMLINK(name1,name2,mode)    symlink(name1,name2)
202 #else
203 # define UMASKED_SYMLINK(name1,name2,mode)    umasked_symlink(name1,name2,mode)
204 #endif /* SYMLINK_USES_UMASK */
205
206 void set_perms (int fd, struct cpio_file_stat *header);
207 void set_file_times (int fd, const char *name, unsigned long atime,
208                      unsigned long mtime);
209 void stat_to_cpio (struct cpio_file_stat *hdr, struct stat *st);
210 void cpio_safer_name_suffix (char *name, bool link_target,
211                              bool absolute_names, bool strip_leading_dots);
212
213 /* FIXME: These two defines should be defined in paxutils */
214 #define LG_8  3
215 #define LG_16 4
216
217 uintmax_t from_ascii (char const *where, size_t digs, unsigned logbase);
218
219 #define FROM_OCTAL(f) from_ascii (f, sizeof f, LG_8)
220 #define FROM_HEX(f) from_ascii (f, sizeof f, LG_16)
221