aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arm/gnunet-arm.c7
-rw-r--r--src/chat/gnunet-chat.c7
-rw-r--r--src/core/gnunet-core.c11
-rw-r--r--src/dht/gnunet-dht-monitor.c2
-rw-r--r--src/fs/gnunet-download.c11
-rw-r--r--src/fs/gnunet-publish.c6
-rw-r--r--src/fs/gnunet-unindex.c5
-rw-r--r--src/fs/test_fs_directory.c6
-rw-r--r--src/include/gnunet_strings_lib.h12
-rw-r--r--src/mesh/mesh_api.c6
-rw-r--r--src/namestore/gnunet-namestore.c5
-rw-r--r--src/statistics/gnunet-statistics.c4
-rw-r--r--src/testing_old/testing.c32
-rw-r--r--src/transport/gnunet-transport.c8
-rw-r--r--src/util/common_logging.c5
-rw-r--r--src/util/container_meta_data.c3
-rw-r--r--src/util/strings.c40
-rw-r--r--src/util/test_strings.c39
-rw-r--r--src/util/time.c24
19 files changed, 112 insertions, 121 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 84d91355a..d84de1c7a 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -412,8 +412,6 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
412int 412int
413main (int argc, char *const *argv) 413main (int argc, char *const *argv)
414{ 414{
415 static unsigned long long temp_timeout_ms;
416
417 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 415 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
418 {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), 416 {'e', "end", NULL, gettext_noop ("stop all GNUnet services"),
419 GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, 417 GNUNET_NO, &GNUNET_GETOPT_set_one, &end},
@@ -433,7 +431,7 @@ main (int argc, char *const *argv)
433 GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, 431 GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet},
434 {'T', "timeout", NULL, 432 {'T', "timeout", NULL,
435 gettext_noop ("timeout for completing current operation"), 433 gettext_noop ("timeout for completing current operation"),
436 GNUNET_YES, &GNUNET_GETOPT_set_ulong, &temp_timeout_ms}, 434 GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout},
437 {'I', "info", NULL, gettext_noop ("List currently running services"), 435 {'I', "info", NULL, gettext_noop ("List currently running services"),
438 GNUNET_NO, &GNUNET_GETOPT_set_one, &list}, 436 GNUNET_NO, &GNUNET_GETOPT_set_one, &list},
439 {'O', "no-stdout", NULL, gettext_noop ("Don't let gnunet-service-arm inherit standard output"), 437 {'O', "no-stdout", NULL, gettext_noop ("Don't let gnunet-service-arm inherit standard output"),
@@ -443,9 +441,6 @@ main (int argc, char *const *argv)
443 GNUNET_GETOPT_OPTION_END 441 GNUNET_GETOPT_OPTION_END
444 }; 442 };
445 443
446 if (temp_timeout_ms > 0)
447 timeout.rel_value = temp_timeout_ms;
448
449 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 444 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
450 return 2; 445 return 2;
451 446
diff --git a/src/chat/gnunet-chat.c b/src/chat/gnunet-chat.c
index d41d59062..8e6ba9bc2 100644
--- a/src/chat/gnunet-chat.c
+++ b/src/chat/gnunet-chat.c
@@ -118,7 +118,7 @@ receive_cb (void *cls, struct GNUNET_CHAT_Room *room,
118 char *non_unique_nick; 118 char *non_unique_nick;
119 char *nick; 119 char *nick;
120 int nick_is_a_dup; 120 int nick_is_a_dup;
121 char *time; 121 const char *timestr;
122 const char *fmt; 122 const char *fmt;
123 123
124 if (NULL == sender) 124 if (NULL == sender)
@@ -176,10 +176,9 @@ receive_cb (void *cls, struct GNUNET_CHAT_Room *room,
176 fmt = _("(%s) <%s> said using an unknown message type: %s\n"); 176 fmt = _("(%s) <%s> said using an unknown message type: %s\n");
177 break; 177 break;
178 } 178 }
179 time = GNUNET_STRINGS_absolute_time_to_string (timestamp); 179 timestr = GNUNET_STRINGS_absolute_time_to_string (timestamp);
180 FPRINTF (stdout, fmt, time, nick, message); 180 FPRINTF (stdout, fmt, timestr, nick, message);
181 GNUNET_free (nick); 181 GNUNET_free (nick);
182 GNUNET_free (time);
183 return GNUNET_OK; 182 return GNUNET_OK;
184} 183}
185 184
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index ebdd8aab3..571a2a53d 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -110,7 +110,8 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
110 const struct GNUNET_ATS_Information *ats, uint32_t ats_count) 110 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
111{ 111{
112 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 112 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
113 char *now_str; 113 const char *now_str;
114
114 if (0 != memcmp (&my_id, peer, sizeof (my_id))) 115 if (0 != memcmp (&my_id, peer, sizeof (my_id)))
115 { 116 {
116 monitor_connections_counter ++; 117 monitor_connections_counter ++;
@@ -120,8 +121,6 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
120 _("Connected to"), 121 _("Connected to"),
121 GNUNET_i2s (peer), 122 GNUNET_i2s (peer),
122 monitor_connections_counter); 123 monitor_connections_counter);
123
124 GNUNET_free (now_str);
125 } 124 }
126} 125}
127 126
@@ -137,21 +136,19 @@ static void
137monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 136monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
138{ 137{
139 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 138 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
140 char *now_str; 139 const char *now_str;
141 140
142 if (0 != memcmp (&my_id, peer, sizeof (my_id))) 141 if (0 != memcmp (&my_id, peer, sizeof (my_id)))
143 { 142 {
144 now_str = GNUNET_STRINGS_absolute_time_to_string (now); 143 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
145 144
146 GNUNET_assert (monitor_connections_counter > 0); 145 GNUNET_assert (monitor_connections_counter > 0);
147 monitor_connections_counter --; 146 monitor_connections_counter--;
148
149 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), 147 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
150 now_str, 148 now_str,
151 _("Disconnected from"), 149 _("Disconnected from"),
152 GNUNET_i2s (peer), 150 GNUNET_i2s (peer),
153 monitor_connections_counter); 151 monitor_connections_counter);
154 GNUNET_free (now_str);
155 } 152 }
156} 153}
157 154
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c
index e0e087786..b03c7c7c0 100644
--- a/src/dht/gnunet-dht-monitor.c
+++ b/src/dht/gnunet-dht-monitor.c
@@ -242,7 +242,7 @@ run (void *cls, char *const *args, const char *cfgfile,
242 if (verbose) 242 if (verbose)
243 FPRINTF (stderr, 243 FPRINTF (stderr,
244 "Monitoring for %s\n", 244 "Monitoring for %s\n",
245 GNUNET_TIME_relative_to_string (timeout_request)); 245 GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO));
246 GNUNET_SCHEDULER_add_delayed (timeout_request, &cleanup_task, NULL); 246 GNUNET_SCHEDULER_add_delayed (timeout_request, &cleanup_task, NULL);
247 monitor_handle = GNUNET_DHT_monitor_start (dht_handle, 247 monitor_handle = GNUNET_DHT_monitor_start (dht_handle,
248 block_type, 248 block_type,
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 2293cedd7..093dd7bdc 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -127,7 +127,7 @@ static void *
127progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) 127progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
128{ 128{
129 char *s; 129 char *s;
130 char *s2; 130 const char *s2;
131 char *t; 131 char *t;
132 132
133 switch (info->status) 133 switch (info->status)
@@ -140,13 +140,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
140 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 140 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
141 if (verbose) 141 if (verbose)
142 { 142 {
143 s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta); 143 s = GNUNET_strdup (GNUNET_STRINGS_relative_time_to_string (info->value.download.eta,
144 GNUNET_YES));
144 if (info->value.download.specifics.progress.block_download_duration.rel_value 145 if (info->value.download.specifics.progress.block_download_duration.rel_value
145 == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 146 == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
146 s2 = GNUNET_strdup (_("<unknown time>")); 147 s2 = _("<unknown time>");
147 else 148 else
148 s2 = GNUNET_STRINGS_relative_time_to_string ( 149 s2 = GNUNET_STRINGS_relative_time_to_string (
149 info->value.download.specifics.progress.block_download_duration); 150 info->value.download.specifics.progress.block_download_duration,
151 GNUNET_YES);
150 t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 152 t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
151 1000LL / 153 1000LL /
152 (info->value.download. 154 (info->value.download.
@@ -157,7 +159,6 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
157 (unsigned long long) info->value.download.completed, 159 (unsigned long long) info->value.download.completed,
158 (unsigned long long) info->value.download.size, s, t, s2); 160 (unsigned long long) info->value.download.size, s, t, s2);
159 GNUNET_free (s); 161 GNUNET_free (s);
160 GNUNET_free (s2);
161 GNUNET_free (t); 162 GNUNET_free (t);
162 } 163 }
163 else 164 else
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 96dcfbf69..3fdc1a9fa 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -134,7 +134,7 @@ stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
134static void * 134static void *
135progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) 135progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
136{ 136{
137 char *s; 137 const char *s;
138 138
139 switch (info->status) 139 switch (info->status)
140 { 140 {
@@ -143,12 +143,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
143 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 143 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
144 if (verbose) 144 if (verbose)
145 { 145 {
146 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta); 146 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
147 GNUNET_YES);
147 FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"), 148 FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
148 info->value.publish.filename, 149 info->value.publish.filename,
149 (unsigned long long) info->value.publish.completed, 150 (unsigned long long) info->value.publish.completed,
150 (unsigned long long) info->value.publish.size, s); 151 (unsigned long long) info->value.publish.size, s);
151 GNUNET_free (s);
152 } 152 }
153 break; 153 break;
154 case GNUNET_FS_STATUS_PUBLISH_ERROR: 154 case GNUNET_FS_STATUS_PUBLISH_ERROR:
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index f4e352737..be16e9100 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -76,7 +76,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
76static void * 76static void *
77progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) 77progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
78{ 78{
79 char *s; 79 const char *s;
80 80
81 switch (info->status) 81 switch (info->status)
82 { 82 {
@@ -85,11 +85,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
85 case GNUNET_FS_STATUS_UNINDEX_PROGRESS: 85 case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
86 if (verbose) 86 if (verbose)
87 { 87 {
88 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta); 88 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta, GNUNET_YES);
89 FPRINTF (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"), 89 FPRINTF (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"),
90 (unsigned long long) info->value.unindex.completed, 90 (unsigned long long) info->value.unindex.completed,
91 (unsigned long long) info->value.unindex.size, s); 91 (unsigned long long) info->value.unindex.size, s);
92 GNUNET_free (s);
93 } 92 }
94 break; 93 break;
95 case GNUNET_FS_STATUS_UNINDEX_ERROR: 94 case GNUNET_FS_STATUS_UNINDEX_ERROR:
diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c
index 96ad29cb4..95225d7c0 100644
--- a/src/fs/test_fs_directory.c
+++ b/src/fs/test_fs_directory.c
@@ -79,7 +79,7 @@ testDirectory (unsigned int i)
79 char txt[128]; 79 char txt[128];
80 int ret = 0; 80 int ret = 0;
81 struct GNUNET_TIME_Absolute start; 81 struct GNUNET_TIME_Absolute start;
82 char *s; 82 const char *s;
83 83
84 cls.max = i; 84 cls.max = i;
85 uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i); 85 uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i);
@@ -130,11 +130,11 @@ testDirectory (unsigned int i)
130 GNUNET_FS_directory_builder_add (db, uris[p], mds[p], NULL); 130 GNUNET_FS_directory_builder_add (db, uris[p], mds[p], NULL);
131 GNUNET_FS_directory_builder_finish (db, &dlen, (void **) &data); 131 GNUNET_FS_directory_builder_finish (db, &dlen, (void **) &data);
132 s = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration 132 s = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration
133 (start)); 133 (start),
134 GNUNET_YES);
134 FPRINTF (stdout, 135 FPRINTF (stdout,
135 "Creating directory with %u entires and total size %llu took %s\n", 136 "Creating directory with %u entires and total size %llu took %s\n",
136 i, (unsigned long long) dlen, s); 137 i, (unsigned long long) dlen, s);
137 GNUNET_free (s);
138 if (i < 100) 138 if (i < 100)
139 { 139 {
140 cls.pos = 0; 140 cls.pos = 0;
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 4073b0cfa..64dbd1ef3 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -224,22 +224,28 @@ GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size,
224 224
225/** 225/**
226 * "asctime", except for GNUnet time. 226 * "asctime", except for GNUnet time.
227 * This is one of the very few calls in the entire API that is
228 * NOT reentrant!
227 * 229 *
228 * @param t the absolute time to convert 230 * @param t the absolute time to convert
229 * @return timestamp in human-readable form 231 * @return timestamp in human-readable form
230 */ 232 */
231char * 233const char *
232GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t); 234GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t);
233 235
234 236
235/** 237/**
236 * Give relative time in human-readable fancy format. 238 * Give relative time in human-readable fancy format.
239 * This is one of the very few calls in the entire API that is
240 * NOT reentrant!
237 * 241 *
238 * @param delta time in milli seconds 242 * @param delta time in milli seconds
243 * @param do_round are we allowed to round a bit?
239 * @return string in human-readable form 244 * @return string in human-readable form
240 */ 245 */
241char * 246const char *
242GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta); 247GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
248 int do_round);
243 249
244 250
245/** 251/**
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 5a8c1bc48..347b68aec 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -828,8 +828,10 @@ do_reconnect (struct GNUNET_MESH_Handle *h)
828 GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, 828 GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
829 GNUNET_TIME_relative_multiply 829 GNUNET_TIME_relative_multiply
830 (h->reconnect_time, 2)); 830 (h->reconnect_time, 2));
831 LOG (GNUNET_ERROR_TYPE_DEBUG, " Next retry in %sms\n", 831 LOG (GNUNET_ERROR_TYPE_DEBUG,
832 GNUNET_TIME_relative_to_string (h->reconnect_time)); 832 "Next retry in %s\n",
833 GNUNET_STRINGS_relative_time_to_string (h->reconnect_time,
834 GNUNET_NO));
833 GNUNET_break (0); 835 GNUNET_break (0);
834 return GNUNET_NO; 836 return GNUNET_NO;
835 } 837 }
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 7fc3ad45f..fbb242569 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -277,7 +277,7 @@ display_record (void *cls,
277 const char *typestring; 277 const char *typestring;
278 char *s; 278 char *s;
279 unsigned int i; 279 unsigned int i;
280 char *etime; 280 const char *etime;
281 struct GNUNET_TIME_Absolute aex; 281 struct GNUNET_TIME_Absolute aex;
282 struct GNUNET_TIME_Relative rex; 282 struct GNUNET_TIME_Relative rex;
283 283
@@ -308,7 +308,7 @@ display_record (void *cls,
308 if (0 != (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)) 308 if (0 != (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
309 { 309 {
310 rex.rel_value = rd[i].expiration_time; 310 rex.rel_value = rd[i].expiration_time;
311 etime = GNUNET_STRINGS_relative_time_to_string (rex); 311 etime = GNUNET_STRINGS_relative_time_to_string (rex, GNUNET_YES);
312 } 312 }
313 else 313 else
314 { 314 {
@@ -320,7 +320,6 @@ display_record (void *cls,
320 ? _(/* what follows is relative expiration */ "for at least") 320 ? _(/* what follows is relative expiration */ "for at least")
321 : _(/* what follows is absolute expiration */ "until"), 321 : _(/* what follows is absolute expiration */ "until"),
322 etime); 322 etime);
323 GNUNET_free (etime);
324 GNUNET_free (s); 323 GNUNET_free (s);
325 } 324 }
326 FPRINTF (stdout, "%s", "\n"); 325 FPRINTF (stdout, "%s", "\n");
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 671fd35be..15dedaec1 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -79,7 +79,8 @@ printer (void *cls, const char *subsystem, const char *name, uint64_t value,
79 int is_persistent) 79 int is_persistent)
80{ 80{
81 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 81 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
82 char * now_str; 82 const char * now_str;
83
83 if (quiet == GNUNET_NO) 84 if (quiet == GNUNET_NO)
84 { 85 {
85 if (GNUNET_YES == watch) 86 if (GNUNET_YES == watch)
@@ -89,7 +90,6 @@ printer (void *cls, const char *subsystem, const char *name, uint64_t value,
89 now_str, 90 now_str,
90 is_persistent ? "!" : " ", 91 is_persistent ? "!" : " ",
91 subsystem, _(name), (unsigned long long) value); 92 subsystem, _(name), (unsigned long long) value);
92 GNUNET_free (now_str);
93 } 93 }
94 else 94 else
95 { 95 {
diff --git a/src/testing_old/testing.c b/src/testing_old/testing.c
index 1b164aa0f..b09afca0a 100644
--- a/src/testing_old/testing.c
+++ b/src/testing_old/testing.c
@@ -417,9 +417,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
417 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", 417 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
418 d->cfgfile, 418 d->cfgfile,
419 "-s", "-q", "-T", 419 "-s", "-q", "-T",
420 GNUNET_TIME_relative_to_string 420 GNUNET_STRINGS_relative_time_to_string
421 (GNUNET_TIME_absolute_get_remaining 421 (GNUNET_TIME_absolute_get_remaining
422 (d->max_timeout)), NULL); 422 (d->max_timeout), GNUNET_NO), NULL);
423 } 423 }
424 else 424 else
425 { 425 {
@@ -438,9 +438,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
438 "-q", 438 "-q",
439 dst, "gnunet-arm", 439 dst, "gnunet-arm",
440 "-c", d->cfgfile, "-s", "-q", "-T", 440 "-c", d->cfgfile, "-s", "-q", "-T",
441 GNUNET_TIME_relative_to_string 441 GNUNET_STRINGS_relative_time_to_string
442 (GNUNET_TIME_absolute_get_remaining 442 (GNUNET_TIME_absolute_get_remaining
443 (d->max_timeout)), NULL); 443 (d->max_timeout), GNUNET_NO), NULL);
444 } 444 }
445 else 445 else
446 { 446 {
@@ -451,9 +451,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
451 "-q", 451 "-q",
452 dst, "gnunet-arm", 452 dst, "gnunet-arm",
453 "-c", d->cfgfile, "-s", "-q", "-T", 453 "-c", d->cfgfile, "-s", "-q", "-T",
454 GNUNET_TIME_relative_to_string 454 GNUNET_STRINGS_relative_time_to_string
455 (GNUNET_TIME_absolute_get_remaining 455 (GNUNET_TIME_absolute_get_remaining
456 (d->max_timeout)), NULL); 456 (d->max_timeout), GNUNET_NO), NULL);
457 } 457 }
458 GNUNET_free (dst); 458 GNUNET_free (dst);
459 } 459 }
@@ -897,7 +897,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d,
897 arg, "gnunet-arm", 897 arg, "gnunet-arm",
898 "-c", d->cfgfile, "-i", service, "-q", 898 "-c", d->cfgfile, "-i", service, "-q",
899 "-T", 899 "-T",
900 GNUNET_TIME_relative_to_string (timeout), 900 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
901 NULL); 901 NULL);
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
903 "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", 903 "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n",
@@ -911,7 +911,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d,
911 d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", 911 d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm",
912 "-c", d->cfgfile, "-i", service, "-q", 912 "-c", d->cfgfile, "-i", service, "-q",
913 "-T", 913 "-T",
914 GNUNET_TIME_relative_to_string (timeout), 914 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
915 NULL); 915 NULL);
916 } 916 }
917 917
@@ -965,12 +965,12 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d,
965 arg, "gnunet-arm", 965 arg, "gnunet-arm",
966 "-c", d->cfgfile, "-i", service, "-q", 966 "-c", d->cfgfile, "-i", service, "-q",
967 "-T", 967 "-T",
968 GNUNET_TIME_relative_to_string (timeout), 968 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
969 NULL); 969 NULL);
970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
971 "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q -T %s\n", 971 "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q -T %s\n",
972 arg, "gnunet-arm", d->cfgfile, service, 972 arg, "gnunet-arm", d->cfgfile, service,
973 GNUNET_TIME_relative_to_string (timeout)); 973 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO));
974 GNUNET_free (arg); 974 GNUNET_free (arg);
975 } 975 }
976 else 976 else
@@ -980,12 +980,12 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d,
980 d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", 980 d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm",
981 "-c", d->cfgfile, "-i", service, "-q", 981 "-c", d->cfgfile, "-i", service, "-q",
982 "-T", 982 "-T",
983 GNUNET_TIME_relative_to_string (timeout), 983 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
984 NULL); 984 NULL);
985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
986 "Starting gnunet-arm with command %s -c %s -i %s -q -T %s\n", 986 "Starting gnunet-arm with command %s -c %s -i %s -q -T %s\n",
987 "gnunet-arm", d->cfgfile, service, 987 "gnunet-arm", d->cfgfile, service,
988 GNUNET_TIME_relative_to_string (timeout)); 988 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO));
989 } 989 }
990 990
991 d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 991 d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
@@ -1382,7 +1382,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
1382 arg, "gnunet-arm", 1382 arg, "gnunet-arm",
1383 "-c", d->cfgfile, "-k", service, "-q", 1383 "-c", d->cfgfile, "-k", service, "-q",
1384 "-T", 1384 "-T",
1385 GNUNET_TIME_relative_to_string (timeout), 1385 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
1386 NULL); 1386 NULL);
1387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1388 "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -k %s -q\n", 1388 "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -k %s -q\n",
@@ -1396,7 +1396,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
1396 d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", 1396 d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm",
1397 "-c", d->cfgfile, "-k", service, "-q", 1397 "-c", d->cfgfile, "-k", service, "-q",
1398 "-T", 1398 "-T",
1399 GNUNET_TIME_relative_to_string (timeout), 1399 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
1400 NULL); 1400 NULL);
1401 } 1401 }
1402 1402
@@ -1550,7 +1550,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1550 "-q", 1550 "-q",
1551 arg, "gnunet-arm", 1551 arg, "gnunet-arm",
1552 "-c", d->cfgfile, "-e", "-q", "-T", 1552 "-c", d->cfgfile, "-e", "-q", "-T",
1553 GNUNET_TIME_relative_to_string (timeout), 1553 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
1554 del_arg, NULL); 1554 del_arg, NULL);
1555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1556 "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -e -q %s\n", 1556 "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -e -q %s\n",
@@ -1564,7 +1564,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1564 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); 1564 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
1565 d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm", 1565 d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-arm", "gnunet-arm",
1566 "-c", d->cfgfile, "-e", "-q", "-T", 1566 "-c", d->cfgfile, "-e", "-q", "-T",
1567 GNUNET_TIME_relative_to_string (timeout), 1567 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO),
1568 del_arg, NULL); 1568 del_arg, NULL);
1569 GNUNET_assert (NULL != d->proc_arm_stop); 1569 GNUNET_assert (NULL != d->proc_arm_stop);
1570 } 1570 }
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 36c02014e..1c865ad94 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -447,14 +447,13 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
447{ 447{
448 monitor_connections_counter ++; 448 monitor_connections_counter ++;
449 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 449 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
450 char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); 450 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
451
451 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), 452 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
452 now_str, 453 now_str,
453 _("Connected to"), 454 _("Connected to"),
454 GNUNET_i2s (peer), 455 GNUNET_i2s (peer),
455 monitor_connections_counter); 456 monitor_connections_counter);
456
457 GNUNET_free (now_str);
458} 457}
459 458
460 459
@@ -469,7 +468,7 @@ static void
469monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 468monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
470{ 469{
471 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 470 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
472 char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); 471 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
473 472
474 GNUNET_assert (monitor_connections_counter > 0); 473 GNUNET_assert (monitor_connections_counter > 0);
475 monitor_connections_counter --; 474 monitor_connections_counter --;
@@ -479,7 +478,6 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
479 _("Disconnected from"), 478 _("Disconnected from"),
480 GNUNET_i2s (peer), 479 GNUNET_i2s (peer),
481 monitor_connections_counter); 480 monitor_connections_counter);
482 GNUNET_free (now_str);
483} 481}
484 482
485 483
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 873420460..fbc0de50c 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -798,7 +798,7 @@ flush_bulk (const char *datestr)
798 char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256]; 798 char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256];
799 int rev; 799 int rev;
800 char *last; 800 char *last;
801 char *ft; 801 const char *ft;
802 802
803 if ((last_bulk_time.abs_value == 0) || (last_bulk_repeat == 0)) 803 if ((last_bulk_time.abs_value == 0) || (last_bulk_repeat == 0))
804 return; 804 return;
@@ -814,11 +814,10 @@ flush_bulk (const char *datestr)
814 last[0] = '\0'; 814 last[0] = '\0';
815 } 815 }
816 ft = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration 816 ft = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration
817 (last_bulk_time)); 817 (last_bulk_time), GNUNET_YES);
818 snprintf (msg, sizeof (msg), 818 snprintf (msg, sizeof (msg),
819 _("Message `%.*s' repeated %u times in the last %s\n"), 819 _("Message `%.*s' repeated %u times in the last %s\n"),
820 BULK_TRACK_SIZE, last_bulk, last_bulk_repeat, ft); 820 BULK_TRACK_SIZE, last_bulk, last_bulk_repeat, ft);
821 GNUNET_free (ft);
822 if (rev == 1) 821 if (rev == 1)
823 last[0] = '\n'; 822 last[0] = '\n';
824 output_message (last_bulk_kind, last_bulk_comp, datestr, msg); 823 output_message (last_bulk_kind, last_bulk_comp, datestr, msg);
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c
index e725486b7..9e60a746a 100644
--- a/src/util/container_meta_data.c
+++ b/src/util/container_meta_data.c
@@ -427,7 +427,7 @@ void
427GNUNET_CONTAINER_meta_data_add_publication_date (struct 427GNUNET_CONTAINER_meta_data_add_publication_date (struct
428 GNUNET_CONTAINER_MetaData *md) 428 GNUNET_CONTAINER_MetaData *md)
429{ 429{
430 char *dat; 430 const char *dat;
431 struct GNUNET_TIME_Absolute t; 431 struct GNUNET_TIME_Absolute t;
432 432
433 t = GNUNET_TIME_absolute_get (); 433 t = GNUNET_TIME_absolute_get ();
@@ -438,7 +438,6 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct
438 EXTRACTOR_METATYPE_PUBLICATION_DATE, 438 EXTRACTOR_METATYPE_PUBLICATION_DATE,
439 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 439 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
440 dat, strlen (dat) + 1); 440 dat, strlen (dat) + 1);
441 GNUNET_free (dat);
442} 441}
443 442
444 443
diff --git a/src/util/strings.c b/src/util/strings.c
index ef7658697..efa6029b4 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -616,33 +616,46 @@ GNUNET_STRINGS_filename_expand (const char *fil)
616 616
617/** 617/**
618 * Give relative time in human-readable fancy format. 618 * Give relative time in human-readable fancy format.
619 * This is one of the very few calls in the entire API that is
620 * NOT reentrant!
619 * 621 *
620 * @param delta time in milli seconds 622 * @param delta time in milli seconds
623 * @param do_round are we allowed to round a bit?
621 * @return time as human-readable string 624 * @return time as human-readable string
622 */ 625 */
623char * 626const char *
624GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta) 627GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
628 int do_round)
625{ 629{
630 static char buf[128];
626 const char *unit = _( /* time unit */ "ms"); 631 const char *unit = _( /* time unit */ "ms");
627 char *ret; 632 char *ret;
628 uint64_t dval = delta.rel_value; 633 uint64_t dval = delta.rel_value;
629 634
630 if (delta.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 635 if (delta.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
631 return GNUNET_strdup (_("forever")); 636 return _("forever");
632 if ( (dval > 5 * 1000) || (0 == (dval % 1000) )) 637 if ( ( (GNUNET_YES == do_round) &&
638 (dval > 5 * 1000) ) ||
639 (0 == (dval % 1000) ))
633 { 640 {
634 dval = dval / 1000; 641 dval = dval / 1000;
635 unit = _( /* time unit */ "s"); 642 unit = _( /* time unit */ "s");
636 if ( (dval > 5 * 60) || (0 == (dval % 60) ) ) 643 if ( ( (GNUNET_YES == do_round) &&
644 (dval > 5 * 60) ) ||
645 (0 == (dval % 60) ) )
637 { 646 {
638 dval = dval / 60; 647 dval = dval / 60;
639 unit = _( /* time unit */ "m"); 648 unit = _( /* time unit */ "m");
640 if ( (dval > 5 * 60) || (0 == (dval % 60) )) 649 if ( ( (GNUNET_YES == do_round) &&
650 (dval > 5 * 60) ) ||
651 (0 == (dval % 60) ))
641 { 652 {
642 dval = dval / 60; 653 dval = dval / 60;
643 unit = _( /* time unit */ "h"); 654 unit = _( /* time unit */ "h");
644 if ( (dval > 5 * 24) || (0 == (dval % 24)) ) 655 if ( ( (GNUNET_YES == do_round) &&
645 { 656 (dval > 5 * 24) ) ||
657 (0 == (dval % 24)) )
658 {
646 dval = dval / 24; 659 dval = dval / 24;
647 if (1 == dval) 660 if (1 == dval)
648 unit = _( /* time unit */ "day"); 661 unit = _( /* time unit */ "day");
@@ -652,23 +665,26 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta)
652 } 665 }
653 } 666 }
654 } 667 }
655 GNUNET_asprintf (&ret, "%llu %s", dval, unit); 668 GNUNET_snprintf (buf, sizeof (buf),
656 return ret; 669 "%llu %s", dval, unit);
670 return buf;
657} 671}
658 672
659 673
660/** 674/**
661 * "asctime", except for GNUnet time. 675 * "asctime", except for GNUnet time.
676 * This is one of the very few calls in the entire API that is
677 * NOT reentrant!
662 * 678 *
663 * @param t time to convert 679 * @param t time to convert
664 * @return absolute time in human-readable format 680 * @return absolute time in human-readable format
665 */ 681 */
666char * 682const char *
667GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t) 683GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
668{ 684{
685 static char buf[255];
669 time_t tt; 686 time_t tt;
670 struct tm *tp; 687 struct tm *tp;
671 char buf[255];
672 688
673 if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 689 if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
674 return GNUNET_strdup (_("end of time")); 690 return GNUNET_strdup (_("end of time"));
diff --git a/src/util/test_strings.c b/src/util/test_strings.c
index 749650589..a77acaa59 100644
--- a/src/util/test_strings.c
+++ b/src/util/test_strings.c
@@ -27,6 +27,7 @@
27 27
28 28
29#define WANT(a,b) if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_free(b); GNUNET_break(0); return 1;} else { GNUNET_free (b); } 29#define WANT(a,b) if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_free(b); GNUNET_break(0); return 1;} else { GNUNET_free (b); }
30#define WANTNF(a,b) do { if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_break(0); return 1;} } while (0)
30#define WANTB(a,b,l) if (0 != memcmp(a,b,l)) { GNUNET_break(0); return 1;} else { } 31#define WANTB(a,b,l) if (0 != memcmp(a,b,l)) { GNUNET_break(0); return 1;} else { }
31 32
32int 33int
@@ -35,6 +36,7 @@ main (int argc, char *argv[])
35 char buf[128]; 36 char buf[128];
36 char *r; 37 char *r;
37 char *b; 38 char *b;
39 const char *bc;
38 struct GNUNET_TIME_Absolute at; 40 struct GNUNET_TIME_Absolute at;
39 struct GNUNET_TIME_Absolute atx; 41 struct GNUNET_TIME_Absolute atx;
40 const char *hdir; 42 const char *hdir;
@@ -50,20 +52,20 @@ main (int argc, char *argv[])
50 b = GNUNET_STRINGS_byte_size_fancy (10240LL * 1024LL * 1024LL * 1024LL); 52 b = GNUNET_STRINGS_byte_size_fancy (10240LL * 1024LL * 1024LL * 1024LL);
51 WANT (buf, b); 53 WANT (buf, b);
52 sprintf (buf, "4 %s", _( /* time unit */ "ms")); 54 sprintf (buf, "4 %s", _( /* time unit */ "ms"));
53 b = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply 55 bc = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply
54 (GNUNET_TIME_UNIT_MILLISECONDS, 56 (GNUNET_TIME_UNIT_MILLISECONDS,
55 4)); 57 4), GNUNET_YES);
56 WANT (buf, b); 58 WANTNF (buf, bc);
57 sprintf (buf, "7 %s", _( /* time unit */ "s")); 59 sprintf (buf, "7 %s", _( /* time unit */ "s"));
58 b = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply 60 bc = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply
59 (GNUNET_TIME_UNIT_MILLISECONDS, 61 (GNUNET_TIME_UNIT_MILLISECONDS,
60 7 * 1000)); 62 7 * 1000), GNUNET_YES);
61 WANT (buf, b); 63 WANTNF (buf, bc);
62 sprintf (buf, "7 %s", _( /* time unit */ "h")); 64 sprintf (buf, "7 %s", _( /* time unit */ "h"));
63 b = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply 65 bc = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_relative_multiply
64 (GNUNET_TIME_UNIT_MILLISECONDS, 66 (GNUNET_TIME_UNIT_MILLISECONDS,
65 7 * 60 * 60 * 1000)); 67 7 * 60 * 60 * 1000), GNUNET_YES);
66 WANT (buf, b); 68 WANTNF (buf, bc);
67#ifndef MINGW 69#ifndef MINGW
68 hdir = getenv ("HOME"); 70 hdir = getenv ("HOME");
69#else 71#else
@@ -84,27 +86,24 @@ main (int argc, char *argv[])
84 if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b)) 86 if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b))
85 return 1; 87 return 1;
86 at.abs_value = 5000; 88 at.abs_value = 5000;
87 r = GNUNET_STRINGS_absolute_time_to_string (at); 89 bc = GNUNET_STRINGS_absolute_time_to_string (at);
88 /* r should be something like "Wed Dec 31 17:00:05 1969" 90 /* bc should be something like "Wed Dec 31 17:00:05 1969"
89 * where the details of the day and hour depend on the timezone; 91 * where the details of the day and hour depend on the timezone;
90 * however, the "0:05 19" should always be there; hence: */ 92 * however, the "0:05 19" should always be there; hence: */
91 if (NULL == strstr (r, "0:05 19")) 93 if (NULL == strstr (bc, "0:05 19"))
92 { 94 {
93 FPRINTF (stderr, "Got %s\n", r); 95 FPRINTF (stderr, "Got %s\n", bc);
94 GNUNET_break (0); 96 GNUNET_break (0);
95 GNUNET_free (r);
96 return 1; 97 return 1;
97 } 98 }
98 GNUNET_free (r);
99 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII"); 99 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII");
100 WANT ("TEST", b); 100 WANT ("TEST", b);
101 101
102 at = GNUNET_TIME_UNIT_FOREVER_ABS; 102 at = GNUNET_TIME_UNIT_FOREVER_ABS;
103 b = GNUNET_STRINGS_absolute_time_to_string (at); 103 bc = GNUNET_STRINGS_absolute_time_to_string (at);
104 GNUNET_assert (GNUNET_OK == 104 GNUNET_assert (GNUNET_OK ==
105 GNUNET_STRINGS_fancy_time_to_absolute (b, &atx)); 105 GNUNET_STRINGS_fancy_time_to_absolute (bc, &atx));
106 GNUNET_assert (atx.abs_value == at.abs_value); 106 GNUNET_assert (atx.abs_value == at.abs_value);
107 GNUNET_free (b);
108 107
109#if ENABLE_NLS && HAVE_ICONV 108#if ENABLE_NLS && HAVE_ICONV
110 GNUNET_log_skip (2, GNUNET_NO); 109 GNUNET_log_skip (2, GNUNET_NO);
diff --git a/src/util/time.c b/src/util/time.c
index 7467b4497..afb0c00c1 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -484,6 +484,7 @@ GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a)
484 return ret; 484 return ret;
485} 485}
486 486
487
487/** 488/**
488 * Convert relative time from network byte order. 489 * Convert relative time from network byte order.
489 * 490 *
@@ -500,6 +501,7 @@ GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a)
500 501
501} 502}
502 503
504
503/** 505/**
504 * Convert absolute time to network byte order. 506 * Convert absolute time to network byte order.
505 * 507 *
@@ -515,6 +517,7 @@ GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a)
515 return ret; 517 return ret;
516} 518}
517 519
520
518/** 521/**
519 * Convert absolute time from network byte order. 522 * Convert absolute time from network byte order.
520 * 523 *
@@ -531,26 +534,5 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
531 534
532} 535}
533 536
534/**
535 * Convert a relative time to a string.
536 * This is one of the very few calls in the entire API that is
537 * NOT reentrant!
538 *
539 * @param time the time to print
540 *
541 * @return string form of the time (as milliseconds)
542 */
543const char *
544GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time)
545{
546 static char time_string[21];
547
548 memset (time_string, 0, sizeof (time_string));
549
550 sprintf (time_string, "%llu", (unsigned long long) time.rel_value);
551 return (const char *) time_string;
552}
553
554
555 537
556/* end of time.c */ 538/* end of time.c */