From Burkhard Plaum:
1. Fix a crash, which happened when cdtext_get() was called for an emtp= y (i.e. NULL) field. 2. Add another function cdtext_get_const(), which returns a const point= er and avoids too much strcpying (apps may want only to TEST if a field is present or have their own string management routines).
This commit is contained in:
@@ -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 <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
adapted from cuetools
|
adapted from cuetools
|
||||||
@@ -85,6 +85,17 @@ extern "C" {
|
|||||||
input here.
|
input here.
|
||||||
*/
|
*/
|
||||||
char *cdtext_get (cdtext_field_t key, const cdtext_t *cdtext);
|
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,
|
returns enum of keyword if key is a CD-Text keyword,
|
||||||
|
|||||||
@@ -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 <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
toc reading routine adapted from cuetools
|
toc reading routine adapted from cuetools
|
||||||
@@ -89,10 +89,18 @@ cdtext_destroy (cdtext_t *p_cdtext)
|
|||||||
char *
|
char *
|
||||||
cdtext_get (cdtext_field_t key, const cdtext_t *p_cdtext)
|
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]);
|
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.
|
/*! Initialize a new cdtext structure.
|
||||||
When the structure is no longer needed, release the
|
When the structure is no longer needed, release the
|
||||||
resources using cdtext_delete.
|
resources using cdtext_delete.
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ cdio_warn
|
|||||||
cdtext_destroy
|
cdtext_destroy
|
||||||
cdtext_field2str
|
cdtext_field2str
|
||||||
cdtext_get
|
cdtext_get
|
||||||
|
cdtext_get_const
|
||||||
cdtext_init
|
cdtext_init
|
||||||
cdtext_is_keyword
|
cdtext_is_keyword
|
||||||
cdtext_set
|
cdtext_set
|
||||||
|
|||||||
Reference in New Issue
Block a user