Store the list of fonts in a linked list instead of in a static array (together with...
[kugel-rb.git] / apps / metadata / nsf.c
blobe1ad331d7501238b953815eccda185db33bb9351
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <ctype.h>
5 #include <inttypes.h>
7 #include "system.h"
8 #include "metadata.h"
9 #include "metadata_common.h"
10 #include "metadata_parsers.h"
11 #include "rbunicode.h"
13 bool get_nsf_metadata(int fd, struct mp3entry* id3)
15 /* Use the trackname part of the id3 structure as a temporary buffer */
16 unsigned char* buf = (unsigned char *)id3->path;
17 int read_bytes;
18 char *p;
21 if ((lseek(fd, 0, SEEK_SET) < 0)
22 || ((read_bytes = read(fd, buf, 110)) < 110))
24 return false;
27 id3->length = 120*1000;
28 id3->vbr = false;
29 id3->filesize = filesize(fd);
31 if (memcmp(buf,"NSFE",4) == 0) /* only NESM contain metadata */
33 return true;
35 else
37 if (memcmp(buf, "NESM",4) != 0) /* not a valid format*/
39 return false;
43 p = id3->id3v2buf;
45 /* Title */
46 memcpy(p, &buf[14], 32);
47 id3->title = p;
48 p += strlen(p)+1;
50 /* Artist */
51 memcpy(p, &buf[46], 32);
52 id3->artist = p;
53 p += strlen(p)+1;
55 /* Copyright (per codec) */
56 memcpy(p, &buf[78], 32);
57 id3->album = p;
58 p += strlen(p)+1;
60 return true;