gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23186 - Extractor/src/plugins


From: gnunet
Subject: [GNUnet-SVN] r23186 - Extractor/src/plugins
Date: Thu, 9 Aug 2012 23:07:33 +0200

Author: grothoff
Date: 2012-08-09 23:07:33 +0200 (Thu, 09 Aug 2012)
New Revision: 23186

Modified:
   Extractor/src/plugins/Makefile.am
   Extractor/src/plugins/it_extractor.c
   Extractor/src/plugins/xm_extractor.c
Log:
-porting it extractor to new api

Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am   2012-08-09 18:17:38 UTC (rev 23185)
+++ Extractor/src/plugins/Makefile.am   2012-08-09 21:07:33 UTC (rev 23186)
@@ -67,6 +67,7 @@
 
 
 plugin_LTLIBRARIES = \
+  libextractor_it.la \
   libextractor_xm.la \
   libextractor_wav.la \
   $(PLUGIN_OGG) \
@@ -112,7 +113,12 @@
 libextractor_xm_la_LDFLAGS = \
   $(PLUGINFLAGS)
 
+libextractor_it_la_SOURCES = \
+  it_extractor.c
+libextractor_it_la_LDFLAGS = \
+  $(PLUGINFLAGS)
 
+
 libextractor_wav_la_SOURCES = \
   wav_extractor.c
 libextractor_wav_la_LDFLAGS = \

Modified: Extractor/src/plugins/it_extractor.c
===================================================================
--- Extractor/src/plugins/it_extractor.c        2012-08-09 18:17:38 UTC (rev 
23185)
+++ Extractor/src/plugins/it_extractor.c        2012-08-09 21:07:33 UTC (rev 
23186)
@@ -18,13 +18,27 @@
  * Boston, MA 02111-1307, USA.
  *
  */
-
+/**
+ * @file plugins/xm_extractor.c
+ * @brief plugin to support Impulse Tracker (IT) files
+ * @author Toni Ruottu
+ * @author Christian Grothoff
+ */
 #include "platform.h"
 #include "extractor.h"
 
+
+/**
+ * Number of bytes in the full IT header and thus
+ * the minimum size we're going to accept for an IT file.
+ */
 #define HEADER_SIZE  0xD0
 
-struct header
+
+/**
+ * Header of an IT file.
+ */
+struct Header
 {
   char magicid[4];
   char title[26];
@@ -39,65 +53,68 @@
   char special[2];
 };
 
-/* "extract" keyword from an Impulse Tracker module
+
+/**
+ * extract meta data from an Impulse Tracker module
  *
- * ITTECH.TXT as taken from IT 2.14p5 was used,
- * while this piece of software was originally
- * written.
+ * ITTECH.TXT as taken from IT 2.14p5 was used, while this piece of
+ * software was originally written.
  *
+ * @param ec extraction context
  */
-int 
-EXTRACTOR_it_extract (const char *data,
-                     size_t size,
-                     EXTRACTOR_MetaDataProcessor proc,
-                     void *proc_cls,
-                     const char *options)
+void
+EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec)
 {
+  void *data;
   char title[27];
   char itversion[8];
-  struct header *head;
+  const struct Header *head;
 
-  /* Check header size */
-  if (size < HEADER_SIZE)    
-    return 0;
-  head = (struct header *) data;
+  if (HEADER_SIZE >
+      ec->read (ec->cls,
+               &data,
+               HEADER_SIZE))
+    return;
+  head = (struct Header *) data;
   /* Check "magic" id bytes */
   if (memcmp (head->magicid, "IMPM", 4))
-    return 0;
+    return;
   /* Mime-type */
-  if (0 != proc (proc_cls,
-                "it",
-                EXTRACTOR_METATYPE_MIMETYPE,
-                EXTRACTOR_METAFORMAT_UTF8,
-                "text/plain",
-                "audio/x-it",
-                strlen("audio/x-it")+1))
-    return 1;
+  if (0 != ec->proc (ec->cls,
+                    "it",
+                    EXTRACTOR_METATYPE_MIMETYPE,
+                    EXTRACTOR_METAFORMAT_UTF8,
+                    "text/plain",
+                    "audio/x-it",
+                    strlen ("audio/x-it") + 1))
+    return;
 
   /* Version of Tracker */
   snprintf (itversion, 
            sizeof (itversion),
            "%d.%d", 
-           (head->version[0]& 0x01),head->version[1]);
-  if (0 != proc (proc_cls,
-                "it",
-                EXTRACTOR_METATYPE_FORMAT_VERSION,
-                EXTRACTOR_METAFORMAT_C_STRING,
-                "text/plain",
-                itversion,
-                strlen(itversion)+1))
-    return 1;
+           (head->version[0] & 0x01),
+           head->version[1]);
+  if (0 != ec->proc (ec->cls,
+                    "it",
+                    EXTRACTOR_METATYPE_FORMAT_VERSION,
+                    EXTRACTOR_METAFORMAT_C_STRING,
+                    "text/plain",
+                    itversion,
+                    strlen (itversion) + 1))
+    return;
 
   /* Song title */
   memcpy (&title, head->title, 26);
   title[26] = '\0';
-  if (0 != proc (proc_cls,
-                "it",
-                EXTRACTOR_METATYPE_TITLE,
-                EXTRACTOR_METAFORMAT_C_STRING,
-                "text/plain",
-                title,
-                strlen(title)+1))
-    return 1;
-  return 0;
+  if (0 != ec->proc (ec->cls,
+                    "it",
+                    EXTRACTOR_METATYPE_TITLE,
+                    EXTRACTOR_METAFORMAT_C_STRING,
+                    "text/plain",
+                    title,
+                    strlen (title) + 1))
+    return;
 }
+
+/* end of it_extractor.c */

Modified: Extractor/src/plugins/xm_extractor.c
===================================================================
--- Extractor/src/plugins/xm_extractor.c        2012-08-09 18:17:38 UTC (rev 
23185)
+++ Extractor/src/plugins/xm_extractor.c        2012-08-09 21:07:33 UTC (rev 
23186)
@@ -31,7 +31,7 @@
 /**
  * Header of an XM file.
  */
-struct header
+struct Header
 {
   char magicid[17];
   char title[20];
@@ -64,15 +64,15 @@
 EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec)
 {
   void *data;
-  const struct header *head;
+  const struct Header *head;
   char title[21];
   char tracker[21];
   char xmversion[8];
 
-  if (sizeof (struct header) >
+  if (sizeof (struct Header) >
       ec->read (ec->cls,
                &data,
-               sizeof (struct header)))
+               sizeof (struct Header)))
     return;
   head = data;
   /* Check "magic" id bytes */




reply via email to

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