pax_global_header00006660000000000000000000000064135733127660014527gustar00rootroot0000000000000052 comment=bbaf81f87928ea72bb63304a39ba2138ac9a7943 libmusicbrainz-discid-perl-0.06/000077500000000000000000000000001357331276600166665ustar00rootroot00000000000000libmusicbrainz-discid-perl-0.06/Changes000066400000000000000000000011161357331276600201600ustar00rootroot00000000000000Revision history for libdiscid perl bindings 0.06 Mon 7 Oct 2019 23:32:36 BST - Changed license to MIT 0.04 Tue 13 Jun 2017 22:27:29 BST - Use ExtUtils::MakeMaker instead of Module::Build - Fixed encoding in POD (RT#85212) - Fixed stack corruption in discid_put (RT#98179) - Updated tests for libdiscid 0.6.x (RT#89285) - Fixed typo in POD (RT#85212) 0.03 Wed 23 Sep 2009 22:07:22 BST - Corrections to synopsis from Adam Sjøgren 0.02 Wed 27 May 2009 23:19:11 BST - Proper tests - Added support for put method 0.01 Wed May 27 16:21:52 BST 2009 - First release libmusicbrainz-discid-perl-0.06/DiscID.xs000066400000000000000000000042151357331276600203430ustar00rootroot00000000000000/* libdiscid perl bindings Copyright 2009 Nicholas J. Humfrey */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include MODULE = MusicBrainz::DiscID PACKAGE = MusicBrainz::DiscID ## ## Return the name of the default disc drive for this operating system. ## char* discid_get_default_device() ## ## Return a handle for a new DiscId object. ## DiscId* discid_new() ## ## Release the memory allocated for the DiscId object. ## void discid_free( disc ) DiscId *disc ## ## Read the disc in the given CD-ROM/DVD-ROM drive. ## int discid_read( disc, device ) DiscId *disc char* device ## ## Return a human-readable error message. ## char* discid_get_error_msg( disc ) DiscId *disc ## ## Return a MusicBrainz DiscID. ## char* discid_get_id( disc ) DiscId *disc ## ## Return a FreeDB DiscID. ## char* discid_get_freedb_id( disc ) DiscId *disc ## ## Return an URL for submitting the DiscID to MusicBrainz. ## char* discid_get_submission_url( disc ) DiscId *disc ## ## Return the number of the first track on this disc. ## int discid_get_first_track_num( disc ) DiscId *disc ## ## Return the number of the last track on this disc. ## int discid_get_last_track_num( disc ) DiscId *disc ## ## Return the length of the disc in sectors. ## int discid_get_sectors( disc ) DiscId *disc ## ## Return the sector offset of a track. ## int discid_get_track_offset( disc, track_num ) DiscId *disc int track_num ## ## Return the length of a track in sectors. ## int discid_get_track_length( disc, track_num ) DiscId *disc int track_num ## ## Provides the TOC of a known CD. ## int discid_put( disc, first_track, sectors, offsets ... ) DiscId *disc int first_track int sectors int n_items = items; PREINIT: int i, last_track, offsets[100]; CODE: memset(offsets, 0, sizeof(offsets)); if (items > 102 ) n_items = 102; // rely on discid_put to return error for (i=3; i 'MusicBrainz::DiscID', ABSTRACT_FROM => 'lib/MusicBrainz/DiscID.pm', VERSION_FROM => 'lib/MusicBrainz/DiscID.pm', AUTHOR => 'Nicholas J. Humfrey', LICENSE => 'mit', TEST_REQUIRES => { 'Test' => '1.00', 'Test::More' => 0, 'Test::Pod' => '1.00' }, CCFLAGS => "$Config{ccflags} $LIBDISCID_CFLAGS", LIBS => $LIBDISCID_LIBS, XSPROTOARG => '-noprototypes' ); if (eval { ExtUtils::MakeMaker->VERSION(6.46) }) { $WriteMakefileArgs{META_MERGE} = { 'meta-spec' => { version => 2 }, resources => { bugtracker => { web => 'https://github.com/njh/perl-musicbrainz-discid/issues', }, repository => { type => 'git', url => 'https://github.com/njh/perl-musicbrainz-discid.git', web => 'https://github.com/njh/perl-musicbrainz-discid', }, }, } } if (!eval { ExtUtils::MakeMaker->VERSION(6.64) }) { while (my ($m, $v) = each %{$WriteMakefileArgs{TEST_REQUIRES}}) { $WriteMakefileArgs{PREREQ_PM}->{$m} = $v; } delete $WriteMakefileArgs{TEST_REQUIRES}; } WriteMakefile(%WriteMakefileArgs); libmusicbrainz-discid-perl-0.06/README.md000066400000000000000000000013401357331276600201430ustar00rootroot00000000000000libdiscid perl binding ====================== Perl binding for the libdiscid library. libdiscid library version 0.2.2 or higher is required. http://musicbrainz.org/doc/libdiscid Pkg-config version 0.11 or higher is required: http://pkgconfig.freedesktop.org/ INSTALLATION ------------ I use ExtUtils::MakeMaker to build and install the module. To install this module type the following: perl Makefile.PL make make test And then as root: make install License ------- This perl module is licensed under the terms of the MIT license. See the file LICENSE for details. Contact ------- * Author: Nicholas J Humfrey * Twitter: [@njh] * Home Page: http://njh.me/ [@njh]: http://twitter.com/njh libmusicbrainz-discid-perl-0.06/examples/000077500000000000000000000000001357331276600205045ustar00rootroot00000000000000libmusicbrainz-discid-perl-0.06/examples/discid.pl000066400000000000000000000014121357331276600222760ustar00rootroot00000000000000#!/usr/bin/perl use MusicBrainz::DiscID; use strict; my $disc = new MusicBrainz::DiscID(); # read the disc in the default disc drive */ if ( $disc->read() == 0 ) { printf STDERR "Error: %s\n", $disc->error_msg(); exit(1); } printf("DiscID : %s\n", $disc->id()); printf("FreeDB DiscID : %s\n", $disc->freedb_id()); printf("First track : %d\n", $disc->first_track_num()); printf("Last track : %d\n", $disc->last_track_num()); printf("Length : %d sectors\n", $disc->sectors()); for ( my $i = $disc->first_track_num; $i <= $disc->last_track_num; $i++ ) { printf("Track %-2d : %8d %8d\n", $i, $disc->track_offset($i), $disc->track_length($i)); } printf("Submit via : %s\n", $disc->submission_url()); undef $disc; libmusicbrainz-discid-perl-0.06/lib/000077500000000000000000000000001357331276600174345ustar00rootroot00000000000000libmusicbrainz-discid-perl-0.06/lib/MusicBrainz/000077500000000000000000000000001357331276600216625ustar00rootroot00000000000000libmusicbrainz-discid-perl-0.06/lib/MusicBrainz/DiscID.pm000066400000000000000000000135051357331276600233230ustar00rootroot00000000000000package MusicBrainz::DiscID; ################ # # libdiscid: perl bindings # # Copyright 2009-2019 Nicholas J. Humfrey # use XSLoader; use Carp; use strict; use vars qw/$VERSION/; $VERSION="0.06"; XSLoader::load('MusicBrainz::DiscID', $VERSION); sub default_device { return MusicBrainz::DiscID::discid_get_default_device(); } sub new { my $class = shift; my ($device) = @_; # Get default device if none given if (!defined $device) { $device = MusicBrainz::DiscID::discid_get_default_device(); } # Bless the hash into an object my $self = { device => $device }; bless $self, $class; # Create new DiscID instance $self->{disc} = MusicBrainz::DiscID::discid_new(); if (!defined $self->{disc}) { carp("Error creating DiscId structure"); undef $self; } return $self; } sub first_track_num { my $self = shift; return MusicBrainz::DiscID::discid_get_first_track_num($self->{disc}); } sub error_msg { my $self = shift; return MusicBrainz::DiscID::discid_get_error_msg($self->{disc}); } sub freedb_id { my $self = shift; return MusicBrainz::DiscID::discid_get_freedb_id($self->{disc}); } sub id { my $self = shift; return MusicBrainz::DiscID::discid_get_id($self->{disc}); } sub last_track_num { my $self = shift; return MusicBrainz::DiscID::discid_get_last_track_num($self->{disc}); } sub put { my $self = shift; return MusicBrainz::DiscID::discid_put($self->{disc}, @_); } sub read { my $self = shift; $self->{device} = $_[0] if (defined $_[0]); return MusicBrainz::DiscID::discid_read($self->{disc},$self->{device}); } sub sectors { my $self = shift; return MusicBrainz::DiscID::discid_get_sectors($self->{disc}); } sub submission_url { my $self = shift; return MusicBrainz::DiscID::discid_get_submission_url($self->{disc}); } sub track_offset { my $self = shift; return MusicBrainz::DiscID::discid_get_track_offset($self->{disc}, $_[0]); } sub track_length { my $self = shift; return MusicBrainz::DiscID::discid_get_track_length($self->{disc}, $_[0]); } sub DESTROY { my $self=shift; if (defined $self->{disc}) { MusicBrainz::DiscID::discid_free( $self->{disc} ); undef $self->{disc}; } } 1; __END__ =pod =head1 NAME MusicBrainz::DiscID - Perl interface for the MusicBrainz libdiscid library =head1 SYNOPSIS use MusicBrainz::DiscID; my $discid = MusicBrainz::DiscID->new(); if ( $disc->read() == 0 ) { print STDERR "Error: " . $discid->error_msg() . "\n"; exit(1); } print "DiscID: " . $discid->id() . "\n"; =head1 DESCRIPTION MusicBrainz::DiscID is a class to calculate a MusicBrainz DiscID from an audio CD in the drive. The coding style is slightly different to the C interface to libdiscid, because it makes use of perl's Object Oriented functionality. =over 4 =item MusicBrainz::DiscID::default_device() Returns a device string for the default device for this platform. =item MusicBrainz::DiscID::new( [$device] ) Construct a new DiscID object. As an optional argument the name of the device to read the ID from may be given. If you don't specify a device here you can later read the ID with the read method. =item $discid->error_msg() Return a human-readable error message of the last error that occured. =item $discid->first_track_num() Return the number of the first track on this disc (usually 1). Returns undef if no ID was yet read. =item $discid->last_track_num() Return the number of the last track on this disc. =item $discid->id() Returns the DiscID as a string. Returns undef if no ID was yet read. =item $discid->last_track_num() Return the number of the last track on this disc. Returns undef if no ID was yet read. =item $discid->put( $first_track, $sectors, $offset1, $offset2, ... ) This function may be used if the TOC has been read earlier and you want to calculate the disc ID afterwards, without accessing the disc drive. =item $discid->read( [$device] ) Read the disc ID from the given device. If no device is given the default device of the platform will be used. On error, this function returns false and sets the error message which you can access $discid->error_msg(). =item $discid->sectors() Return the length of the disc in sectors. Returns undef if no ID was yet read. =item $discid->submission_url() Returns a submission URL for the DiscID as a string. Returns undef if no ID was yet read. =item $discid->track_length( $track_num ) Return the length of a track in sectors. =item $discid->track_offset( $track_num ) Return the sector offset of a track. =back =head1 SEE ALSO L =head1 AUTHOR Nicholas J. Humfrey =head1 COPYRIGHT AND LICENSE The MIT License (MIT) Copyright (c) 2009-2019 Nicholas J Humfrey Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut libmusicbrainz-discid-perl-0.06/t/000077500000000000000000000000001357331276600171315ustar00rootroot00000000000000libmusicbrainz-discid-perl-0.06/t/00use.t000066400000000000000000000003221357331276600202470ustar00rootroot00000000000000#!/usr/bin/perl use strict; use Test; # use a BEGIN block so we print our plan before loading modules BEGIN { plan tests => 1 } # Check MusicBrainz::DiscID loads ok use MusicBrainz::DiscID; ok(1); exit; libmusicbrainz-discid-perl-0.06/t/05pod.t000066400000000000000000000003141357331276600202430ustar00rootroot00000000000000#!/usr/bin/perl # # Check that the POD documentation is Ok # use strict; use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); libmusicbrainz-discid-perl-0.06/t/10discid.t000066400000000000000000000053541357331276600207250ustar00rootroot00000000000000#!/usr/bin/perl # use strict; use Test::More; # use a BEGIN block so we print our plan before modules are loaded BEGIN { plan tests => 55 } # load modules use MusicBrainz::DiscID; # Create a new object my $disc = new MusicBrainz::DiscID(); ok( $disc ); is(ref $disc, 'MusicBrainz::DiscID'); ok( !$disc->put( 1, 140, 1 .. 100 ) ); like( $disc->error_msg, qr{Illegal (parameters|track limits)} ); ok( $disc->put( 1, 303602, 150, 9700, 25887, 39297, 53795, 63735, 77517, 94877, 107270, 123552, 135522, 148422, 161197, 174790, 192022, 205545, 218010, 228700, 239590, 255470, 266932, 288750 ) ); is( $disc->id, 'xUp1F2NkfP8s8jaeFn_Av3jNEI4-'); is( $disc->first_track_num, 1); is( $disc->freedb_id, '370fce16'); is( $disc->last_track_num, 22); is( $disc->sectors, 303602); like( $disc->submission_url, qr{http://(mm\.musicbrainz\.org/bare/cdlookup\.html|musicbrainz\.org/cdtoc/attach)\?id=xUp1F2NkfP8s8jaeFn_Av3jNEI4-&tracks=22&toc=1\+22\+303602\+150\+9700\+25887\+39297\+53795\+63735\+77517\+94877\+107270\+123552\+135522\+148422\+161197\+174790\+192022\+205545\+218010\+228700\+239590\+255470\+266932\+288750}); is( $disc->track_offset(1), 150); is( $disc->track_offset(2), 9700); is( $disc->track_offset(3), 25887); is( $disc->track_offset(4), 39297); is( $disc->track_offset(5), 53795); is( $disc->track_offset(6), 63735); is( $disc->track_offset(7), 77517); is( $disc->track_offset(8), 94877); is( $disc->track_offset(9), 107270); is( $disc->track_offset(10), 123552); is( $disc->track_offset(11), 135522); is( $disc->track_offset(12), 148422); is( $disc->track_offset(13), 161197); is( $disc->track_offset(14), 174790); is( $disc->track_offset(15), 192022); is( $disc->track_offset(16), 205545); is( $disc->track_offset(17), 218010); is( $disc->track_offset(18), 228700); is( $disc->track_offset(19), 239590); is( $disc->track_offset(20), 255470); is( $disc->track_offset(21), 266932); is( $disc->track_offset(22), 288750); is( $disc->track_length(1), 9550); is( $disc->track_length(2), 16187); is( $disc->track_length(3), 13410); is( $disc->track_length(4), 14498); is( $disc->track_length(5), 9940); is( $disc->track_length(6), 13782); is( $disc->track_length(7), 17360); is( $disc->track_length(8), 12393); is( $disc->track_length(9), 16282); is( $disc->track_length(10), 11970); is( $disc->track_length(11), 12900); is( $disc->track_length(12), 12775); is( $disc->track_length(13), 13593); is( $disc->track_length(14), 17232); is( $disc->track_length(15), 13523); is( $disc->track_length(16), 12465); is( $disc->track_length(17), 10690); is( $disc->track_length(18), 10890); is( $disc->track_length(19), 15880); is( $disc->track_length(20), 11462); is( $disc->track_length(21), 21818); is( $disc->track_length(22), 14852); undef $disc; libmusicbrainz-discid-perl-0.06/typemap000066400000000000000000000000321357331276600202630ustar00rootroot00000000000000TYPEMAP DiscId* T_PTROBJ