]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - contrib/cpio/src/global.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / contrib / cpio / src / global.c
1 /* global.c - global variables and initial values for cpio.
2    Copyright (C) 1990, 1991, 1992, 2001 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 License along
15    with this program; if not, write to the Free Software Foundation, Inc.,
16    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18 #include <system.h>
19
20 #include <sys/types.h>
21 #include "cpiohdr.h"
22 #include "dstring.h"
23 #include "extern.h"
24
25 /* If true, reset access times after reading files (-a).  */
26 int reset_time_flag = false;
27
28 /* Block size value, initially 512.  -B sets to 5120.  */
29 int io_block_size = 512;
30
31 /* The header format to recognize and produce.  */
32 enum archive_format archive_format = arf_unknown;
33
34 /* If true, create directories as needed. (-d with -i or -p) */
35 int create_dir_flag = false;
36
37 /* If true, interactively rename files. (-r) */
38 int rename_flag = false;
39
40 /* If non-NULL, the name of a file that will be read to
41    rename all of the files in the archive.  --rename-batch-file.  */
42 char *rename_batch_file = NULL;
43
44 /* If true, print a table of contents of input. (-t) */
45 int table_flag = false;
46
47 /* If true, copy unconditionally (older replaces newer). (-u) */
48 int unconditional_flag = false;
49
50 /* If true, list the files processed, or ls -l style output with -t. (-v) */
51 int verbose_flag = false;
52
53 /* If true, print a . for each file processed. (-V) */
54 int dot_flag = false;
55
56 /* If true, link files whenever possible.  Used with -p option. (-l) */
57 int link_flag = false;
58
59 /* If true, retain previous file modification time. (-m) */
60 int retain_time_flag = false;
61
62 /* Set true if crc_flag is true and we are doing a cpio -i.  Used
63    by copy_files so it knows whether to compute the crc.  */
64 int crc_i_flag = false;
65
66 /* If true, append to end of archive. (-A) */
67 int append_flag = false;
68
69 /* If true, swap bytes of each file during cpio -i.  */
70 int swap_bytes_flag = false;
71
72 /* If true, swap halfwords of each file during cpio -i.  */
73 int swap_halfwords_flag = false;
74
75 /* If true, we are swapping halfwords on the current file.  */
76 int swapping_halfwords = false;
77
78 /* If true, we are swapping bytes on the current file.  */
79 int swapping_bytes = false;
80
81 /* If true, set ownership of all files to UID `set_owner'.  */
82 int set_owner_flag = false;
83 uid_t set_owner;
84
85 /* If true, set group ownership of all files to GID `set_group'.  */
86 int set_group_flag = false;
87 gid_t set_group;
88
89 /* If true, do not chown the files.  */
90 int no_chown_flag = false;
91
92 /* If true, try to write sparse ("holey") files.  */
93 int sparse_flag = false;
94
95 /* If true, don't report number of blocks copied.  */
96 int quiet_flag = false;
97
98 /* If true, only read the archive and verify the files' CRC's, don't
99    actually extract the files. */
100 int only_verify_crc_flag = false;
101
102 /* If true, don't use any absolute paths, prefix them by `./'.  */
103 int abs_paths_flag = false;
104
105 #ifdef DEBUG_CPIO
106 /* If true, print debugging information.  */
107 int debug_flag = false;
108 #endif
109
110 /* File position of last header read.  Only used during -A to determine
111    where the old TRAILER!!! record started.  */
112 int last_header_start = 0;
113
114 /* With -i; if true, copy only files that match any of the given patterns;
115    if false, copy only files that do not match any of the patterns. (-f) */
116 int copy_matching_files = true;
117
118 /* With -itv; if true, list numeric uid and gid instead of translating them
119    into names.  */
120 int numeric_uid = false;
121
122 /* Name of file containing additional patterns (-E).  */
123 char *pattern_file_name = NULL;
124
125 /* Message to print when end of medium is reached (-M).  */
126 char *new_media_message = NULL;
127
128 /* With -M with %d, message to print when end of medium is reached.  */
129 char *new_media_message_with_number = NULL;
130 char *new_media_message_after_number = NULL;
131
132 /* File descriptor containing the archive.  */
133 int archive_des;
134
135 /* Name of file containing the archive, if known; NULL if stdin/out.  */
136 char *archive_name = NULL;
137
138 /* Name of the remote shell command, if known; NULL otherwise.  */
139 char *rsh_command_option = NULL;
140
141 /* CRC checksum.  */
142 unsigned long crc;
143
144 /* Input and output buffers.  */
145 char *input_buffer, *output_buffer;
146
147 /* The size of the input buffer.  */
148 long input_buffer_size;
149
150 /* Current locations in `input_buffer' and `output_buffer'.  */
151 char *in_buff, *out_buff;
152
153 /* Current number of bytes stored at `input_buff' and `output_buff'.  */
154 long input_size, output_size;
155
156 /* Total number of bytes read and written for all files.  
157    Now that many tape drives hold more than 4Gb we need more than 32
158    bits to hold input_bytes and output_bytes.  But it's not worth
159    the trouble of adding special multi-precision arithmetic if the 
160    compiler doesn't support 64 bit ints since input_bytes and
161    output_bytes are only used to print the number of blocks copied.  */
162 #ifdef __GNUC__
163 long long input_bytes, output_bytes;
164 #else
165 long input_bytes, output_bytes;
166 #endif
167
168 /* 512 bytes of 0; used for various padding operations.  */
169 char zeros_512[512];
170
171 /* Saving of argument values for later reference.  */
172 char *directory_name = NULL;
173 char **save_patterns;
174 int num_patterns;
175
176 /* Character that terminates file names read from stdin.  */
177 char name_end = '\n';
178
179 /* true if input (cpio -i) or output (cpio -o) is a device node.  */
180 char input_is_special = false;
181 char output_is_special = false;
182
183 /* true if lseek works on the input.  */
184 char input_is_seekable = false;
185
186 /* true if lseek works on the output.  */
187 char output_is_seekable = false;
188
189 /* Print extra warning messages */
190 unsigned int warn_option = 0;
191
192 /* Extract to standard output? */
193 bool to_stdout_option = false;
194
195 /* The name this program was run with.  */
196 char *program_name;
197
198 /* A pointer to either lstat or stat, depending on whether
199    dereferencing of symlinks is done for input files.  */
200 int (*xstat) ();
201
202 /* Which copy operation to perform. (-i, -o, -p) */
203 void (*copy_function) () = 0;