discid (http://discid.sourceforge.net/) using libcdio.
This commit is contained in:
1
example/.gitignore
vendored
1
example/.gitignore
vendored
@@ -11,6 +11,7 @@
|
|||||||
/cdio-eject
|
/cdio-eject
|
||||||
/cdtext
|
/cdtext
|
||||||
/device
|
/device
|
||||||
|
/discid
|
||||||
/drives
|
/drives
|
||||||
/eject
|
/eject
|
||||||
/isofile
|
/isofile
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if BUILD_CD_PARANOIA
|
|||||||
paranoia_progs = paranoia paranoia2
|
paranoia_progs = paranoia paranoia2
|
||||||
endif
|
endif
|
||||||
if BUILD_EXAMPLES
|
if BUILD_EXAMPLES
|
||||||
noinst_PROGRAMS = audio cdchange cdtext device drives eject \
|
noinst_PROGRAMS = audio cdchange cdtext device discid drives eject \
|
||||||
isofile isofile2 isofuzzy isolist isolsn \
|
isofile isofile2 isofuzzy isolist isolsn \
|
||||||
mmc1 mmc2 mmc2a mmc3 $(paranoia_progs) tracks \
|
mmc1 mmc2 mmc2a mmc3 $(paranoia_progs) tracks \
|
||||||
sample3 sample4 udf1 udffile cdio-eject
|
sample3 sample4 udf1 udffile cdio-eject
|
||||||
@@ -45,6 +45,9 @@ cdtext_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
|||||||
device_DEPENDENCIES = $(LIBCDIO_DEPS)
|
device_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
device_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
device_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||||
|
|
||||||
|
discid_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
|
discid_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||||
|
|
||||||
drives_DEPENDENCIES = $(LIBCDIO_DEPS)
|
drives_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
drives_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
drives_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ cdio-eject.c: a stripped-down "eject" command to open or close a CDROM
|
|||||||
|
|
||||||
cdtext.c: A program to show CD-Text and CD disc mode info.
|
cdtext.c: A program to show CD-Text and CD disc mode info.
|
||||||
|
|
||||||
|
discid.c: http://sourceforge.net/projects/discid/ using libcdio:
|
||||||
|
a small program to calculate the disc-ID for audio
|
||||||
|
compact discs. The disc-ID can be used to query info
|
||||||
|
(tracks, title, interpret) about compact audio discs from
|
||||||
|
a CDDB-Server.
|
||||||
|
|
||||||
drives.c: A program to show drivers installed and what the default
|
drives.c: A program to show drivers installed and what the default
|
||||||
CD-ROM drive is and what CD drives are available.
|
CD-ROM drive is and what CD drives are available.
|
||||||
|
|
||||||
|
|||||||
83
example/discid.c
Normal file
83
example/discid.c
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2011
|
||||||
|
Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* http://sourceforge.net/projects/discid/ using libcdio:
|
||||||
|
|
||||||
|
a small program to calculate the disc-ID for audio compact
|
||||||
|
discs. The disc-ID can be used to query info (tracks, title,
|
||||||
|
interpret) about compact audio discs from a CDDB-Server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
|
||||||
|
static int cddb_sum(int n)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
while (n > 0)
|
||||||
|
{
|
||||||
|
result += n % 10;
|
||||||
|
n /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
CdIo_t *p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
|
||||||
|
track_t i_track;
|
||||||
|
track_t i_tracks;
|
||||||
|
unsigned n = 0;
|
||||||
|
|
||||||
|
if (NULL == p_cdio) {
|
||||||
|
printf("Couldn't find a driver.. leaving.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i_tracks = cdio_get_num_tracks(p_cdio);
|
||||||
|
for (i_track = 1; i_track <= i_tracks; ++i_track) {
|
||||||
|
lba_t lba = cdio_get_track_lba(p_cdio, i_track);
|
||||||
|
n += cddb_sum(lba / CDIO_CD_FRAMES_PER_SEC);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
unsigned start_sec =
|
||||||
|
cdio_get_track_lba(p_cdio, 1) / CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
unsigned leadout_sec =
|
||||||
|
cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
|
||||||
|
/ CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
unsigned total = leadout_sec - start_sec;
|
||||||
|
unsigned id = ((n % 0xff) << 24 | total << 8 | i_tracks);
|
||||||
|
|
||||||
|
printf("%08X %d", id, i_tracks);
|
||||||
|
for (i_track = 1; i_track <= i_tracks; ++i_track) {
|
||||||
|
lba_t lba = cdio_get_track_lba(p_cdio, i_track);
|
||||||
|
printf(" %ld", (long) lba);
|
||||||
|
}
|
||||||
|
printf(" %ld\n", (long) cdio_get_track_lba(p_cdio,
|
||||||
|
CDIO_CDROM_LEADOUT_TRACK)
|
||||||
|
/ CDIO_CD_FRAMES_PER_SEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
cdio_destroy(p_cdio);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
lib/.gitignore
vendored
1
lib/.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
|
/*~
|
||||||
/Makefile
|
/Makefile
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
|
|||||||
Reference in New Issue
Block a user