From db8ee6e65a5fe7f3f63c0ddd42e29c919f1e7c8c Mon Sep 17 00:00:00 2001 From: "R. Bernstein" Date: Fri, 25 Dec 2009 09:14:26 -0500 Subject: [PATCH] Add run-time variables for libcdio version number/string. --- include/cdio/version.h.in | 11 +++++++-- lib/driver/libcdio.sym | 18 +++++++------- lib/driver/util.c | 3 +++ test/.gitignore | 1 + test/Makefile.am | 5 +++- test/test_lib_driver_util.c | 48 +++++++++++++++++++++++++++++++++++++ 6 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 test/test_lib_driver_util.c diff --git a/include/cdio/version.h.in b/include/cdio/version.h.in index 17d199e7..9105b5cd 100644 --- a/include/cdio/version.h.in +++ b/include/cdio/version.h.in @@ -5,8 +5,15 @@ * number (@LIBCDIO_VERSION_NUM@) and OS build name. */ -/*! CDIO_VERSION can as a string in programs to show what version is used. */ +/*! CDIO_VERSION can as a string in programs to show what version is + used. cdio_version_string is the same thing but represented as a + constant in memory. */ #define CDIO_VERSION "@VERSION@ @build@" +extern const char *cdio_version_string; /**< = CDIO_VERSION */ -/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor */ +/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor, + libcdio_version_num is the same thing but reresented as a constant + in memory. */ #define LIBCDIO_VERSION_NUM @LIBCDIO_VERSION_NUM@ + +extern const unsigned int libcdio_version_num; /**< = LIBCDIO_VERSION_NUM */ diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym index 5174e72d..51955e7e 100644 --- a/lib/driver/libcdio.sym +++ b/lib/driver/libcdio.sym @@ -23,6 +23,11 @@ cdio_audio_read_subchannel cdio_audio_resume cdio_audio_set_volume cdio_audio_stop +cdio_charset_convert +cdio_charset_converter_create +cdio_charset_converter_destroy +cdio_charset_from_utf8 +cdio_charset_to_utf8 cdio_close_tray cdio_debug cdio_destroy @@ -80,14 +85,14 @@ cdio_get_track_channels cdio_get_track_copy_permit cdio_get_track_format cdio_get_track_green +cdio_get_track_isrc cdio_get_track_last_lsn cdio_get_track_lba -cdio_get_track_pregap_lba -cdio_get_track_pregap_lsn -cdio_get_track_isrc cdio_get_track_lsn cdio_get_track_msf cdio_get_track_preemphasis +cdio_get_track_pregap_lba +cdio_get_track_pregap_lsn cdio_get_track_sec_count cdio_guess_cd_type cdio_have_atapi @@ -169,6 +174,7 @@ cdio_stream_getpos cdio_stream_read cdio_stream_seek cdio_to_bcd8 +cdio_version_string cdio_warn cdtext_destroy cdtext_field2str @@ -184,6 +190,7 @@ debug_cdio_mmc_get_conf debug_cdio_mmc_gpcmd debug_cdio_mmc_read_sub_state discmode2str +libcdio_version_num mmc_audio_read_subchannel mmc_audio_state2str mmc_close_tray @@ -216,8 +223,3 @@ mmc_set_speed mmc_start_stop_media mmc_timeout_ms track_format2str -cdio_charset_converter_create -cdio_charset_converter_destroy -cdio_charset_convert -cdio_charset_from_utf8 -cdio_charset_to_utf8 diff --git a/lib/driver/util.c b/lib/driver/util.c index 88ffafb3..0cf52ecd 100644 --- a/lib/driver/util.c +++ b/lib/driver/util.c @@ -40,6 +40,7 @@ #include "cdio_assert.h" #include #include +#include #ifndef PATH_MAX #define PATH_MAX 4096 @@ -183,6 +184,8 @@ void cdio_follow_symlink (const char * src, char * dst) { #endif } +const char *cdio_version_string = CDIO_VERSION; +const unsigned int libcdio_version_num = LIBCDIO_VERSION_NUM; /* diff --git a/test/.gitignore b/test/.gitignore index beb0776c..97d52b74 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -17,6 +17,7 @@ /check_nrg.sh /check_paranoia.sh /check_sizeof +/test_lib_driver_util /testassert /testbincue /testbincue.c diff --git a/test/Makefile.am b/test/Makefile.am index 0e9f7367..19777e61 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -27,7 +27,7 @@ testparanoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIB endif hack = check_sizeof testassert testbincue testgetdevices testischar \ - testisocd testisocd2 testiso9660 testlinux \ + testisocd testisocd2 testiso9660 testlinux test_lib_driver_util \ testnrg $(testparanoia) testtoc testpregap testsolaris EXTRA_PROGRAMS = testdefault @@ -47,6 +47,9 @@ testisocd2_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV) testtoc_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) testtoc_CFLAGS = -DTEST_DIR=\"$(srcdir)\" +test_lib_driver_util_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) +tets_lib_driver_util_CFLAGS = -DTEST_DIR=\"$(srcdir)\" + testlinux_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) testlinux_CFLAGS = -DTEST_DIR=\"$(srcdir)\" diff --git a/test/test_lib_driver_util.c b/test/test_lib_driver_util.c new file mode 100644 index 00000000..e774acdd --- /dev/null +++ b/test/test_lib_driver_util.c @@ -0,0 +1,48 @@ +/* -*- C -*- + Copyright (C) 2009 Rocky Bernstein + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/* Unit test for lib/driver/util.c */ + +#include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include + +int +main(int argc, const char *argv[]) +{ + if (0 != strncmp(cdio_version_string, CDIO_VERSION, + strlen(CDIO_VERSION))) { + fprintf(stderr, "CDIO VERSION string mismatch %s vs %s\n", + cdio_version_string, CDIO_VERSION); + exit(1); + } + if (libcdio_version_num != LIBCDIO_VERSION_NUM) { + fprintf(stderr, "LIBCDIO_VERSION_NUM value mismatch %d vs %d\n", + libcdio_version_num, LIBCDIO_VERSION_NUM); + exit(2); + } + exit(0); +} +