Require libcddb 0.9.4 or nothing at all. We now allow:

- setting cache directory
- disabling caching altogther
- setting timeout on CDDB network operations
- setting email address reported to CDDB server
- setting name of CDDB server
- printing/suppressing messages from CDDB
This commit is contained in:
rocky
2003-06-01 21:05:45 +00:00
parent 432c19833b
commit 636c51416f
3 changed files with 84 additions and 45 deletions

View File

@@ -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 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA. dnl 02111-1307, USA.
AC_REVISION([$Id: configure.ac,v 1.22 2003/05/27 02:55:58 rocky Exp $])dnl AC_REVISION([$Id: configure.ac,v 1.23 2003/06/01 21:05:45 rocky Exp $])dnl
AC_INIT(lib/cdio.c) AC_INIT(lib/cdio.c)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(libcdio, 0.61) AM_INIT_AUTOMAKE(libcdio, 0.61)
@@ -196,7 +196,7 @@ int has_timeout=sizeof(test.timeout);],
AC_DEFINE([HAVE_SOLARIS_CDROM], [1], AC_DEFINE([HAVE_SOLARIS_CDROM], [1],
[Define 1 if you have Solaris CD-ROM support]) [Define 1 if you have Solaris CD-ROM support])
;; ;;
cygwin*) mingw*)
AC_DEFINE([HAVE_WIN32_CDROM], [1], AC_DEFINE([HAVE_WIN32_CDROM], [1],
[Define 1 if you have cywin MinGW CD-ROM support]) [Define 1 if you have cywin MinGW CD-ROM support])
;; ;;
@@ -218,25 +218,18 @@ AC_ARG_ENABLE(cddb,
enable_cddb=yes) enable_cddb=yes)
fi fi
if test x$enable_cddb = xyes; then if test x$enable_cddb = xyes; then
AC_CHECK_LIB(cddb, cddb_disc_calc_discid, PKG_CHECK_MODULES(CDDB, libcddb >= 0.9.4, [
[ CDDB_LIB="-lcddb"; ac_have_cddb=yes ])
dnl AC_DEFINE([HAVE_CDDB],[],
dnl [Define this if you have libcddb installed])
AC_TRY_COMPILE([#include <cddb/cddb.h>],[
cddb_conn_t *conn;
cddb_http_enable(conn);
], [
HAVE_CDDB=yes HAVE_CDDB=yes
AC_DEFINE(HAVE_CDDB, [], [Define this if you have libcddb installed]) AC_DEFINE(HAVE_CDDB, [], [Define this if you have libcddb installed])
], ],
AC_MSG_WARN(libcddb library might not be new enough; need version 0.90 or greater), [AC_MSG_WARN(new enough libcddb not found. CDDB access disabled)
HAVE_CDDB=no) HAVE_CDDB=no])
AC_CHECK_LIB(socket, connect) AC_CHECK_LIB(socket, connect)
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname)) AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
fi fi
AC_SUBST(CDDB_LIB) AC_SUBST(CDDB)
if test x$enable_vcdinfo = x; then if test x$enable_vcdinfo = x; then
AC_ARG_ENABLE(vcdinfo, AC_ARG_ENABLE(vcdinfo,

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.6 2003/04/26 14:24:44 rocky Exp $ # $Id: Makefile.am,v 1.7 2003/06/01 21:05:45 rocky Exp $
# #
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
# #
@@ -19,11 +19,11 @@
#################################################### ####################################################
# Things to make the sample/test programs # Things to make the sample/test programs
#################################################### ####################################################
CDDB_LIB=@CDDB_LIB@ CDDB_LIBS=@CDDB_LIBS@
if BUILD_CDINFO if BUILD_CDINFO
cd_info_SOURCES = cd-info.c cd_info_SOURCES = cd-info.c
cd_info_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIB) $(VCDINFO_LIB) cd_info_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIBS) $(VCDINFO_LIB)
if BUILD_CDINFO_LINUX if BUILD_CDINFO_LINUX
cdinfo_linux_SOURCES = cdinfo-linux.c cdinfo_linux_SOURCES = cdinfo-linux.c
cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS)

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.4 2003/05/24 15:46:28 rocky Exp $ $Id: cd-info.c,v 1.5 2003/06/01 21:05:45 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 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>
@@ -243,19 +243,24 @@ typedef enum
*/ */
struct arguments struct arguments
{ {
int no_tracks; int no_tracks;
int no_ioctl; int no_ioctl;
int no_analysis; int no_analysis;
#ifdef HAVE_CDDB #ifdef HAVE_CDDB
int no_cddb; int no_cddb; /* If set the below are meaningless. */
int cddb_port; /* port number to contact CDDB server. */ char *cddb_email; /* email to report to CDDB server. */
int cddb_http; /* 1 if use http proxy */ char *cddb_server; /* CDDB server to contact */
int cddb_port; /* port number to contact CDDB server. */
int cddb_http; /* 1 if use http proxy */
int cddb_timeout;
bool cddb_disable_cache; /* If set the below is meaningless. */
char *cddb_cachedir;
#endif #endif
#ifdef HAVE_VCDINFO #ifdef HAVE_VCDINFO
int no_vcd; int no_vcd;
#endif #endif
int debug_level; uint32_t debug_level;
int silent; int silent;
source_image_t source_image; source_image_t source_image;
} opts; } opts;
@@ -285,20 +290,20 @@ enum {
char *temp_str; char *temp_str;
struct poptOption optionsTable[] = { struct poptOption optionsTable[] = {
{"debug", 'd', POPT_ARG_INT, &opts.debug_level, 0, {"debug", 'd', POPT_ARG_INT, &opts.debug_level, 0,
"Set debugging to LEVEL"}, "Set debugging to LEVEL"},
{"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" },
{"no-tracks", 'T', POPT_ARG_NONE, &opts.no_tracks, 0, {"no-tracks", 'T', POPT_ARG_NONE, &opts.no_tracks, 0,
"Don't show track information"}, "Don't show track information"},
{"no-analyze",'A', POPT_ARG_NONE, &opts.no_analysis, 0, {"no-analyze", 'A', POPT_ARG_NONE, &opts.no_analysis, 0,
"Don't filesystem analysis"}, "Don't filesystem analysis"},
#ifdef HAVE_CDDB #ifdef HAVE_CDDB
{"no-cddb", 'a', POPT_ARG_NONE, &opts.no_cddb, 0, {"no-cddb", 'a', POPT_ARG_NONE, &opts.no_cddb, 0,
"Don't look up audio CDDB information or print that"}, "Don't look up audio CDDB information or print that"},
{"cddb-port", 'P', POPT_ARG_INT, &opts.cddb_port, 0, {"cddb-port", 'P', POPT_ARG_INT, &opts.cddb_port, 0,
@@ -306,6 +311,22 @@ struct poptOption optionsTable[] = {
{"cddb-http", 'H', POPT_ARG_NONE, &opts.cddb_http, 0, {"cddb-http", 'H', POPT_ARG_NONE, &opts.cddb_http, 0,
"Lookup CDDB via HTTP proxy (default no proxy)"}, "Lookup CDDB via HTTP proxy (default no proxy)"},
{"cddb-server", '\0', POPT_ARG_STRING, &opts.cddb_server, 0,
"CDDB server to contact for information (default: freedb.freedb.org)"},
{"cddb-cache", '\0', POPT_ARG_STRING, &opts.cddb_cachedir, 0,
"Location of CDDB cache directory (default ~/.cddbclient)"},
{"cddb-email", '\0', POPT_ARG_STRING, &opts.cddb_email, 0,
"Email address to give CDDB server (default me@home"},
{"no-cddb-cache", '\0', POPT_ARG_NONE, &opts.cddb_disable_cache, 0,
"Lookup CDDB via HTTP proxy (default no proxy)"},
{"cddb-timeout", '\0', POPT_ARG_INT, &opts.cddb_timeout, 0,
"CDDB timeout value in seconds (default 10 seconds)"},
#endif #endif
#ifdef HAVE_VCDINFO #ifdef HAVE_VCDINFO
@@ -714,7 +735,8 @@ cddb_discid()
/* CDIO logging routines */ /* CDIO logging routines */
static cdio_log_handler_t gl_default_log_handler = NULL; static cdio_log_handler_t gl_default_cdio_log_handler = NULL;
static cddb_log_handler_t gl_default_cddb_log_handler = NULL;
static void static void
_log_handler (cdio_log_level_t level, const char message[]) _log_handler (cdio_log_level_t level, const char message[])
@@ -728,7 +750,7 @@ _log_handler (cdio_log_level_t level, const char message[])
if (level == CDIO_LOG_WARN && opts.silent) if (level == CDIO_LOG_WARN && opts.silent)
return; return;
gl_default_log_handler (level, message); gl_default_cdio_log_handler (level, message);
} }
@@ -745,13 +767,31 @@ print_cddb_info() {
goto cddb_destroy; goto cddb_destroy;
} }
cddb_set_email_address(conn, "me@home"); if (NULL == opts.cddb_email)
cddb_set_server_name(conn, "freedb.freedb.org"); cddb_set_email_address(conn, "me@home");
else
cddb_set_email_address(conn, opts.cddb_email);
if (NULL == opts.cddb_server)
cddb_set_server_name(conn, "freedb.freedb.org");
else
cddb_set_server_name(conn, opts.cddb_server);
if (opts.cddb_timeout >= 0)
cddb_set_timeout(conn, opts.cddb_timeout);
cddb_set_server_port(conn, opts.cddb_port); cddb_set_server_port(conn, opts.cddb_port);
if (opts.cddb_http) if (opts.cddb_http)
cddb_http_enable(conn); cddb_http_enable(conn);
else else
cddb_http_disable(conn); cddb_http_disable(conn);
if (NULL != opts.cddb_cachedir)
cddb_cache_set_dir(conn, opts.cddb_cachedir);
if (opts.cddb_disable_cache)
cddb_cache_disable(conn);
disc = cddb_disc_new(); disc = cddb_disc_new();
if (!disc) { if (!disc) {
@@ -933,23 +973,29 @@ main(int argc, const char *argv[])
int fs=0; int fs=0;
poptContext optCon = poptGetContext (NULL, argc, argv, optionsTable, 0); poptContext optCon = poptGetContext (NULL, argc, argv, optionsTable, 0);
gl_default_log_handler = cdio_log_set_handler (_log_handler); gl_default_cdio_log_handler = cdio_log_set_handler (_log_handler);
gl_default_cddb_log_handler = cddb_log_set_handler (_log_handler);
program_name = strrchr(argv[0],'/'); program_name = strrchr(argv[0],'/');
program_name = program_name ? program_name+1 : strdup(argv[0]); program_name = program_name ? program_name+1 : strdup(argv[0]);
/* Default option values. */ /* Default option values. */
opts.silent = false; opts.silent = false;
opts.debug_level = 0; opts.debug_level = 0;
opts.no_tracks = 0; opts.no_tracks = 0;
#ifdef HAVE_CDDB #ifdef HAVE_CDDB
opts.no_cddb = 0; opts.no_cddb = 0;
opts.cddb_port = 8880; opts.cddb_port = 8880;
opts.cddb_http = 0; opts.cddb_http = 0;
opts.cddb_cachedir = NULL;
opts.cddb_server = NULL;
opts.cddb_timeout = -1;
opts.cddb_disable_cache = false;
#endif #endif
opts.no_ioctl = 0; opts.no_ioctl = 0;
opts.no_analysis = 0; opts.no_analysis = 0;
opts.source_image = IMAGE_UNKNOWN; opts.source_image = IMAGE_UNKNOWN;
/* Parse our arguments; every option seen by `parse_opt' will /* Parse our arguments; every option seen by `parse_opt' will