cd-info.c: tolerate CDDB options even when we don't support CDDB.
Better error reporting of bad options.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cd-info.c,v 1.114 2005/02/18 01:31:08 rocky Exp $
|
$Id: cd-info.c,v 1.115 2005/02/19 11:43:05 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||||
@@ -75,7 +75,6 @@ struct arguments
|
|||||||
int no_ioctl;
|
int no_ioctl;
|
||||||
int no_analysis;
|
int no_analysis;
|
||||||
char *access_mode; /* Access method driver should use for control */
|
char *access_mode; /* Access method driver should use for control */
|
||||||
#ifdef HAVE_CDDB
|
|
||||||
int no_cddb; /* If set the below are meaningless. */
|
int no_cddb; /* If set the below are meaningless. */
|
||||||
char *cddb_email; /* email to report to CDDB server. */
|
char *cddb_email; /* email to report to CDDB server. */
|
||||||
char *cddb_server; /* CDDB server to contact */
|
char *cddb_server; /* CDDB server to contact */
|
||||||
@@ -84,7 +83,6 @@ struct arguments
|
|||||||
int cddb_timeout;
|
int cddb_timeout;
|
||||||
bool cddb_disable_cache; /* If set the below is meaningless. */
|
bool cddb_disable_cache; /* If set the below is meaningless. */
|
||||||
char *cddb_cachedir;
|
char *cddb_cachedir;
|
||||||
#endif
|
|
||||||
int no_vcd;
|
int no_vcd;
|
||||||
int show_dvd;
|
int show_dvd;
|
||||||
int no_device;
|
int no_device;
|
||||||
@@ -122,7 +120,7 @@ char *temp_str;
|
|||||||
static bool
|
static bool
|
||||||
parse_options (int argc, const char *argv[])
|
parse_options (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
char opt; /* used for argument parsing */
|
||||||
char *psz_my_source;
|
char *psz_my_source;
|
||||||
|
|
||||||
struct poptOption optionsTable[] = {
|
struct poptOption optionsTable[] = {
|
||||||
@@ -162,6 +160,30 @@ parse_options (int argc, const char *argv[])
|
|||||||
|
|
||||||
{"cddb-timeout", '\0', POPT_ARG_INT, &opts.cddb_timeout, 0,
|
{"cddb-timeout", '\0', POPT_ARG_INT, &opts.cddb_timeout, 0,
|
||||||
"CDDB timeout value in seconds (default 10 seconds)"},
|
"CDDB timeout value in seconds (default 10 seconds)"},
|
||||||
|
#else
|
||||||
|
{"no-cddb", '\0', POPT_ARG_NONE, &opts.no_cddb, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-port", 'P', POPT_ARG_INT, &opts.cddb_port, 8880,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-http", 'H', POPT_ARG_NONE, &opts.cddb_http, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-server", '\0', POPT_ARG_STRING, &opts.cddb_server, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-cache", '\0', POPT_ARG_STRING, &opts.cddb_cachedir, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-email", '\0', POPT_ARG_STRING, &opts.cddb_email, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"no-cddb-cache", '\0', POPT_ARG_NONE, &opts.cddb_disable_cache, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
|
|
||||||
|
{"cddb-timeout", '\0', POPT_ARG_INT, &opts.cddb_timeout, 0,
|
||||||
|
"Does nothing since this program is not CDDB-enabled"},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{"no-device-info", '\0', POPT_ARG_NONE, &opts.no_device, 0,
|
{"no-device-info", '\0', POPT_ARG_NONE, &opts.no_device, 0,
|
||||||
@@ -229,7 +251,7 @@ parse_options (int argc, const char *argv[])
|
|||||||
program_name = strrchr(argv[0],'/');
|
program_name = strrchr(argv[0],'/');
|
||||||
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
||||||
|
|
||||||
while ((opt = poptGetNextOpt (optCon)) != -1) {
|
while ((opt = poptGetNextOpt (optCon)) >= 0) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
|
||||||
case OP_SOURCE_AUTO:
|
case OP_SOURCE_AUTO:
|
||||||
@@ -275,12 +297,17 @@ parse_options (int argc, const char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
poptFreeContext(optCon);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (opt < -1) {
|
||||||
|
/* an error occurred during option processing */
|
||||||
|
report(stderr, "%s: %s\n",
|
||||||
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
||||||
|
poptStrerror(opt));
|
||||||
|
free(program_name);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *remaining_arg = poptGetArg(optCon);
|
const char *remaining_arg = poptGetArg(optCon);
|
||||||
if ( remaining_arg != NULL) {
|
if ( remaining_arg != NULL) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cd-read.c,v 1.23 2005/01/09 00:10:49 rocky Exp $
|
$Id: cd-read.c,v 1.24 2005/02/19 11:43:05 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ static bool
|
|||||||
parse_options (int argc, const char *argv[])
|
parse_options (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
int opt;
|
char opt;
|
||||||
char *psz_my_source;
|
char *psz_my_source;
|
||||||
char *opt_arg;
|
char *opt_arg;
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ parse_options (int argc, const char *argv[])
|
|||||||
program_name = strrchr(argv[0],'/');
|
program_name = strrchr(argv[0],'/');
|
||||||
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
||||||
|
|
||||||
while ((opt = poptGetNextOpt (optCon)) != -1)
|
while ((opt = poptGetNextOpt (optCon)) >= 0)
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case OP_SOURCE_AUTO:
|
case OP_SOURCE_AUTO:
|
||||||
@@ -306,17 +306,16 @@ parse_options (int argc, const char *argv[])
|
|||||||
free(program_name);
|
free(program_name);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
report( stderr, "%s: %s\n",
|
|
||||||
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
||||||
poptStrerror(opt) );
|
|
||||||
report( stderr, "error while parsing command line - try --help\n" );
|
|
||||||
poptFreeContext(optCon);
|
|
||||||
free(program_name);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt < -1) {
|
||||||
|
report( stderr, "%s: %s\n",
|
||||||
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
||||||
|
poptStrerror(opt) );
|
||||||
|
free(program_name);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *remaining_arg = poptGetArg(optCon);
|
const char *remaining_arg = poptGetArg(optCon);
|
||||||
if ( remaining_arg != NULL) {
|
if ( remaining_arg != NULL) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso-info.c,v 1.23 2005/02/18 23:25:45 rocky Exp $
|
$Id: iso-info.c,v 1.24 2005/02/19 11:43:05 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -65,6 +65,8 @@ struct arguments
|
|||||||
int silent;
|
int silent;
|
||||||
int no_header;
|
int no_header;
|
||||||
int no_joliet;
|
int no_joliet;
|
||||||
|
int no_xa;
|
||||||
|
int no_rock_ridge;
|
||||||
int print_iso9660;
|
int print_iso9660;
|
||||||
int print_iso9660_short;
|
int print_iso9660_short;
|
||||||
} opts;
|
} opts;
|
||||||
@@ -104,9 +106,15 @@ parse_options (int argc, const char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_JOLIET
|
#ifdef HAVE_JOLIET
|
||||||
{"no-joliet", '\0', POPT_ARG_NONE, &opts.no_joliet,
|
{"no-joliet", '\0', POPT_ARG_NONE, &opts.no_joliet,
|
||||||
0, "Don't use Joliet extensions"},
|
0, "Don't use Joliet-extension information"},
|
||||||
#endif /*HAVE_JOLIET*/
|
#endif /*HAVE_JOLIET*/
|
||||||
|
|
||||||
|
{"no-rock-ridge", '\0', POPT_ARG_NONE, &opts.no_rock_ridge,
|
||||||
|
0, "Don't use Rock-Ridge-extension information"},
|
||||||
|
|
||||||
|
{"no-xa", '\0', POPT_ARG_NONE, &opts.no_xa,
|
||||||
|
0, "Don't use XA-extension information"},
|
||||||
|
|
||||||
{"quiet", 'q', POPT_ARG_NONE, &opts.silent, 0,
|
{"quiet", 'q', POPT_ARG_NONE, &opts.silent, 0,
|
||||||
"Don't produce warning output" },
|
"Don't produce warning output" },
|
||||||
|
|
||||||
@@ -119,12 +127,16 @@ parse_options (int argc, const char *argv[])
|
|||||||
program_name = strrchr(argv[0],'/');
|
program_name = strrchr(argv[0],'/');
|
||||||
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
|
||||||
|
|
||||||
while ((opt = poptGetNextOpt (optCon)) != -1) {
|
while ((opt = poptGetNextOpt (optCon)) >= 0) {
|
||||||
switch (opt) {
|
;
|
||||||
default:
|
}
|
||||||
poptFreeContext(optCon);
|
if (opt < -1) {
|
||||||
return false;
|
/* an error occurred during option processing */
|
||||||
}
|
report(stderr, "%s: %s\n",
|
||||||
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
||||||
|
poptStrerror(opt));
|
||||||
|
free(program_name);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char *remaining_arg = poptGetArg(optCon);
|
const char *remaining_arg = poptGetArg(optCon);
|
||||||
@@ -133,6 +145,7 @@ parse_options (int argc, const char *argv[])
|
|||||||
report( stderr, "%s: Source specified in previously %s and %s\n",
|
report( stderr, "%s: Source specified in previously %s and %s\n",
|
||||||
program_name, source_name, remaining_arg );
|
program_name, source_name, remaining_arg );
|
||||||
poptFreeContext(optCon);
|
poptFreeContext(optCon);
|
||||||
|
free(program_name);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
source_name = strdup(remaining_arg);
|
source_name = strdup(remaining_arg);
|
||||||
@@ -210,7 +223,7 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
|
|||||||
_cdio_list_append (dirlist, strdup (_fullname));
|
_cdio_list_append (dirlist, strdup (_fullname));
|
||||||
|
|
||||||
if (opts.print_iso9660) {
|
if (opts.print_iso9660) {
|
||||||
if (iso9660_ifs_is_xa(p_iso)) {
|
if (iso9660_ifs_is_xa(p_iso) && 0 == opts.no_xa) {
|
||||||
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
|
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
|
||||||
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
|
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
|
||||||
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
|
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
|
||||||
@@ -270,7 +283,9 @@ init(void)
|
|||||||
/* Default option values. */
|
/* Default option values. */
|
||||||
opts.silent = false;
|
opts.silent = false;
|
||||||
opts.no_header = false;
|
opts.no_header = false;
|
||||||
opts.no_joliet = false;
|
opts.no_joliet = 0;
|
||||||
|
opts.no_rock_ridge = 0;
|
||||||
|
opts.no_xa = 0;
|
||||||
opts.debug_level = 0;
|
opts.debug_level = 0;
|
||||||
opts.print_iso9660 = 0;
|
opts.print_iso9660 = 0;
|
||||||
opts.print_iso9660_short = 0;
|
opts.print_iso9660_short = 0;
|
||||||
@@ -297,7 +312,7 @@ main(int argc, const char *argv[])
|
|||||||
/* Parse our arguments; every option seen by `parse_opt' will
|
/* Parse our arguments; every option seen by `parse_opt' will
|
||||||
be reflected in `arguments'. */
|
be reflected in `arguments'. */
|
||||||
parse_options(argc, argv);
|
parse_options(argc, argv);
|
||||||
|
|
||||||
print_version(program_name, CDIO_VERSION, opts.no_header, opts.version_only);
|
print_version(program_name, CDIO_VERSION, opts.no_header, opts.version_only);
|
||||||
|
|
||||||
if (opts.debug_level == 3) {
|
if (opts.debug_level == 3) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso-read.c,v 1.8 2005/01/22 22:21:36 rocky Exp $
|
$Id: iso-read.c,v 1.9 2005/02/19 11:43:05 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@ struct arguments
|
|||||||
char *output_file;
|
char *output_file;
|
||||||
char *iso9660_image;
|
char *iso9660_image;
|
||||||
int debug_level;
|
int debug_level;
|
||||||
|
int no_header;
|
||||||
} opts;
|
} opts;
|
||||||
|
|
||||||
/* Parse a options. */
|
/* Parse a options. */
|
||||||
@@ -83,6 +84,9 @@ parse_options (int argc, const char *argv[])
|
|||||||
"Extract FILE from ISO-9660 image. This option is mandatory.",
|
"Extract FILE from ISO-9660 image. This option is mandatory.",
|
||||||
"FILE"},
|
"FILE"},
|
||||||
|
|
||||||
|
{"no-header", '\0', POPT_ARG_NONE, &opts.no_header,
|
||||||
|
0, "Don't display header and copyright (for regression testing)"},
|
||||||
|
|
||||||
{"output-file", 'o', POPT_ARG_STRING, &opts.output_file, 0,
|
{"output-file", 'o', POPT_ARG_STRING, &opts.output_file, 0,
|
||||||
"Output file. This option is mandatory.", "FILE"},
|
"Output file. This option is mandatory.", "FILE"},
|
||||||
|
|
||||||
@@ -192,7 +196,11 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
/* Parse our arguments; every option seen by `parse_opt' will
|
/* Parse our arguments; every option seen by `parse_opt' will
|
||||||
be reflected in `arguments'. */
|
be reflected in `arguments'. */
|
||||||
parse_options(argc, argv);
|
if (!parse_options(argc, argv)) {
|
||||||
|
report(stderr,
|
||||||
|
"error while parsing command line - try --help\n");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
iso = iso9660_open (opts.iso9660_image);
|
iso = iso9660_open (opts.iso9660_image);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user