From 77e4dd81f5abedda802b8b6e895849995907b484 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 13 Mar 2022 10:55:47 -0400 Subject: option_string clean-up and consolidate with metadata_common Change-Id: I2649f6af37bd871fb8f181ae2f716ff0bcf1f65c --- lib/rbcodec/metadata/metadata_common.c | 36 ++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'lib/rbcodec/metadata/metadata_common.c') diff --git a/lib/rbcodec/metadata/metadata_common.c b/lib/rbcodec/metadata/metadata_common.c index 3677599c30..2586b2b65e 100644 --- a/lib/rbcodec/metadata/metadata_common.c +++ b/lib/rbcodec/metadata/metadata_common.c @@ -252,22 +252,42 @@ bool skip_id3v2(int fd, struct mp3entry *id3) return success; } -static int get_tag_option(const char *option, const char *const oplist[]) +#ifndef ROCKBOX /*codecs can be built without rockbox */ +/* returns match index from option list + * returns -1 if option was not found + * option list is array of char pointers with the final item set to null + * ex - const char *option[] = { "op_a", "op_b", "op_c", NULL} + */ +int string_option(const char *option, const char *const oplist[], bool ignore_case) { int i; int ifound = -1; const char *op; - for (i=0; (op=oplist[i]) != NULL; i++) + if (ignore_case) { - if (strcasecmp(op, option) == 0) + for (i=0; (op=oplist[i]) != NULL; i++) { - ifound = i; - break; + if (strcasecmp(op, option) == 0) + { + ifound = i; + break; + } + } + } + else + { + for (i=0; (op=oplist[i]) != NULL; i++) + { + if (strcmp(op, option) == 0) + { + ifound = i; + break; + } } } return ifound; } - +#endif /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. * String values to keep are written to buf. Returns number of bytes written * to buf (including end nil). @@ -287,7 +307,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, eMUSICBRAINZ1, eMUSICBRAINZ2 }; - const char *tagops[] = + static const char *tagops[] = { "track", "tracknumber", "discnumber", "disc", "year","date","title", "artist", "album", "genre" "composer","comment","albumartist","album artist", @@ -295,7 +315,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, "musicbrainz_trackid", "http://musicbrainz.org", NULL }; - int item = get_tag_option(name, tagops); + int item = string_option(name, tagops, true); if (((item == eTRACK && (type == TAGTYPE_APE))) || (item == eTRACKNUMBER && (type == TAGTYPE_VORBIS))) -- cgit v1.2.3