dhtlog updates
[oweals/gnunet.git] / src / util / strings.c
index 133fda857d85f83487a1376d50a7f38a81fd4e5a..1f7f45d5192504cb27e3b0812d9d3d78da24673a 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #include "platform.h"
-#if HAVE_ICONV_H
+#if HAVE_ICONV
 #include <iconv.h>
 #endif
 #include "gnunet_common.h"
@@ -159,7 +159,7 @@ GNUNET_STRINGS_byte_size_fancy (unsigned long long size)
         }
     }
   ret = GNUNET_malloc (32);
-  GNUNET_snprintf (ret, 32, "%llu%s", size, unit);
+  GNUNET_snprintf (ret, 32, "%llu %s", size, unit);
   return ret;
 }
 
@@ -198,13 +198,13 @@ GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset)
   tmp = GNUNET_malloc (tmpSize);
   itmp = tmp;
   finSize = tmpSize;
-  if (iconv (cd, 
-#if FREEBSD
-            (const char **) &input, 
+  if (iconv (cd,
+#if FREEBSD || DARWIN
+             (const char **) &input,
 #else
-            (char **) &input, 
+             (char **) &input,
 #endif
-            &len, &itmp, &finSize) == (size_t) - 1)
+             &len, &itmp, &finSize) == SIZE_MAX)
     {
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "iconv");
       iconv_close (cd);
@@ -363,6 +363,8 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta)
   char *ret;
   uint64_t dval = delta.value;
 
+  if (delta.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
+    return GNUNET_strdup (_("eternity"));
   if (dval > 5 * 1000)
     {
       dval = dval / 1000;
@@ -383,7 +385,7 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta)
             }
         }
     }
-  GNUNET_asprintf (&ret, "%llu%s", dval, unit);
+  GNUNET_asprintf (&ret, "%llu %s", dval, unit);
   return ret;
 }
 
@@ -401,6 +403,8 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
   time_t tt;
   char *ret;
 
+  if (t.value == GNUNET_TIME_UNIT_FOREVER_ABS.value)
+    return GNUNET_strdup (_("end of time"));
   tt = t.value / 1000;
 #ifdef ctime_r
   ret = ctime_r (&tt, GNUNET_malloc (32));