summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c301
1 files changed, 169 insertions, 132 deletions
diff --git a/src/main.c b/src/main.c
index cd96e584d99f..7581b8ffd17e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,6 @@
/* main.c - main program and argument processing for cpio.
- Copyright (C) 1990, 1991, 1992, 2001, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1991, 1992, 2001, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA. */
/* Written by Phil Nelson <phil@cs.wwu.edu>,
David MacKenzie <djm@gnu.ai.mit.edu>,
@@ -21,6 +23,7 @@
and Sergey Poznyakoff <gray@mirddin.farlep.net> */
#include <system.h>
+#include <paxlib.h>
#include <stdio.h>
#include <getopt.h>
@@ -29,7 +32,7 @@
#include <sys/stat.h>
#ifdef HAVE_LOCALE_H
-# include <locale.h>
+# include <locale.h>
#endif
#include "filetypes.h"
@@ -37,10 +40,11 @@
#include "dstring.h"
#include "extern.h"
#include <rmt.h>
-#include <localedir.h>
+#include <rmt-command.h>
enum cpio_options {
- NO_ABSOLUTE_FILENAMES_OPTION=256,
+ NO_ABSOLUTE_FILENAMES_OPTION=256,
+ ABSOLUTE_FILENAMES_OPTION,
NO_PRESERVE_OWNER_OPTION,
ONLY_VERIFY_CRC_OPTION,
RENAME_BATCH_FILE_OPTION,
@@ -50,8 +54,9 @@ enum cpio_options {
FORCE_LOCAL_OPTION,
DEBUG_OPTION,
BLOCK_SIZE_OPTION,
- TO_STDOUT_OPTION,
-
+ TO_STDOUT_OPTION,
+
+ HANG_OPTION,
USAGE_OPTION,
LICENSE_OPTION,
VERSION_OPTION
@@ -71,129 +76,156 @@ Examples:\n\
/* Print usage error message and exit with error. */
-#define USAGE_ERROR(args) do { error args; exit(2); } while (0)
#define CHECK_USAGE(cond, opt, mode_opt) \
- if (cond) USAGE_ERROR((0, 0, _("%s is meaningless with %s"), opt, mode_opt));
+ if (cond) \
+ ERROR((PAXEXIT_FAILURE, 0, _("%s is meaningless with %s"), opt, mode_opt));
static struct argp_option options[] = {
+ /* ********** */
+#define GRID 10
{NULL, 0, NULL, 0,
- N_("Main operation mode:"), 10},
+ N_("Main operation mode:"), GRID },
{"create", 'o', 0, 0,
- N_("Create the archive (run in copy-out mode)"), 10},
+ N_("Create the archive (run in copy-out mode)"), GRID },
{"extract", 'i', 0, 0,
- N_("Extract files from an archive (run in copy-in mode)")},
+ N_("Extract files from an archive (run in copy-in mode)"), GRID },
{"pass-through", 'p', 0, 0,
- N_("Run in copy-pass mode"), 10},
+ N_("Run in copy-pass mode"), GRID },
{"list", 't', 0, 0,
- N_("Print a table of contents of the input"), 10},
-
+ N_("Print a table of contents of the input"), GRID },
+#undef GRID
+
+ /* ********** */
+#define GRID 100
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid in any mode:"), 100},
+ N_("Operation modifiers valid in any mode:"), GRID },
{"file", 'F', N_("[[USER@]HOST:]FILE-NAME"), 0,
- N_("Use this FILE-NAME instead of standard input or output. Optional USER and HOST specify the user and host names in case of a remote archive"), 110},
+ N_("Use this FILE-NAME instead of standard input or output. Optional USER and HOST specify the user and host names in case of a remote archive"), GRID+1 },
{"force-local", FORCE_LOCAL_OPTION, 0, 0,
- N_("Archive file is local, even if its name contains colons"), 110},
+ N_("Archive file is local, even if its name contains colons"), GRID+1 },
{"format", 'H', N_("FORMAT"), 0,
- N_("Use given archive FORMAT"), 110},
+ N_("Use given archive FORMAT"), GRID+1 },
{NULL, 'B', NULL, 0,
- N_("Set the I/O block size to 5120 bytes"), 110},
+ N_("Set the I/O block size to 5120 bytes"), GRID+1 },
{"block-size", BLOCK_SIZE_OPTION, N_("BLOCK-SIZE"), 0,
- N_("Set the I/O block size to BLOCK-SIZE * 512 bytes"), 110},
+ N_("Set the I/O block size to BLOCK-SIZE * 512 bytes"), GRID+1 },
{NULL, 'c', NULL, 0,
- N_("Use the old portable (ASCII) archive format"), 0},
+ N_("Use the old portable (ASCII) archive format"), GRID+1 },
{"dot", 'V', NULL, 0,
- N_("Print a \".\" for each file processed"), 110},
+ N_("Print a \".\" for each file processed"), GRID+1 },
{"io-size", 'C', N_("NUMBER"), 0,
- N_("Set the I/O block size to the given NUMBER of bytes"), 110},
+ N_("Set the I/O block size to the given NUMBER of bytes"), GRID+1 },
{"message", 'M', N_("STRING"), 0,
N_("Print STRING when the end of a volume of the backup media is reached"),
- 110},
+ GRID+1 },
{"nonmatching", 'f', 0, 0,
- N_("Only copy files that do not match any of the given patterns"), 110},
+ N_("Only copy files that do not match any of the given patterns"), GRID+1 },
{"numeric-uid-gid", 'n', 0, 0,
N_("In the verbose table of contents listing, show numeric UID and GID"),
- 110},
+ GRID+1 },
{"rsh-command", RSH_COMMAND_OPTION, N_("COMMAND"), 0,
- N_("Use remote COMMAND instead of rsh"), 110},
+ N_("Use remote COMMAND instead of rsh"), GRID+1 },
{"quiet", QUIET_OPTION, NULL, 0,
- N_("Do not print the number of blocks copied"), 110},
+ N_("Do not print the number of blocks copied"), GRID+1 },
{"verbose", 'v', NULL, 0,
- N_("Verbosely list the files processed"), 110},
+ N_("Verbosely list the files processed"), GRID+1 },
#ifdef DEBUG_CPIO
{"debug", DEBUG_OPTION, NULL, 0,
- N_("Enable debugging info"), 110},
+ N_("Enable debugging info"), GRID+1 },
#endif
{"warning", 'W', N_("FLAG"), 0,
- N_("Control warning display. Currently FLAG is one of 'none', 'truncate', 'all'. Multiple options accumulate."), 110 },
-
+ N_("Control warning display. Currently FLAG is one of 'none', 'truncate', 'all'. Multiple options accumulate."), GRID+1 },
+#undef GRID
+
/* ********** */
+#define GRID 200
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid only in copy-in mode:"), 200},
+ N_("Operation modifiers valid only in copy-in mode:"), GRID },
{"pattern-file", 'E', N_("FILE"), 0,
- N_("In copy-in mode, read additional patterns specifying filenames to extract or list from FILE"), 210},
- {"no-absolute-filenames", NO_ABSOLUTE_FILENAMES_OPTION, 0, 0,
- N_("Create all files relative to the current directory"), 210},
+ N_("Read additional patterns specifying filenames to extract or list from FILE"), 210},
{"only-verify-crc", ONLY_VERIFY_CRC_OPTION, 0, 0,
- N_("When reading a CRC format archive in copy-in mode, only verify the CRC's of each file in the archive, don't actually extract the files"), 210},
+ N_("When reading a CRC format archive, only verify the CRC's of each file in the archive, don't actually extract the files"), 210},
{"rename", 'r', 0, 0,
- N_("Interactively rename files"), 210},
+ N_("Interactively rename files"), GRID+1 },
{"rename-batch-file", RENAME_BATCH_FILE_OPTION, N_("FILE"), OPTION_HIDDEN,
- "", 210},
+ "", GRID+1 },
{"swap", 'b', NULL, 0,
- N_("Swap both halfwords of words and bytes of halfwords in the data. Equivalent to -sS"), 210},
+ N_("Swap both halfwords of words and bytes of halfwords in the data. Equivalent to -sS"), GRID+1 },
{"swap-bytes", 's', NULL, 0,
- N_("Swap the bytes of each halfword in the files"), 210},
+ N_("Swap the bytes of each halfword in the files"), GRID+1 },
{"swap-halfwords", 'S', NULL, 0,
N_("Swap the halfwords of each word (4 bytes) in the files"),
- 210},
+ GRID+1 },
{"to-stdout", TO_STDOUT_OPTION, NULL, 0,
- N_("Extract files to standard output"), 210},
+ N_("Extract files to standard output"), GRID+1 },
+#undef GRID
/* ********** */
+#define GRID 300
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid only in copy-out mode:"), 300},
+ N_("Operation modifiers valid only in copy-out mode:"), GRID },
{"append", 'A', 0, 0,
- N_("Append to an existing archive."), 310 },
+ N_("Append to an existing archive."), GRID+1 },
{NULL, 'O', N_("[[USER@]HOST:]FILE-NAME"), 0,
- N_("Archive filename to use instead of standard output. Optional USER and HOST specify the user and host names in case of a remote archive"), 310},
+ N_("Archive filename to use instead of standard output. Optional USER and HOST specify the user and host names in case of a remote archive"), GRID+1 },
+#undef GRID
/* ********** */
+#define GRID 400
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid only in copy-pass mode:"), 400},
+ N_("Operation modifiers valid only in copy-pass mode:"), GRID},
{"link", 'l', 0, 0,
- N_("Link files instead of copying them, when possible"), 410},
+ N_("Link files instead of copying them, when possible"), GRID+1 },
+#undef GRID
+
/* ********** */
+#define GRID 500
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid for copy-out and copy-pass modes:"), 500},
+ N_("Operation modifiers valid in copy-in and copy-out modes:"), GRID },
+ {"absolute-filenames", ABSOLUTE_FILENAMES_OPTION, 0, 0,
+ N_("Do not strip file system prefix components from the file names"),
+ GRID+1 },
+ {"no-absolute-filenames", NO_ABSOLUTE_FILENAMES_OPTION, 0, 0,
+ N_("Create all files relative to the current directory"), GRID+1 },
+#undef GRID
+ /* ********** */
+#define GRID 600
+ {NULL, 0, NULL, 0,
+ N_("Operation modifiers valid in copy-out and copy-pass modes:"), GRID },
{"null", '0', 0, 0,
- N_("A list of filenames is terminated by a null character instead of a newline"), 510 },
+ N_("A list of filenames is terminated by a null character instead of a newline"), GRID+1 },
{NULL, 'I', N_("[[USER@]HOST:]FILE-NAME"), 0,
- N_("Archive filename to use instead of standard input. Optional USER and HOST specify the user and host names in case of a remote archive"), 510},
+ N_("Archive filename to use instead of standard input. Optional USER and HOST specify the user and host names in case of a remote archive"), GRID+1 },
{"dereference", 'L', 0, 0,
- N_("Dereference symbolic links (copy the files that they point to instead of copying the links)."), 510},
+ N_("Dereference symbolic links (copy the files that they point to instead of copying the links)."), GRID+1 },
{"owner", 'R', N_("[USER][:.][GROUP]"), 0,
- N_("Set the ownership of all files created to the specified USER and/or GROUP"), 510},
- {"sparse", SPARSE_OPTION, NULL, 0,
- N_("Write files with large blocks of zeros as sparse files"), 510},
+ N_("Set the ownership of all files created to the specified USER and/or GROUP"), GRID+1 },
{"reset-access-time", 'a', NULL, 0,
- N_("Reset the access times of files after reading them"), 510},
+ N_("Reset the access times of files after reading them"), GRID+1 },
+#undef GRID
/* ********** */
+#define GRID 700
{NULL, 0, NULL, 0,
- N_("Operation modifiers valid for copy-in and copy-pass modes:"), 600},
+ N_("Operation modifiers valid in copy-in and copy-pass modes:"), GRID },
{"preserve-modification-time", 'm', 0, 0,
- N_("Retain previous file modification times when creating files"), 610},
+ N_("Retain previous file modification times when creating files"), GRID+1 },
{"make-directories", 'd', 0, 0,
- N_("Create leading directories where needed"), 610},
+ N_("Create leading directories where needed"), GRID+1 },
{"no-preserve-owner", NO_PRESERVE_OWNER_OPTION, 0, 0,
- N_("Do not change the ownership of the files"), 610},
+ N_("Do not change the ownership of the files"), GRID+1 },
{"unconditional", 'u', NULL, 0,
- N_("Replace all files unconditionally"), 610},
-
+ N_("Replace all files unconditionally"), GRID+1 },
+ {"sparse", SPARSE_OPTION, NULL, 0,
+ N_("Write files with large blocks of zeros as sparse files"), GRID+1 },
+#undef GRID
+
+ /* ********** */
+#define GRID 800
{NULL, 0, NULL, 0,
- N_("Informative options:"), 700 },
+ N_("Informative options:"), GRID },
{"help", '?', 0, 0, N_("Give this help list"), -1},
{"usage", USAGE_OPTION, 0, 0, N_("Give a short usage message"), -1},
@@ -201,7 +233,9 @@ static struct argp_option options[] = {
{"version", VERSION_OPTION, 0, 0, N_("Print program version"), -1},
/* FIXME -V (--dot) conflicts with the default short option for
--version */
-
+ {"HANG", HANG_OPTION, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
+ N_("hang for SECS seconds (default 3600)"), 0},
+#undef GRID
{0, 0, 0, 0}
};
@@ -224,8 +258,8 @@ license ()
" GNU General Public License for more details.\n"
"\n"
" You should have received a copy of the GNU General Public License\n"
- " along with GNU cpio; if not, write to the Free Software\n"
- " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n"));
+ " along with GNU cpio; if not, write to the Free Software Foundation,\n"
+ " Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n\n"));
exit (0);
}
@@ -269,6 +303,7 @@ warn_control (char *arg)
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
+ static volatile int _argp_hang;
switch (key)
{
case '0': /* Read null-terminated filenames. */
@@ -301,7 +336,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'c': /* Use the old portable ASCII format. */
if (archive_format != arf_unknown)
- USAGE_ERROR ((0, 0, _("Archive format multiply defined")));
+ error (0, EXIT_FAILURE, _("Archive format multiply defined"));
#ifdef SVR4_COMPAT
archive_format = arf_newascii; /* -H newc. */
#else
@@ -333,7 +368,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'H': /* Header format name. */
if (archive_format != arf_unknown)
- USAGE_ERROR ((0, 0, _("Archive format multiply defined")));
+ error (PAXEXIT_FAILURE, 0, _("Archive format multiply defined"));
if (!strcasecmp (arg, "crc"))
archive_format = arf_crcascii;
else if (!strcasecmp (arg, "newc"))
@@ -358,7 +393,7 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg);
case 'i': /* Copy-in mode. */
if (copy_function != 0)
- USAGE_ERROR ((0, 0, _("Mode already defined")));
+ error (PAXEXIT_FAILURE, 0, _("Mode already defined"));
copy_function = process_copy_in;
break;
@@ -394,17 +429,21 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg);
case NO_ABSOLUTE_FILENAMES_OPTION: /* --no-absolute-filenames */
no_abs_paths_flag = true;
break;
-
+
+ case ABSOLUTE_FILENAMES_OPTION: /* --absolute-filenames */
+ no_abs_paths_flag = false;
+ break;
+
case NO_PRESERVE_OWNER_OPTION: /* --no-preserve-owner */
if (set_owner_flag || set_group_flag)
- USAGE_ERROR ((0, 0,
- _("--no-preserve-owner cannot be used with --owner")));
+ error (PAXEXIT_FAILURE, 0,
+ _("--no-preserve-owner cannot be used with --owner"));
no_chown_flag = true;
break;
case 'o': /* Copy-out mode. */
if (copy_function != 0)
- USAGE_ERROR ((0, 0, _("Mode already defined")));
+ error (PAXEXIT_FAILURE, 0, _("Mode already defined"));
copy_function = process_copy_out;
break;
@@ -418,7 +457,7 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg);
case 'p': /* Copy-pass mode. */
if (copy_function != 0)
- USAGE_ERROR ((0, 0, _("Mode already defined")));
+ error (PAXEXIT_FAILURE, 0, _("Mode already defined"));
copy_function = process_copy_pass;
break;
@@ -440,25 +479,26 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg);
case 'R': /* Set the owner. */
if (no_chown_flag)
- USAGE_ERROR ((0, 0,
- _("--owner cannot be used with --no-preserve-owner")));
- {
- char *e, *u, *g;
-
- e = parse_user_spec (arg, &set_owner, &set_group, &u, &g);
- if (e)
- error (2, 0, "%s: %s", arg, e);
- if (u)
- {
- free (u);
- set_owner_flag = true;
- }
- if (g)
- {
- free (g);
- set_group_flag = true;
- }
- }
+ error (PAXEXIT_FAILURE, 0,
+ _("--owner cannot be used with --no-preserve-owner"));
+ else
+ {
+ char *e, *u, *g;
+
+ e = parse_user_spec (arg, &set_owner, &set_group, &u, &g);
+ if (e)
+ error (PAXEXIT_FAILURE, 0, "%s: %s", arg, e);
+ if (u)
+ {
+ free (u);
+ set_owner_flag = true;
+ }
+ if (g)
+ {
+ free (g);
+ set_group_flag = true;
+ }
+ }
break;
case 's': /* Swap bytes. */
@@ -507,6 +547,12 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg);
case TO_STDOUT_OPTION:
to_stdout_option = true;
break;
+
+ case HANG_OPTION:
+ _argp_hang = atoi (arg ? arg : "3600");
+ while (_argp_hang-- > 0)
+ sleep (1);
+ break;
case '?':
argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
@@ -552,9 +598,9 @@ process_args (int argc, char *argv[])
int index;
if (argc < 2)
- USAGE_ERROR ((0, 0,
- _("You must specify one of -oipt options.\nTry `%s --help' or `%s --usage' for more information.\n"),
- program_name, program_name));
+ error (PAXEXIT_FAILURE, 0,
+ _("You must specify one of -oipt options.\nTry `%s --help' or `%s --usage' for more information.\n"),
+ program_name, program_name);
xstat = lstat;
@@ -568,9 +614,9 @@ process_args (int argc, char *argv[])
if (table_flag)
copy_function = process_copy_in;
else
- USAGE_ERROR ((0, 0,
- _("You must specify one of -oipt options.\nTry `%s --help' or `%s --usage' for more information.\n"),
- program_name, program_name));
+ error (PAXEXIT_FAILURE, 0,
+ _("You must specify one of -oipt options.\nTry `%s --help' or `%s --usage' for more information.\n"),
+ program_name, program_name);
}
/* Work around for pcc bug. */
@@ -584,7 +630,6 @@ process_args (int argc, char *argv[])
CHECK_USAGE(reset_time_flag, "--reset", "--extract");
CHECK_USAGE(xstat != lstat, "--dereference", "--extract");
CHECK_USAGE(append_flag, "--append", "--extract");
- CHECK_USAGE(sparse_flag, "--sparse", "--extract");
CHECK_USAGE(output_archive_name, "-O", "--extract");
if (to_stdout_option)
{
@@ -597,7 +642,8 @@ process_args (int argc, char *argv[])
}
if (archive_name && input_archive_name)
- USAGE_ERROR((0, 0, _("Both -I and -F are used in copy-in mode")));
+ error (PAXEXIT_FAILURE, 0,
+ _("Both -I and -F are used in copy-in mode"));
if (archive_format == arf_crcascii)
crc_i_flag = true;
@@ -609,7 +655,7 @@ process_args (int argc, char *argv[])
else if (copy_function == copy_out)
{
if (index != argc)
- USAGE_ERROR ((0, 0, _("Too many arguments")));
+ error (PAXEXIT_FAILURE, 0, _("Too many arguments"));
archive_des = 1;
CHECK_USAGE(create_dir_flag, "--make-directories", "--create");
@@ -617,24 +663,24 @@ process_args (int argc, char *argv[])
CHECK_USAGE(table_flag, "--list", "--create");
CHECK_USAGE(unconditional_flag, "--unconditional", "--create");
CHECK_USAGE(link_flag, "--link", "--create");
+ CHECK_USAGE(sparse_flag, "--sparse", "--create");
CHECK_USAGE(retain_time_flag, "--preserve-modification-time",
"--create");
CHECK_USAGE(no_chown_flag, "--no-preserve-owner", "--create");
- CHECK_USAGE(set_owner_flag||set_group_flag, "--owner", "--create");
CHECK_USAGE(swap_bytes_flag, "--swap-bytes (--swap)", "--create");
CHECK_USAGE(swap_halfwords_flag, "--swap-halfwords (--swap)",
"--create");
CHECK_USAGE(to_stdout_option, "--to-stdout", "--create");
if (append_flag && !(archive_name || output_archive_name))
- USAGE_ERROR ((0, 0,
- _("--append is used but no archive file name is given (use -F or -O options")));
+ error (PAXEXIT_FAILURE, 0,
+ _("--append is used but no archive file name is given (use -F or -O options)"));
CHECK_USAGE(rename_batch_file, "--rename-batch-file", "--create");
- CHECK_USAGE(no_abs_paths_flag, "--no-absolute-pathnames", "--create");
CHECK_USAGE(input_archive_name, "-I", "--create");
if (archive_name && output_archive_name)
- USAGE_ERROR ((0, 0, _("Both -O and -F are used in copy-out mode")));
+ error (PAXEXIT_FAILURE, 0,
+ _("Both -O and -F are used in copy-out mode"));
if (archive_format == arf_unknown)
archive_format = arf_binary;
@@ -644,12 +690,14 @@ process_args (int argc, char *argv[])
else
{
/* Copy pass. */
- if (index != argc - 1)
- USAGE_ERROR ((0, 0, _("Too many arguments")));
+ if (index < argc - 1)
+ error (PAXEXIT_FAILURE, 0, _("Too many arguments"));
+ else if (index > argc - 1)
+ error (PAXEXIT_FAILURE, 0, _("Not enough arguments"));
if (archive_format != arf_unknown)
- USAGE_ERROR((0, 0,
- _("Archive format is not specified in copy-pass mode (use --format option)")));
+ error (PAXEXIT_FAILURE, 0,
+ _("Archive format is not specified in copy-pass mode (use --format option)"));
CHECK_USAGE(swap_bytes_flag, "--swap-bytes (--swap)", "--pass-through");
CHECK_USAGE(swap_halfwords_flag, "--swap-halfwords (--swap)",
@@ -660,6 +708,8 @@ process_args (int argc, char *argv[])
CHECK_USAGE(rename_batch_file, "--rename-batch-file", "--pass-through");
CHECK_USAGE(no_abs_paths_flag, "--no-absolute-pathnames",
"--pass-through");
+ CHECK_USAGE(no_abs_paths_flag, "--absolute-pathnames",
+ "--pass-through");
CHECK_USAGE(to_stdout_option, "--to-stdout", "--pass-through");
directory_name = argv[index];
@@ -668,11 +718,12 @@ process_args (int argc, char *argv[])
if (archive_name)
{
if (copy_function != copy_in && copy_function != copy_out)
- USAGE_ERROR ((0, 0,
- _("-F can be used only with --create or --extract")));
+ error (PAXEXIT_FAILURE, 0,
+ _("-F can be used only with --create or --extract"));
archive_des = open_archive (archive_name);
if (archive_des < 0)
- error (1, errno, "%s", archive_name);
+ error (PAXEXIT_FAILURE, errno, _("Cannot open %s"),
+ quotearg_colon (archive_name));
}
/* Prevent SysV non-root users from giving away files inadvertantly.
@@ -725,33 +776,19 @@ initialize_buffers ()
out_buff = output_buffer;
output_size = 0;
output_bytes = 0;
-
- /* Clear the block of zeros. */
- bzero (zeros_512, 512);
}
int
main (int argc, char *argv[])
{
-#ifdef HAVE_LOCALE_H
setlocale (LC_ALL, "");
-#endif
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
program_name = argv[0];
- umask (0);
-
-#ifdef __TURBOC__
- _fmode = O_BINARY; /* Put stdin and stdout in binary mode. */
-#endif
-#ifdef __EMX__ /* gcc on OS/2. */
- _response (&argc, &argv);
- _wildcard (&argc, &argv);
-#endif
process_args (argc, argv);
-
+
initialize_buffers ();
(*copy_function) ();