1 /* Zutils - Utilities dealing with compressed files 2 Copyright (C) 2009-2021 Antonio Diaz Diaz. 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 enum { fmt_bz2, fmt_gz, fmt_lz, fmt_xz, num_formats }; // format_index 19 const char * const format_names[num_formats] = { "bz2", "gz", "lz", "xz" }; 20 const char * const simple_extensions[num_formats] = 21 { ".bz2", ".gz", ".lz", ".xz" }; 22 const int format_order[num_formats] = 23 { fmt_lz, fmt_bz2, fmt_gz, fmt_xz }; // search order 24 25 bool enabled_format( const int format_index ); 26 void parse_format_list( const std::string & arg ); 27 int parse_format_type( const std::string & arg ); 28 29 int extension_index( const std::string & name ); // -1 if unknown 30 int extension_format( const int eindex ); // -1 if uncompressed 31 const char * extension_from( const int eindex ); 32 const char * extension_to( const int eindex ); 33 34 extern const char * invocation_name; 35 extern const char * program_name; 36 extern int verbosity; 37 38 class Arg_parser; 39 40 void maybe_process_config_file( const Arg_parser & parser ); 41 42 void parse_compressor( const std::string & arg, const int format_index, 43 const int eretval = 2 ); 44 45 const char * get_compressor_name( const int format_index ); 46 const std::vector< std::string > & get_compressor_args( const int format_index ); 47 48 void show_help_addr(); 49 void show_version(); 50 void show_error( const char * const msg, const int errcode = 0, 51 const bool help = false ); 52 void show_file_error( const char * const filename, const char * const msg, 53 const int errcode = 0 ); 54 void internal_error( const char * const msg ); 55 void show_close_error( const char * const prog_name = "data feeder" ); 56 void show_exec_error( const char * const prog_name ); 57 void show_fork_error( const char * const prog_name ); 58 59 // Returns exit status of child process 'pid', or 'eretval' in case of error. 60 // 61 int wait_for_child( const pid_t pid, const char * const name, 62 const int eretval = 2, const bool isgzxz = false ); 63