diff options
Diffstat (limited to 'lib/rbcodec/metadata')
-rw-r--r-- | lib/rbcodec/metadata/metadata_common.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/rbcodec/metadata/metadata_common.c b/lib/rbcodec/metadata/metadata_common.c index 0967570a5d..45b2b90bf8 100644 --- a/lib/rbcodec/metadata/metadata_common.c +++ b/lib/rbcodec/metadata/metadata_common.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "metadata_parsers.h" | 30 | #include "metadata_parsers.h" |
31 | #include "replaygain.h" | 31 | #include "replaygain.h" |
32 | 32 | ||
33 | /* Read a string from the file. Read up to size bytes, or, if eos != -1, | 33 | /* Read a string from the file. Read up to size bytes, or, if eos != -1, |
34 | * until the eos character is found (eos is not stored in buf, unless it is | 34 | * until the eos character is found (eos is not stored in buf, unless it is |
35 | * nil). Writes up to buf_size chars to buf, always terminating with a nil. | 35 | * nil). Writes up to buf_size chars to buf, always terminating with a nil. |
36 | * Returns number of chars read or -1 on read error. | 36 | * Returns number of chars read or -1 on read error. |
@@ -39,7 +39,7 @@ long read_string(int fd, char* buf, long buf_size, int eos, long size) | |||
39 | { | 39 | { |
40 | long read_bytes = 0; | 40 | long read_bytes = 0; |
41 | char c; | 41 | char c; |
42 | 42 | ||
43 | while (size != 0) | 43 | while (size != 0) |
44 | { | 44 | { |
45 | if (read(fd, &c, 1) != 1) | 45 | if (read(fd, &c, 1) != 1) |
@@ -47,22 +47,22 @@ long read_string(int fd, char* buf, long buf_size, int eos, long size) | |||
47 | read_bytes = -1; | 47 | read_bytes = -1; |
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | 50 | ||
51 | read_bytes++; | 51 | read_bytes++; |
52 | size--; | 52 | size--; |
53 | 53 | ||
54 | if ((eos != -1) && (eos == (unsigned char) c)) | 54 | if ((eos != -1) && (eos == (unsigned char) c)) |
55 | { | 55 | { |
56 | break; | 56 | break; |
57 | } | 57 | } |
58 | 58 | ||
59 | if (buf_size > 1) | 59 | if (buf_size > 1) |
60 | { | 60 | { |
61 | *buf++ = c; | 61 | *buf++ = c; |
62 | buf_size--; | 62 | buf_size--; |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | *buf = 0; | 66 | *buf = 0; |
67 | return read_bytes; | 67 | return read_bytes; |
68 | } | 68 | } |
@@ -198,31 +198,31 @@ uint32_t get_itunes_int32(char* value, int count) | |||
198 | static const char hexdigits[] = "0123456789ABCDEF"; | 198 | static const char hexdigits[] = "0123456789ABCDEF"; |
199 | const char* c; | 199 | const char* c; |
200 | int r = 0; | 200 | int r = 0; |
201 | 201 | ||
202 | while (count-- > 0) | 202 | while (count-- > 0) |
203 | { | 203 | { |
204 | while (isspace(*value)) | 204 | while (isspace(*value)) |
205 | { | 205 | { |
206 | value++; | 206 | value++; |
207 | } | 207 | } |
208 | 208 | ||
209 | while (*value && !isspace(*value)) | 209 | while (*value && !isspace(*value)) |
210 | { | 210 | { |
211 | value++; | 211 | value++; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | while (isspace(*value)) | 215 | while (isspace(*value)) |
216 | { | 216 | { |
217 | value++; | 217 | value++; |
218 | } | 218 | } |
219 | 219 | ||
220 | while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL)) | 220 | while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL)) |
221 | { | 221 | { |
222 | r = (r << 4) | (c - hexdigits); | 222 | r = (r << 4) | (c - hexdigits); |
223 | value++; | 223 | value++; |
224 | } | 224 | } |
225 | 225 | ||
226 | return r; | 226 | return r; |
227 | } | 227 | } |
228 | 228 | ||
@@ -243,9 +243,9 @@ bool skip_id3v2(int fd, struct mp3entry *id3) | |||
243 | if ((id3->first_frame_offset = getid3v2len(fd)) == 0) | 243 | if ((id3->first_frame_offset = getid3v2len(fd)) == 0) |
244 | return false; | 244 | return false; |
245 | 245 | ||
246 | if ((lseek(fd, id3->first_frame_offset, SEEK_SET) < 0)) | 246 | if ((lseek(fd, id3->first_frame_offset, SEEK_SET) < 0)) |
247 | return false; | 247 | return false; |
248 | 248 | ||
249 | return true; | 249 | return true; |
250 | } else { | 250 | } else { |
251 | lseek(fd, 0, SEEK_SET); | 251 | lseek(fd, 0, SEEK_SET); |
@@ -278,7 +278,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
278 | else if (((strcasecmp(name, "year") == 0) && (type == TAGTYPE_APE)) | 278 | else if (((strcasecmp(name, "year") == 0) && (type == TAGTYPE_APE)) |
279 | || ((strcasecmp(name, "date") == 0) && (type == TAGTYPE_VORBIS))) | 279 | || ((strcasecmp(name, "date") == 0) && (type == TAGTYPE_VORBIS))) |
280 | { | 280 | { |
281 | /* Date's can be in any format in Vorbis. However most of them | 281 | /* Date's can be in any format in Vorbis. However most of them |
282 | * are in ISO8601 format so if we try and parse the first part | 282 | * are in ISO8601 format so if we try and parse the first part |
283 | * of the tag as a number, we should get the year. If we get crap, | 283 | * of the tag as a number, we should get the year. If we get crap, |
284 | * then act like we never parsed it. | 284 | * then act like we never parsed it. |
@@ -334,7 +334,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
334 | { | 334 | { |
335 | p = &(id3->grouping); | 335 | p = &(id3->grouping); |
336 | } | 336 | } |
337 | else if (strcasecmp(name, "contentgroup") == 0) | 337 | else if (strcasecmp(name, "contentgroup") == 0) |
338 | { | 338 | { |
339 | p = &(id3->grouping); | 339 | p = &(id3->grouping); |
340 | } | 340 | } |
@@ -348,9 +348,9 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
348 | parse_replaygain(name, value, id3); | 348 | parse_replaygain(name, value, id3); |
349 | p = NULL; | 349 | p = NULL; |
350 | } | 350 | } |
351 | 351 | ||
352 | /* Do not overwrite already available metadata. Especially when reading | 352 | /* Do not overwrite already available metadata. Especially when reading |
353 | * tags with e.g. multiple genres / artists. This way only the first | 353 | * tags with e.g. multiple genres / artists. This way only the first |
354 | * of multiple entries is used, all following are dropped. */ | 354 | * of multiple entries is used, all following are dropped. */ |
355 | if (p!=NULL && *p==NULL) | 355 | if (p!=NULL && *p==NULL) |
356 | { | 356 | { |
@@ -369,6 +369,6 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
369 | len = 0; | 369 | len = 0; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | return len; | 373 | return len; |
374 | } | 374 | } |