MusicBrainz-libdiscid 0.4.1.1 → 0.5.0.0
raw patch · 16 files changed
+156/−157 lines, 16 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- MusicBrainz-libdiscid.cabal +2/−3
- libdiscid/include/config.h +0/−84
- libdiscid/include/discid/discid.h +59/−6
- libdiscid/include/discid/discid_private.h +4/−4
- libdiscid/src/base64.c +1/−1
- libdiscid/src/base64.h +3/−1
- libdiscid/src/disc.c +11/−3
- libdiscid/src/disc_darwin.c +50/−38
- libdiscid/src/disc_freebsd.c +1/−1
- libdiscid/src/disc_generic.c +1/−1
- libdiscid/src/disc_linux.c +7/−3
- libdiscid/src/disc_openbsd.c +1/−1
- libdiscid/src/disc_solaris.c +1/−1
- libdiscid/src/disc_win32.c +1/−1
- libdiscid/src/disc_win32_new.c +7/−3
- libdiscid/src/sha1.h +7/−6
MusicBrainz-libdiscid.cabal view
@@ -1,5 +1,5 @@ name: MusicBrainz-libdiscid-version: 0.4.1.1+version: 0.5.0.0 cabal-version: >=1.6 build-type: Simple license: LGPL@@ -14,7 +14,7 @@ author: André Twupack data-dir: "" extra-source-files: COPYING libdiscid/AUTHORS libdiscid/COPYING- libdiscid/README libdiscid/include/config.h+ libdiscid/README libdiscid/include/discid/*.h libdiscid/src/*.c libdiscid/src/*.h library@@ -22,7 +22,6 @@ exposed-modules: Sound.MusicBrainz.DiscId exposed: True buildable: True- cc-options: -DHAVE_CONFIG_H if os(windows) c-sources: libdiscid/src/base64.c libdiscid/src/disc.c libdiscid/src/disc_win32_new.c libdiscid/src/sha1.c
− libdiscid/include/config.h
@@ -1,84 +0,0 @@-/* config.h. Generated from config.h.in by configure. */-/* config.h.in. Generated from configure.ac by autoheader. */--/* Define if building universal (internal helper macro) */-/* #undef AC_APPLE_UNIVERSAL_BUILD */--/* Define to 1 if you have the <dlfcn.h> header file. */-#define HAVE_DLFCN_H 1--/* Define to 1 if you have the <inttypes.h> header file. */-#define HAVE_INTTYPES_H 1--/* Define to 1 if you have the <memory.h> header file. */-#define HAVE_MEMORY_H 1--/* Define to 1 if you have the <stdint.h> header file. */-#define HAVE_STDINT_H 1--/* Define to 1 if you have the <stdlib.h> header file. */-#define HAVE_STDLIB_H 1--/* Define to 1 if you have the <strings.h> header file. */-#define HAVE_STRINGS_H 1--/* Define to 1 if you have the <string.h> header file. */-#define HAVE_STRING_H 1--/* Define to 1 if you have the <sys/stat.h> header file. */-#define HAVE_SYS_STAT_H 1--/* Define to 1 if you have the <sys/types.h> header file. */-#define HAVE_SYS_TYPES_H 1--/* Define to 1 if you have the <unistd.h> header file. */-#define HAVE_UNISTD_H 1--/* Define to the sub-directory in which libtool stores uninstalled libraries.- */-#define LT_OBJDIR ".libs/"--/* Name of package */-#define PACKAGE "libdiscid"--/* Define to the address where bug reports for this package should be sent. */-#define PACKAGE_BUGREPORT ""--/* Define to the full name of this package. */-#define PACKAGE_NAME "libdiscid"--/* Define to the full name and version of this package. */-#define PACKAGE_STRING "libdiscid 0.4.1"--/* Define to the one symbol short name of this package. */-#define PACKAGE_TARNAME "libdiscid"--/* Define to the home page for this package. */-#define PACKAGE_URL ""--/* Define to the version of this package. */-#define PACKAGE_VERSION "0.4.1"--/* The size of `long', as computed by sizeof. */-#define SIZEOF_LONG 8--/* Define to 1 if you have the ANSI C header files. */-#define STDC_HEADERS 1--/* Version number of package */-#define VERSION "0.4.1"--/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most- significant byte first (like Motorola and SPARC, unlike Intel). */-#if defined AC_APPLE_UNIVERSAL_BUILD-# if defined __BIG_ENDIAN__-# define WORDS_BIGENDIAN 1-# endif-#else-# ifndef WORDS_BIGENDIAN-/* # undef WORDS_BIGENDIAN */-# endif-#endif--/* "the header is used to create the library" */-#define libdiscid_EXPORTS /**/
libdiscid/include/discid/discid.h view
@@ -24,17 +24,28 @@ #ifndef MUSICBRAINZ_DISC_ID_H #define MUSICBRAINZ_DISC_ID_H -#if (defined(_WIN32) || defined(_WIN64))+#if (defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)) # ifdef libdiscid_EXPORTS # define LIBDISCID_API __declspec(dllexport) # else # define LIBDISCID_API __declspec(dllimport) # endif+# define LIBDISCID_INTERNAL+#elif (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)+# define LIBDISCID_API+# define LIBDISCID_INTERNAL __attribute__((visibility("hidden")))+#elif defined(__SUNPRO_C)+# define LIBDISCID_API __global+# define LIBDISCID_INTERNAL __hidden #else # define LIBDISCID_API+# define LIBDISCID_INTERNAL #endif -+#define DISCID_VERSION_MAJOR 0+#define DISCID_VERSION_MINOR 5+#define DISCID_VERSION_PATCH 0+#define DISCID_VERSION_NUM 500 #ifdef __cplusplus extern "C" {@@ -64,7 +75,7 @@ * * DiscId *disc = discid_new(); *- * if ( discid_read(disc, "/dev/cdrom") == 0 ) {+ * if ( discid_read_sparse(disc, "/dev/cdrom", 0) == 0 ) { * fprintf(stderr, "Error: %s\n", discid_get_error_msg(disc)); * return 1; * }@@ -129,6 +140,10 @@ * identifier. If the device is NULL, the default drive, as returned by * discid_get_default_device() is used. *+ * If you do not require all features provided by libdiscid, such as MCN+ * or ISRC reading, you should consider using discid_read_sparse() instead+ * of discid_read() for performance reasons.+ * * On error, this function returns false and sets the error message which you * can access using discid_get_error_msg(). In this case, the other functions * won't return meaningful values and should not be used.@@ -143,6 +158,33 @@ /**+ * Read the disc in the given CD-ROM/DVD-ROM drive+ * using only the specified features.+ *+ * This function is similar to discid_read() but it allows to use only the+ * features explicitely specified.+ * By default this function will read only the TOC, but additional features+ * like ::DISCID_FEATURE_MCN and ::DISCID_FEATURE_ISRC can be set+ * using the features parameter. Multiple features can be set using bitwise OR.+ *+ * On error, this function returns false and sets the error message which you+ * can access using discid_get_error_msg(). In this case, the other functions+ * won't return meaningful values and should not be used.+ *+ * This function may be used multiple times with the same DiscId object.+ *+ * \since libdiscid 0.5.0+ *+ * @param d a DiscId object created by discid_new()+ * @param device an operating system dependent device identifier, or NULL+ * @param features a list of bit flags from the enum ::discid_feature+ * @return true if successful, or false on error.+ */+LIBDISCID_API int discid_read_sparse(DiscId *d, const char *device, unsigned int features);++#define DISCID_HAVE_SPARSE_READ++/** * Provides the TOC of a known CD. * * This function may be used if the TOC has been read earlier and you@@ -245,7 +287,7 @@ /**- * Return the number of the last track on this disc.+ * Return the number of the last audio track on this disc. * * @param d a DiscId object created by discid_new() * @return the number of the last track@@ -290,6 +332,8 @@ /** * Return the Media Catalogue Number for the disc. *+ * \since libdiscid 0.3.0+ * * @param d a DiscId object created by discid_new() * @return a string containing an Media Catalogue Number of the disk */@@ -301,6 +345,8 @@ * Only track numbers between (and including) discid_get_first_track_num() * and discid_get_last_track_num() may be used. *+ * \since libdiscid 0.3.0+ * * @param d a DiscId object created by discid_new() * @param track_num the number of a track * @return a string containing an ISRC for the specified track@@ -327,6 +373,9 @@ /** * Check if a certain feature is implemented on the current platform. *+ * \since libdiscid 0.4.0+ *+ * @param feature as enum ::discid_feature * @return 1 if the feature is implemented and 0 if not. */ LIBDISCID_API int discid_has_feature(enum discid_feature feature);@@ -337,11 +386,13 @@ #define DISCID_FEATURE_LENGTH 32 /** * Return a list of features supported by the current platform.- * The array of length DISCID_FEATURES_LENGTH should be allocated by the user.+ * The array of length ::DISCID_FEATURE_LENGTH should be allocated by the user. * After the call each element of the array is either NULL * or a pointer to a static string. *- * @return an array of supported features (as strings)+ * \since libdiscid 0.4.0+ *+ * @param[out] features a static string array of length ::DISCID_FEATURE_LENGTH */ LIBDISCID_API void discid_get_feature_list( char *features[DISCID_FEATURE_LENGTH]);@@ -350,6 +401,8 @@ * Return the full version string of this library, including the name. * This can be used for debug output. * Don't use this to test for features, see discid_has_feature().+ *+ * \since libdiscid 0.4.0 * * @return a string containing the version of libdiscid. */
libdiscid/include/discid/discid_private.h view
@@ -27,7 +27,7 @@ #ifndef MUSICBRAINZ_DISC_ID_PRIVATE_H #define MUSICBRAINZ_DISC_ID_PRIVATE_H -#include "discid.h"+#include "discid/discid.h" /* Length of a MusicBrainz DiscID in bytes (without a trailing '\0'-byte). */@@ -88,7 +88,7 @@ * * On error, 0 is returned. On success, 1 is returned. */-int mb_disc_read_unportable(mb_disc_private *disc, const char *device);+LIBDISCID_INTERNAL int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features); /*@@ -96,12 +96,12 @@ * on this operating system. It has to be in a format usable for the second * parameter of mb_disc_read_unportable(). */-char *mb_disc_get_default_device_unportable(void);+LIBDISCID_INTERNAL char *mb_disc_get_default_device_unportable(void); /* * This should return 1 if the feature is supported by the platform * and 0 if not. */-int mb_disc_has_feature_unportable(enum discid_feature feature);+LIBDISCID_INTERNAL int mb_disc_has_feature_unportable(enum discid_feature feature); #endif /* MUSICBRAINZ_DISC_ID_PRIVATE_H */
libdiscid/src/base64.c view
@@ -68,7 +68,7 @@ #include <stdio.h> #include <time.h> #include <stdlib.h>-+#include "base64.h" /* NOTE: This is not true RFC822 anymore. The use of the characters '/', '+', and '=' is no bueno when the ID will be used as part of a URL.
libdiscid/src/base64.h view
@@ -67,6 +67,8 @@ #ifndef BASE64_H #define BASE64_H -unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len);+#include "discid/discid.h" /* for LIBDISCID_INTERNAL */++LIBDISCID_INTERNAL unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len); #endif
libdiscid/src/disc.c view
@@ -23,8 +23,14 @@ $Id$ --------------------------------------------------------------------------- */++#ifdef HAVE_CONFIG_H+#include <config.h>+#endif+ #include <string.h> #include <assert.h>+#include <limits.h> #include "sha1.h" #include "base64.h"@@ -127,6 +133,10 @@ } int discid_read(DiscId *d, const char *device) {+ return discid_read_sparse(d, device, UINT_MAX);+}++int discid_read_sparse(DiscId *d, const char *device, unsigned int features) { mb_disc_private *disc = (mb_disc_private *) d; assert( disc != NULL );@@ -139,10 +149,9 @@ /* Necessary, because the disc handle could have been used before. */ memset(disc, 0, sizeof(mb_disc_private)); - return disc->success = mb_disc_read_unportable(disc, device);+ return disc->success = mb_disc_read_unportable(disc, device, features); } - int discid_put(DiscId *d, int first, int last, int *offsets) { mb_disc_private *disc = (mb_disc_private *) d; @@ -273,7 +282,6 @@ char *discid_get_version_string(void) { #ifdef HAVE_CONFIG_H-#include <config.h> return PACKAGE_STRING; #else return "";
libdiscid/src/disc_darwin.c view
@@ -170,26 +170,29 @@ return defaultDevice; } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) +int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { int fd; int i; dk_cd_read_toc_t toc; CDTOC *cdToc; - if (device == NULL || *device == 0)- device = mb_disc_get_default_device_unportable();+ if (device == NULL || *device == 0) {+ device = mb_disc_get_default_device_unportable();+ } - if (!*device)- {- snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH, "No CD-ROMs found. Please insert a disc and try again.");- return 0;+ if (!*device) {+ snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH,+ "No CD-ROMs found. Please insert a disc and try again."+ );+ return 0; } fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) {- snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH, "Cannot open '%s'", device);- return 0;+ snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH,+ "Cannot open '%s'", device);+ return 0; } memset(&toc, 0, sizeof(toc));@@ -198,46 +201,55 @@ toc.buffer = (char *)malloc(TOC_BUFFER_LEN); toc.bufferLength = TOC_BUFFER_LEN; if (ioctl(fd, DKIOCCDREADTOC, &toc) < 0 ) {- snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH, "Cannot read TOC from '%s'", device);- free(toc.buffer);- return 0;+ snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH,+ "Cannot read TOC from '%s'", device);+ free(toc.buffer);+ return 0; } if ( toc.bufferLength < sizeof(CDTOC) ) {- snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH, "Short TOC was returned from '%s'", device);- free(toc.buffer);- return 0;+ snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH,+ "Short TOC was returned from '%s'", device);+ free(toc.buffer);+ return 0; } // Read in the media catalogue number- read_disc_mcn( fd, disc );- + if (features & DISCID_FEATURE_MCN) {+ read_disc_mcn(fd, disc);+ }+ cdToc = (CDTOC *)toc.buffer; int numDesc = CDTOCGetDescriptorCount(cdToc);- + int numTracks = 0;- for(i = 0; i < numDesc; i++)- {- CDTOCDescriptor *desc = &cdToc->descriptors[i];- - if (desc->session > 1)- continue;- - if (desc->point == 0xA2 && desc->adr == 1)- disc->track_offsets[0] = CDConvertMSFToLBA(desc->p) + 150; - - if (desc->point <= 99 && desc->adr == 1) {- disc->track_offsets[1 + numTracks] = CDConvertMSFToLBA(desc->p) + 150; - - // Read in the IRSC codes for tracks- read_disc_isrc( fd, disc, 1 + numTracks );- - numTracks++;- }+ for(i = 0; i < numDesc; i++) {+ CDTOCDescriptor *desc = &cdToc->descriptors[i];++ if (desc->session > 1) {+ continue;+ }++ if (desc->point == 0xA2 && desc->adr == 1) {+ disc->track_offsets[0] = CDConvertMSFToLBA(desc->p)+ + 150;+ }++ if (desc->point <= 99 && desc->adr == 1) {+ disc->track_offsets[1 + numTracks] = CDConvertMSFToLBA(+ desc->p) + 150;++ // Read in the IRSC codes for tracks+ if (features & DISCID_FEATURE_ISRC) {+ read_disc_isrc(fd, disc, 1 + numTracks);+ }++ numTracks++;+ } } disc->first_track_num = 1; disc->last_track_num = numTracks;- - ++ close(fd); free(toc.buffer);
libdiscid/src/disc_freebsd.c view
@@ -127,7 +127,7 @@ } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) {+int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { int fd; unsigned long lba; int first, last;
libdiscid/src/disc_generic.c view
@@ -34,7 +34,7 @@ return 0; } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) {+int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { snprintf(disc->error_msg, MB_ERROR_MSG_LENGTH, "disc reading not implemented on this platform"); return 0;
libdiscid/src/disc_linux.c view
@@ -216,7 +216,7 @@ } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) {+int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { int fd; unsigned long lba; int first, last;@@ -247,7 +247,9 @@ } /* Read in the media catalog number */- read_disc_mcn( fd, disc );+ if (features & DISCID_FEATURE_MCN) {+ read_disc_mcn( fd, disc );+ } disc->first_track_num = first; disc->last_track_num = last;@@ -266,7 +268,9 @@ disc->track_offsets[i] = lba + 150; /* Read the ISRC for the track */- read_track_isrc(fd, disc, i);+ if (features & DISCID_FEATURE_ISRC) {+ read_track_isrc(fd, disc, i);+ } } close(fd);
libdiscid/src/disc_openbsd.c view
@@ -71,7 +71,7 @@ } int-mb_disc_read_unportable (mb_disc_private *disc, const char *device)+mb_disc_read_unportable (mb_disc_private *disc, const char *device, unsigned int features) { struct cd_toc_entry te; struct ioc_toc_header th;
libdiscid/src/disc_solaris.c view
@@ -141,7 +141,7 @@ } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) {+int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { int fd; unsigned long lba; int first, last;
libdiscid/src/disc_win32.c view
@@ -41,7 +41,7 @@ return MB_DEFAULT_DEVICE; } -int mb_disc_read_unportable(mb_disc_private *disc, const char *device) {+int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features) { int i, ret, last_track; char mci_command[128]; char mci_return[128];
libdiscid/src/disc_win32_new.c view
@@ -164,7 +164,7 @@ } -int mb_disc_read_unportable_nt(mb_disc_private *disc, const char *device)+int mb_disc_read_unportable_nt(mb_disc_private *disc, const char *device, unsigned int features) { HANDLE hDevice; DWORD dwReturned;@@ -213,7 +213,9 @@ return 0; } - read_disc_mcn(hDevice, disc);+ if (features & DISCID_FEATURE_MCN) {+ read_disc_mcn(hDevice, disc);+ } disc->first_track_num = toc.FirstTrack; disc->last_track_num = toc.LastTrack;@@ -232,7 +234,9 @@ for (i = disc->first_track_num; i <= disc->last_track_num; i++) { disc->track_offsets[i] = AddressToSectors(toc.TrackData[i - 1].Address);- read_disc_isrc(hDevice, disc, i);+ if (features & DISCID_FEATURE_ISRC) {+ read_disc_isrc(hDevice, disc, i);+ } } CloseHandle(hDevice);
libdiscid/src/sha1.h view
@@ -10,6 +10,7 @@ #include <stdlib.h> #include <stdio.h>+#include "discid/discid.h" /* for LIBDISCID_INTERNAL */ /* Useful defines & typedefs */ typedef unsigned char SHA_BYTE; /* 8-bit quantity */@@ -25,13 +26,13 @@ int local; /* unprocessed amount in data */ } SHA_INFO; -void sha_init(SHA_INFO *);-void sha_update(SHA_INFO *, SHA_BYTE *, int);-void sha_final(unsigned char [20], SHA_INFO *);+LIBDISCID_INTERNAL void sha_init(SHA_INFO *);+LIBDISCID_INTERNAL void sha_update(SHA_INFO *, SHA_BYTE *, int);+LIBDISCID_INTERNAL void sha_final(unsigned char [20], SHA_INFO *); -void sha_stream(unsigned char [20], SHA_INFO *, FILE *);-void sha_print(unsigned char [20]);-char *sha_version(void);+LIBDISCID_INTERNAL void sha_stream(unsigned char [20], SHA_INFO *, FILE *);+LIBDISCID_INTERNAL void sha_print(unsigned char [20]);+LIBDISCID_INTERNAL char *sha_version(void); #define SHA_VERSION 1