diff --git a/include/cdio/cdtext.h b/include/cdio/cdtext.h index fbd932f7..66369261 100644 --- a/include/cdio/cdtext.h +++ b/include/cdio/cdtext.h @@ -1,5 +1,5 @@ /* - $Id: cdtext.h,v 1.10 2005/01/29 20:54:20 rocky Exp $ + $Id: cdtext.h,v 1.11 2005/04/25 23:06:21 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein adapted from cuetools @@ -85,6 +85,17 @@ extern "C" { input here. */ char *cdtext_get (cdtext_field_t key, const cdtext_t *cdtext); + + /*! returns a const string associated with the given field. NULL is + returned if key is CDTEXT_INVALID or the field is not set. + + Don't use the string when the cdtext object (i.e. the CdIo_t object + you got it from) is no longer valid. + + @see cdio_get_cdtext to retrieve the cdtext structure used as + input here. + */ + const char *cdtext_get_const (cdtext_field_t key, const cdtext_t *cdtext); /*! returns enum of keyword if key is a CD-Text keyword, diff --git a/lib/driver/cdtext.c b/lib/driver/cdtext.c index 4cdc5b43..c6de8219 100644 --- a/lib/driver/cdtext.c +++ b/lib/driver/cdtext.c @@ -1,5 +1,5 @@ /* - $Id: cdtext.c,v 1.4 2005/03/23 11:15:25 rocky Exp $ + $Id: cdtext.c,v 1.5 2005/04/25 23:06:21 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein toc reading routine adapted from cuetools @@ -89,10 +89,18 @@ cdtext_destroy (cdtext_t *p_cdtext) char * cdtext_get (cdtext_field_t key, const cdtext_t *p_cdtext) { - if (key == CDTEXT_INVALID) return NULL; + if ((key == CDTEXT_INVALID) || (!p_cdtext->field[key])) return NULL; return strdup(p_cdtext->field[key]); } +const char * +cdtext_get_const (cdtext_field_t key, const cdtext_t *p_cdtext) +{ + if (key == CDTEXT_INVALID) return NULL; + return p_cdtext->field[key]; +} + + /*! Initialize a new cdtext structure. When the structure is no longer needed, release the resources using cdtext_delete. diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym index 977b0d23..cd4155cd 100644 --- a/lib/driver/libcdio.sym +++ b/lib/driver/libcdio.sym @@ -158,6 +158,7 @@ cdio_warn cdtext_destroy cdtext_field2str cdtext_get +cdtext_get_const cdtext_init cdtext_is_keyword cdtext_set