gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r23951 - in Extractor/src: include main
Date: Sat, 22 Sep 2012 22:30:25 +0200

Author: grothoff
Date: 2012-09-22 22:30:25 +0200 (Sat, 22 Sep 2012)
New Revision: 23951

Modified:
   Extractor/src/include/platform.h
   Extractor/src/main/extract.c
   Extractor/src/main/extractor_print.c
   Extractor/src/main/iconv.c
Log:
trying to make code build even without GNU iconv

Modified: Extractor/src/include/platform.h
===================================================================
--- Extractor/src/include/platform.h    2012-09-22 20:23:47 UTC (rev 23950)
+++ Extractor/src/include/platform.h    2012-09-22 20:30:25 UTC (rev 23951)
@@ -63,7 +63,9 @@
  #include <winsock2.h>
 #endif
 #include <locale.h>
+#if HAVE_ICONV_H
 #include <iconv.h>
+#endif
 #include <langinfo.h>
 
 #ifndef SIZE_MAX

Modified: Extractor/src/main/extract.c
===================================================================
--- Extractor/src/main/extract.c        2012-09-22 20:23:47 UTC (rev 23950)
+++ Extractor/src/main/extract.c        2012-09-22 20:30:25 UTC (rev 23951)
@@ -245,7 +245,9 @@
 
 }
 
+#if HAVE_ICONV
 #include "iconv.c"
+#endif
 
 /**
  * Print a keyword list to a file.
@@ -273,7 +275,9 @@
                         size_t data_len)
 { 
   char *keyword;
+#if HAVE_ICONV
   iconv_t cd;
+#endif
   const char *stype;
   const char *mt;
 
@@ -294,12 +298,14 @@
               (unsigned int) data_len);
       break;
     case EXTRACTOR_METAFORMAT_UTF8:
+#if HAVE_ICONV
       cd = iconv_open (nl_langinfo(CODESET), "UTF-8");
       if (((iconv_t) -1) != cd)
        keyword = iconv_helper (cd,
                                data,
                                data_len);
       else
+#endif
        keyword = strdup (data);
       if (NULL != keyword)
        {
@@ -309,8 +315,10 @@
                   keyword);
          free (keyword);
        }
+#if HAVE_ICONV
       if (((iconv_t) -1) != cd)
        iconv_close (cd);
+#endif
       break;
     case EXTRACTOR_METAFORMAT_BINARY:
       fprintf (stdout,
@@ -358,7 +366,9 @@
                                       size_t data_len)
 { 
   char *keyword;
+#if HAVE_ICONV 
   iconv_t cd;
+#endif
   const char *mt;
 
   if (YES != print[type])
@@ -375,12 +385,14 @@
        fprintf (stdout,
                 "%s: ",
                 gettext(mt));
+#if HAVE_ICONV 
       cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
       if (((iconv_t) -1) != cd)
        keyword = iconv_helper (cd,
                                data,
                                data_len);
       else
+#endif
        keyword = strdup (data);
       if (NULL != keyword)
        {
@@ -389,8 +401,10 @@
                   keyword);
          free (keyword);
        }
+#if HAVE_ICONV 
       if (((iconv_t) -1) != cd)
        iconv_close (cd);
+#endif
       break;
     case EXTRACTOR_METAFORMAT_BINARY:
       break;

Modified: Extractor/src/main/extractor_print.c
===================================================================
--- Extractor/src/main/extractor_print.c        2012-09-22 20:23:47 UTC (rev 
23950)
+++ Extractor/src/main/extractor_print.c        2012-09-22 20:30:25 UTC (rev 
23951)
@@ -22,11 +22,12 @@
  * @brief convenience functions for printing meta data
  * @author Christian Grothoff
  */
-
 #include "platform.h"
 #include "extractor.h"
 #include "extractor_logging.h"
+#if HAVE_ICONV
 #include "iconv.c"
+#endif
 
 /**
  * Simple EXTRACTOR_MetaDataProcessor implementation that simply
@@ -53,13 +54,16 @@
                           const char *data,
                           size_t data_len)
 {
+#if HAVE_ICONV
   iconv_t cd;
+#endif
   char * buf;
   int ret;
   const char *mt;
 
   if (EXTRACTOR_METAFORMAT_UTF8 != format)
     return 0;
+#if HAVE_ICONV
   cd = iconv_open (nl_langinfo(CODESET),
                   "UTF-8");
   if (((iconv_t) -1) == cd)
@@ -85,6 +89,15 @@
       free(buf);
     }
   iconv_close(cd);
+#else
+  ret = fprintf (handle,
+                "%s - %.*s\n",
+                (NULL == mt) 
+                ? dgettext ("libextractor", gettext_noop ("unknown"))
+                : dgettext ("libextractor", mt),
+                (int) data_len,
+                data);
+#endif
   return (ret < 0) ? 1 : 0;
 }
 

Modified: Extractor/src/main/iconv.c
===================================================================
--- Extractor/src/main/iconv.c  2012-09-22 20:23:47 UTC (rev 23950)
+++ Extractor/src/main/iconv.c  2012-09-22 20:30:25 UTC (rev 23951)
@@ -38,9 +38,10 @@
              const char *in,
              size_t inSize) 
 {
-  char * buf;
-  char * ibuf;
-  const char * i;
+#if HAVE_ICONV
+  char *buf;
+  char *ibuf;
+  const char *i;
   size_t outSize;
   size_t outLeft;
 
@@ -66,6 +67,14 @@
       return strdup (i);
     }
   return buf;
+#else
+  /* good luck, just copying string... */
+  char *buf;
+  
+  buf = malloc (inSize + 1);
+  memcpy (buf, in, inSize);
+  buf[inSize] = '\0';
+#endif
 }
 
 /* end of iconv.c */




reply via email to

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