2004-07-09 01:05:31 +00:00
|
|
|
/*
|
2004-07-25 20:59:29 +00:00
|
|
|
$Id: sample8.c,v 1.9 2004/07/25 20:59:29 rocky Exp $
|
2004-07-09 01:05:31 +00:00
|
|
|
|
|
|
|
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
|
|
|
|
|
|
|
|
|
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 2 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, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Simple program to list CDTEXT info of a Compact Disc using libcdio. */
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <cdio/cdio.h>
|
|
|
|
|
#include <cdio/cdtext.h>
|
2004-07-17 02:18:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_cdtext_track_info(CdIo *cdio, track_t i_track, const char *message) {
|
2004-07-21 10:19:20 +00:00
|
|
|
const cdtext_t *cdtext = cdio_get_cdtext(cdio, 0);
|
2004-07-17 02:18:26 +00:00
|
|
|
if (NULL != cdtext) {
|
|
|
|
|
cdtext_field_t i;
|
|
|
|
|
|
|
|
|
|
printf("%s\n", message);
|
|
|
|
|
|
|
|
|
|
for (i=0; i < MAX_CDTEXT_FIELDS; i++) {
|
|
|
|
|
if (cdtext->field[i]) {
|
|
|
|
|
printf("\t%s: %s\n", cdtext_field2str(i), cdtext->field[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-21 10:19:20 +00:00
|
|
|
|
2004-07-17 02:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-24 06:11:30 +00:00
|
|
|
print_disc_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) {
|
2004-07-17 02:18:26 +00:00
|
|
|
track_t i_last_track = i_first_track+i_tracks;
|
2004-07-21 11:01:23 +00:00
|
|
|
discmode_t cd_discmode = cdio_get_discmode(cdio);
|
2004-07-21 10:19:20 +00:00
|
|
|
|
2004-07-21 11:01:23 +00:00
|
|
|
switch (cd_discmode) {
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_CD_DA:
|
|
|
|
|
printf("CD-DA\n");
|
2004-07-21 10:19:20 +00:00
|
|
|
break;
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_CD_DATA:
|
|
|
|
|
printf("CD-ROM form 1");
|
2004-07-21 10:19:20 +00:00
|
|
|
break;
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_CD_XA:
|
|
|
|
|
printf("CD-ROM XA form2");
|
2004-07-21 10:19:20 +00:00
|
|
|
break;
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_CD_MIXED:
|
|
|
|
|
printf("CD-ROM mixed mode");
|
2004-07-21 11:01:23 +00:00
|
|
|
break;
|
2004-07-25 03:17:47 +00:00
|
|
|
case CDIO_DISC_MODE_DVD_ROM:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD-ROM");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_RAM:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD-RAM");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_R:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD-R");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_RW:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD-RW");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_PR:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD+R");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_PRW:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("DVD+RW");
|
2004-07-25 03:17:47 +00:00
|
|
|
break;
|
|
|
|
|
case CDIO_DISC_MODE_DVD_OTHER:
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("Unknown/unclassified DVD");
|
2004-07-21 11:01:23 +00:00
|
|
|
break;
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_NO_INFO:
|
|
|
|
|
printf("No information");
|
2004-07-21 11:01:23 +00:00
|
|
|
break;
|
2004-07-25 20:59:29 +00:00
|
|
|
case CDIO_DISC_MODE_ERROR:
|
|
|
|
|
printf("Error in getting information");
|
2004-07-21 10:19:20 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2004-07-25 20:59:29 +00:00
|
|
|
printf("\n");
|
2004-07-17 02:18:26 +00:00
|
|
|
|
|
|
|
|
print_cdtext_track_info(cdio, 0, "\nCD-TEXT for Disc:");
|
|
|
|
|
for ( ; i_first_track < i_last_track; i_first_track++ ) {
|
|
|
|
|
char msg[50];
|
|
|
|
|
sprintf(msg, "CD-TEXT for Track %d:", i_first_track);
|
|
|
|
|
print_cdtext_track_info(cdio, i_first_track, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-09 01:05:31 +00:00
|
|
|
int
|
|
|
|
|
main(int argc, const char *argv[])
|
|
|
|
|
{
|
2004-07-21 10:19:20 +00:00
|
|
|
track_t i_first_track;
|
|
|
|
|
track_t i_tracks;
|
2004-07-17 02:18:26 +00:00
|
|
|
CdIo *cdio = cdio_open ("../test/cdda.cue", DRIVER_BINCUE);
|
|
|
|
|
|
2004-07-09 01:05:31 +00:00
|
|
|
|
|
|
|
|
if (NULL == cdio) {
|
2004-07-21 10:19:20 +00:00
|
|
|
printf("Couldn't open ../test/cdda.cue with BIN/CUE driver.\n");
|
2004-07-11 14:25:07 +00:00
|
|
|
} else {
|
2004-07-21 10:19:20 +00:00
|
|
|
i_first_track = cdio_get_first_track_num(cdio);
|
|
|
|
|
i_tracks = cdio_get_num_tracks(cdio);
|
2004-07-24 06:11:30 +00:00
|
|
|
print_disc_info(cdio, i_tracks, i_first_track);
|
2004-07-21 10:19:20 +00:00
|
|
|
cdio_destroy(cdio);
|
2004-07-09 01:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
2004-07-13 03:45:15 +00:00
|
|
|
cdio = cdio_open (NULL, DRIVER_UNKNOWN);
|
2004-07-17 02:18:26 +00:00
|
|
|
i_first_track = cdio_get_first_track_num(cdio);
|
|
|
|
|
i_tracks = cdio_get_num_tracks(cdio);
|
2004-07-13 03:45:15 +00:00
|
|
|
|
|
|
|
|
if (NULL == cdio) {
|
|
|
|
|
printf("Couldn't find CD\n");
|
|
|
|
|
return 1;
|
|
|
|
|
} else {
|
2004-07-24 06:11:30 +00:00
|
|
|
print_disc_info(cdio, i_tracks, i_first_track);
|
2004-07-13 03:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cdio_destroy(cdio);
|
|
|
|
|
|
2004-07-09 01:05:31 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|