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 | enum archive_format
|
---|
20 | {
|
---|
21 | arf_unknown, arf_binary, arf_oldascii, arf_newascii, arf_crcascii,
|
---|
22 | arf_tar, arf_ustar, arf_hpoldascii, arf_hpbinary
|
---|
23 | };
|
---|
24 |
|
---|
25 | extern enum archive_format archive_format;
|
---|
26 | extern int reset_time_flag;
|
---|
27 | extern int io_block_size;
|
---|
28 | extern int create_dir_flag;
|
---|
29 | extern int rename_flag;
|
---|
30 | extern char *rename_batch_file;
|
---|
31 | extern int table_flag;
|
---|
32 | extern int unconditional_flag;
|
---|
33 | extern int verbose_flag;
|
---|
34 | extern int dot_flag;
|
---|
35 | extern int link_flag;
|
---|
36 | extern int retain_time_flag;
|
---|
37 | extern int crc_i_flag;
|
---|
38 | extern int append_flag;
|
---|
39 | extern int swap_bytes_flag;
|
---|
40 | extern int swap_halfwords_flag;
|
---|
41 | extern int swapping_bytes;
|
---|
42 | extern int swapping_halfwords;
|
---|
43 | extern int set_owner_flag;
|
---|
44 | extern uid_t set_owner;
|
---|
45 | extern int set_group_flag;
|
---|
46 | extern gid_t set_group;
|
---|
47 | extern int no_chown_flag;
|
---|
48 | extern int sparse_flag;
|
---|
49 | extern int quiet_flag;
|
---|
50 | extern int only_verify_crc_flag;
|
---|
51 | extern int no_abs_paths_flag;
|
---|
52 | extern unsigned int warn_option;
|
---|
53 |
|
---|
54 | /* Values for warn_option */
|
---|
55 | #define CPIO_WARN_NONE 0
|
---|
56 | #define CPIO_WARN_TRUNCATE 0x01
|
---|
57 | #define CPIO_WARN_ALL (unsigned int)-1
|
---|
58 |
|
---|
59 | extern bool to_stdout_option;
|
---|
60 |
|
---|
61 | extern int last_header_start;
|
---|
62 | extern int copy_matching_files;
|
---|
63 | extern int numeric_uid;
|
---|
64 | extern char *pattern_file_name;
|
---|
65 | extern char *new_media_message;
|
---|
66 | extern char *new_media_message_with_number;
|
---|
67 | extern char *new_media_message_after_number;
|
---|
68 | extern int archive_des;
|
---|
69 | extern char *archive_name;
|
---|
70 | extern char *rsh_command_option;
|
---|
71 | extern unsigned int crc;
|
---|
72 | extern int delayed_seek_count;
|
---|
73 | #ifdef DEBUG_CPIO
|
---|
74 | extern int debug_flag;
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | extern char *input_buffer, *output_buffer;
|
---|
78 | extern char *in_buff, *out_buff;
|
---|
79 | extern long input_buffer_size;
|
---|
80 | extern long input_size, output_size;
|
---|
81 | #ifdef __GNUC__
|
---|
82 | extern long long input_bytes, output_bytes;
|
---|
83 | #else
|
---|
84 | extern long input_bytes, output_bytes;
|
---|
85 | #endif
|
---|
86 | extern char *directory_name;
|
---|
87 | extern char **save_patterns;
|
---|
88 | extern int num_patterns;
|
---|
89 | extern char name_end;
|
---|
90 | extern char input_is_special;
|
---|
91 | extern char output_is_special;
|
---|
92 | extern char input_is_seekable;
|
---|
93 | extern char output_is_seekable;
|
---|
94 | extern char *program_name;
|
---|
95 | extern int (*xstat) ();
|
---|
96 | extern void (*copy_function) ();
|
---|
97 | |
---|
98 |
|
---|
99 |
|
---|
100 | /* copyin.c */
|
---|
101 | void warn_junk_bytes (long bytes_skipped);
|
---|
102 | /* FIXME: make read_* static in copyin.c */
|
---|
103 | void read_in_header (struct cpio_file_stat *file_hdr, int in_des);
|
---|
104 | void read_in_old_ascii (struct cpio_file_stat *file_hdr, int in_des);
|
---|
105 | void read_in_new_ascii (struct cpio_file_stat *file_hdr, int in_des);
|
---|
106 | void read_in_binary (struct cpio_file_stat *file_hdr,
|
---|
107 | struct old_cpio_header *short_hdr, int in_des);
|
---|
108 | void swab_array (char *arg, int count);
|
---|
109 | void process_copy_in (void);
|
---|
110 | void long_format (struct cpio_file_stat *file_hdr, char *link_name);
|
---|
111 | void print_name_with_quoting (char *p);
|
---|
112 |
|
---|
113 | /* copyout.c */
|
---|
114 | int write_out_header (struct cpio_file_stat *file_hdr, int out_des);
|
---|
115 | void process_copy_out (void);
|
---|
116 |
|
---|
117 | /* copypass.c */
|
---|
118 | void process_copy_pass (void);
|
---|
119 | int link_to_maj_min_ino (char *file_name, int st_dev_maj,
|
---|
120 | int st_dev_min, int st_ino);
|
---|
121 | int link_to_name (char *link_name, char *link_target);
|
---|
122 |
|
---|
123 | /* dirname.c */
|
---|
124 | char *dirname (char *path);
|
---|
125 |
|
---|
126 | /* filemode.c */
|
---|
127 | void mode_string (unsigned int mode, char *str);
|
---|
128 |
|
---|
129 | /* idcache.c */
|
---|
130 | #ifndef __MSDOS__
|
---|
131 | char *getgroup ();
|
---|
132 | char *getuser ();
|
---|
133 | uid_t *getuidbyname ();
|
---|
134 | gid_t *getgidbyname ();
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | /* main.c */
|
---|
138 | void process_args (int argc, char *argv[]);
|
---|
139 | void initialize_buffers (void);
|
---|
140 |
|
---|
141 | /* makepath.c */
|
---|
142 | int make_path (char *argpath, int mode, int parent_mode,
|
---|
143 | uid_t owner, gid_t group, char *verbose_fmt_string);
|
---|
144 |
|
---|
145 | /* tar.c */
|
---|
146 | void write_out_tar_header (struct cpio_file_stat *file_hdr, int out_des);
|
---|
147 | int null_block (long *block, int size);
|
---|
148 | void read_in_tar_header (struct cpio_file_stat *file_hdr, int in_des);
|
---|
149 | int otoa (char *s, unsigned long *n);
|
---|
150 | int is_tar_header (char *buf);
|
---|
151 | int is_tar_filename_too_long (char *name);
|
---|
152 |
|
---|
153 | /* userspec.c */
|
---|
154 | #ifndef __MSDOS__
|
---|
155 | char *parse_user_spec (char *name, uid_t *uid, gid_t *gid,
|
---|
156 | char **username, char **groupname);
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | /* util.c */
|
---|
160 | void tape_empty_output_buffer (int out_des);
|
---|
161 | void disk_empty_output_buffer (int out_des);
|
---|
162 | void swahw_array (char *ptr, int count);
|
---|
163 | void tape_buffered_write (char *in_buf, int out_des, off_t num_bytes);
|
---|
164 | void tape_buffered_read (char *in_buf, int in_des, off_t num_bytes);
|
---|
165 | int tape_buffered_peek (char *peek_buf, int in_des, int num_bytes);
|
---|
166 | void tape_toss_input (int in_des, long num_bytes);
|
---|
167 | void copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes);
|
---|
168 | void copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, char *filename);
|
---|
169 | void copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, char *filename);
|
---|
170 | void warn_if_file_changed (char *file_name, unsigned long old_file_size,
|
---|
171 | unsigned long old_file_mtime);
|
---|
172 | void create_all_directories (char *name);
|
---|
173 | void prepare_append (int out_file_des);
|
---|
174 | char *find_inode_file (unsigned long node_num,
|
---|
175 | unsigned long major_num, unsigned long minor_num);
|
---|
176 | void add_inode (unsigned long node_num, char *file_name,
|
---|
177 | unsigned long major_num, unsigned long minor_num);
|
---|
178 | int open_archive (char *file);
|
---|
179 | void tape_offline (int tape_des);
|
---|
180 | void get_next_reel (int tape_des);
|
---|
181 | void set_new_media_message (char *message);
|
---|
182 | #if defined(__MSDOS__) && !defined(__GNUC__)
|
---|
183 | int chown (char *path, int owner, int group);
|
---|
184 | #endif
|
---|
185 | #ifdef __TURBOC__
|
---|
186 | int utime (char *filename, struct utimbuf *utb);
|
---|
187 | #endif
|
---|
188 | #ifdef HPUX_CDF
|
---|
189 | char *add_cdf_double_slashes (char *filename);
|
---|
190 | #endif
|
---|
191 | void write_nuls_to_file (off_t num_bytes, int out_des,
|
---|
192 | void (*writer) (char *in_buf,
|
---|
193 | int out_des, off_t num_bytes));
|
---|
194 | #define DISK_IO_BLOCK_SIZE 512
|
---|
195 |
|
---|
196 | /* FIXME: Move to system.h? */
|
---|
197 | #ifndef SYMLINK_USES_UMASK
|
---|
198 | # define UMASKED_SYMLINK(name1,name2,mode) symlink(name1,name2)
|
---|
199 | #else
|
---|
200 | # define UMASKED_SYMLINK(name1,name2,mode) umasked_symlink(name1,name2,mode)
|
---|
201 | #endif /* SYMLINK_USES_UMASK */
|
---|
202 |
|
---|
203 | void set_perms (struct cpio_file_stat *header);
|
---|
204 | void set_file_times (const char *name, unsigned long atime, unsigned long mtime);
|
---|
205 | void stat_to_cpio (struct cpio_file_stat *hdr, struct stat *st);
|
---|
206 | void cpio_safer_name_suffix (char *name, bool link_target,
|
---|
207 | bool absolute_names, bool strip_leading_dots);
|
---|
208 |
|
---|
209 | /* FIXME: These two defines should be defined in paxutils */
|
---|
210 | #define LG_8 3
|
---|
211 | #define LG_16 4
|
---|
212 |
|
---|
213 | uintmax_t from_ascii (char const *where, size_t digs, unsigned logbase);
|
---|
214 |
|
---|
215 | #define FROM_OCTAL(f) from_ascii (f, sizeof f, LG_8)
|
---|
216 | #define FROM_HEX(f) from_ascii (f, sizeof f, LG_16)
|
---|
217 |
|
---|