1/* This file is part of GNU paxutils 2 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 4 2005 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 2, 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 53extern int exit_status; 54 55void pax_decode_mode (mode_t mode, char *string); 56void call_arg_error (char const *call, char const *name); 57void call_arg_fatal (char const *call, char const *name) __attribute__ ((noreturn)); 58void call_arg_warn (char const *call, char const *name); 59void chmod_error_details (char const *name, mode_t mode); 60void chown_error_details (char const *name, uid_t uid, gid_t gid); 61 62void decode_mode (mode_t, char *); 63 64void chdir_fatal (char const *) __attribute__ ((noreturn)); 65void chmod_error_details (char const *, mode_t); 66void chown_error_details (char const *, uid_t, gid_t); 67void close_error (char const *); 68void close_warn (char const *); 69void exec_fatal (char const *) __attribute__ ((noreturn)); 70void link_error (char const *, char const *); 71void mkdir_error (char const *); 72void mkfifo_error (char const *); 73void mknod_error (char const *); 74void open_error (char const *); 75void open_fatal (char const *) __attribute__ ((noreturn)); 76void open_warn (char const *); 77void read_error (char const *); 78void read_error_details (char const *, off_t, size_t); 79void read_fatal (char const *) __attribute__ ((noreturn)); 80void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn)); 81void read_warn_details (char const *, off_t, size_t); 82void readlink_error (char const *); 83void readlink_warn (char const *); 84void rmdir_error (char const *); 85void savedir_error (char const *); 86void savedir_warn (char const *); 87void seek_error (char const *); 88void seek_error_details (char const *, off_t); 89void seek_warn (char const *); 90void seek_warn_details (char const *, off_t); 91void stat_fatal (char const *); 92void stat_error (char const *); 93void stat_warn (char const *); 94void symlink_error (char const *, char const *); 95void truncate_error (char const *); 96void truncate_warn (char const *); 97void unlink_error (char const *); 98void utime_error (char const *); 99void waitpid_error (char const *); 100void write_error (char const *); 101 102void pax_exit (void); 103void fatal_exit (void) __attribute__ ((noreturn)); 104 105#define STRINGIFY_BIGINT(i, b) umaxtostr (i, b) 106 107 108/* Name-related functions */ 109bool hash_string_insert (Hash_table **table, char const *string); 110bool hash_string_lookup (Hash_table const *table, char const *string); 111 112bool removed_prefixes_p (void); 113char *safer_name_suffix (char const *file_name, bool link_target, bool absolute_names); 114 115#endif 116