diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 10:55:47 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 10:55:47 -0400 |
commit | 77e4dd81f5abedda802b8b6e895849995907b484 (patch) | |
tree | 750656ede0dac091aa1512ccd81660ec40ddbb58 /lib/rbcodec/metadata/metadata_common.c | |
parent | eb86ee296a40249c33d1969087f98108735beaa9 (diff) | |
download | rockbox-77e4dd81f5abedda802b8b6e895849995907b484.tar.gz rockbox-77e4dd81f5abedda802b8b6e895849995907b484.zip |
option_string clean-up and consolidate with metadata_common
Change-Id: I2649f6af37bd871fb8f181ae2f716ff0bcf1f65c
Diffstat (limited to 'lib/rbcodec/metadata/metadata_common.c')
-rw-r--r-- | lib/rbcodec/metadata/metadata_common.c | 36 |
1 files changed, 28 insertions, 8 deletions
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) | |||
252 | return success; | 252 | return success; |
253 | } | 253 | } |
254 | 254 | ||
255 | static int get_tag_option(const char *option, const char *const oplist[]) | 255 | #ifndef ROCKBOX /*codecs can be built without rockbox */ |
256 | /* returns match index from option list | ||
257 | * returns -1 if option was not found | ||
258 | * option list is array of char pointers with the final item set to null | ||
259 | * ex - const char *option[] = { "op_a", "op_b", "op_c", NULL} | ||
260 | */ | ||
261 | int string_option(const char *option, const char *const oplist[], bool ignore_case) | ||
256 | { | 262 | { |
257 | int i; | 263 | int i; |
258 | int ifound = -1; | 264 | int ifound = -1; |
259 | const char *op; | 265 | const char *op; |
260 | for (i=0; (op=oplist[i]) != NULL; i++) | 266 | if (ignore_case) |
261 | { | 267 | { |
262 | if (strcasecmp(op, option) == 0) | 268 | for (i=0; (op=oplist[i]) != NULL; i++) |
263 | { | 269 | { |
264 | ifound = i; | 270 | if (strcasecmp(op, option) == 0) |
265 | break; | 271 | { |
272 | ifound = i; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | for (i=0; (op=oplist[i]) != NULL; i++) | ||
280 | { | ||
281 | if (strcmp(op, option) == 0) | ||
282 | { | ||
283 | ifound = i; | ||
284 | break; | ||
285 | } | ||
266 | } | 286 | } |
267 | } | 287 | } |
268 | return ifound; | 288 | return ifound; |
269 | } | 289 | } |
270 | 290 | #endif | |
271 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. | 291 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. |
272 | * String values to keep are written to buf. Returns number of bytes written | 292 | * String values to keep are written to buf. Returns number of bytes written |
273 | * to buf (including end nil). | 293 | * to buf (including end nil). |
@@ -287,7 +307,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
287 | eMUSICBRAINZ1, eMUSICBRAINZ2 | 307 | eMUSICBRAINZ1, eMUSICBRAINZ2 |
288 | }; | 308 | }; |
289 | 309 | ||
290 | const char *tagops[] = | 310 | static const char *tagops[] = |
291 | { "track", "tracknumber", "discnumber", "disc", | 311 | { "track", "tracknumber", "discnumber", "disc", |
292 | "year","date","title", "artist", "album", "genre" | 312 | "year","date","title", "artist", "album", "genre" |
293 | "composer","comment","albumartist","album artist", | 313 | "composer","comment","albumartist","album artist", |
@@ -295,7 +315,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
295 | "musicbrainz_trackid", "http://musicbrainz.org", NULL | 315 | "musicbrainz_trackid", "http://musicbrainz.org", NULL |
296 | }; | 316 | }; |
297 | 317 | ||
298 | int item = get_tag_option(name, tagops); | 318 | int item = string_option(name, tagops, true); |
299 | 319 | ||
300 | if (((item == eTRACK && (type == TAGTYPE_APE))) | 320 | if (((item == eTRACK && (type == TAGTYPE_APE))) |
301 | || (item == eTRACKNUMBER && (type == TAGTYPE_VORBIS))) | 321 | || (item == eTRACKNUMBER && (type == TAGTYPE_VORBIS))) |