source: trunk/essentials/app-arch/cpio/src/global.c

Last change on this file was 3332, checked in by bird, 18 years ago

cpio 2.7

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