From ed6f60868d2bef230b7db28e910708ec09cc55b4 Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 9 Jul 2004 01:05:31 +0000 Subject: [PATCH] Start to merge in cue parsing from cuetools. Also moves forward CDTEXT from a different direction. --- example/sample8.c | 45 ++++++++++ include/cdio/cdtext.h | 58 ++++--------- lib/Makefile.am | 6 +- lib/_cdio_linux.c | 12 +-- lib/cdio.c | 20 +---- lib/cdio_private.h | 8 +- lib/cdtext.c | 132 ++++++++++++++++++++++++++++ lib/cdtext_private.h | 68 +++++++++++++++ lib/image/bincue.c | 195 +++++++++++++++++++++++++++++++++++++++++- lib/image/cdrdao.c | 40 ++------- 10 files changed, 475 insertions(+), 109 deletions(-) create mode 100644 example/sample8.c create mode 100644 lib/cdtext.c create mode 100644 lib/cdtext_private.h diff --git a/example/sample8.c b/example/sample8.c new file mode 100644 index 00000000..e4b4b9fa --- /dev/null +++ b/example/sample8.c @@ -0,0 +1,45 @@ +/* + $Id: sample8.c,v 1.1 2004/07/09 01:05:31 rocky Exp $ + + Copyright (C) 2003 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 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 +#include +#include +#include +int +main(int argc, const char *argv[]) +{ + CdIo *cdio = cdio_open (NULL, DRIVER_UNKNOWN); + + if (NULL == cdio) { + printf("Couldn't find a driver.. leaving.\n"); + return 1; + } + +#if 0 + cdio_cdtext_query(cdio); +#endif + cdio_destroy(cdio); + + return 0; +} diff --git a/include/cdio/cdtext.h b/include/cdio/cdtext.h index 8fd9d377..440d509a 100644 --- a/include/cdio/cdtext.h +++ b/include/cdio/cdtext.h @@ -1,5 +1,5 @@ /* - $Id: cdtext.h,v 1.1 2004/07/08 01:27:58 rocky Exp $ + $Id: cdtext.h,v 1.2 2004/07/09 01:05:31 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -28,49 +28,29 @@ #include -#define CDIO_CDTEXT_MAX_PACK_DATA 255 -#define CDIO_CDTEXT_MAX_TEXT_DATA 12 +typedef struct cdtext cdtext_t; -#define CDIO_CDTEXT_TITLE 0x80 -#define CDIO_CDTEXT_PERFORMER 0x81 -#define CDIO_CDTEXT_SONGWRITER 0x82 -#define CDIO_CDTEXT_COMPOSER 0x83 -#define CDIO_CDTEXT_ARRANGER 0x84 -#define CDIO_CDTEXT_MESSAGE 0x85 -#define CDIO_CDTEXT_DISCID 0x86 -#define CDIO_CDTEXT_GENRE 0x87 +/*! Initialize and allocate a new cdtext structure and return a + pointer to that. When the structure is no longer needed, release the + resources using cdtext_delete. +*/ +cdtext_t *cdtext_init (void); -PRAGMA_BEGIN_PACKED +/*! Free memory assocated with cdtext*/ +void cdtext_delete (cdtext_t *cdtext); -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +/*! + returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise. +*/ +int cdtext_is_keyword (char *key); -struct CDText_data -{ - uint8_t type; - track_t i_track; - uint8_t seq; - uint8_t characterPosition:4; /* character position */ - uint8_t block:3; /* block number 0..7 */ - uint8_t bDBC:1; /* double byte character */ - char text[12]; - uint8_t crc[2]; -} GNUC_PACKED; - -PRAGMA_END_PACKED - -typedef struct CDText_data CDText_data_t; - -/** - * Query the CDTEXT information - * - * @param cd The CD object to extract CDTEXT data from - * - * @return An allocated structure containing CDTEXT information found. - * NULL is returned if there was a problem. +/*! + sets cdtext's keyword entry to field */ -CDText_data_t *cdio_cdtext_query(const CdIo *cd); +void cdtext_set (char *key, char *value, cdtext_t *cdtext); + +char *cdtext_get (char *key, cdtext_t *cdtext); + #ifdef __cplusplus } diff --git a/lib/Makefile.am b/lib/Makefile.am index 79dada8d..770c7e5e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.40 2004/06/27 22:00:09 rocky Exp $ +# $Id: Makefile.am,v 1.41 2004/07/09 01:05:31 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -65,8 +65,10 @@ libcdio_sources = \ _cdio_sunos.c \ bytesex.h \ bytesex_asm.h \ - cdio.c \ cd_types.c \ + cdio.c \ + cdtext.c \ + cdtext_private.h \ ds.c \ ds.h \ FreeBSD/freebsd.c \ diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index ef1e78b7..fb158260 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rocky Exp $ + $Id: _cdio_linux.c,v 1.61 2004/07/09 01:05:32 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.61 2004/07/09 01:05:32 rocky Exp $"; #include @@ -35,6 +35,7 @@ static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rock #include #include #include +#include "cdtext_private.h" #include "cdio_assert.h" #include "cdio_private.h" @@ -674,11 +675,11 @@ _cdio_read_toc (_img_private_t *env) return true; } +#ifdef CDTEXT_FIXED static CDText_data_t * -_cdtext_query( void *user_data ) +cdtext_init( void *user_data ) { -#ifdef CDTEXT_FIXED _img_private_t *env = user_data; CDText_data_t *pdata; int i; @@ -778,9 +779,9 @@ _cdtext_query( void *user_data ) } pdata++; } -#endif return NULL; /* FIXME */ } +#endif /* * Eject using SCSI commands. Return 1 if successful, 0 otherwise. @@ -1212,7 +1213,6 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode) char *psz_source; cdio_funcs _funcs = { - .cdtext_query = _cdtext_query, .eject_media = _eject_media_linux, .free = cdio_generic_free, .get_arg = _get_arg_linux, diff --git a/lib/cdio.c b/lib/cdio.c index 7416dfce..64cfe7a6 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.57 2004/07/08 01:28:00 rocky Exp $ + $Id: cdio.c,v 1.58 2004/07/09 01:05:32 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -39,7 +39,7 @@ #include #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.57 2004/07/08 01:28:00 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.58 2004/07/09 01:05:32 rocky Exp $"; const char *track_format2str[6] = @@ -212,22 +212,6 @@ scan_for_driver(driver_id_t start, driver_id_t end, return NULL; } -/*! - Return the value associatied with key. NULL is returned if obj is NULL - or "key" does not exist. - */ -CDText_data_t * -cdio_cdtext_query (const CdIo *obj) -{ - if (obj == NULL) return NULL; - - if (obj->op.get_arg) { - return obj->op.cdtext_query (obj->env); - } else { - return NULL; - } -} - const char * cdio_driver_describe(driver_id_t driver_id) { diff --git a/lib/cdio_private.h b/lib/cdio_private.h index 0bc37e4a..2e4c0434 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.25 2004/07/08 01:28:00 rocky Exp $ + $Id: cdio_private.h,v 1.26 2004/07/09 01:05:32 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -40,12 +40,6 @@ extern "C" { typedef struct { - /*! - Return an allocated structure containing CDTEXT information found. - NULL is returned if there was a problem. - */ - CDText_data_t * (*cdtext_query) (void *env); - /*! Eject media in CD drive. If successful, as a side effect we also free obj. Return 0 if success and 1 for failure. diff --git a/lib/cdtext.c b/lib/cdtext.c new file mode 100644 index 00000000..34196342 --- /dev/null +++ b/lib/cdtext.c @@ -0,0 +1,132 @@ +/* + $Id: cdtext.c,v 1.1 2004/07/09 01:05:32 rocky Exp $ + + Copyright (C) 2004 Rocky Bernstein + toc reading routine adapted from cuetools + Copyright (C) 2003 Svend Sanjay Sorensen + + 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 +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +/* Private type */ +struct cdtext { + const char *key; + char *value; +}; + +const cdtext_t cdtext[] = { + {"TITLE", NULL}, + {"PERFORMER", NULL}, + {"SONGWRITER", NULL}, + {"COMPOSER", NULL}, + {"ARRANGER", NULL}, + {"MESSAGE", NULL}, + {"DISC_ID", NULL}, + {"GENRE", NULL}, + {"TOC_INFO", NULL}, + {"TOC_INFO2", NULL}, + {"UPC_EAN", NULL}, + {"ISRC", NULL}, + {"SIZE_INFO", NULL}, + {NULL, NULL} + }; + +cdtext_t *cdtext_init () +{ + cdtext_t *new_cdtext = NULL; + + new_cdtext = (cdtext_t *) calloc (sizeof (cdtext) / sizeof (cdtext_t), + sizeof (cdtext_t)); + if (NULL == new_cdtext) + cdio_warn("problem allocating memory"); + else + memcpy (new_cdtext, cdtext, sizeof(cdtext)); + + return (new_cdtext); +} + + +/*! Free memory assocated with cdtext*/ +void cdtext_delete (cdtext_t *cdtext) +{ + int i; + + if (NULL != cdtext) { + for (i = 0; NULL != cdtext[i].key; i++) + free (cdtext[i].value); + free (cdtext); + } +} + +/*! + returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise +*/ +int +cdtext_is_keyword (char *key) +{ + const char *cdtext_keywords[] = + { + "ARRANGER", /* name(s) of the arranger(s) */ + "COMPOSER", /* name(s) of the composer(s) */ + "DISC ID", /* disc identification information */ + "GENRE", /* genre identification and genre information */ + "ISRC", /* ISRC code of each track */ + "MESSAGE", /* message(s) from the content provider and/or artist */ + "PERFORMER", /* name(s) of the performer(s) */ + "SIZE_INFO", /* size information of the block */ + "SONGWRITER", /* name(s) of the songwriter(s) */ + "TITLE", /* title of album name or track titles */ + "TOC_INFO", /* table of contents information */ + "TOC_INFO2" /* second table of contents information */ + "UPC_EAN", + }; + + char *item; + + item = bsearch(key, + cdtext_keywords, 12, + sizeof (char *), + (int (*)(const void *, const void *)) + strcmp); + return (NULL != item) ? 0 : 1; +} + +/*! sets cdtext's keyword entry to field. + */ +void cdtext_set (char *key, char *value, cdtext_t *cdtext) +{ + if (NULL != value) /* don't pass NULL to strdup! */ + for (; NULL != cdtext->key; cdtext++) + if (0 == strcmp (cdtext->key, key)) { + free (cdtext->value); + cdtext->value = strdup (value); + } +} + diff --git a/lib/cdtext_private.h b/lib/cdtext_private.h new file mode 100644 index 00000000..4bf747be --- /dev/null +++ b/lib/cdtext_private.h @@ -0,0 +1,68 @@ +/* + $Id: cdtext_private.h,v 1.1 2004/07/09 01:05:32 rocky Exp $ + + Copyright (C) 2004 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 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 +*/ + +#ifndef __CDIO_CDTEXT_PRIVATE_H__ +#define __CDIO_CDTEXT_PRIVATE_H__ + +#include + +#define CDIO_CDTEXT_MAX_PACK_DATA 255 +#define CDIO_CDTEXT_MAX_TEXT_DATA 12 + +#define CDIO_CDTEXT_TITLE 0x80 +#define CDIO_CDTEXT_PERFORMER 0x81 +#define CDIO_CDTEXT_SONGWRITER 0x82 +#define CDIO_CDTEXT_COMPOSER 0x83 +#define CDIO_CDTEXT_ARRANGER 0x84 +#define CDIO_CDTEXT_MESSAGE 0x85 +#define CDIO_CDTEXT_DISCID 0x86 +#define CDIO_CDTEXT_GENRE 0x87 + +PRAGMA_BEGIN_PACKED + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct CDText_data +{ + uint8_t type; + track_t i_track; + uint8_t seq; + uint8_t characterPosition:4; /* character position */ + uint8_t block:3; /* block number 0..7 */ + uint8_t bDBC:1; /* double byte character */ + char text[12]; + uint8_t crc[2]; +} GNUC_PACKED; + +PRAGMA_END_PACKED + +typedef struct CDText_data CDText_data_t; + +#endif /* __CDIO_CDTEXT_PRIVATE_H__ */ + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/lib/image/bincue.c b/lib/image/bincue.c index 9831a26d..d523f781 100644 --- a/lib/image/bincue.c +++ b/lib/image/bincue.c @@ -1,5 +1,5 @@ /* - $Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $ + $Id: bincue.c,v 1.24 2004/07/09 01:05:32 rocky Exp $ Copyright (C) 2002, 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -24,7 +24,7 @@ (*.cue). */ -static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $"; +static const char _rcsid[] = "$Id: bincue.c,v 1.24 2004/07/09 01:05:32 rocky Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -33,6 +33,7 @@ static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp #include #include #include +#include #ifdef HAVE_STDIO_H #include @@ -65,6 +66,37 @@ static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp #define DEFAULT_CDIO_DEVICE "videocd.bin" #define DEFAULT_CDIO_CUE "videocd.cue" +/* track modes (Table 350) */ +typedef enum { + AUDIO, /* 2352 byte block length */ + MODE1, /* 2048 byte block length */ + MODE1_RAW, /* 2352 byte block length */ + MODE2, /* 2336 byte block length */ + MODE2_FORM1, /* 2048 byte block length */ + MODE2_FORM2, /* 2324 byte block length */ + MODE2_FORM_MIX, /* 2336 byte block length */ + MODE2_RAW /* 2352 byte block length */ +} trackmode_t; + +/* disc modes (5.29.2.8) */ +typedef enum { + CD_DA, /* CD-DA */ + CD_ROM, /* CD-ROM mode 1 */ + CD_ROM_XA /* CD-ROM XA and CD-I */ +} discmode_t; + +/* track flags + * Q Sub-channel Control Field (4.2.3.3) + */ +typedef enum { + NONE = 0x00, /* no flags set */ + PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */ + COPY_PERMITTED = 0x02, /* digital copy permitted */ + DATA = 0x04, /* data track */ + FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */ + SCMS = 0x10 /* SCMS (5.29.2.7) */ +} flag_t; + typedef struct { track_t track_num; /* Probably is index+1 */ msf_t start_msf; @@ -73,9 +105,15 @@ typedef struct { int sec_count; /* Number of sectors in this track. Does not include pregap */ int num_indices; - int flags; /* "DCP", "4CH", "PRE" */ + flag_t flags; /* "DCP", "4CH", "PRE" */ track_format_t track_format; + char *filename; bool track_green; + long int pregap; /* pre-gap with zero audio data */ + char *isrc; /* IRSC Code (5.22.4) exactly 12 bytes */ + cdtext_t *cdtext; /* CD-TEXT */ + + trackmode_t mode; uint16_t datasize; /* How much is in the portion we return back? */ uint16_t datastart; /* Offset from begining that data starts */ uint16_t endsize; /* How much stuff at the end to skip over. This @@ -99,6 +137,8 @@ typedef struct { add 1 for leadout. */ track_t i_tracks; /* number of tracks in image */ track_t i_first_track; /* track number of first track */ + char *catalog; + cdtext_t *cdtext; /* CD-TEXT */ bool have_cue; } _img_private_t; @@ -301,7 +341,154 @@ _stat_size_bincue (void *user_data) return size; } -#define MAXLINE 512 +#define MAXLINE 4096 /* maximum line length + 1 */ + +static void +parse_cue (_img_private_t *cd, char *line, int line_num) +{ + char *keyword, *field; + int i = cd->i_tracks - 1; + + if (NULL != (keyword = strtok (line, " \t\n\r"))) { + /* REM remarks ... */ + if (0 == strcmp ("REM", keyword)) { + ; + + /* global section */ + /* CATALOG ddddddddddddd */ + } else if (0 == strcmp ("CATALOG", keyword)) { + if (-1 == i) { + if (NULL != (field = strtok (NULL, " \t\n\r"))) + cd->catalog = strdup (field); + if (NULL != (field = strtok (NULL, " \t\n\r"))) + fprintf (stderr, "%s: format error\n", keyword); + } else { + fprintf (stderr, "%d: only allowed in global section: %s\n", + line_num, keyword); + } + + /* FILE "" */ + } else if (0 == strcmp ("FILE", keyword)) { + if (NULL != (field = strtok (NULL, "\"\t\n\r"))) + cd->tocent[i + 1].filename = strdup (field); + else + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + + /* TRACK N */ + } else if (0 == strcmp ("TRACK", keyword)) { + i++; + cd->tocent[i].cdtext = NULL; + if (NULL != (field = strtok (NULL, " \t\n\r"))) + ; /* skip index number */ + if (NULL != (field = strtok (NULL, " \t\n\r"))) { + if (0 == strcmp ("AUDIO", field)) + cd->tocent[i].mode = AUDIO; + else if (0 == strcmp ("MODE1/2048", field)) + cd->tocent[i].mode = MODE1; + else if (0 == strcmp ("MODE1/2352", field)) + cd->tocent[i].mode = MODE1_RAW; + else if (0 == strcmp ("MODE2/2336", field)) + cd->tocent[i].mode = MODE2; + else if (0 == strcmp ("MODE2/2048", field)) + cd->tocent[i].mode = MODE2_FORM1; + else if (0 == strcmp ("MODE2/2324", field)) + cd->tocent[i].mode = MODE2_FORM2; + else if (0 == strcmp ("MODE2/2336", field)) + cd->tocent[i].mode = MODE2_FORM_MIX; + else if (0 == strcmp ("MODE2/2352", field)) + cd->tocent[i].mode = MODE2_RAW; + else + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } else { + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } + + /* FLAGS flag1 flag2 ... */ + } else if (0 == strcmp ("FLAGS", keyword)) { + if (0 <= i) { + while (NULL != (field = strtok (NULL, " \t\n\r"))) { + if (0 == strcmp ("PRE", field)) { + cd->tocent[i].flags |= PRE_EMPHASIS; + } else if (0 == strcmp ("DCP", field)) { + cd->tocent[i].flags |= COPY_PERMITTED; + } else if (0 == strcmp ("4CH", field)) { + cd->tocent[i].flags |= FOUR_CHANNEL_AUDIO; + } else if (0 == strcmp ("SCMS", field)) { + cd->tocent[i].flags |= SCMS; + } else { + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } + } + } else { + fprintf (stderr, "%d: not allowed in global section: %s\n", line_num, + keyword); + } + + /* ISRC CCOOOYYSSSSS */ + } else if (0 == strcmp ("ISRC", keyword)) { + if (0 <= i) { + if (NULL != (field = strtok (NULL, " \t\n\r"))) + cd->tocent[i].isrc = strdup (field); + else + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } else { + fprintf (stderr, "%d: not allowed in global section: %s\n", + line_num, keyword); + } + + /* PREGAP MM:SS:FF */ + } else if (0 == strcmp ("PREGAP", keyword)) { + if (0 <= i) { + if (NULL != (field = strtok (NULL, " \t\n\r"))) + cd->tocent[i].pregap = msf_frame_from_mmssff (field); + else + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + if (NULL != (field = strtok (NULL, " \t\n\r"))) + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } else { + fprintf (stderr, "%d: not allowed in global section: %s\n", + line_num, keyword); + } + + /* INDEX [##] MM:SS:FF */ + } else if (0 == strcmp ("INDEX", keyword)) { + if (0 <= i) { + if (NULL != (field = strtok (NULL, " \t\n\r"))) + ; /* skip index number */ + if (NULL != (field = strtok (NULL, " \t\n\r"))) +#if 0 + // cd->tocent[i].indexes[cd->tocent[i].nindex++] = msf_frame_from_mmssff (field); +#else + ; +#endif + else + fprintf (stderr, "%d: format error: %s\n", line_num, keyword); + } else { + fprintf (stderr, "%d: not allowed in global section: %s\n", + line_num, keyword); + } + + /* CD-TEXT */ + } else if (0 == cdtext_is_keyword (keyword)) { + if (-1 == i) { + if (NULL == cd->cdtext) + cd->cdtext = cdtext_init (); + cdtext_set (keyword, strtok (NULL, "\"\t\n\r"), cd->cdtext); + } else { + if (NULL == cd->tocent[i].cdtext) + cd->tocent[i].cdtext = cdtext_init (); + cdtext_set (keyword, strtok (NULL, "\"\t\n\r"), cd->tocent[i].cdtext); + } + + /* unrecognized line */ + } else { + fprintf(stderr, "%d: warning: unrecognized keyword: %s\n", + line_num, keyword); + } + } + + cd->i_tracks = i + 1; +} static bool _bincue_image_read_cue (_img_private_t *env) diff --git a/lib/image/cdrdao.c b/lib/image/cdrdao.c index e7740691..c6e1c9a4 100644 --- a/lib/image/cdrdao.c +++ b/lib/image/cdrdao.c @@ -1,5 +1,5 @@ /* - $Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $ + $Id: cdrdao.c,v 1.11 2004/07/09 01:05:32 rocky Exp $ Copyright (C) 2004 Rocky Bernstein toc reading routine adapted from cuetools @@ -25,7 +25,11 @@ (*.cue). */ -static const char _rcsid[] = "$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static const char _rcsid[] = "$Id: cdrdao.c,v 1.11 2004/07/09 01:05:32 rocky Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -34,6 +38,7 @@ static const char _rcsid[] = "$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp #include #include #include +#include #ifdef HAVE_STDIO_H #include @@ -119,37 +124,6 @@ static bool parse_tocfile (_img_private_t *cd, const char *toc_name); #include "image_common.h" -/* returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise */ -static int -cdtext_is_keyword (char *key) -{ - const char *cdtext_keywords[] = - { - "ARRANGER", /* name(s) of the arranger(s) */ - "COMPOSER", /* name(s) of the composer(s) */ - "DISC ID", /* disc identification information */ - "GENRE", /* genre identification and genre information */ - "ISRC", /* ISRC code of each track */ - "MESSAGE", /* message(s) from the content provider and/or artist */ - "PERFORMER", /* name(s) of the performer(s) */ - "SIZE_INFO", /* size information of the block */ - "SONGWRITER", /* name(s) of the songwriter(s) */ - "TITLE", /* title of album name or track titles */ - "TOC_INFO", /* table of contents information */ - "TOC_INFO2" /* second table of contents information */ - "UPC_EAN", - }; - - char *item; - - item = bsearch(key, - cdtext_keywords, 12, - sizeof (char *), - (int (*)(const void *, const void *)) - strcmp); - return (NULL != item) ? 0 : 1; -} - static lba_t msf_to_lba (int minutes, int seconds, int frames) {