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