1 /* This file is part of GNU paxutils
3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003,
4 2005, 2007 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 /* Error reporting functions and definitions */
28 /* Exit status for paxutils app. Let's try to keep this list as simple as
29 possible. tar -d option strongly invites a status different for unequal
30 comparison and other errors. */
31 #define PAXEXIT_SUCCESS 0
32 #define PAXEXIT_DIFFERS 1
33 #define PAXEXIT_FAILURE 2
35 extern void (*error_hook) (void);
37 /* Both WARN and ERROR write a message on stderr and continue processing,
38 however ERROR manages so tar will exit unsuccessfully. FATAL_ERROR
39 writes a message on stderr and aborts immediately, with another message
40 line telling so. USAGE_ERROR works like FATAL_ERROR except that the
41 other message line suggests trying --help. All four macros accept a
42 single argument of the form ((0, errno, _("FORMAT"), Args...)). errno
43 is zero when the error is not being detected by the system. */
46 do { if (error_hook) error_hook (); error Args; } while (0)
50 if (error_hook) error_hook (); \
52 exit_status = PAXEXIT_FAILURE; \
55 #define FATAL_ERROR(Args) \
58 if (error_hook) error_hook (); \
63 #define USAGE_ERROR(Args) \
66 if (error_hook) error_hook (); \
68 usage (PAXEXIT_FAILURE); \
72 extern int exit_status;
74 void pax_decode_mode (mode_t mode, char *string);
75 void call_arg_error (char const *call, char const *name);
76 void call_arg_fatal (char const *call, char const *name) __attribute__ ((noreturn));
77 void call_arg_warn (char const *call, char const *name);
78 void chmod_error_details (char const *name, mode_t mode);
79 void chown_error_details (char const *name, uid_t uid, gid_t gid);
81 void decode_mode (mode_t, char *);
83 void chdir_fatal (char const *) __attribute__ ((noreturn));
84 void chmod_error_details (char const *, mode_t);
85 void chown_error_details (char const *, uid_t, gid_t);
86 void close_error (char const *);
87 void close_warn (char const *);
88 void exec_fatal (char const *) __attribute__ ((noreturn));
89 void link_error (char const *, char const *);
90 void mkdir_error (char const *);
91 void mkfifo_error (char const *);
92 void mknod_error (char const *);
93 void open_error (char const *);
94 void open_fatal (char const *) __attribute__ ((noreturn));
95 void open_warn (char const *);
96 void read_error (char const *);
97 void read_error_details (char const *, off_t, size_t);
98 void read_fatal (char const *) __attribute__ ((noreturn));
99 void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn));
100 void read_warn_details (char const *, off_t, size_t);
101 void readlink_error (char const *);
102 void readlink_warn (char const *);
103 void rmdir_error (char const *);
104 void savedir_error (char const *);
105 void savedir_warn (char const *);
106 void seek_error (char const *);
107 void seek_error_details (char const *, off_t);
108 void seek_warn (char const *);
109 void seek_warn_details (char const *, off_t);
110 void stat_fatal (char const *) __attribute__ ((noreturn));
111 void stat_error (char const *);
112 void stat_warn (char const *);
113 void symlink_error (char const *, char const *);
114 void truncate_error (char const *);
115 void truncate_warn (char const *);
116 void unlink_error (char const *);
117 void utime_error (char const *);
118 void waitpid_error (char const *);
119 void write_error (char const *);
120 void write_error_details (char const *, size_t, size_t);
122 void pax_exit (void) __attribute__ ((noreturn));
123 void fatal_exit (void) __attribute__ ((noreturn));
125 #define STRINGIFY_BIGINT(i, b) umaxtostr (i, b)
128 /* Name-related functions */
129 bool removed_prefixes_p (void);
130 char *safer_name_suffix (char const *file_name, bool link_target, bool absolute_names);