adding GNUNET_FS_time_to_year function to FS API
authorChristian Grothoff <christian@grothoff.org>
Mon, 26 Dec 2011 19:31:18 +0000 (19:31 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 26 Dec 2011 19:31:18 +0000 (19:31 +0000)
src/fs/fs_misc.c
src/include/gnunet_fs_service.h
src/util/os_network.c

index d4afc0d55dcbb502a791d1577765a64e838c313f..89dc48683ad9aded3ca00f02dfbd6a805c2303fe 100644 (file)
@@ -207,6 +207,25 @@ GNUNET_FS_year_to_time (unsigned int year)
 }
 
 
+/**
+ * Convert an expiration time to the respective year (rounds)
+ *
+ * @param at absolute time 
+ * @return year a year (after 1970), 0 on error
+ */
+unsigned int 
+GNUNET_FS_time_to_year (struct GNUNET_TIME_Absolute at)
+{
+  struct tm *t;
+  time_t tp;
+
+  tp = at.abs_value / 1000;    /* ms to seconds */
+  t = gmtime (&tp);
+  if (t == NULL)
+    return 0;
+  return t->tm_year + 1900;
+
+}
 
 
 /* end of fs_misc.c */
index ad4441bd3631aed543d874f0209f4f8bc83737d2..4b1b1b1993e5fec0190119eb534d2cdd3fff6cd6 100644 (file)
@@ -1642,6 +1642,16 @@ struct GNUNET_TIME_Absolute
 GNUNET_FS_year_to_time (unsigned int year);
 
 
+/**
+ * Convert an expiration time to the respective year (rounds)
+ *
+ * @param at absolute time 
+ * @return year a year (after 1970), 0 on error
+ */
+unsigned int 
+GNUNET_FS_time_to_year (struct GNUNET_TIME_Absolute at);
+
+
 /**
  * Handle to the file-sharing service.
  */
index 83248bf3e041782708709e32d91d2fb81afcfa27..7449f80686872b9f96b49fa3d8b067ca7ead3084 100644 (file)
@@ -105,6 +105,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
   const char *start;
   char ifc[12];
   char addrstr[128];
+  char bcstr[128];
   FILE *f;
   int have_ifc;
   struct sockaddr_in a4;
@@ -149,7 +150,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
     while (('\0' != *start) && (isspace (*start)))
       start++;
     if (                        /* Linux */
-         (1 == SSCANF (start, "inet addr:%127s", addrstr)) ||
+       (2 == SSCANF (start, "inet addr:%127s Bcast:%127s", addrstr, bcstr)) ||
          (1 == SSCANF (start, "inet6 addr:%127s", addrstr)) ||
          /* Solaris, OS X */
          (1 == SSCANF (start, "inet %127s", addrstr)) ||