gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9805 - in Extractor/src: include main plugins


From: gnunet
Subject: [GNUnet-SVN] r9805 - in Extractor/src: include main plugins
Date: Sat, 19 Dec 2009 13:32:34 +0100

Author: grothoff
Date: 2009-12-19 13:32:34 +0100 (Sat, 19 Dec 2009)
New Revision: 9805

Added:
   Extractor/src/plugins/sid_extractor.c
Removed:
   Extractor/src/plugins/sidextractor.c
Modified:
   Extractor/src/include/extractor.h
   Extractor/src/main/extractor_metatypes.c
   Extractor/src/plugins/Makefile.am
Log:
sid

Modified: Extractor/src/include/extractor.h
===================================================================
--- Extractor/src/include/extractor.h   2009-12-19 12:17:06 UTC (rev 9804)
+++ Extractor/src/include/extractor.h   2009-12-19 12:32:34 UTC (rev 9805)
@@ -283,6 +283,8 @@
     EXTRACTOR_METATYPE_TV_NETWORK_NAME = 151,
     EXTRACTOR_METATYPE_TV_SHOW_NAME = 152,
     EXTRACTOR_METATYPE_CHAPTER_NAME = 153,
+    EXTRACTOR_METATYPE_SONG_COUNT = 154,
+    EXTRACTOR_METATYPE_STARTING_SONG = 155,
 
     /* fixme: used up to here! */
 
@@ -290,8 +292,6 @@
     EXTRACTOR_METATYPE_CONDUCTOR = 64,
     EXTRACTOR_METATYPE_INTERPRET = 65,
     EXTRACTOR_METATYPE_MUSIC_CD_IDENTIFIER = 117,
-    EXTRACTOR_METATYPE_SONG_COUNT = 127,
-    EXTRACTOR_METATYPE_STARTING_SONG = 128,
     EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 123,
 
     

Modified: Extractor/src/main/extractor_metatypes.c
===================================================================
--- Extractor/src/main/extractor_metatypes.c    2009-12-19 12:17:06 UTC (rev 
9804)
+++ Extractor/src/main/extractor_metatypes.c    2009-12-19 12:32:34 UTC (rev 
9805)
@@ -217,7 +217,7 @@
   { gettext_noop ("is essential"),
     gettext_noop ("package is marked as essential") },
   { gettext_noop ("target architecture"),
-    gettext_noop ("hardware architecture the package can be used for") },
+    gettext_noop ("hardware architecture the contents can be used for") },
   { gettext_noop ("pre-dependency"),
     gettext_noop ("dependency that must be satisfied before installation") }, 
   /* 85 */
@@ -375,10 +375,21 @@
     gettext_noop ("name of the TV show") }, 
   { gettext_noop ("chapter name"),
     gettext_noop ("name of the chapter") }, 
+  { gettext_noop ("song count"),
+    gettext_noop ("number of songs") }, 
+  /* 155 */
+  { gettext_noop ("starting song"),
+    gettext_noop ("number of the first song to play") }, 
   { gettext_noop (""),
     gettext_noop ("") }, 
   { gettext_noop (""),
     gettext_noop ("") }, 
+  { gettext_noop (""),
+    gettext_noop ("") }, 
+  { gettext_noop (""),
+    gettext_noop ("") }, 
+  { gettext_noop (""),
+    gettext_noop ("") }, 
 #if 0
   
   gettext_noop("author"),
@@ -498,7 +509,6 @@
   gettext_noop("format version"), /* 125 */
   gettext_noop("television system"),
   gettext_noop("song count"),
-  gettext_noop("starting song"),
   gettext_noop("hardware dependency"),
   gettext_noop("ripper"), /* 130 */
   gettext_noop("filesize"),

Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2009-12-19 12:17:06 UTC (rev 9804)
+++ Extractor/src/plugins/Makefile.am   2009-12-19 12:32:34 UTC (rev 9805)
@@ -93,6 +93,7 @@
   libextractor_real.la \
   libextractor_riff.la \
   $(rpm) \
+  libextractor_sid.la \
   libextractor_tar.la \
   $(thumbgtk) \
   libextractor_tiff.la \
@@ -280,6 +281,11 @@
 libextractor_rpm_la_LIBADD = \
   -lrpm
 
+libextractor_sid_la_SOURCES = \
+  sid_extractor.c 
+libextractor_sid_la_LDFLAGS = \
+  $(PLUGINFLAGS)
+
 libextractor_tar_la_SOURCES = \
   tar_extractor.c 
 libextractor_tar_la_LDFLAGS = \
@@ -335,7 +341,6 @@
   libextractor_nsf.la \
   libextractor_nsfe.la \
   libextractor_s3m.la \
-  libextractor_sid.la \
   libextractor_tar.la \
   $(thumbqt) \
   libextractor_xm.la \
@@ -364,13 +369,6 @@
   $(top_builddir)/src/common/libextractor_common.la
 
 
-libextractor_sid_la_SOURCES = \
-  sidextractor.c 
-libextractor_sid_la_LDFLAGS = \
-  $(PLUGINFLAGS)
-libextractor_sid_la_LIBADD = \
-  $(top_builddir)/src/main/libextractor.la
-
 libextractor_nsf_la_SOURCES = \
   nsfextractor.c 
 libextractor_nsf_la_LDFLAGS = \

Copied: Extractor/src/plugins/sid_extractor.c (from rev 9803, 
Extractor/src/plugins/sidextractor.c)
===================================================================
--- Extractor/src/plugins/sid_extractor.c                               (rev 0)
+++ Extractor/src/plugins/sid_extractor.c       2009-12-19 12:32:34 UTC (rev 
9805)
@@ -0,0 +1,191 @@
+/*
+ * This file is part of libextractor.
+ * (C) 2006, 2007 Toni Ruottu
+ *
+ * libextractor is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * libextractor is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libextractor; see the file COPYING.  If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+#include "platform.h"
+#include "extractor.h"
+
+
+#define SID1_HEADER_SIZE 0x76
+#define SID2_HEADER_SIZE 0x7c
+
+/* flags */
+
+#define MUSPLAYER_FLAG   0x01
+#define PLAYSID_FLAG     0x02
+#define PAL_FLAG         0x04
+#define NTSC_FLAG        0x08
+#define MOS6581_FLAG     0x10
+#define MOS8580_FLAG     0x20
+
+typedef char sidwrd[2];
+typedef char sidlongwrd[4];
+
+struct header
+{
+  char magicid[4];
+  sidwrd sidversion;
+  sidwrd dataoffset;
+  sidwrd loadaddr;
+  sidwrd initaddr;
+  sidwrd playaddr;
+  sidwrd songs;
+  sidwrd firstsong;
+  sidlongwrd speed;
+  char title[32];
+  char artist[32];
+  char copyright[32];
+  sidwrd flags;                 /* version 2 specific fields start */
+  char startpage;
+  char pagelength;
+  sidwrd reserved;
+};
+
+static int
+sidword (const sidwrd data)
+{
+  int value = (unsigned char) data[0] * 0x100 + (unsigned char) data[1];
+  return value;
+
+}
+
+#define ADD(s,t) do { if (0 != proc (proc_cls, "sid", t, 
EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0)
+
+/* "extract" keyword from a SID file
+ *
+ *  This plugin is based on the nsf extractor
+ *
+ */
+
+int 
+EXTRACTOR_sid_extract (const char *data,
+                      size_t size,
+                      EXTRACTOR_MetaDataProcessor proc,
+                      void *proc_cls,
+                      const char *options)
+{
+  unsigned int flags;
+  int version;
+  char album[33];
+  char artist[33];
+  char copyright[33];
+  char songs[32];
+  char startingsong[32];
+  char sidversion[32];
+  const struct header *head;
+
+  /* Check header size */
+
+  if (size < SID1_HEADER_SIZE)
+    return 0;
+  head = (const struct header *) data;
+
+  /* Check "magic" id bytes */
+  if (memcmp (head->magicid, "PSID", 4) &&
+      memcmp (head->magicid, "RSID", 4))
+    return 0;
+
+  /* Mime-type */
+  ADD ("audio/prs.sid", EXTRACTOR_METATYPE_MIMETYPE);
+
+  /* Version of SID format */
+  version = sidword (head->sidversion);
+  snprintf (sidversion, 
+           sizeof(sidversion),
+           "%d",
+           version);
+  ADD (sidversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
+
+  /* Get song count */
+  snprintf (songs,
+           sizeof(songs),
+           "%d", sidword (head->songs));
+  ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT);
+
+  /* Get number of the first song to be played */
+  snprintf (startingsong,
+           sizeof(startingsong),
+           "%d", 
+           sidword (head->firstsong));
+  ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG);
+
+
+  /* name, artist, copyright fields */
+  memcpy (&album, head->title, 32);
+  album[32] = '\0';
+  ADD (album, EXTRACTOR_METATYPE_ALBUM);
+
+  memcpy (&artist, head->artist, 32);
+  artist[32] = '\0'; 
+  ADD (artist, EXTRACTOR_METATYPE_ARTIST);
+  
+  memcpy (&copyright, head->copyright, 32);
+  copyright[32] = '\0';
+  ADD (copyright, EXTRACTOR_METATYPE_COPYRIGHT);
+
+
+  if ( (version < 2) || (size < SID2_HEADER_SIZE))
+    return 0;
+
+  /* Version 2 specific options follow
+   *
+   * Note: Had some troubles understanding specification
+   * on the flags in version 2. I hope this is correct.
+   */
+  flags = sidword (head->flags);
+  /* MUS data */
+  if (flags & MUSPLAYER_FLAG)    
+    ADD ("Compute!'s Sidplayer", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);    
+
+  /* PlaySID data */
+  if (flags & PLAYSID_FLAG)    
+    ADD ("PlaySID", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);    
+
+
+  /* PAL or NTSC */
+
+  if (flags & PAL_FLAG)
+    {
+      if (flags & NTSC_FLAG)
+       ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);       
 
+      else        
+       ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);        
+    }
+  else
+    {
+      if (flags & NTSC_FLAG)
+       ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);        
+    }
+
+  /* Detect SID Chips suitable for play the files */
+  if (flags & MOS6581_FLAG)
+    {
+      if (flags & MOS8580_FLAG)
+       ADD ("MOS6581/MOS8580", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);        
+      else
+       ADD ("MOS6581", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);        
+    }
+  else
+    {
+      if (flags & MOS8580_FLAG)
+       ADD ("MOS8580", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);        
+    }
+
+  return 0;
+}

Deleted: Extractor/src/plugins/sidextractor.c
===================================================================
--- Extractor/src/plugins/sidextractor.c        2009-12-19 12:17:06 UTC (rev 
9804)
+++ Extractor/src/plugins/sidextractor.c        2009-12-19 12:32:34 UTC (rev 
9805)
@@ -1,234 +0,0 @@
-/*
- * This file is part of libextractor.
- * (C) 2006, 2007 Toni Ruottu
- *
- * libextractor is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * libextractor is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with libextractor; see the file COPYING.  If not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "platform.h"
-#include "extractor.h"
-#include "convert.h"
-
-
-#define SID1_HEADER_SIZE 0x76
-#define SID2_HEADER_SIZE 0x7c
-
-/* flags */
-
-#define MUSPLAYER_FLAG   0x01
-#define PLAYSID_FLAG     0x02
-#define PAL_FLAG         0x04
-#define NTSC_FLAG        0x08
-#define MOS6581_FLAG     0x10
-#define MOS8580_FLAG     0x20
-
-typedef char sidwrd[2];
-typedef char sidlongwrd[4];
-
-struct header
-{
-  char magicid[4];
-  sidwrd sidversion;
-  sidwrd dataoffset;
-  sidwrd loadaddr;
-  sidwrd initaddr;
-  sidwrd playaddr;
-  sidwrd songs;
-  sidwrd firstsong;
-  sidlongwrd speed;
-  char title[32];
-  char artist[32];
-  char copyright[32];
-  sidwrd flags;                 /* version 2 specific fields start */
-  char startpage;
-  char pagelength;
-  sidwrd reserved;
-};
-
-int
-sidword (sidwrd data)
-{
-  int value = (unsigned char) data[0] * 0x100 + (unsigned char) data[1];
-
-  return (value);
-
-}
-
-static struct EXTRACTOR_Keywords *addkword
-  (EXTRACTOR_KeywordList * oldhead,
-   const char *phrase, EXTRACTOR_KeywordType type)
-{
-  EXTRACTOR_KeywordList *keyword;
-
-  keyword = malloc (sizeof (EXTRACTOR_KeywordList));
-  keyword->next = oldhead;
-  keyword->keyword = strdup (phrase);
-  keyword->keywordType = type;
-  return (keyword);
-}
-
-
-/* "extract" keyword from a SID file
- *
- *  This plugin is based on the nsf extractor
- *
- */
-struct EXTRACTOR_Keywords *libextractor_sid_extract
-  (const char *filename,
-   char *data, size_t size, struct EXTRACTOR_Keywords *prev)
-{
-  unsigned int flags;
-  int version;
-  char album[33];
-  char artist[33];
-  char copyright[33];
-  char songs[32];
-  char startingsong[32];
-  char sidversion[32];
-  struct header *head;
-
-  /* Check header size */
-
-  if (size < SID1_HEADER_SIZE)
-    {
-      return (prev);
-    }
-
-  head = (struct header *) data;
-
-  /* Check "magic" id bytes */
-
-  if (memcmp (head->magicid, "PSID", 4) && memcmp (head->magicid, "RSID", 4))
-    {
-      return (prev);
-    }
-
-
-  /* Mime-type */
-
-  prev = addkword (prev, "audio/prs.sid", EXTRACTOR_MIMETYPE);
-
-
-  /* Version of SID format */
-
-  version = sidword (head->sidversion);
-  sprintf (sidversion, "%d", version);
-  prev = addkword (prev, sidversion, EXTRACTOR_FORMAT_VERSION);
-
-
-  /* Get song count */
-
-  sprintf (songs, "%d", sidword (head->songs));
-  prev = addkword (prev, songs, EXTRACTOR_SONG_COUNT);
-
-
-  /* Get number of the first song to be played */
-
-  sprintf (startingsong, "%d", sidword (head->firstsong));
-  prev = addkword (prev, startingsong, EXTRACTOR_STARTING_SONG);
-
-
-  /* name, artist, copyright fields */
-
-  memcpy (&album, head->title, 32);
-  memcpy (&artist, head->artist, 32);
-  memcpy (&copyright, head->copyright, 32);
-
-  album[32] = '\0';
-  artist[32] = '\0';
-  copyright[32] = '\0';
-
-  prev = addkword (prev, album, EXTRACTOR_ALBUM);
-  prev = addkword (prev, artist, EXTRACTOR_ARTIST);
-  prev = addkword (prev, copyright, EXTRACTOR_COPYRIGHT);
-
-
-  if (version < 2 || size < SID2_HEADER_SIZE)
-    {
-      return (prev);
-    }
-
-  /* Version 2 specific options follow
-   *
-   * Note: Had some troubles understanding specification
-   * on the flags in version 2. I hope this is correct.
-   *
-   */
-
-  flags = sidword (head->flags);
-
-
-  /* MUS data */
-
-  if (flags & MUSPLAYER_FLAG)
-    {
-      prev = addkword (prev, "Compute!'s Sidplayer", EXTRACTOR_DEPENDENCY);
-    }
-
-  /* PlaySID data */
-
-  if (flags & PLAYSID_FLAG)
-    {
-      prev = addkword (prev, "PlaySID", EXTRACTOR_DEPENDENCY);
-    }
-
-
-  /* PAL or NTSC */
-
-  if (flags & PAL_FLAG)
-    {
-      if (flags & NTSC_FLAG)
-        {
-          prev = addkword (prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM);
-        }
-      else
-        {
-          prev = addkword (prev, "PAL", EXTRACTOR_TELEVISION_SYSTEM);
-        }
-    }
-  else
-    {
-      if (flags & NTSC_FLAG)
-        {
-          prev = addkword (prev, "NTSC", EXTRACTOR_TELEVISION_SYSTEM);
-        }
-    }
-
-  /* Detect SID Chips suitable for play the files */
-
-  if (flags & MOS6581_FLAG)
-    {
-      if (flags & MOS8580_FLAG)
-        {
-          prev =
-            addkword (prev, "MOS6581/MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY);
-        }
-      else
-        {
-          prev = addkword (prev, "MOS6581", EXTRACTOR_HARDWARE_DEPENDENCY);
-        }
-    }
-  else
-    {
-      if (flags & MOS8580_FLAG)
-        {
-          prev = addkword (prev, "MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY);
-        }
-    }
-
-  return (prev);
-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]