cue_tag: added function cue_tag()

Merge code from cue_tag_file() and cue_tag_string().
This commit is contained in:
Max Kellermann 2009-12-16 20:49:03 +01:00
parent 67c41033c1
commit b89281411f
2 changed files with 30 additions and 18 deletions

View File

@ -171,11 +171,31 @@ cue_tag_merge(struct tag *a, struct tag *b)
return NULL; return NULL;
} }
struct tag *
cue_tag(struct Cd *cd, unsigned tnum)
{
struct tag *cd_tag, *track_tag;
assert(cd != NULL);
if (tnum > 256)
return NULL;
/* tag from CDtext info */
cd_tag = cue_tag_cd(cd_get_cdtext(cd), cd_get_rem(cd));
/* tag from TRACKtext info */
track_tag = cue_tag_track(track_get_cdtext(cd_get_track(cd, tnum)),
track_get_rem(cd_get_track(cd, tnum)));
return cue_tag_merge(cd_tag, track_tag);
}
struct tag * struct tag *
cue_tag_file(FILE *fp, unsigned tnum) cue_tag_file(FILE *fp, unsigned tnum)
{ {
struct Cd *cd; struct Cd *cd;
struct tag *cd_tag, *track_tag; struct tag *tag;
assert(fp != NULL); assert(fp != NULL);
@ -186,23 +206,17 @@ cue_tag_file(FILE *fp, unsigned tnum)
if (cd == NULL) if (cd == NULL)
return NULL; return NULL;
/* tag from CDtext info */ tag = cue_tag(cd, tnum);
cd_tag = cue_tag_cd(cd_get_cdtext(cd), cd_get_rem(cd));
/* tag from TRACKtext info */
track_tag = cue_tag_track(track_get_cdtext(cd_get_track(cd, tnum)),
track_get_rem(cd_get_track(cd, tnum)));
cd_delete(cd); cd_delete(cd);
return cue_tag_merge(cd_tag, track_tag); return tag;
} }
struct tag * struct tag *
cue_tag_string(const char *str, unsigned tnum) cue_tag_string(const char *str, unsigned tnum)
{ {
struct Cd *cd; struct Cd *cd;
struct tag *cd_tag, *track_tag; struct tag *tag;
assert(str != NULL); assert(str != NULL);
@ -213,14 +227,8 @@ cue_tag_string(const char *str, unsigned tnum)
if (cd == NULL) if (cd == NULL)
return NULL; return NULL;
/* tag from CDtext info */ tag = cue_tag(cd, tnum);
cd_tag = cue_tag_cd(cd_get_cdtext(cd), cd_get_rem(cd));
/* tag from TRACKtext info */
track_tag = cue_tag_track(track_get_cdtext(cd_get_track(cd, tnum)),
track_get_rem(cd_get_track(cd, tnum)));
cd_delete(cd); cd_delete(cd);
return cue_tag_merge(cd_tag, track_tag); return tag;
} }

View File

@ -8,6 +8,10 @@
#include <stdio.h> #include <stdio.h>
struct tag; struct tag;
struct Cd;
struct tag *
cue_tag(struct Cd *cd, unsigned tnum);
struct tag * struct tag *
cue_tag_file(FILE *file, unsigned tnum); cue_tag_file(FILE *file, unsigned tnum);