From 5aa007965a34068d1279a9bd162d27d1843dc5f1 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 7 Jun 2003 01:20:40 +0000 Subject: [PATCH] cygwin/mingw improvements cd-info: list drivers and exit when --version requested. --- configure.ac | 8 ++++++-- src/cd-info.c | 28 +++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index a06bd249..d154fd33 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. -AC_REVISION([$Id: configure.ac,v 1.23 2003/06/01 21:05:45 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.24 2003/06/07 01:20:40 rocky Exp $])dnl AC_INIT(lib/cdio.c) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(libcdio, 0.61) @@ -143,7 +143,10 @@ fi dnl dnl system + +dnl test for non-Unix variants AC_CYGWIN +AC_MINGW32 LIBS="$LIBS -lm" CFLAGS="$CFLAGS $WARN_CFLAGS" @@ -196,9 +199,10 @@ int has_timeout=sizeof(test.timeout);], AC_DEFINE([HAVE_SOLARIS_CDROM], [1], [Define 1 if you have Solaris CD-ROM support]) ;; - mingw*) + mingw*|cygwin*) AC_DEFINE([HAVE_WIN32_CDROM], [1], [Define 1 if you have cywin MinGW CD-ROM support]) + LIBS="$LIBS -lwinmm -mwindows" ;; *) AC_MSG_WARN(Don't have OS CD-reading support for ${host_os}...) diff --git a/src/cd-info.c b/src/cd-info.c index 4be18e86..778d1bf5 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.5 2003/06/01 21:05:45 rocky Exp $ + $Id: cd-info.c,v 1.6 2003/06/07 01:20:40 rocky Exp $ Copyright (C) 2003 Rocky Bernstein Copyright (C) 1996,1997,1998 Gerd Knorr @@ -261,6 +261,7 @@ struct arguments #endif uint32_t debug_level; int silent; + bool version_only; source_image_t source_image; } opts; @@ -356,7 +357,7 @@ struct poptOption optionsTable[] = { {"quiet", 'q', POPT_ARG_NONE, &opts.silent, 0, "show only critical messages"}, - {"version", 'V', POPT_ARG_NONE, NULL, OP_VERSION, + {"version", 'V', POPT_ARG_NONE, &opts.version_only, 0, "display version and copyright information and exit"}, POPT_AUTOHELP {NULL, 0, 0, NULL, 0} }; @@ -447,16 +448,29 @@ parse_options (poptContext optCon) return true; } - + static void -print_version (void) +print_version (bool version_only) { + + driver_id_t driver_id; + printf( _("CD Info %s | (c) 2003 Gerd Knorr, Heiko Eißfeldt & R. Bernstein\n\ This is free software; see the source for copying conditions.\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\ PARTICULAR PURPOSE.\n\ "), CDINFO_VERSION); + + if (version_only) { + for (driver_id=DRIVER_UNKNOWN+1; driver_id<=MAX_DRIVER; driver_id++) { + if (cdio_have_driver(driver_id)) { + printf("driver: %s\n", cdio_driver_describe(driver_id)); + } + } + exit(100); + } + } /* ------------------------------------------------------------------------ */ @@ -736,7 +750,9 @@ cddb_discid() /* CDIO logging routines */ static cdio_log_handler_t gl_default_cdio_log_handler = NULL; +#ifdef HAVE_CDDB static cddb_log_handler_t gl_default_cddb_log_handler = NULL; +#endif static void _log_handler (cdio_log_level_t level, const char message[]) @@ -974,7 +990,9 @@ main(int argc, const char *argv[]) poptContext optCon = poptGetContext (NULL, argc, argv, optionsTable, 0); gl_default_cdio_log_handler = cdio_log_set_handler (_log_handler); +#ifdef HAVE_CDDB gl_default_cddb_log_handler = cddb_log_set_handler (_log_handler); +#endif program_name = strrchr(argv[0],'/'); program_name = program_name ? program_name+1 : strdup(argv[0]); @@ -1002,7 +1020,7 @@ main(int argc, const char *argv[]) be reflected in `arguments'. */ parse_options(optCon); - print_version(); + print_version(opts.version_only); switch (opts.source_image) { case IMAGE_UNKNOWN: