summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2009-08-30 03:15:43 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2009-08-30 03:15:43 +0000
commitf701fc516633798524369de07fedb8a21e8fc99f (patch)
treeb7d5fcf6146c4c17d496d3db6057d23dd4df68ec
parente4c30bdf0edf6b93343ebafaa15bbbdf590a1d37 (diff)
Patch doesn't SVN add . . .
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22558 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata/nsf.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/apps/metadata/nsf.c b/apps/metadata/nsf.c
new file mode 100644
index 0000000000..a12af14347
--- /dev/null
+++ b/apps/metadata/nsf.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include "system.h"
+#include "metadata.h"
+#include "metadata_common.h"
+#include "metadata_parsers.h"
+#include "rbunicode.h"
+
+bool get_nsf_metadata(int fd, struct mp3entry* id3)
+{
+ /* Use the trackname part of the id3 structure as a temporary buffer */
+ unsigned char* buf = (unsigned char *)id3->path;
+ int read_bytes;
+ char *p;
+
+
+ if ((lseek(fd, 0, SEEK_SET) < 0)
+ || ((read_bytes = read(fd, buf, 110)) < 110))
+ {
+ return false;
+ }
+
+ id3->length = 120*1000;
+ id3->vbr = false;
+ id3->filesize = filesize(fd);
+
+ if (memcmp(buf,"NESM",4) && memcmp(buf,"NSFE",4))
+ {
+ return false;
+ }
+ else if (memcmp(buf, "NESM",4)) /* only NESM contain metadata */
+ {
+ return true;
+ }
+
+ p = id3->id3v2buf;
+
+ /* Title */
+ memcpy(p, &buf[14], 32);
+ id3->title = p;
+ p += strlen(p)+1;
+
+ /* Artist */
+ memcpy(p, &buf[46], 32);
+ id3->artist = p;
+ p += strlen(p)+1;
+
+ /* Copyright (per codec) */
+ memcpy(p, &buf[78], 32);
+ id3->album = p;
+ p += strlen(p)+1;
+
+ return true;
+}
+