[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29116 - in gnunet/src: fs include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29116 - in gnunet/src: fs include util |
Date: |
Sun, 8 Sep 2013 20:07:21 +0200 |
Author: grothoff
Date: 2013-09-08 20:07:21 +0200 (Sun, 08 Sep 2013)
New Revision: 29116
Modified:
gnunet/src/fs/fs_misc.c
gnunet/src/fs/gnunet-publish.c
gnunet/src/include/gnunet_fs_service.h
gnunet/src/include/gnunet_time_lib.h
gnunet/src/util/time.c
Log:
-moving time functions from FS to TIME
Modified: gnunet/src/fs/fs_misc.c
===================================================================
--- gnunet/src/fs/fs_misc.c 2013-09-08 18:02:18 UTC (rev 29115)
+++ gnunet/src/fs/fs_misc.c 2013-09-08 18:07:21 UTC (rev 29116)
@@ -159,73 +159,4 @@
}
-/**
- * Return the current year (i.e. '2011').
- */
-unsigned int
-GNUNET_FS_get_current_year ()
-{
- time_t tp;
- struct tm *t;
-
- tp = time (NULL);
- t = gmtime (&tp);
- if (t == NULL)
- return 0;
- return t->tm_year + 1900;
-}
-
-
-/**
- * Convert a year to an expiration time of January 1st of that year.
- *
- * @param year a year (after 1970, please ;-)).
- * @return absolute time for January 1st of that year.
- */
-struct GNUNET_TIME_Absolute
-GNUNET_FS_year_to_time (unsigned int year)
-{
- struct GNUNET_TIME_Absolute ret;
- time_t tp;
- struct tm t;
-
- memset (&t, 0, sizeof (t));
- if (year < 1900)
- {
- GNUNET_break (0);
- return GNUNET_TIME_absolute_get (); /* now */
- }
- t.tm_year = year - 1900;
- t.tm_mday = 1;
- t.tm_mon = 1;
- t.tm_wday = 1;
- t.tm_yday = 1;
- tp = mktime (&t);
- GNUNET_break (tp != (time_t) - 1);
- ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
- return ret;
-}
-
-
-/**
- * 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_us / 1000LL / 1000LL; /* microseconds to seconds */
- t = gmtime (&tp);
- if (t == NULL)
- return 0;
- return t->tm_year + 1900;
-
-}
-
-
/* end of fs_misc.c */
Modified: gnunet/src/fs/gnunet-publish.c
===================================================================
--- gnunet/src/fs/gnunet-publish.c 2013-09-08 18:02:18 UTC (rev 29115)
+++ gnunet/src/fs/gnunet-publish.c 2013-09-08 18:07:21 UTC (rev 29116)
@@ -866,7 +866,7 @@
GNUNET_GETOPT_OPTION_END
};
bo.expiration_time =
- GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
+ GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2);
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
Modified: gnunet/src/include/gnunet_fs_service.h
===================================================================
--- gnunet/src/include/gnunet_fs_service.h 2013-09-08 18:02:18 UTC (rev
29115)
+++ gnunet/src/include/gnunet_fs_service.h 2013-09-08 18:07:21 UTC (rev
29116)
@@ -1630,33 +1630,6 @@
/**
- * Return the current year (i.e. '2011').
- */
-unsigned int
-GNUNET_FS_get_current_year (void);
-
-
-/**
- * Convert a year to an expiration time of January 1st of that year.
- *
- * @param year a year (after 1970, please ;-)).
- * @return absolute time for January 1st of that year.
- */
-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.
*/
struct GNUNET_FS_Handle;
Modified: gnunet/src/include/gnunet_time_lib.h
===================================================================
--- gnunet/src/include/gnunet_time_lib.h 2013-09-08 18:02:18 UTC (rev
29115)
+++ gnunet/src/include/gnunet_time_lib.h 2013-09-08 18:07:21 UTC (rev
29116)
@@ -487,6 +487,33 @@
GNUNET_TIME_get_offset (void);
+/**
+ * Return the current year (i.e. '2011').
+ */
+unsigned int
+GNUNET_TIME_get_current_year (void);
+
+
+/**
+ * Convert a year to an expiration time of January 1st of that year.
+ *
+ * @param year a year (after 1970, please ;-)).
+ * @return absolute time for January 1st of that year.
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_TIME_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_TIME_time_to_year (struct GNUNET_TIME_Absolute at);
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: gnunet/src/util/time.c
===================================================================
--- gnunet/src/util/time.c 2013-09-08 18:02:18 UTC (rev 29115)
+++ gnunet/src/util/time.c 2013-09-08 18:07:21 UTC (rev 29116)
@@ -559,4 +559,74 @@
}
+/**
+ * Return the current year (i.e. '2011').
+ */
+unsigned int
+GNUNET_TIME_get_current_year ()
+{
+ time_t tp;
+ struct tm *t;
+
+ tp = time (NULL);
+ t = gmtime (&tp);
+ if (t == NULL)
+ return 0;
+ return t->tm_year + 1900;
+}
+
+
+/**
+ * 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_TIME_time_to_year (struct GNUNET_TIME_Absolute at)
+{
+ struct tm *t;
+ time_t tp;
+
+ tp = at.abs_value_us / 1000LL / 1000LL; /* microseconds to seconds */
+ t = gmtime (&tp);
+ if (t == NULL)
+ return 0;
+ return t->tm_year + 1900;
+
+}
+
+
+/**
+ * Convert a year to an expiration time of January 1st of that year.
+ *
+ * @param year a year (after 1970, please ;-)).
+ * @return absolute time for January 1st of that year.
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_TIME_year_to_time (unsigned int year)
+{
+ struct GNUNET_TIME_Absolute ret;
+ time_t tp;
+ struct tm t;
+
+ memset (&t, 0, sizeof (t));
+ if (year < 1900)
+ {
+ GNUNET_break (0);
+ return GNUNET_TIME_absolute_get (); /* now */
+ }
+ t.tm_year = year - 1900;
+ t.tm_mday = 1;
+ t.tm_mon = 1;
+ t.tm_wday = 1;
+ t.tm_yday = 1;
+ tp = mktime (&t);
+ GNUNET_break (tp != (time_t) - 1);
+ ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
+ return ret;
+}
+
+
+
/* end of time.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29116 - in gnunet/src: fs include util,
gnunet <=