summaryrefslogtreecommitdiffstats
path: root/rc.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-12-08 15:52:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-12-08 15:52:09 +0000
commit4568b11461f80bbc5fa0fb2c522205683ea14ec7 (patch)
tree58834b3aa970b99bc0a1b0fcb9ae5510ca149cb1 /rc.h
parentAdding upstream version 1.12~pre2. (diff)
downloadzutils-4568b11461f80bbc5fa0fb2c522205683ea14ec7.tar.xz
zutils-4568b11461f80bbc5fa0fb2c522205683ea14ec7.zip
Adding upstream version 1.12~rc1.upstream/1.12_rc1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--rc.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/rc.h b/rc.h
index 37f8552..ab71fc9 100644
--- a/rc.h
+++ b/rc.h
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-enum { fmt_bz2, fmt_gz, fmt_lz, fmt_xz, fmt_zst, num_formats }; // format_index
+// format_index; < 0 means undefined, >= num_formats means uncompressed
+enum { fmt_bz2, fmt_gz, fmt_lz, fmt_xz, fmt_zst, num_formats };
+
const char * const format_names[num_formats] =
{ "bz2", "gz", "lz", "xz", "zst" };
const char * const simple_extensions[num_formats] =
@@ -23,15 +25,22 @@ const char * const simple_extensions[num_formats] =
const int format_order[num_formats] =
{ fmt_lz, fmt_bz2, fmt_gz, fmt_zst, fmt_xz }; // search order
-bool enabled_format( const int format_index );
+bool enabled_format( const int format_index ); // -1 == uncompressed
void parse_format_list( const std::string & arg, const char * const pn );
-int parse_format_type( const std::string & arg, const char * const pn );
+// Return num_formats if arg == "un" (uncompressed).
+int parse_format_type( const std::string & arg, const char * const pn,
+ const bool allow_uncompressed = true );
int extension_index( const std::string & name ); // -1 if unknown
int extension_format( const int eindex ); // -1 if uncompressed
const char * extension_from( const int eindex );
const char * extension_to( const int eindex );
+// Return format_index, or -1 if uncompressed.
+//
+inline int test_extension( const std::string & name )
+ { return extension_format( extension_index( name ) ); }
+
extern const char * invocation_name;
extern const char * program_name;
extern int verbosity;
@@ -40,8 +49,8 @@ class Arg_parser;
void maybe_process_config_file( const Arg_parser & parser );
-void parse_compressor( const std::string & arg, const int format_index,
- const int eretval = 2 );
+void parse_compressor( const std::string & arg, const char * const pn,
+ const int format_index, const int eretval = 2 );
const char * get_compressor_name( const int format_index );
const std::vector< std::string > & get_compressor_args( const int format_index );
@@ -53,6 +62,8 @@ void show_error( const char * const msg, const int errcode = 0,
void show_file_error( const char * const filename, const char * const msg,
const int errcode = 0 );
void internal_error( const char * const msg );
+void show_option_error( const char * const arg, const char * const msg,
+ const char * const option_name );
void show_close_error( const char * const prog_name = "data feeder" );
void show_exec_error( const char * const prog_name );
void show_fork_error( const char * const prog_name );