Prefer functions like ‘paxerror’ to macros like ‘ERROR’.
The functions have cleaner semantics, and calls are
easier to read.
{
case ct_tar:
if (shortfile)
- ERROR ((0, 0, _("This does not look like a tar archive")));
+ paxerror (0, _("This does not look like a tar archive"));
return archive;
case ct_none:
if (shortfile)
- ERROR ((0, 0, _("This does not look like a tar archive")));
+ paxerror (0, _("This does not look like a tar archive"));
set_compression_program_by_suffix (archive_name_array[0], NULL,
false);
if (!use_compress_program_option)
if (strcmp (archive_name_array[0], "-") == 0
&& isatty (mode == ACCESS_READ ? STDIN_FILENO : STDOUT_FILENO))
{
- FATAL_ERROR ((0, 0,
- mode == ACCESS_READ
+ paxfatal (0, (mode == ACCESS_READ
? _("Refusing to read archive contents from terminal "
"(missing -f option?)")
: _("Refusing to write archive contents to terminal "
bool backed_up_flag = false;
if (record_size == 0)
- FATAL_ERROR ((0, 0, _("Invalid value for record_size")));
+ paxfatal (0, 0, _("Invalid value for record_size"));
if (archive_names == 0)
- FATAL_ERROR ((0, 0, _("No archive name given")));
+ paxfatal (0, _("No archive name given"));
tar_stat_destroy (¤t_stat_info);
{
read_full_records = true; /* could be a pipe, be safe */
if (verify_option)
- FATAL_ERROR ((0, 0, _("Cannot verify stdin/stdout archive")));
+ paxfatal (0, _("Cannot verify stdin/stdout archive"));
switch (wanted_access)
{
archive = STDIN_FILENO;
type = check_compressed_archive (&shortfile);
if (type != ct_tar && type != ct_none)
- FATAL_ERROR ((0, 0,
- _("Archive is compressed. Use %s option"),
- compress_option (type)));
+ paxfatal (0, _("Archive is compressed. Use %s option"),
+ compress_option (type));
if (shortfile)
- ERROR ((0, 0, _("This does not look like a tar archive")));
+ paxerror (0, _("This does not look like a tar archive"));
}
break;
break;
default:
- FATAL_ERROR ((0, 0,
- _("Cannot update compressed archives")));
+ paxfatal (0, _("Cannot update compressed archives"));
}
break;
}
read_error (*archive_name_cursor);
if (record_start_block == 0)
- FATAL_ERROR ((0, 0, _("At beginning of tape, quitting now")));
+ paxfatal (0, _("At beginning of tape, quitting now"));
/* Read error in mid archive. We retry up to READ_ERROR_MAX times and
then give up on reading the archive. */
if (read_error_count++ > READ_ERROR_MAX)
- FATAL_ERROR ((0, 0, _("Too many errors, quitting")));
+ paxfatal (0, _("Too many errors, quitting"));
return;
}
&& archive_is_dev ())
{
idx_t rsize = status / BLOCKSIZE;
- WARN ((0, 0,
- ngettext ("Record size = %td block",
- "Record size = %td blocks",
- rsize),
- rsize));
+ paxwarn (0,
+ ngettext ("Record size = %td block",
+ "Record size = %td blocks",
+ rsize),
+ rsize);
}
while (left % BLOCKSIZE != 0
{
idx_t rest = record_size - left;
- FATAL_ERROR ((0, 0,
- ngettext ("Unaligned block (%td byte) in archive",
- "Unaligned block (%td bytes) in archive",
+ paxfatal (0, ngettext ("Unaligned block (%td byte) in archive",
+ "Unaligned block (%td bytes) in archive",
rest),
- rest));
+ rest);
}
left -= status;
{
/* Lseek failed. Try a different method. */
- WARN ((0, 0,
- _("Cannot backspace archive file; it may be unreadable without -i")));
+ paxwarn (0, _("Cannot backspace archive file;"
+ " it may be unreadable without -i"));
/* Replace the first part of the record with NULs. */
return offset;
if (offset % record_size)
- FATAL_ERROR ((0, 0, _("rmtlseek not stopped at a record boundary")));
+ paxfatal (0, _("rmtlseek not stopped at a record boundary"));
/* Convert to number of records */
offset /= BLOCKSIZE;
{
if (fscanf (file, "%d", &global_volno) != 1
|| global_volno < 0)
- FATAL_ERROR ((0, 0, _("%s: contains invalid volume number"),
- quotearg_colon (volno_file_option)));
+ paxfatal (0, _("%s: contains invalid volume number"),
+ quotearg_colon (volno_file_option));
if (ferror (file))
read_error (volno_file_option);
if (fclose (file) != 0)
{
global_volno++;
if (global_volno < 0)
- FATAL_ERROR ((0, 0, _("Volume number overflow")));
+ paxfatal (0, _("Volume number overflow"));
volno++;
}
if (getline (&input_buffer, &size, read_file) <= 0)
{
- WARN ((0, 0, _("EOF where user reply was expected")));
+ paxwarn (0, _("EOF where user reply was expected"));
if (subcommand_option != EXTRACT_SUBCOMMAND
&& subcommand_option != LIST_SUBCOMMAND
&& subcommand_option != DIFF_SUBCOMMAND)
- WARN ((0, 0, _("WARNING: Archive is incomplete")));
+ paxwarn (0, _("WARNING: Archive is incomplete"));
fatal_exit ();
}
case 'q':
/* Quit. */
- WARN ((0, 0, _("No new volume; exiting.\n")));
+ paxwarn (0, _("No new volume; exiting.\n"));
if (subcommand_option != EXTRACT_SUBCOMMAND
&& subcommand_option != LIST_SUBCOMMAND
&& subcommand_option != DIFF_SUBCOMMAND)
- WARN ((0, 0, _("WARNING: Archive is incomplete")));
+ paxwarn (0, _("WARNING: Archive is incomplete"));
fatal_exit ();
if (volno_file_option)
closeout_volume_number ();
if (sys_exec_info_script (archive_name_cursor, global_volno+1))
- FATAL_ERROR ((0, 0, _("%s command failed"),
- quote (info_script_option)));
+ paxfatal (0, _("%s command failed"), quote (info_script_option));
}
else
change_tape_menu (read_file);
set_next_block_after (current_header);
return true;
}
- ERROR ((0, 0, _("This does not look like a tar archive")));
+ paxerror (0, _("This does not look like a tar archive"));
return false;
}
header = find_next_block ();
if (!header)
{
- WARN ((0, 0, _("This does not look like a tar archive")));
+ paxwarn (0, _("This does not look like a tar archive"));
return false;
}
if (read_header (&header, &dummy, read_header_x_global)
!= HEADER_SUCCESS_EXTENDED)
{
- WARN ((0, 0, _("This does not look like a tar archive")));
+ paxwarn (0, _("This does not look like a tar archive"));
return false;
}
break;
default:
- WARN ((0, 0, _("This does not look like a tar archive")));
+ paxwarn (0, _("This does not look like a tar archive"));
return false;
}
break;
{
if (!continued_file_name)
{
- WARN ((0, 0, _("%s is not continued on this volume"),
- quote (bufmap_head->file_name)));
+ paxwarn (0, _("%s is not continued on this volume"),
+ quote (bufmap_head->file_name));
return false;
}
&& strlen (bufmap_head->file_name) >= NAME_FIELD_SIZE
&& strncmp (continued_file_name, bufmap_head->file_name,
NAME_FIELD_SIZE) == 0)
- WARN ((0, 0,
- _("%s is possibly continued on this volume: header contains truncated name"),
- quote (bufmap_head->file_name)));
+ paxwarn (0,
+ _("%s is possibly continued on this volume:"
+ " header contains truncated name"),
+ quote (bufmap_head->file_name));
else
{
- WARN ((0, 0, _("%s is not continued on this volume"),
- quote (bufmap_head->file_name)));
+ paxwarn (0, _("%s is not continued on this volume"),
+ quote (bufmap_head->file_name));
return false;
}
}
if (ckd_add (&s, continued_file_size, continued_file_offset)
|| s != bufmap_head->sizetotal)
{
- WARN ((0, 0, _("%s is the wrong size (%jd != %ju + %ju)"),
- quote (continued_file_name),
- intmax (bufmap_head->sizetotal),
- uintmax (continued_file_size),
- uintmax (continued_file_offset)));
+ paxwarn (0, _("%s is the wrong size (%jd != %ju + %ju)"),
+ quote (continued_file_name),
+ intmax (bufmap_head->sizetotal),
+ uintmax (continued_file_size),
+ uintmax (continued_file_offset));
return false;
}
if (bufmap_head->sizetotal - bufmap_head->sizeleft
!= continued_file_offset)
{
- WARN ((0, 0, _("This volume is out of sequence (%jd - %jd != %ju)"),
- intmax (bufmap_head->sizetotal),
- intmax (bufmap_head->sizeleft),
- uintmax (continued_file_offset)));
+ paxwarn (0, _("This volume is out of sequence (%jd - %jd != %ju)"),
+ intmax (bufmap_head->sizetotal),
+ intmax (bufmap_head->sizeleft),
+ uintmax (continued_file_offset));
return false;
}
}
union block *label = find_next_block ();
if (!label)
- FATAL_ERROR ((0, 0, _("Archive not labeled to match %s"),
- quote (volume_label_option)));
+ paxfatal (0, _("Archive not labeled to match %s"),
+ quote (volume_label_option));
if (label->header.typeflag == GNUTYPE_VOLHDR)
{
ASSIGN_STRING_N (&volume_label, label->header.name);
}
if (!volume_label)
- FATAL_ERROR ((0, 0, _("Archive not labeled to match %s"),
- quote (volume_label_option)));
+ paxfatal (0, _("Archive not labeled to match %s"),
+ quote (volume_label_option));
if (!check_label_pattern (volume_label))
- FATAL_ERROR ((0, 0, _("Volume %s does not match %s"),
- quote_n (0, volume_label),
- quote_n (1, volume_label_option)));
+ paxfatal (0, _("Volume %s does not match %s"),
+ quote_n (0, volume_label),
+ quote_n (1, volume_label_option));
}
/* Mark the archive with volume label STR. */
if (len > NAME_FIELD_SIZE)
{
- WARN ((0, 0,
- _("%s: file name too long to be stored in a GNU multivolume header, truncated"),
- quotearg_colon (map->file_name)));
+ paxwarn (0,
+ _("%s: file name too long to be stored"
+ " in a GNU multivolume header, truncated"),
+ quotearg_colon (map->file_name));
len = NAME_FIELD_SIZE;
}
if (status % BLOCKSIZE)
{
- ERROR ((0, 0, _("write did not end on a block boundary")));
+ paxerror (0, _("write did not end on a block boundary"));
archive_write_error (status);
}
act = alloc_action (cop_sleep);
act->v.time = stoint (arg, &p, NULL, 0, TYPE_MAXIMUM (time_t));
if ((p == arg) | *p)
- FATAL_ERROR ((0, 0, _("%s: not a valid timeout"), str));
+ paxfatal (0, _("%s: not a valid timeout"), str);
}
else if (strcmp (str, "totals") == 0)
alloc_action (cop_totals);
sigaddset (&sigs, act->v.signal);
}
else
- FATAL_ERROR ((0, 0, _("%s: unknown checkpoint action"), str));
+ paxfatal (0, _("%s: unknown checkpoint action"), str);
}
void
if (wordsplit (arg, &ws,
(WRDSF_NOVAR | WRDSF_NOCMD
| WRDSF_QUOTE | WRDSF_DELIM)))
- ERROR ((0, 0, _("cannot split string '%s': %s"),
- arg, wordsplit_strerror (&ws)));
+ paxerror (0, _("cannot split string '%s': %s"),
+ arg, wordsplit_strerror (&ws));
else if (3 < ws.ws_wordc)
- ERROR ((0, 0, _("too many words in '%s'"), arg));
+ paxerror (0, _("too many words in '%s'"), arg);
else
{
int i;
#define WARNING_ENABLED(opt) (warning_option & (opt))
-#define WARNOPT(opt,args) \
- do \
- { \
- if (WARNING_ENABLED (opt)) WARN (args); \
- } \
- while (0)
+extern void warnopt (int, int, char const *, ...)
+ ATTRIBUTE_COLD ATTRIBUTE_FORMAT ((printf, 3, 4));
/* Module unlink.c */
data_block = find_next_block ();
if (! data_block)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
return;
}
switch (current_header->header.typeflag)
{
default:
- ERROR ((0, 0, _("%s: Unknown file type '%c', diffed as normal file"),
- quotearg_colon (current_stat_info.file_name),
- current_header->header.typeflag));
+ paxerror (0, _("%s: Unknown file type '%c', diffed as normal file"),
+ quotearg_colon (current_stat_info.file_name),
+ current_header->header.typeflag);
FALLTHROUGH;
case AREGTYPE:
case REGTYPE:
int may_fail = 0;
if (removed_prefixes_p ())
{
- WARN((0, 0,
- _("Archive contains file names with leading prefixes removed.")));
+ paxwarn (0,
+ _("Archive contains file names with leading prefixes removed."));
may_fail = 1;
}
if (transform_program_p ())
{
- WARN((0, 0,
- _("Archive contains transformed file names.")));
+ paxwarn (0, _("Archive contains transformed file names."));
may_fail = 1;
}
if (may_fail)
- WARN((0, 0,
- _("Verification may fail to locate original files.")));
+ paxwarn (0, _("Verification may fail to locate original files."));
clear_directory_table ();
}
while (status == HEADER_FAILURE);
- ERROR ((0, 0,
- ngettext ("VERIFY FAILURE: %d invalid header detected",
- "VERIFY FAILURE: %d invalid headers detected",
- counter), counter));
+ paxerror (0,
+ ngettext ("VERIFY FAILURE: %d invalid header detected",
+ "VERIFY FAILURE: %d invalid headers detected",
+ counter),
+ counter);
}
if (status == HEADER_END_OF_FILE)
break;
read_header_auto);
if (status == HEADER_ZERO_BLOCK)
break;
- WARNOPT (WARN_ALONE_ZERO_BLOCK,
- (0, 0, _("A lone zero block at %jd"),
- intmax (current_block_ordinal ())));
+ warnopt (WARN_ALONE_ZERO_BLOCK,
+ 0, _("A lone zero block at %jd"),
+ intmax (current_block_ordinal ()));
}
continue;
}
const char *message)
{
if (verbose_option)
- WARNOPT (WARN_CACHEDIR,
- (0, 0,
- _("%s: contains a cache directory tag %s; %s"),
- quotearg_colon (dirname),
- quotearg_n (1, tagname),
- message));
+ warnopt (WARN_CACHEDIR, 0,
+ _("%s: contains a cache directory tag %s; %s"),
+ quotearg_colon (dirname),
+ quotearg_n (1, tagname),
+ message);
}
enum exclusion_tag_type
Apart from this they are completely identical. */
uintmax_t s = (negsub &= archive_format == GNU_FORMAT) ? - sub : sub;
char const *ssign = &"-"[!negsub];
- WARN ((0, 0, _("value %s%ju out of %s range %jd..%ju;"
- " substituting %s%ju"),
- valuesign, value, type, minval, maxval, ssign, s));
+ paxwarn (0, _("value %s%ju out of %s range %jd..%ju;"
+ " substituting %s%ju"),
+ valuesign, value, type, minval, maxval, ssign, s);
return to_chars (negsub, s, valsize, 0, where, size, type);
}
else
- ERROR ((0, 0, _("value %s%ju out of %s range %jd..%ju"),
- valuesign, value, type, minval, maxval));
+ paxerror (0, _("value %s%ju out of %s range %jd..%ju"),
+ valuesign, value, type, minval, maxval);
return false;
}
if (! warned_once)
{
warned_once = true;
- WARN ((0, 0, _("Generating negative octal headers")));
+ paxwarn (0, _("Generating negative octal headers"));
}
where[size - 1] = '\0';
to_octal (value & MAX_VAL_WITH_DIGITS (valsize * CHAR_BIT, 1),
if (length > PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1)
{
- ERROR ((0, 0, _("%s: file name is too long (max %d); not dumped"),
- quotearg_colon (name),
- PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1));
+ paxerror (0, _("%s: file name is too long (max %d); not dumped"),
+ quotearg_colon (name),
+ PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1);
return NULL;
}
i = split_long_name (name, length);
if (i == 0 || (nlen = length - i - 1) > NAME_FIELD_SIZE || nlen == 0)
{
- ERROR ((0, 0,
- _("%s: file name is too long (cannot be split); not dumped"),
- quotearg_colon (name)));
+ paxerror (0, _("%s: file name is too long (cannot be split); not dumped"),
+ quotearg_colon (name));
return NULL;
}
case V7_FORMAT: /* old V7 tar format */
case USTAR_FORMAT:
case STAR_FORMAT:
- ERROR ((0, 0,
- _("%s: link name is too long; not dumped"),
- quotearg_colon (st->link_name)));
+ paxerror (0, _("%s: link name is too long; not dumped"),
+ quotearg_colon (st->link_name));
break;
case OLDGNU_FORMAT:
case V7_FORMAT:
if (strlen (st->file_name) > NAME_FIELD_SIZE-1)
{
- ERROR ((0, 0, _("%s: file name is too long (max %d); not dumped"),
- quotearg_colon (st->file_name),
- NAME_FIELD_SIZE - 1));
+ paxerror (0, _("%s: file name is too long (max %d); not dumped"),
+ quotearg_colon (st->file_name), NAME_FIELD_SIZE - 1);
return NULL;
}
break;
if (count != bufsize)
{
memset (blk->buffer + count, 0, bufsize - count);
- WARNOPT (WARN_FILE_SHRANK,
- (0, 0,
- ngettext (("%s: File shrank by %jd byte;"
- " padding with zeros"),
- ("%s: File shrank by %jd bytes;"
- " padding with zeros"),
- size_left),
- quotearg_colon (st->orig_file_name),
- intmax (size_left)));
+ warnopt (WARN_FILE_SHRANK, 0,
+ ngettext (("%s: File shrank by %jd byte;"
+ " padding with zeros"),
+ ("%s: File shrank by %jd bytes;"
+ " padding with zeros"),
+ size_left),
+ quotearg_colon (st->orig_file_name),
+ intmax (size_left));
if (! ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
pad_archive (size_left - (bufsize - count));
&& st->parent->stat.st_dev != st->stat.st_dev)
{
if (verbose_option)
- WARNOPT (WARN_XDEV,
- (0, 0,
- _("%s: file is on a different filesystem; not dumped"),
- quotearg_colon (st->orig_file_name)));
+ warnopt (WARN_XDEV, 0,
+ _("%s: file is on a different filesystem; not dumped"),
+ quotearg_colon (st->orig_file_name));
}
else
{
static void
unknown_file_error (char const *p)
{
- WARNOPT (WARN_FILE_IGNORED,
- (0, 0, _("%s: Unknown file type; file ignored"),
- quotearg_colon (p)));
+ warnopt (WARN_FILE_IGNORED, 0,
+ _("%s: Unknown file type; file ignored"), quotearg_colon (p));
if (!ignore_failed_read_option)
set_exit_status (TAREXIT_FAILURE);
}
void
check_links (void)
{
- struct link *lp;
-
if (!link_table)
return;
- for (lp = hash_get_first (link_table); lp;
+ for (struct link *lp = hash_get_first (link_table); lp;
lp = hash_get_next (link_table, lp))
- {
- if (lp->nlink)
- {
- WARN ((0, 0, _("Missing links to %s."), quote (lp->name)));
- }
- }
+ if (lp->nlink)
+ paxwarn (0, _("Missing links to %s."), quote (lp->name));
}
/* Assuming DIR is the working directory, open FILE, using FLAGS to
&& (!after_date_option || OLDER_TAR_STAT_TIME (*st, c)))
{
if (!incremental_option && verbose_option)
- WARNOPT (WARN_FILE_UNCHANGED,
- (0, 0, _("%s: file is unchanged; not dumped"),
- quotearg_colon (p)));
+ warnopt (WARN_FILE_UNCHANGED, 0, _("%s: file is unchanged; not dumped"),
+ quotearg_colon (p));
return allocated;
}
/* See if we are trying to dump the archive. */
if (sys_file_is_archive (st))
{
- WARNOPT (WARN_IGNORE_ARCHIVE,
- (0, 0, _("%s: archive cannot contain itself; not dumped"),
- quotearg_colon (p)));
+ warnopt (WARN_IGNORE_ARCHIVE, 0,
+ _("%s: archive cannot contain itself; not dumped"), quotearg_colon (p));
return allocated;
}
if (!ok)
{
- WARNOPT (WARN_FILE_CHANGED,
- (0, 0, _("%s: file changed as we read it"),
- quotearg_colon (p)));
+ warnopt (WARN_FILE_CHANGED, 0, _("%s: file changed as we read it"),
+ quotearg_colon (p));
if (! ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
}
}
else if (S_ISSOCK (st->stat.st_mode))
{
- WARNOPT (WARN_FILE_IGNORED,
- (0, 0, _("%s: socket ignored"), quotearg_colon (p)));
+ warnopt (WARN_FILE_IGNORED, 0, _("%s: socket ignored"), quotearg_colon (p));
return allocated;
}
else if (S_ISDOOR (st->stat.st_mode))
{
- WARNOPT (WARN_FILE_IGNORED,
- (0, 0, _("%s: door ignored"), quotearg_colon (p)));
+ warnopt (WARN_FILE_IGNORED, 0, _("%s: door ignored"), quotearg_colon (p));
return allocated;
}
else
|| ckd_add (&position, move_start, increment)
|| position < 0)
{
- ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0]));
+ paxerror (EOVERFLOW, "lseek: %s", archive_name_array[0]);
return;
}
else if (rmtlseek (archive, position, SEEK_SET) == position)
switch (previous_status)
{
case HEADER_STILL_UNREAD:
- WARN ((0, 0, _("This does not look like a tar archive")));
+ paxwarn (0, _("This does not look like a tar archive"));
FALLTHROUGH;
case HEADER_SUCCESS:
case HEADER_SUCCESS_EXTENDED:
case HEADER_ZERO_BLOCK:
- ERROR ((0, 0, _("Skipping to next header")));
+ paxerror (0, _("Skipping to next header"));
FALLTHROUGH;
case HEADER_FAILURE:
break;
break;
case HEADER_FAILURE:
- ERROR ((0, 0, _("Deleting non-header from archive")));
+ paxerror (0, _("Deleting non-header from archive"));
set_next_block_after (current_header);
break;
fp = fdopen (fd, "r");
if (!fp)
{
- ERROR ((0, errno, _("%s: fdopen failed"), file->name));
+ paxerror (errno, _("%s: fdopen failed"), file->name);
close (fd);
continue;
}
FNM_FILE_NAME|EXCLUDE_WILDCARDS|EXCLUDE_ANCHORED,
'\n',
vcsfile->data))
- {
- int e = errno;
- FATAL_ERROR ((0, e, "%s", quotearg_colon (file->name)));
- }
+ paxfatal (errno, "%s", quotearg_colon (file->name));
fclose (fp);
ent = xmalloc (sizeof (*ent));
check_time (char const *file_name, struct timespec t)
{
if (t.tv_sec < 0)
- WARNOPT (WARN_TIMESTAMP,
- (0, 0, _("%s: implausibly old time stamp %s"),
- file_name, tartime (t, true)));
+ warnopt (WARN_TIMESTAMP, 0, _("%s: implausibly old time stamp %s"),
+ file_name, tartime (t, true));
else if (timespec_cmp (volume_start_time, t) < 0)
{
struct timespec now;
diff.tv_nsec += BILLION;
diff.tv_sec--;
}
- WARNOPT (WARN_TIMESTAMP,
- (0, 0, _("%s: time stamp %s is %s s in the future"),
- file_name, tartime (t, true), code_timespec (diff, buf)));
+ warnopt (WARN_TIMESTAMP, 0, _("%s: time stamp %s is %s s in the future"),
+ file_name, tartime (t, true), code_timespec (diff, buf));
}
}
}
}
}
- ERROR ((0, 0, _("%s: Unexpected inconsistency when making directory"),
- quotearg_colon (dir)));
+ paxerror (0, _("%s: Unexpected inconsistency when making directory"),
+ quotearg_colon (dir));
}
static void
switch (old_files_option)
{
case SKIP_OLD_FILES:
- WARNOPT (WARN_EXISTING_FILE,
- (0, 0, _("%s: skipping existing file"), file_name));
+ warnopt (WARN_EXISTING_FILE, 0, _("%s: skipping existing file"), file_name);
return RECOVER_SKIP;
case KEEP_OLD_FILES:
current_mode_mask = ALL_MODE_BITS;
if (! (st.st_dev == data->dev && st.st_ino == data->ino))
{
- ERROR ((0, 0,
- _("%s: Directory renamed before its status could be extracted"),
- quotearg_colon (data->file_name)));
+ paxerror (0,
+ _("%s: Directory renamed before its status"
+ " could be extracted"),
+ quotearg_colon (data->file_name));
skip_this_one = 1;
}
}
if (!conttype_diagnosed)
{
conttype_diagnosed = 1;
- WARNOPT (WARN_CONTIGUOUS_CAST,
- (0, 0, _("Extracting contiguous files as regular files")));
+ warnopt (WARN_CONTIGUOUS_CAST, 0,
+ _("Extracting contiguous files as regular files"));
}
}
data_block = find_next_block ();
if (! data_block)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
break; /* FIXME: What happens, then? */
}
if (!warned)
{
warned = true;
- WARNOPT (WARN_SYMLINK_CAST,
- (0, 0,
- _("Attempting extraction of symbolic links"
- " as hard links")));
+ warnopt (WARN_SYMLINK_CAST, 0,
+ _("Attempting extraction of symbolic links"
+ " as hard links"));
}
return extract_link (file_name, typeflag);
}
return false;
case GNUTYPE_MULTIVOL:
- ERROR ((0, 0,
- _("%s: Cannot extract -- file is continued from another volume"),
- quotearg_colon (current_stat_info.file_name)));
+ paxerror (0, _("%s: Cannot extract -- file is continued from another volume"),
+ quotearg_colon (current_stat_info.file_name));
return false;
case GNUTYPE_LONGNAME:
case GNUTYPE_LONGLINK:
- ERROR ((0, 0, _("Unexpected long name header")));
+ paxerror (0, _("Unexpected long name header"));
return false;
default:
- WARNOPT (WARN_UNKNOWN_CAST,
- (0, 0,
- _("%s: Unknown file type '%c', extracted as normal file"),
- quotearg_colon (file_name), typeflag));
+ warnopt (WARN_UNKNOWN_CAST, 0,
+ _("%s: Unknown file type '%c', extracted as normal file"),
+ quotearg_colon (file_name), typeflag);
extractor = extract_file;
}
case KEEP_NEWER_FILES:
if (file_newer_p (file_name, 0, ¤t_stat_info))
{
- WARNOPT (WARN_IGNORE_NEWER,
- (0, 0, _("Current %s is newer or same age"),
- quote (file_name)));
+ warnopt (WARN_IGNORE_NEWER, 0, _("Current %s is newer or same age"),
+ quote (file_name));
return false;
}
break;
skip_dotdot_name = (!absolute_names_option
&& contains_dot_dot (current_stat_info.orig_file_name));
if (skip_dotdot_name)
- ERROR ((0, 0, _("%s: Member name contains '..'"),
- quotearg_colon (current_stat_info.orig_file_name)));
+ paxerror (0, _("%s: Member name contains '..'"),
+ quotearg_colon (current_stat_info.orig_file_name));
if (!current_stat_info.file_name[0]
|| skip_dotdot_name
if (backup_option)
if (!maybe_backup_file (current_stat_info.file_name, 0))
{
- int e = errno;
- ERROR ((0, e, _("%s: Was unable to backup this file"),
- quotearg_colon (current_stat_info.file_name)));
+ paxerror (errno, _("%s: Was unable to backup this file"),
+ quotearg_colon (current_stat_info.file_name));
skip_member ();
return;
}
break;
}
- ERROR ((0, e, _("Cannot rename %s to %s"),
- quote_n (0, src),
- quote_n (1, dst)));
+ paxerror (e, _("Cannot rename %s to %s"),
+ quote_n (0, src),
+ quote_n (1, dst));
return false;
}
return true;
{
if (strcmp (d->name, name_buffer))
{
- WARNOPT (WARN_RENAME_DIRECTORY,
- (0, 0,
- _("%s: Directory has been renamed from %s"),
- quotearg_colon (name_buffer),
- quote_n (1, d->name)));
+ warnopt (WARN_RENAME_DIRECTORY, 0,
+ _("%s: Directory has been renamed from %s"),
+ quotearg_colon (name_buffer),
+ quote_n (1, d->name));
directory->orig = d;
DIR_SET_FLAG (directory, DIRF_RENAMED);
DIR_CLEAR_FLAG (d, DIRF_RENAMED);
{
if (strcmp (d->name, name_buffer))
{
- WARNOPT (WARN_RENAME_DIRECTORY,
- (0, 0, _("%s: Directory has been renamed from %s"),
- quotearg_colon (name_buffer),
- quote_n (1, d->name)));
+ warnopt (WARN_RENAME_DIRECTORY, 0,
+ _("%s: Directory has been renamed from %s"),
+ quotearg_colon (name_buffer),
+ quote_n (1, d->name));
directory->orig = d;
DIR_SET_FLAG (directory, DIRF_RENAMED);
DIR_CLEAR_FLAG (d, DIRF_RENAMED);
else
{
DIR_SET_FLAG (directory, DIRF_NEW);
- WARNOPT (WARN_NEW_DIRECTORY,
- (0, 0, _("%s: Directory is new"),
- quotearg_colon (name_buffer)));
+ warnopt (WARN_NEW_DIRECTORY, 0, _("%s: Directory is new"),
+ quotearg_colon (name_buffer));
directory->children =
(listed_incremental_option
|| (OLDER_STAT_TIME (*stat_data, m)
if (one_file_system_option && st->parent
&& stat_data->st_dev != st->parent->stat.st_dev)
{
- WARNOPT (WARN_XDEV,
- (0, 0,
- _("%s: directory is on a different filesystem; not dumped"),
- quotearg_colon (directory->name)));
+ warnopt (WARN_XDEV, 0,
+ _("%s: directory is on a different filesystem; not dumped"),
+ quotearg_colon (directory->name));
directory->children = NO_CHILDREN;
/* If there is any dumpdir info in that directory, remove it */
if (directory->dump)
}
if (perhaps_renamed)
- WARNOPT (WARN_RENAME_DIRECTORY,
- (0, 0, _("%s: Directory has been renamed"),
- quotearg_colon (name_buffer)));
+ warnopt (WARN_RENAME_DIRECTORY, 0, _("%s: Directory has been renamed"),
+ quotearg_colon (name_buffer));
DIR_SET_FLAG (directory, DIRF_INIT);
newer_mtime_option = decode_timespec (buf, &ebuf, false);
if (! valid_timespec (newer_mtime_option))
- FATAL_ERROR ((0, errno, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option),
- lineno,
- _("Invalid time stamp")));
+ paxfatal (errno, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option),
+ lineno, _("Invalid time stamp"));
else
{
if (version == 1 && *ebuf)
= stoint (buf_ns, &ebuf, &overflow, 0, BILLION - 1);
if ((ebuf == buf_ns) | *ebuf | overflow)
{
- ERROR ((0, 0, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option),
- lineno,
- _("Invalid time stamp")));
+ paxerror (0, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option), lineno,
+ _("Invalid time stamp"));
newer_mtime_option.tv_sec = TYPE_MINIMUM (time_t);
newer_mtime_option.tv_nsec = -1;
}
mtime = decode_timespec (strp, &ebuf, false);
strp = ebuf;
if (!valid_timespec (mtime) || *strp != ' ')
- FATAL_ERROR ((0, errno, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option), lineno,
- _("Invalid modification time")));
+ paxfatal (errno, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option), lineno,
+ _("Invalid modification time"));
bool overflow;
mtime.tv_nsec = stoint (strp, &ebuf, &overflow, 0, BILLION - 1);
if ((ebuf == strp) | (*ebuf != ' ') | overflow)
{
- FATAL_ERROR ((0, 0, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option), lineno,
- _("Invalid modification time (nanoseconds)")));
+ paxfatal (0, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option), lineno,
+ _("Invalid modification time (nanoseconds)"));
mtime.tv_nsec = -1;
}
strp = ebuf;
dev = stoint (strp, &ebuf, &overflow,
TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t));
if ((ebuf == strp) | (*ebuf != ' ') | overflow)
- FATAL_ERROR ((0, 0, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option), lineno,
- _("Invalid device number")));
+ paxfatal (0, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option), lineno,
+ _("Invalid device number"));
strp = ebuf + 1;
ino = stoint (strp, &ebuf, &overflow,
TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t));
if ((ebuf == strp) | (*ebuf != ' ') | overflow)
- FATAL_ERROR ((0, 0, "%s:%jd: %s",
- quotearg_colon (listed_incremental_option), lineno,
- _("Invalid inode number")));
+ paxfatal (0, "%s:%jd: %s",
+ quotearg_colon (listed_incremental_option), lineno,
+ _("Invalid inode number"));
strp = ebuf + 1;
unquote_string (strp);
{
buf[i] = c;
if (i == sizeof buf - 1)
- FATAL_ERROR ((0, 0,
- _("%s: byte %jd: %s %.*s... too long"),
- quotearg_colon (listed_incremental_option),
- intmax (ftello (fp)),
- fieldname, i + 1, buf));
+ paxfatal (0,
+ _("%s: byte %jd: %s %.*s... too long"),
+ quotearg_colon (listed_incremental_option),
+ intmax (ftello (fp)),
+ fieldname, i + 1, buf);
c = getc (fp);
}
if (ferror (fp))
read_fatal (listed_incremental_option);
if (i != 0)
- FATAL_ERROR ((0, 0, "%s: %s",
- quotearg_colon (listed_incremental_option),
- _("Unexpected EOF in snapshot file")));
+ paxfatal (0, "%s: %s",
+ quotearg_colon (listed_incremental_option),
+ _("Unexpected EOF in snapshot file"));
return false;
}
if (c)
{
unsigned uc = c;
- FATAL_ERROR ((0, 0,
- _("%s: byte %jd: %s %s followed by invalid byte 0x%02x"),
- quotearg_colon (listed_incremental_option),
- intmax (ftello (fp)),
- fieldname, buf, uc));
+ paxfatal (0, _("%s: byte %jd: %s %s followed by invalid byte 0x%02x"),
+ quotearg_colon (listed_incremental_option),
+ intmax (ftello (fp)), fieldname, buf, uc);
}
char *bufend;
*pval = stoint (buf, &bufend, &overflow, min_val, max_val);
if (buf == bufend)
- FATAL_ERROR ((0, EINVAL,
- _("%s: byte %jd: %s %s"),
- quotearg_colon (listed_incremental_option),
- intmax (ftello (fp)), fieldname, buf));
+ paxfatal (EINVAL, _("%s: byte %jd: %s %s"),
+ quotearg_colon (listed_incremental_option),
+ intmax (ftello (fp)), fieldname, buf);
if (overflow)
- FATAL_ERROR ((0, ERANGE,
- _("%s: byte %jd: (valid range %jd..%ju)\n\t%s %s"),
- quotearg_colon (listed_incremental_option),
- intmax (ftello (fp)), min_val, max_val, fieldname, buf));
+ paxfatal (ERANGE, _("%s: byte %jd: (valid range %jd..%ju)\n\t%s %s"),
+ quotearg_colon (listed_incremental_option),
+ intmax (ftello (fp)), min_val, max_val, fieldname, buf);
return true;
}
}
else
{
- FATAL_ERROR ((0, 0, "%s: %s",
- quotearg_colon (listed_incremental_option),
- _("Unexpected EOF in snapshot file")));
+ paxfatal (0, "%s: %s", quotearg_colon (listed_incremental_option),
+ _("Unexpected EOF in snapshot file"));
}
}
while (read_obstack (listed_incremental_stream, &stk, &s) == 0 && s > 1)
;
if (getc (listed_incremental_stream) != 0)
- FATAL_ERROR ((0, 0, _("%s: byte %s: %s"),
- quotearg_colon (listed_incremental_option),
- offtostr (ftello (listed_incremental_stream), offbuf),
- _("Missing record terminator")));
+ paxfatal (0, _("%s: byte %s: %s"),
+ quotearg_colon (listed_incremental_option),
+ offtostr (ftello (listed_incremental_stream), offbuf),
+ _("Missing record terminator"));
content = obstack_finish (&stk);
note_directory (name, mtime, dev, ino, nfs, false, content);
obstack_free (&stk, content);
}
- FATAL_ERROR ((0, 0, "%s: %s",
- quotearg_colon (listed_incremental_option),
- _("Unexpected EOF in snapshot file")));
+ paxfatal (0, "%s: %s", quotearg_colon (listed_incremental_option),
+ _("Unexpected EOF in snapshot file"));
}
/* Display (to stdout) the range of allowed values for each field
{
ebuf = buf + sizeof PACKAGE_NAME - 1;
if (*ebuf++ != '-')
- FATAL_ERROR ((0, 0, _("Bad incremental file format")));
+ paxfatal (0, _("Bad incremental file format"));
for (; *ebuf != '-'; ebuf++)
if (!*ebuf)
- FATAL_ERROR ((0, 0, _("Bad incremental file format")));
+ paxfatal (0, _("Bad incremental file format"));
ebuf++;
if (! ('0' <= *ebuf && *ebuf <= '0' + TAR_INCREMENTAL_VERSION
&& !c_isdigit (ebuf[1])))
- FATAL_ERROR ((0, 0,
- _("Unsupported incremental format version: %s"),
- ebuf));
+ paxfatal (0, _("Unsupported incremental format version: %s"), ebuf);
incremental_version = *ebuf - '0';
}
else
mv_size_left (size);
data_block = find_next_block ();
if (!data_block)
- FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxfatal (0, _("Unexpected EOF in archive"));
copied = available_space_after (data_block);
if (copied > size)
copied = size;
if (expect && *p != expect)
{
unsigned char uc = *p;
- ERROR ((0, 0,
- _("Malformed dumpdir: expected '%c' but found %#3o"),
- expect, uc));
+ paxerror (0, _("Malformed dumpdir: expected '%c' but found %#3o"),
+ expect, uc);
return false;
}
switch (*p)
case 'X':
if (has_tempdir)
{
- ERROR ((0, 0,
- _("Malformed dumpdir: 'X' duplicated")));
+ paxerror (0, _("Malformed dumpdir: 'X' duplicated"));
return false;
}
else
{
if (!has_tempdir)
{
- ERROR ((0, 0,
- _("Malformed dumpdir: empty name in 'R'")));
+ paxerror (0, _("Malformed dumpdir: empty name in 'R'"));
return false;
}
else
case 'T':
if (expect != 'T')
{
- ERROR ((0, 0,
- _("Malformed dumpdir: 'T' not preceded by 'R'")));
+ paxerror (0, _("Malformed dumpdir: 'T' not preceded by 'R'"));
return false;
}
if (p[1] == 0 && !has_tempdir)
{
- ERROR ((0, 0,
- _("Malformed dumpdir: empty name in 'T'")));
+ paxerror (0, _("Malformed dumpdir: empty name in 'T'"));
return false;
}
expect = 0;
if (expect)
{
- ERROR ((0, 0,
- _("Malformed dumpdir: expected '%c' but found end of data"),
- expect));
+ paxerror (0, _("Malformed dumpdir: expected '%c' but found end of data"), expect);
return false;
}
if (has_tempdir)
- WARNOPT (WARN_BAD_DUMPDIR,
- (0, 0, _("Malformed dumpdir: 'X' never used")));
+ warnopt (WARN_BAD_DUMPDIR, 0, _("Malformed dumpdir: 'X' never used"));
return true;
}
sizeof TEMP_DIR_TEMPLATE);
if (!mkdtemp (temp_stub))
{
- ERROR ((0, errno,
- _("Cannot create temporary directory using template %s"),
- quote (temp_stub)));
+ paxerror (errno, _("Cannot create temporary directory using template %s"),
+ quote (temp_stub));
free (temp_stub);
free (current_dir);
return false;
dirs and check it here? */
{
stat_diag (p);
- WARN ((0, 0, _("%s: Not purging directory: unable to stat"),
- quotearg_colon (p)));
+ paxwarn (0, _("%s: Not purging directory: unable to stat"),
+ quotearg_colon (p));
}
continue;
}
{
if (one_file_system_option && st.st_dev != root_device)
{
- WARN ((0, 0,
- _("%s: directory is on a different device: not purging"),
- quotearg_colon (p)));
+ paxwarn (0, _("%s: directory is on a different device: not purging"),
+ quotearg_colon (p));
continue;
}
fprintf (stdlis, _("%s: Deleting %s\n"),
program_name, quote (p));
if (! remove_any_file (p, RECURSIVE_REMOVE_OPTION))
- {
- int e = errno;
- ERROR ((0, e, _("%s: Cannot remove"), quotearg_colon (p)));
- }
+ paxerror (errno, _("%s: Cannot remove"), quotearg_colon (p));
}
}
}
case DIRTYPE:
if (show_omitted_dirs_option)
- WARN ((0, 0, _("%s: Omitting"),
- quotearg_colon (current_stat_info.file_name)));
+ paxwarn (0, _("%s: Omitting"),
+ quotearg_colon (current_stat_info.file_name));
FALLTHROUGH;
default:
skip_member ();
read_header_auto);
if (status == HEADER_ZERO_BLOCK)
break;
- WARNOPT (WARN_ALONE_ZERO_BLOCK,
- (0, 0, _("A lone zero block at %jd"),
- intmax (current_block_ordinal ())));
+ warnopt (WARN_ALONE_ZERO_BLOCK, 0, _("A lone zero block at %jd"),
+ intmax (current_block_ordinal ()));
break;
}
status = prev_status;
case HEADER_END_OF_FILE:
if (!ignore_zeros_option)
- WARNOPT (WARN_MISSING_ZERO_BLOCKS,
- (0, 0, _("Terminating zero blocks missing at %jd"),
- intmax (current_block_ordinal ())));
+ warnopt (WARN_MISSING_ZERO_BLOCKS, 0,
+ _("Terminating zero blocks missing at %jd"),
+ intmax (current_block_ordinal ()));
if (block_number_option)
fprintf (stdlis, _("block %jd: ** End of File **\n"),
intmax (current_block_ordinal ()));
switch (prev_status)
{
case HEADER_STILL_UNREAD:
- ERROR ((0, 0, _("This does not look like a tar archive")));
+ paxerror (0, _("This does not look like a tar archive"));
FALLTHROUGH;
case HEADER_ZERO_BLOCK:
case HEADER_SUCCESS:
fprintf (stdlis, _("block %jd: "),
intmax (block_ordinal));
}
- ERROR ((0, 0, _("Skipping to next header")));
+ paxerror (0, _("Skipping to next header"));
break;
case HEADER_END_OF_FILE:
data_block = find_next_block ();
if (! data_block)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
break;
}
written = available_space_after (data_block);
if (where == lim)
{
if (type && !silent)
- ERROR ((0, 0,
- /* TRANSLATORS: %s is type of the value (gid_t, uid_t,
- etc.) */
- _("Blanks in header where numeric %s value expected"),
- type));
+ paxerror (0,
+ /* TRANSLATORS: %s is type of the value (gid_t, uid_t,
+ etc.) */
+ _("Blanks in header where numeric %s value expected"),
+ type);
return -1;
}
if (!c_isspace (*where))
if (!overflow && value <= minus_minval)
{
if (!silent)
- WARN ((0, 0,
- /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
- _("Archive octal value %.*s is out of %s range; assuming two's complement"),
- (int) (where - where1), where1, type));
+ paxwarn (0,
+ /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
+ _("Archive octal value %.*s is out of %s range;"
+ " assuming two's complement"),
+ (int) (where - where1), where1, type);
negative = true;
}
}
if (overflow)
{
if (type && !silent)
- ERROR ((0, 0,
- /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
- _("Archive octal value %.*s is out of %s range"),
- (int) (where - where1), where1, type));
+ paxerror (0,
+ /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
+ _("Archive octal value %.*s is out of %s range"),
+ (int) (where - where1), where1, type);
return -1;
}
}
if (! warned_once)
{
warned_once = true;
- WARN ((0, 0, _("Archive contains obsolescent base-64 headers")));
+ paxwarn (0, _("Archive contains obsolescent base-64 headers"));
}
}
negative = *where++ == '-';
if (ckd_mul (&value, value, 64))
{
if (type && !silent)
- ERROR ((0, 0,
- _("Archive signed base-64 string %s is out of %s range"),
- quote_mem (where0, digs), type));
+ paxerror (0, _("Archive signed base-64 string %s is out of %s range"),
+ quote_mem (where0, digs), type);
return -1;
}
value |= dig - 1;
if (((value << LG_256 >> LG_256) | topbits) != value)
{
if (type && !silent)
- ERROR ((0, 0,
- _("Archive base-256 value is out of %s range"),
- type));
+ paxerror (0, _("Archive base-256 value is out of %s range"), type);
return -1;
}
}
lim--;
quotearg_buffer (buf, sizeof buf, where0, lim - where0, o);
if (!silent)
- ERROR ((0, 0,
- /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
- _("Archive contains %.*s where numeric %s value expected"),
- (int) sizeof buf, buf, type));
+ paxerror (0,
+ /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
+ _("Archive contains %.*s where numeric %s value expected"),
+ (int) sizeof buf, buf, type);
}
return -1;
{
char const *value_sign = &"-"[!negative];
/* TRANSLATORS: Second %s is type name (gid_t,uid_t,etc.) */
- ERROR ((0, 0, _("Archive value %s%ju is out of %s range %jd..%ju"),
- value_sign, value, type, minval, maxval));
+ paxerror (0, _("Archive value %s%ju is out of %s range %jd..%ju"),
+ value_sign, value, type, minval, maxval);
}
return -1;
case GNUTYPE_LONGNAME:
case GNUTYPE_LONGLINK:
modes[0] = 'L';
- ERROR ((0, 0, _("Unexpected long name header")));
+ paxerror (0, _("Unexpected long name header"));
break;
case GNUTYPE_SPARSE:
{
x = find_next_block ();
if (! x)
- FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxfatal (0, _("Unexpected EOF in archive"));
set_next_block_after (x);
size -= BLOCKSIZE;
++line;
if (wordsplit (buf, &ws, wsopt))
- FATAL_ERROR ((0, 0, _("%s:%jd: cannot split line: %s"),
- file, line, wordsplit_strerror (&ws)));
+ paxfatal (0, _("%s:%jd: cannot split line: %s"),
+ file, line, wordsplit_strerror (&ws));
wsopt |= WRDSF_REUSE;
if (ws.ws_wordc == 0)
continue;
wordsplit_free (&ws);
fclose (fp);
if (err)
- FATAL_ERROR ((0, 0, _("errors reading map file")));
+ paxfatal (0, _("errors reading map file"));
}
\f
/* UID translation */
{
/* The backup operation failed. */
int e = errno;
- ERROR ((0, e, _("%s: Cannot rename to %s"),
- quotearg_colon (before_backup_name),
- quote_n (1, after_backup_name)));
+ paxerror (e, _("%s: Cannot rename to %s"),
+ quotearg_colon (before_backup_name),
+ quote_n (1, after_backup_name));
assign_null (&after_backup_name);
return false;
}
!= 0)
{
int e = errno;
- ERROR ((0, e, _("%s: Cannot rename to %s"),
- quotearg_colon (after_backup_name),
- quote_n (1, before_backup_name)));
+ paxerror (e, _("%s: Cannot rename to %s"),
+ quotearg_colon (after_backup_name),
+ quote_n (1, before_backup_name));
}
if (verbose_option)
fprintf (stdlis, _("Renaming %s back to %s\n"),
{
if (!top_level && errno == ENOENT)
{
- WARNOPT (WARN_FILE_REMOVED,
- (0, 0, _("%s: File removed before we read it"),
- quotearg_colon (name)));
+ warnopt (WARN_FILE_REMOVED, 0, _("%s: File removed before we read it"),
+ quotearg_colon (name));
set_exit_status (TAREXIT_DIFFERS);
}
else
case 'X':
if (add_exclude_file (add_exclude, excluded, arg, EXCLUDE_OPTIONS, '\n')
!= 0)
- {
- int e = errno;
- FATAL_ERROR ((0, e, "%s", quotearg_colon (arg)));
- }
+ paxfatal (errno, "%s", quotearg_colon (arg));
break;
case ANCHORED_OPTION:
break;
default:
- FATAL_ERROR ((0, 0, "unhandled positional option %d", key));
+ paxfatal (0, "unhandled positional option %d", key);
}
}
{
struct name_elt *elt;
- ERROR ((0, 0, _("The following options were used after non-option arguments. These options are positional and affect only arguments that follow them. Please, rearrange them properly.")));
+ paxerror (0, _("The following options were used after non-option arguments."
+ " These options are positional and affect"
+ " only arguments that follow them."
+ " Please, rearrange them properly."));
elt = unconsumed_option_tail;
while (elt->prev)
switch (elt->type)
{
case NELT_CHDIR:
- ERROR ((0, 0, _("-C %s has no effect"), quote (elt->v.name)));
+ paxerror (0, _("-C %s has no effect"), quote (elt->v.name));
break;
case NELT_OPTION:
if (elt->v.opt.arg)
- ERROR ((0, 0, _("--%s %s has no effect"),
- file_selection_option_name (elt->v.opt.option),
- quote (elt->v.opt.arg)));
+ paxerror (0, _("--%s %s has no effect"),
+ file_selection_option_name (elt->v.opt.option),
+ quote (elt->v.opt.arg));
else
- ERROR ((0, 0, _("--%s has no effect"),
- file_selection_option_name (elt->v.opt.option)));
+ paxerror (0, _("--%s has no effect"),
+ file_selection_option_name (elt->v.opt.option));
break;
default:
if (p->ino == st.st_ino && p->dev == st.st_dev)
{
int oldc = set_char_quoting (NULL, ':', 1);
- ERROR ((0, 0,
- _("%s: file list requested from %s already read from %s"),
- quotearg_n (0, filename),
- reading_from, p->from_file));
+ paxerror (0, _("%s: file list requested from %s already read from %s"),
+ quotearg_n (0, filename),
+ reading_from, p->from_file);
set_char_quoting (NULL, ':', oldc);
return 1;
}
ws.ws_offs = 1;
if (wordsplit (str, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS))
- FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
- str, wordsplit_strerror (&ws)));
+ paxfatal (0, _("cannot split string '%s': %s"),
+ str, wordsplit_strerror (&ws));
int argc;
if (ckd_add (&argc, ws.ws_wordc, ws.ws_offs))
- FATAL_ERROR ((0, 0, _("too many options")));
+ paxfatal (0, _("too many options"));
ws.ws_wordv[0] = (char *) program_name;
loc.source = OPTS_FILE;
loc.name = ent->v.file.name;
continue;
case file_list_zero:
- WARNOPT (WARN_FILENAME_WITH_NULS,
- (0, 0, N_("%s: file name read contains nul character"),
- quotearg_colon (ent->v.file.name)));
+ warnopt (WARN_FILENAME_WITH_NULS, 0,
+ N_("%s: file name read contains nul character"),
+ quotearg_colon (ent->v.file.name));
ent->v.file.term = 0;
FALLTHROUGH;
case file_list_success:
&& fnmatch_pattern_has_wildcards (name, 0))
{
warned_once = 1;
- WARN ((0, 0,
- _("Pattern matching characters used in file names")));
- WARN ((0, 0,
- _("Use --wildcards to enable pattern matching,"
- " or --no-wildcards to suppress this warning")));
+ paxwarn (0, _("Pattern matching characters used in file names"));
+ paxwarn (0, _("Use --wildcards to enable pattern matching,"
+ " or --no-wildcards to suppress this warning"));
}
return warned_once;
}
if (!WASFOUND (cursor) && cursor->name[0])
{
regex_usage_warning (cursor->name);
- ERROR ((0, 0,
- (cursor->found_count == 0) ?
- _("%s: Not found in archive") :
- _("%s: Required occurrence not found in archive"),
- quotearg_colon (cursor->name)));
+ paxerror (0,
+ (cursor->found_count == 0
+ ? _("%s: Not found in archive")
+ : _("%s: Required occurrence not found in archive")),
+ quotearg_colon (cursor->name));
}
/* Don't bother freeing the name list; we're about to exit. */
while ((name = name_next (true)))
{
regex_usage_warning (name);
- ERROR ((0, 0, _("%s: Not found in archive"),
- quotearg_colon (name)));
+ paxerror (0, _("%s: Not found in archive"), quotearg_colon (name));
}
}
}
case 1:
if (namelist->change_dir == 0)
- USAGE_ERROR ((0, 0,
- _("Using -C option inside file list is not "
- "allowed with --listed-incremental")));
+ paxusage (_("Using -C option inside file list is not "
+ "allowed with --listed-incremental"));
break;
default:
- USAGE_ERROR ((0, 0,
- _("Only one -C option is allowed with "
- "--listed-incremental")));
+ paxusage (_("Only one -C option is allowed with "
+ "--listed-incremental"));
}
read_directory_file ();
return true;
#else
if (hole_detection == HOLE_DETECTION_SEEK)
- WARN((0, 0,
- _("\"seek\" hole detection is not supported, using \"raw\".")));
+ paxwarn (0, _("\"seek\" hole detection is not supported, using \"raw\"."));
/* fall back to "raw" for this and all other files */
hole_detection = HOLE_DETECTION_RAW;
#endif
+ file->stat_info->sparse_map[i].numbytes
- bytes_left);
- WARNOPT (WARN_FILE_SHRANK,
- (0, 0,
- ngettext ("%s: File shrank by %jd byte; padding with zeros",
- "%s: File shrank by %jd bytes; padding with zeros",
- n),
- quotearg_colon (file->stat_info->orig_file_name),
- intmax (n)));
+ warnopt (WARN_FILE_SHRANK, 0,
+ ngettext ("%s: File shrank by %jd byte; padding with zeros",
+ "%s: File shrank by %jd bytes; padding with zeros",
+ n),
+ quotearg_colon (file->stat_info->orig_file_name),
+ intmax (n));
if (! ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
return false;
union block *blk = find_next_block ();
if (!blk)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
return false;
}
set_next_block_after (blk);
union block *blk = find_next_block ();
if (!blk)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
return false;
}
set_next_block_after (blk);
h = find_next_block ();
if (!h)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
return false;
}
set_next_block_after (h);
if (rc == add_fail)
{
- ERROR ((0, 0, _("%s: invalid sparse archive member"),
- file->stat_info->orig_file_name));
+ paxerror (0, _("%s: invalid sparse archive member"),
+ file->stat_info->orig_file_name);
return false;
}
return true;
h = find_next_block ();
if (!h)
{
- ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxerror (0, _("Unexpected EOF in archive"));
return false;
}
set_next_block_after (h);
if (rc == add_fail)
{
- ERROR ((0, 0, _("%s: invalid sparse archive member"),
- file->stat_info->orig_file_name));
+ paxerror (0, _("%s: invalid sparse archive member"),
+ file->stat_info->orig_file_name);
return false;
}
return true;
{ \
if (dst == buf + UINTMAX_STRSIZE_BOUND -1) \
{ \
- ERROR ((0, 0, _("%s: numeric overflow in sparse archive member"), \
- file->stat_info->orig_file_name)); \
+ paxerror (0, _("%s: numeric overflow in sparse archive member"), \
+ file->stat_info->orig_file_name); \
return false; \
} \
if (src == endp) \
set_next_block_after (b); \
b = find_next_block (); \
if (!b) \
- FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
+ paxfatal (0, _("Unexpected EOF in archive")); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
set_next_block_after (current_header);
blk = find_next_block ();
if (!blk)
- FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxfatal (0, _("Unexpected EOF in archive"));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, SIZE_MAX))
{
- ERROR ((0, 0, _("%s: malformed sparse archive member"),
- file->stat_info->orig_file_name));
+ paxerror (0, _("%s: malformed sparse archive member"),
+ file->stat_info->orig_file_name);
return false;
}
file->stat_info->sparse_map_size = u;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t)))
{
- ERROR ((0, 0, _("%s: malformed sparse archive member"),
- file->stat_info->orig_file_name));
+ paxerror (0, _("%s: malformed sparse archive member"),
+ file->stat_info->orig_file_name);
return false;
}
sp.offset = u;
|| ckd_add (&size, sp.offset, u)
|| file->stat_info->stat.st_size < size)
{
- ERROR ((0, 0, _("%s: malformed sparse archive member"),
- file->stat_info->orig_file_name));
+ paxerror (0, _("%s: malformed sparse archive member"),
+ file->stat_info->orig_file_name);
return false;
}
sp.numbytes = u;
{
use_compress_program_option = defprog;
if (len > 0 && verbose)
- WARN ((0, 0,
- _("no compression program is defined for suffix '%s';"
- " assuming %s"),
- name + len,
- defprog ? defprog : "uncompressed archive"));
+ paxwarn (0,
+ _("no compression program is defined for suffix '%s';"
+ " assuming %s"),
+ name + len,
+ defprog ? defprog : "uncompressed archive");
}
}
void
sys_child_open_for_compress (void)
{
- FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives")));
+ paxfatal (0, _("Cannot use compressed or remote archives"));
}
/* Set ARCHIVE for uncompressing, then reading an archive. */
void
sys_child_open_for_uncompress (void)
{
- FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives")));
+ paxfatal (0, _("Cannot use compressed or remote archives"));
}
int
const char *fmt,
struct timespec *ts)
{
- FATAL_ERROR ((0, 0, _("--set-mtime-command not implemented on this platform")));
+ paxfatal (0, _("--set-mtime-command not implemented on this platform"));
}
#else
{
int sig = WTERMSIG (wait_status);
if (!(!eof && sig == SIGPIPE))
- FATAL_ERROR ((0, 0, _("Child died with signal %d"), sig));
+ paxfatal (0, _("Child died with signal %d"), sig);
}
else if (WEXITSTATUS (wait_status) != 0)
- FATAL_ERROR ((0, 0, _("Child returned status %d"),
- WEXITSTATUS (wait_status)));
+ paxfatal (0, _("Child returned status %d"),
+ WEXITSTATUS (wait_status));
}
}
if (from != into)
{
if (dup2 (from, into) < 0)
- {
- int e = errno;
- FATAL_ERROR ((0, e, _("Cannot dup2")));
- }
+ paxfatal (errno, _("Cannot dup2"));
xclose (from);
}
}
{
if (prog)
{
- WARNOPT (WARN_DECOMPRESS_PROGRAM,
- (0, errno, _("cannot run %s"), prog));
- WARNOPT (WARN_DECOMPRESS_PROGRAM,
- (0, 0, _("trying %s"), p));
+ warnopt (WARN_DECOMPRESS_PROGRAM, errno, _("cannot run %s"), prog);
+ warnopt (WARN_DECOMPRESS_PROGRAM, 0, _("trying %s"), p);
}
if (wordsplit (p, &ws, wsflags))
- FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
- p, wordsplit_strerror (&ws)));
+ paxfatal (0, _("cannot split string '%s': %s"),
+ p, wordsplit_strerror (&ws));
wsflags |= WRDSF_REUSE;
memmove (ws.ws_wordv, ws.ws_wordv + ws.ws_offs,
ws.ws_wordc * sizeof *ws.ws_wordv);
ws.ws_wordv[ws.ws_wordc] = NULL;
}
if (!prog)
- FATAL_ERROR ((0, 0, _("unable to run decompression program")));
+ paxfatal (0, _("unable to run decompression program"));
exec_fatal (prog);
}
if (WIFEXITED (status))
{
if (!ignore_command_error_option && WEXITSTATUS (status))
- ERROR ((0, 0, _("%jd: Child returned status %d"),
- intmax (global_pid), WEXITSTATUS (status)));
+ paxerror (0, _("%jd: Child returned status %d"),
+ intmax (global_pid), WEXITSTATUS (status));
}
else if (WIFSIGNALED (status))
{
- WARN ((0, 0, _("%jd: Child terminated on signal %d"),
- intmax (global_pid), WTERMSIG (status)));
+ paxwarn (0, _("%jd: Child terminated on signal %d"),
+ intmax (global_pid), WTERMSIG (status));
}
else
- ERROR ((0, 0, _("%jd: Child terminated on unknown reason"),
- intmax (global_pid)));
+ paxerror (0, _("%jd: Child terminated on unknown reason"),
+ intmax (global_pid));
global_pid = -1;
}
int rc = 0;
if (pipe (p))
- FATAL_ERROR ((0, errno, _("pipe failed")));
+ paxfatal (errno, _("pipe failed"));
if ((pid = xfork ()) == 0)
{
if (dirfd != AT_FDCWD)
{
if (fchdir (dirfd))
- FATAL_ERROR ((0, errno, _("chdir failed")));
+ paxfatal (errno, _("chdir failed"));
}
close (p[0]);
if (dup2 (p[1], STDOUT_FILENO) < 0)
- FATAL_ERROR ((0, errno, _("dup2 failed")));
+ paxfatal (errno, _("dup2 failed"));
if (p[1] != STDOUT_FILENO)
close (p[1]);
{
if (errno != EINTR)
{
- ERROR ((0, errno, _("poll failed")));
+ paxerror (errno, _("poll failed"));
stop = 1;
break;
}
ssize_t nread = read (pfd.fd, buffer + buflen, bufsize - buflen);
if (nread < 0)
{
- ERROR ((0, errno, _("error reading output of %s"), script_name));
+ paxerror (errno, _("error reading output of %s"), script_name);
stop = 1;
break;
}
if (buflen == 0)
{
- ERROR ((0, 0, _("empty output from \"%s %s\""), script_name, file_name));
+ paxerror (0, _("empty output from \"%s %s\""), script_name, file_name);
return -1;
}
cp = strptime (buffer, fmt, &tm);
if (cp == NULL)
{
- ERROR ((0, 0, _("output from \"%s %s\" does not satisfy format string: %s"),
- script_name, file_name, buffer));
+ paxerror (0, _("output from \"%s %s\" does not satisfy format string:"
+ " %s"),
+ script_name, file_name, buffer);
rc = -1;
}
else if (*cp != 0)
{
- WARN ((0, 0, _("unconsumed output from \"%s %s\": %s"),
- script_name, file_name, cp));
+ paxwarn (0, _("unconsumed output from \"%s %s\": %s"),
+ script_name, file_name, cp);
rc = -1;
}
else
t = mktime (&tm);
if (tm.tm_wday < 0)
{
- ERROR ((0, errno, _("mktime failed")));
+ paxerror (errno, _("mktime failed"));
rc = -1;
}
else
}
else if (! parse_datetime (ts, buffer, NULL))
{
- ERROR ((0, 0, _("unparsable output from \"%s %s\": %s"),
- script_name, file_name, buffer));
+ paxerror (0, _("unparsable output from \"%s %s\": %s"),
+ script_name, file_name, buffer);
rc = -1;
}
request_stdin (const char *option)
{
if (stdin_used_by)
- USAGE_ERROR ((0, 0, _("Options '%s' and '%s' both want standard input"),
- stdin_used_by, option));
+ paxusage (_("Options '%s' and '%s' both want standard input"),
+ stdin_used_by, option);
stdin_used_by = option;
}
for (p = fmttab; strcmp (p->name, name) != 0; )
if (! (++p)->name)
- USAGE_ERROR ((0, 0, _("%s: Invalid archive format"),
- quotearg_colon (name)));
+ paxusage (_("%s: Invalid archive format"),
+ quotearg_colon (name));
archive_format = p->fmt;
}
assert_format (int fmt_mask)
{
if ((FORMAT_MASK (archive_format) & fmt_mask) == 0)
- USAGE_ERROR ((0, 0,
- _("GNU features wanted on incompatible archive format")));
+ paxusage (_("GNU features wanted on incompatible archive format"));
}
const char *
set_quoting_style (NULL, i);
return;
}
- FATAL_ERROR ((0, 0,
- _("Unknown quoting style '%s'. Try '%s --quoting-style=help' to get a list."), arg, program_name));
+ paxfatal (0,
+ _("Unknown quoting style '%s'."
+ " Try '%s --quoting-style=help' to get a list."),
+ arg, program_name);
}
\f
va_end (args);
if (!result)
- FATAL_ERROR ((0, err, "vasprintf"));
+ paxfatal (err, "vasprintf");
return result;
}
{
/* TRANSLATORS: Both %s in this statement are replaced with
option names. */
- USAGE_ERROR ((0, 0, _("'%s' cannot be used with '%s'"), a, b));
+ paxusage (_("'%s' cannot be used with '%s'"), a, b);
}
\f
/* Classes of options that can conflict: */
{
if (subcommand_option != UNKNOWN_SUBCOMMAND
&& subcommand_option != subcommand)
- USAGE_ERROR ((0, 0,
- _("You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option")));
+ paxusage (_("You may not specify more than one '-Acdtrux',"
+ " '--delete' or '--test-label' option"));
subcommand_option = subcommand;
}
if (use_compress_program_option
&& strcmp (use_compress_program_option, string) != 0
&& p->source == OPTS_COMMAND_LINE)
- USAGE_ERROR ((0, 0, _("Conflicting compression options")));
+ paxusage (_("Conflicting compression options"));
use_compress_program_option = string;
}
for (p = sigtab; p < sigtab + sizeof (sigtab) / sizeof (sigtab[0]); p++)
if (strcmp (p->name, s) == 0)
return p->signo;
- FATAL_ERROR ((0, 0, _("Unknown signal name: %s"), name));
+ paxfatal (0, _("Unknown signal name: %s"), name);
}
static void
if (stat (str, &st) != 0)
{
stat_error (str);
- USAGE_ERROR ((0, 0, _("Date sample file not found")));
+ paxusage (_("Date sample file not found"));
}
*ts = get_stat_mtime (&st);
}
{
if (! parse_datetime (ts, str, NULL))
{
- WARN ((0, 0, _("Substituting %s for unknown date format %s"),
- tartime (*ts, false), quote (str)));
+ paxwarn (0, _("Substituting %s for unknown date format %s"),
+ tartime (*ts, false), quote (str));
ts->tv_nsec = 0;
return 1;
}
{
char const *treated_as = tartime (p->ts, true);
if (strcmp (p->date, treated_as) != 0)
- WARN ((0, 0, _("Option %s: Treating date '%s' as %s"),
- p->option, p->date, treated_as));
+ paxwarn (0, _("Option %s: Treating date '%s' as %s"),
+ p->option, p->date, treated_as);
}
free (p->date);
free (p);
char *end;
uintmax_t u = stoint (num, &end, &overflow, 0, field_max);
if ((end == num) | *end | overflow)
- FATAL_ERROR ((0, 0, "%s: %s", quotearg_colon (num),
- _("Invalid owner or group ID")));
+ paxfatal (0, "%s: %s", quotearg_colon (num),
+ _("Invalid owner or group ID"));
if (name_option)
*name_option = name;
return u;
(min (IDX_MAX, min (SSIZE_MAX, SIZE_MAX))
/ BLOCKSIZE));
if ((end == arg) | *end | overflow | !blocking_factor)
- USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
- _("Invalid blocking factor")));
+ paxusage ("%s: %s", quotearg_colon (arg),
+ _("Invalid blocking factor"));
record_size = blocking_factor * BLOCKSIZE;
}
break;
break;
default:
- USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
- _("Invalid tape length")));
+ paxusage ("%s: %s", quotearg_colon (arg),
+ _("Invalid tape length"));
}
multi_volume_option = true;
char *end;
incremental_level = stoint (arg, &end, NULL, 0, 1);
if ((end == arg) | *end)
- USAGE_ERROR ((0, 0, _("Invalid incremental level value")));
+ paxusage (_("Invalid incremental level value"));
}
break;
FALLTHROUGH;
case NEWER_MTIME_OPTION:
if (TIME_OPTION_INITIALIZED (newer_mtime_option))
- USAGE_ERROR ((0, 0, _("More than one threshold date")));
+ paxusage (_("More than one threshold date"));
get_date_or_file (args,
key == NEWER_MTIME_OPTION ? "--newer-mtime"
: "--after-date", arg, &newer_mtime_option);
if ((p != arg) & (*p == '.'))
tar_sparse_minor = stoint (p + 1, &p, &vminor, 0, INTMAX_MAX);
if ((p == arg) | *p | vmajor | vminor)
- USAGE_ERROR ((0, 0, _("Invalid sparse version value")));
+ paxusage (_("Invalid sparse version value"));
}
break;
atime_preserve_args, atime_preserve_types)
: replace_atime_preserve);
if (! O_NOATIME && atime_preserve_option == system_atime_preserve)
- FATAL_ERROR ((0, 0,
- _("--atime-preserve='system' is not supported"
- " on this platform")));
+ paxfatal (0, _("--atime-preserve='system' is not supported"
+ " on this platform"));
break;
case CHECK_DEVICE_OPTION:
}
checkpoint_option = stoint (arg, &p, NULL, 0, INTMAX_MAX);
if (*p | (checkpoint_option <= 0))
- FATAL_ERROR ((0, 0,
- _("invalid --checkpoint value")));
+ paxfatal (0, _("invalid --checkpoint value"));
}
else
checkpoint_option = DEFAULT_CHECKPOINT;
case MODE_OPTION:
mode_option = mode_compile (arg);
if (!mode_option)
- FATAL_ERROR ((0, 0, _("Invalid mode given on option")));
+ paxfatal (0, _("Invalid mode given on option"));
initial_umask = umask (0);
umask (initial_umask);
break;
char *end;
occurrence_option = stoint (arg, &end, NULL, 0, UINTMAX_MAX);
if (*end)
- FATAL_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
- _("Invalid number")));
+ paxfatal (0, "%s: %s", quotearg_colon (arg), _("Invalid number"));
}
break;
if (! (xstrtoumax (arg, NULL, 10, &u, TAR_SIZE_SUFFIXES) == LONGINT_OK
&& !ckd_add (&record_size, u, 0)
&& record_size <= min (SSIZE_MAX, SIZE_MAX)))
- USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
- _("Invalid record size")));
+ paxusage ("%s: %s", quotearg_colon (arg), _("Invalid record size"));
if (record_size % BLOCKSIZE != 0)
- USAGE_ERROR ((0, 0, _("Record size must be a multiple of %d."),
- BLOCKSIZE));
+ paxusage (_("Record size must be a multiple of %d."), BLOCKSIZE);
blocking_factor = record_size / BLOCKSIZE;
}
break;
char *end;
strip_name_components = stoint (arg, &end, NULL, 0, SIZE_MAX);
if (*end)
- USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
- _("Invalid number of elements")));
+ paxusage ("%s: %s", quotearg_colon (arg),
+ _("Invalid number of elements"));
}
break;
case TO_COMMAND_OPTION:
if (to_command_option)
- USAGE_ERROR ((0, 0, _("Only one --to-command option allowed")));
+ paxusage (_("Only one --to-command option allowed"));
to_command_option = arg;
break;
ws.ws_offs = 1;
if (wordsplit (opts, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS))
- FATAL_ERROR ((0, 0, _("cannot split TAR_OPTIONS: %s"),
- wordsplit_strerror (&ws)));
+ paxfatal (0, _("cannot split TAR_OPTIONS: %s"), wordsplit_strerror (&ws));
if (ws.ws_wordc)
{
int idx;
args->loc = &loc;
int argc;
if (ckd_add (&argc, ws.ws_offs, ws.ws_wordc))
- FATAL_ERROR ((0, 0, "too many options"));
+ paxfatal (0, _("too many options"));
if (argp_parse (&argp, argc, ws.ws_wordv,
ARGP_IN_ORDER | ARGP_NO_EXIT, &idx, args))
abort (); /* shouldn't happen */
args->loc = save_loc_ptr;
if (name_more_files ())
- USAGE_ERROR ((0, 0, _("non-option arguments in %s"), loc.name));
+ paxusage (_("non-option arguments in %s"), loc.name);
/* Don't free consumed words */
ws.ws_wordc = 0;
}
opt = find_argp_option (&argp, *letter);
if (opt && opt->arg)
{
- if (in < argv + argc)
- *out++ = *in++;
- else
- USAGE_ERROR ((0, 0, _("Old option '%c' requires an argument."),
- *letter));
+ if (! (in < argv + argc))
+ paxusage (_("Old option '%c' requires an argument."), *letter);
+ *out++ = *in++;
}
}
if (occurrence_option)
{
if (!name_more_files ())
- USAGE_ERROR ((0, 0,
- _("--occurrence is meaningless without a file list")));
+ paxusage (_("--occurrence is meaningless without a file list"));
if (!IS_SUBCOMMAND_CLASS (SUBCL_OCCUR))
{
if (option_set_in_cl (OC_OCCURRENCE))
/* Allow multiple archives only with '-M'. */
if (archive_names > 1 && !multi_volume_option)
- USAGE_ERROR ((0, 0,
- _("Multiple archive files require '-M' option")));
+ paxusage (_("Multiple archive files require '-M' option"));
if (listed_incremental_option
&& TIME_OPTION_INITIALIZED (newer_mtime_option))
}
if (0 <= incremental_level && !listed_incremental_option)
- WARN ((0, 0,
- _("--level is meaningless without --listed-incremental")));
+ paxwarn (0, _("--level is meaningless without --listed-incremental"));
if (volume_label_option)
{
- 1 /* for sign, as 0 <= volno */)
: 0));
if (volume_label_max_len < strlen (volume_label_option))
- USAGE_ERROR ((0, 0,
- _("%s: Volume label length exceeds %d bytes"),
- quotearg_colon (volume_label_option),
- volume_label_max_len));
+ paxusage (_("%s: Volume label length exceeds %d bytes"),
+ quotearg_colon (volume_label_option),
+ volume_label_max_len);
}
/* else FIXME
Label length in PAX format is limited by the volume size. */
if (verify_option)
{
if (multi_volume_option)
- USAGE_ERROR ((0, 0, _("Cannot verify multi-volume archives")));
+ paxusage (_("Cannot verify multi-volume archives"));
if (use_compress_program_option)
- USAGE_ERROR ((0, 0, _("Cannot verify compressed archives")));
+ paxusage (_("Cannot verify compressed archives"));
if (!IS_SUBCOMMAND_CLASS (SUBCL_WRITE))
{
if (option_set_in_cl (OC_VERIFY))
if (use_compress_program_option)
{
if (multi_volume_option)
- USAGE_ERROR ((0, 0, _("Cannot use multi-volume compressed archives")));
+ paxusage (_("Cannot use multi-volume compressed archives"));
if (IS_SUBCOMMAND_CLASS (SUBCL_UPDATE))
- USAGE_ERROR ((0, 0, _("Cannot update compressed archives")));
+ paxusage (_("Cannot update compressed archives"));
if (subcommand_option == CAT_SUBCOMMAND)
- USAGE_ERROR ((0, 0, _("Cannot concatenate compressed archives")));
+ paxusage (_("Cannot concatenate compressed archives"));
}
if (set_mtime_command)
{
if (set_mtime_option != USE_FILE_MTIME)
- {
- USAGE_ERROR ((0, 0,
- _("--mtime conflicts with --set-mtime-command")));
- }
+ paxusage (_("--mtime conflicts with --set-mtime-command"));
set_mtime_option = COMMAND_MTIME;
}
else if (set_mtime_option == CLAMP_MTIME)
{
if (!TIME_OPTION_INITIALIZED (mtime_option))
- USAGE_ERROR ((0, 0,
- _("--clamp-mtime needs a date specified using --mtime")));
+ paxusage (_("--clamp-mtime needs a date specified using --mtime"));
}
/* It is no harm to use --pax-option on non-pax archives in archive
if (args.pax_option
&& archive_format != POSIX_FORMAT
&& !IS_SUBCOMMAND_CLASS (SUBCL_READ))
- USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives")));
+ paxusage (_("--pax-option can be used only on POSIX archives"));
/* star creates non-POSIX typed archives with xattr support, so allow the
extra headers when reading */
if ((acls_option > 0)
&& archive_format != POSIX_FORMAT
&& !IS_SUBCOMMAND_CLASS (SUBCL_READ))
- USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives")));
+ paxusage (_("--acls can be used only on POSIX archives"));
if ((selinux_context_option > 0)
&& archive_format != POSIX_FORMAT
&& !IS_SUBCOMMAND_CLASS (SUBCL_READ))
- USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives")));
+ paxusage (_("--selinux can be used only on POSIX archives"));
if ((xattrs_option > 0)
&& archive_format != POSIX_FORMAT
&& !IS_SUBCOMMAND_CLASS (SUBCL_READ))
- USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives")));
+ paxusage (_("--xattrs can be used only on POSIX archives"));
if (starting_file_option && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
{
free (base);
if (!one_top_level_dir)
- USAGE_ERROR ((0, 0,
- _("Cannot deduce top-level directory name; "
- "please set it explicitly with --one-top-level=DIR")));
+ paxusage (_("Cannot deduce top-level directory name; "
+ "please set it explicitly with --one-top-level=DIR"));
}
}
verbose_option = 2;
if (tape_length_option && tape_length_option < record_size)
- USAGE_ERROR ((0, 0, _("Volume length cannot be less than record size")));
+ paxusage (_("Volume length cannot be less than record size"));
if (same_order_option && listed_incremental_option)
{
{
case CREATE_SUBCOMMAND:
if (!name_more_files ())
- USAGE_ERROR ((0, 0,
- _("Cowardly refusing to create an empty archive")));
+ paxusage (_("Cowardly refusing to create an empty archive"));
if (args.compress_autodetect && archive_names
&& strcmp (archive_name_array[0], "-"))
set_compression_program_by_suffix (archive_name_array[0],
archive_name_cursor < archive_name_array + archive_names;
archive_name_cursor++)
if (!strcmp (*archive_name_cursor, "-"))
- USAGE_ERROR ((0, 0,
- _("Options '-Aru' are incompatible with '-f -'")));
+ paxusage (_("Options '-Aru' are incompatible with '-f -'"));
default:
break;
close_stdout_set_file_name (_("stdout"));
/* Make sure we have first three descriptors available */
if (stdopen ())
- FATAL_ERROR ((0, 0, "%s",
- _("failed to assert availability of the standard file descriptors")));
+ paxfatal (0, _("failed to assert availability"
+ " of the standard file descriptors"));
/* Pre-allocate a few structures. */
switch (subcommand_option)
{
case UNKNOWN_SUBCOMMAND:
- USAGE_ERROR ((0, 0,
- _("You must specify one of the '-Acdtrux', '--delete' or '--test-label' options")));
+ paxusage (_("You must specify one of the '-Acdtrux',"
+ " '--delete' or '--test-label' options"));
case CAT_SUBCOMMAND:
case UPDATE_SUBCOMMAND:
break;
}
if (parse_xform_flags (&transform_flags, *expr))
- USAGE_ERROR ((0, 0, _("Unknown transform flag: %c"),
- *expr));
+ paxusage (_("Unknown transform flag: %c"), *expr);
}
return expr;
}
- USAGE_ERROR ((0, 0, _("Invalid transform expression")));
+ paxusage (_("Invalid transform expression"));
}
delim = expr[1];
if (!delim)
- USAGE_ERROR ((0, 0, _("Invalid transform expression")));
+ paxusage (_("Invalid transform expression"));
/* Scan regular expression */
for (i = 2; expr[i] && expr[i] != delim; i++)
i++;
if (expr[i] != delim)
- USAGE_ERROR ((0, 0, _("Invalid transform expression")));
+ paxusage (_("Invalid transform expression"));
/* Scan replacement expression */
for (j = i + 1; expr[j] && expr[j] != delim; j++)
j++;
if (expr[j] != delim)
- USAGE_ERROR ((0, 0, _("Invalid transform expression")));
+ paxusage (_("Invalid transform expression"));
/* Check flags */
tf->transform_type = transform_first;
default:
if (parse_xform_flags (&tf->flags, *p))
- USAGE_ERROR ((0, 0, _("Unknown flag in transform expression: %c"),
- *p));
+ paxusage (_("Unknown flag in transform expression: %c"), *p);
}
if (*p == ';')
{
char errbuf[512];
regerror (rc, &tf->regex, errbuf, sizeof (errbuf));
- USAGE_ERROR ((0, 0, _("Invalid transform expression: %s"), errbuf));
+ paxusage (_("Invalid transform expression: %s"), errbuf);
}
if (str[0] == '^' || (i > 2 && str[i - 3] == '$'))
{
idx_t n = stoint (cur, &cur, NULL, 0, IDX_MAX);
if (tf->regex.re_nsub < n)
- USAGE_ERROR ((0, 0, _("Invalid transform replacement:"
- " back reference out of range")));
+ paxusage (_("Invalid transform replacement:"
+ " back reference out of range"));
add_backref_segment (tf, n);
}
break;
switch (previous_status)
{
case HEADER_STILL_UNREAD:
- WARN ((0, 0, _("This does not look like a tar archive")));
+ paxwarn (0, _("This does not look like a tar archive"));
FALLTHROUGH;
case HEADER_SUCCESS:
case HEADER_ZERO_BLOCK:
- ERROR ((0, 0, _("Skipping to next header")));
+ paxerror (0, _("Skipping to next header"));
FALLTHROUGH;
case HEADER_FAILURE:
break;
else
warning_option |= option;
}
+
+void
+warnopt (int opt, int errnum, char const *format, ...)
+{
+ if (WARNING_ENABLED (opt))
+ {
+ if (error_hook)
+ error_hook ();
+ va_list ap;
+ va_start (ap, format);
+ verror (0, errnum, format, ap);
+ va_end (ap);
+ }
+}
FILE_NAME may already have inherited default acls from parent
directory; clean them up. */
if (acl_delete_def_file_at (chdir_fd, file_name))
- WARNOPT (WARN_XATTR_WRITE,
- (0, errno,
+ warnopt (WARN_XATTR_WRITE, errno,
_("acl_delete_def_file_at: Cannot drop default POSIX ACLs "
"for file '%s'"),
- file_name));
+ file_name);
return;
}
else
if (acl_set_file_at (chdir_fd, file_name, type, acl) < 0)
/* warn even if filesystem does not support acls */
- WARNOPT (WARN_XATTR_WRITE,
- (0, errno,
- _ ("acl_set_file_at: Cannot set POSIX ACLs for file '%s'"),
- file_name));
+ warnopt (WARN_XATTR_WRITE, errno,
+ _ ("acl_set_file_at: Cannot set POSIX ACLs for file '%s'"),
+ file_name);
acl_free (acl);
}
static int warned;
if (!warned)
{
- WARN ((0, 0, _("--numeric-owner is ignored for ACLs: libacl is not available")));
+ paxwarn (0, _("--numeric-owner is ignored for ACLs:"
+ " libacl is not available"));
warned = 1;
}
#endif
#ifndef HAVE_POSIX_ACLS
static int done = 0;
if (!done)
- WARN ((0, 0, _("POSIX ACL support is not available")));
+ paxwarn (0, _("POSIX ACL support is not available"));
done = 1;
#else
int err = file_has_acl_at (parentfd, file_name, &st->stat);
#ifndef HAVE_POSIX_ACLS
static int done = 0;
if (!done)
- WARN ((0, 0, _("POSIX ACL support is not available")));
+ paxwarn (0, _("POSIX ACL support is not available"));
done = 1;
#else
xattrs__acls_set (st, file_name, ACL_TYPE_ACCESS,
#ifndef HAVE_XATTRS
static int done = 0;
if (!done)
- WARN ((0, 0, _("XATTR support is not available")));
+ paxwarn (0, _("XATTR support is not available"));
done = 1;
#else
static size_t xsz = 1024;
}
if (ret < 0)
- WARNOPT (WARN_XATTR_WRITE,
- (0, errno,
- _("%s: Cannot set '%s' extended attribute for file '%s'"),
- sysname, attr, file_name));
+ warnopt (WARN_XATTR_WRITE, errno,
+ _("%s: Cannot set '%s' extended attribute for file '%s'"),
+ sysname, attr, file_name);
}
}
#endif
#if HAVE_SELINUX_SELINUX_H != 1
static int done = 0;
if (!done)
- WARN ((0, 0, _("SELinux support is not available")));
+ paxwarn (0, _("SELinux support is not available"));
done = 1;
#else
int result = (fd
#if HAVE_SELINUX_SELINUX_H != 1
static int done = 0;
if (!done)
- WARN ((0, 0, _("SELinux support is not available")));
+ paxwarn (0, _("SELinux support is not available"));
done = 1;
#else
const char *sysname = "setfilecon";
}
if (ret < 0)
- WARNOPT (WARN_XATTR_WRITE,
- (0, errno,
- _("%s: Cannot set SELinux context for file '%s'"),
- sysname, file_name));
+ warnopt (WARN_XATTR_WRITE, errno,
+ _("%s: Cannot set SELinux context for file '%s'"),
+ sysname, file_name);
#endif
}
}
#ifndef HAVE_XATTRS
static int done = 0;
if (!done)
- WARN ((0, 0, _("XATTR support is not available")));
+ paxwarn (0, _("XATTR support is not available"));
done = 1;
#else
size_t i;
static _Noreturn void
xheader_set_single_keyword (char *kw)
{
- USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet implemented"), kw));
+ paxusage (_("Keyword %s is unknown or not yet implemented"), kw);
}
static void
char *p;
struct timespec t = decode_timespec (input, &p, false);
if (! valid_timespec (t) || *p)
- ERROR ((0, 0, _("Time stamp is out of allowed range")));
+ paxerror (0, _("Time stamp is out of allowed range"));
else
{
*tval = t.tv_sec;
char *p = eq;
if (eq == kw)
- USAGE_ERROR ((0, 0, _("Malformed pax option: %s"), quote (kw)));
+ paxusage (_("Malformed pax option: %s"), quote (kw));
if (eq[-1] == ':')
{
if (strcmp (kw, "delete") == 0)
{
if (xheader_protected_pattern_p (p))
- USAGE_ERROR ((0, 0, _("Pattern %s cannot be used"), quote (p)));
+ paxusage (_("Pattern %s cannot be used"), quote (p));
xheader_list_append (&keyword_pattern_list, p, NULL);
}
else if (strcmp (kw, "exthdr.name") == 0)
else
{
if (xheader_protected_keyword_p (kw))
- USAGE_ERROR ((0, 0, _("Keyword %s cannot be overridden"), kw));
+ paxusage (_("Keyword %s cannot be overridden"), kw);
if (global)
xheader_list_append (&keyword_global_override_list, kw, p);
else
xheader_forbid_global (void)
{
if (keyword_global_override_list)
- USAGE_ERROR ((0, 0, _("can't update global extended header record")));
+ paxusage (_("can't update global extended header record"));
}
/* This is reversal function for xattr_encode_keyword. See comment for
/* The length is missing.
FIXME: Comment why this is diagnosed only if (*p), or change code. */
if (*p)
- ERROR ((0, 0, _("Malformed extended header: missing length")));
+ paxerror (0, _("Malformed extended header: missing length"));
return false;
}
/* Avoid giant diagnostics, as this won't help user. */
int len_len = min (len_lim - p, 1000);
- ERROR ((0, 0, _("Extended header length %.*s is out of range"),
- len_len, p));
+ paxerror (0, _("Extended header length %.*s is out of range"),
+ len_len, p);
return false;
}
continue;
if (p == len_lim)
{
- ERROR ((0, 0,
- _("Malformed extended header: missing blank after length")));
+ paxerror (0, _("Malformed extended header: missing blank after length"));
return false;
}
p = strchr (p, '=');
if (! (p && p < nextp))
{
- ERROR ((0, 0, _("Malformed extended header: missing equal sign")));
+ paxerror (0, _("Malformed extended header: missing equal sign"));
return false;
}
if (nextp[-1] != '\n')
{
- ERROR ((0, 0, _("Malformed extended header: missing newline")));
+ paxerror (0, _("Malformed extended header: missing newline"));
return false;
}
if (t)
t->decoder (st, keyword, value, size);
else
- WARNOPT (WARN_UNKNOWN_KEYWORD,
- (0, 0, _("Ignoring unknown extended header keyword %s"),
- quotearg_style (shell_escape_always_quoting_style, keyword)));
+ warnopt (WARN_UNKNOWN_KEYWORD, 0,
+ _("Ignoring unknown extended header keyword %s"),
+ quotearg_style (shell_escape_always_quoting_style, keyword));
}
void
len = BLOCKSIZE;
if (!p)
- FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
+ paxfatal (0, _("Unexpected EOF in archive"));
memcpy (&xhdr->buffer[j], p->buffer, len);
set_next_block_after (p);
size = p;
if (size != p)
{
- ERROR ((0, 0,
- _("Generated keyword/value pair is too long (keyword=%s, length=%s)"),
- keyword, nbuf));
+ paxerror (0,
+ _("Generated keyword/value pair is too long"
+ " (keyword=%s, length=%s)"),
+ keyword, nbuf);
obstack_free (xhdr->stk, obstack_finish (xhdr->stk));
return false;
}
{
/* TRANSLATORS: The first %s is the pax extended header keyword
(atime, gid, etc.). */
- ERROR ((0, 0, _("Extended header %s=%s is out of range %jd..%ju"),
- keyword, value, minval, maxval));
+ paxerror (0, _("Extended header %s=%s is out of range %jd..%ju"),
+ keyword, value, minval, maxval);
}
static void
out_of_range_header (keyword, arg, TYPE_MINIMUM (time_t),
TYPE_MAXIMUM (time_t));
else
- ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: invalid %s=%s"),
+ keyword, arg);
return false;
}
if (*arg_lim)
{
- ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: invalid %s=%s"),
+ keyword, arg);
return false;
}
if ((arg_lim == arg) | *arg_lim)
{
- ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: invalid %s=%s"),
+ keyword, arg);
return false;
}
if (st->sparse_map_avail < st->sparse_map_size)
st->sparse_map[st->sparse_map_avail].offset = u;
else
- ERROR ((0, 0, _("Malformed extended header: excess %s=%s"),
- "GNU.sparse.offset", arg));
+ paxerror (0, _("Malformed extended header: excess %s=%s"),
+ "GNU.sparse.offset", arg);
}
}
if (st->sparse_map_avail < st->sparse_map_size)
st->sparse_map[st->sparse_map_avail++].numbytes = u;
else
- ERROR ((0, 0, _("Malformed extended header: excess %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: excess %s=%s"),
+ keyword, arg);
}
}
off_t u = stoint (arg, &delim, &overflow, 0, TYPE_MAXIMUM (off_t));
if (delim == arg)
{
- ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: invalid %s=%s"),
+ keyword, arg);
return;
}
st->sparse_map[st->sparse_map_avail++] = e;
else
{
- ERROR ((0, 0, _("Malformed extended header: excess %s=%s"),
- keyword, arg));
+ paxerror (0, _("Malformed extended header: excess %s=%s"),
+ keyword, arg);
return;
}
}
break;
else if (*delim != ',')
{
- ERROR ((0, 0,
- _("Malformed extended header: invalid %s: unexpected delimiter %c"),
- keyword, *delim));
+ paxerror (0,
+ _("Malformed extended header: invalid %s:"
+ " unexpected delimiter %c"),
+ keyword, *delim);
return;
}
}
if (!offset)
- ERROR ((0, 0,
- _("Malformed extended header: invalid %s: odd number of values"),
- keyword));
+ paxerror (0,
+ _("Malformed extended header: invalid %s:"
+ " odd number of values"),
+ keyword);
}
static void