]> git.cworth.org Git - tar/blob - lib/paxlib.h
upstream: Fix extraction of device nodes.
[tar] / lib / paxlib.h
1 /* This file is part of GNU paxutils
2
3    Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003,
4    2005, 2007 Free Software Foundation, Inc.
5
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)
9    any later version.
10
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.
15
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.
19 */
20
21 #ifndef _paxlib_h_
22 #define _paxlib_h_
23
24 #include <hash.h>
25 #include <inttostr.h>
26
27 /* Error reporting functions and definitions */
28
29 /* Exit status for paxutils app.  Let's try to keep this list as simple as
30    possible. tar -d option strongly invites a status different for unequal
31    comparison and other errors.  */
32 #define PAXEXIT_SUCCESS 0
33 #define PAXEXIT_DIFFERS 1
34 #define PAXEXIT_FAILURE 2
35
36 /* Both WARN and ERROR write a message on stderr and continue processing,
37    however ERROR manages so tar will exit unsuccessfully.  FATAL_ERROR
38    writes a message on stderr and aborts immediately, with another message
39    line telling so.  USAGE_ERROR works like FATAL_ERROR except that the
40    other message line suggests trying --help.  All four macros accept a
41    single argument of the form ((0, errno, _("FORMAT"), Args...)).  errno
42    is zero when the error is not being detected by the system.  */
43
44 #define WARN(Args) \
45   error Args
46 #define ERROR(Args) \
47   (error Args, exit_status = PAXEXIT_FAILURE)
48 #define FATAL_ERROR(Args) \
49   (error Args, fatal_exit ())
50 #define USAGE_ERROR(Args) \
51   (error Args, usage (PAXEXIT_FAILURE))
52
53 extern int exit_status;
54
55 void pax_decode_mode (mode_t mode, char *string);
56 void call_arg_error (char const *call, char const *name);
57 void call_arg_fatal (char const *call, char const *name) __attribute__ ((noreturn));
58 void call_arg_warn (char const *call, char const *name);
59 void chmod_error_details (char const *name, mode_t mode);
60 void chown_error_details (char const *name, uid_t uid, gid_t gid);
61
62 void decode_mode (mode_t, char *);
63
64 void chdir_fatal (char const *) __attribute__ ((noreturn));
65 void chmod_error_details (char const *, mode_t);
66 void chown_error_details (char const *, uid_t, gid_t);
67 void close_error (char const *);
68 void close_warn (char const *);
69 void exec_fatal (char const *) __attribute__ ((noreturn));
70 void link_error (char const *, char const *);
71 void mkdir_error (char const *);
72 void mkfifo_error (char const *);
73 void mknod_error (char const *);
74 void open_error (char const *);
75 void open_fatal (char const *) __attribute__ ((noreturn));
76 void open_warn (char const *);
77 void read_error (char const *);
78 void read_error_details (char const *, off_t, size_t);
79 void read_fatal (char const *) __attribute__ ((noreturn));
80 void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn));
81 void read_warn_details (char const *, off_t, size_t);
82 void readlink_error (char const *);
83 void readlink_warn (char const *);
84 void rmdir_error (char const *);
85 void savedir_error (char const *);
86 void savedir_warn (char const *);
87 void seek_error (char const *);
88 void seek_error_details (char const *, off_t);
89 void seek_warn (char const *);
90 void seek_warn_details (char const *, off_t);
91 void stat_fatal (char const *) __attribute__ ((noreturn));
92 void stat_error (char const *);
93 void stat_warn (char const *);
94 void symlink_error (char const *, char const *);
95 void truncate_error (char const *);
96 void truncate_warn (char const *);
97 void unlink_error (char const *);
98 void utime_error (char const *);
99 void waitpid_error (char const *);
100 void write_error (char const *);
101 void write_error_details (char const *, size_t, size_t);
102
103 void pax_exit (void) __attribute__ ((noreturn));
104 void fatal_exit (void) __attribute__ ((noreturn));
105
106 #define STRINGIFY_BIGINT(i, b) umaxtostr (i, b)
107
108 \f
109 /* Name-related functions */
110 bool hash_string_insert (Hash_table **table, char const *string);
111 bool hash_string_lookup (Hash_table const *table, char const *string);
112
113 bool removed_prefixes_p (void);
114 char *safer_name_suffix (char const *file_name, bool link_target, bool absolute_names);
115
116 #endif