diff options
Diffstat (limited to 'src/util/strings.c')
-rw-r--r-- | src/util/strings.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/util/strings.c b/src/util/strings.c index d0e8fddc7..cddb4bb07 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -291,7 +291,7 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, | |||
291 | * | 291 | * |
292 | * @param fancy_time human readable string (i.e. 1 minute) | 292 | * @param fancy_time human readable string (i.e. 1 minute) |
293 | * @param rtime set to the relative time | 293 | * @param rtime set to the relative time |
294 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 294 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
295 | */ | 295 | */ |
296 | int | 296 | int |
297 | GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, | 297 | GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, |
@@ -332,11 +332,12 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, | |||
332 | 332 | ||
333 | /** | 333 | /** |
334 | * Convert a given fancy human-readable time to our internal | 334 | * Convert a given fancy human-readable time to our internal |
335 | * representation. | 335 | * representation. The human-readable time is expected to be |
336 | * in local time, whereas the returned value will be in UTC. | ||
336 | * | 337 | * |
337 | * @param fancy_time human readable string (i.e. %Y-%m-%d %H:%M:%S) | 338 | * @param fancy_time human readable string (i.e. %Y-%m-%d %H:%M:%S) |
338 | * @param atime set to the absolute time | 339 | * @param atime set to the absolute time |
339 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 340 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
340 | */ | 341 | */ |
341 | int | 342 | int |
342 | GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | 343 | GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, |
@@ -375,6 +376,11 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | |||
375 | * Convert the len characters long character sequence | 376 | * Convert the len characters long character sequence |
376 | * given in input that is in the given input charset | 377 | * given in input that is in the given input charset |
377 | * to a string in given output charset. | 378 | * to a string in given output charset. |
379 | * | ||
380 | * @param input input string | ||
381 | * @param len number of bytes in @a input | ||
382 | * @param input_charset character set used for @a input | ||
383 | * @param ouptut_charset desired character set for the return value | ||
378 | * @return the converted string (0-terminated), | 384 | * @return the converted string (0-terminated), |
379 | * if conversion fails, a copy of the orignal | 385 | * if conversion fails, a copy of the orignal |
380 | * string is returned. | 386 | * string is returned. |
@@ -438,12 +444,18 @@ GNUNET_STRINGS_conv (const char *input, | |||
438 | * Convert the len characters long character sequence | 444 | * Convert the len characters long character sequence |
439 | * given in input that is in the given charset | 445 | * given in input that is in the given charset |
440 | * to UTF-8. | 446 | * to UTF-8. |
447 | * | ||
448 | * @param input the input string (not necessarily 0-terminated) | ||
449 | * @param len the number of bytes in the @a input | ||
450 | * @param charset character set to convert from | ||
441 | * @return the converted string (0-terminated), | 451 | * @return the converted string (0-terminated), |
442 | * if conversion fails, a copy of the orignal | 452 | * if conversion fails, a copy of the orignal |
443 | * string is returned. | 453 | * string is returned. |
444 | */ | 454 | */ |
445 | char * | 455 | char * |
446 | GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset) | 456 | GNUNET_STRINGS_to_utf8 (const char *input, |
457 | size_t len, | ||
458 | const char *charset) | ||
447 | { | 459 | { |
448 | return GNUNET_STRINGS_conv (input, len, charset, "UTF-8"); | 460 | return GNUNET_STRINGS_conv (input, len, charset, "UTF-8"); |
449 | } | 461 | } |
@@ -453,12 +465,17 @@ GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset) | |||
453 | * Convert the len bytes-long UTF-8 string | 465 | * Convert the len bytes-long UTF-8 string |
454 | * given in input to the given charset. | 466 | * given in input to the given charset. |
455 | * | 467 | * |
468 | * @param input the input string (not necessarily 0-terminated) | ||
469 | * @param len the number of bytes in the @a input | ||
470 | * @param charset character set to convert to | ||
456 | * @return the converted string (0-terminated), | 471 | * @return the converted string (0-terminated), |
457 | * if conversion fails, a copy of the orignal | 472 | * if conversion fails, a copy of the orignal |
458 | * string is returned. | 473 | * string is returned. |
459 | */ | 474 | */ |
460 | char * | 475 | char * |
461 | GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset) | 476 | GNUNET_STRINGS_from_utf8 (const char *input, |
477 | size_t len, | ||
478 | const char *charset) | ||
462 | { | 479 | { |
463 | return GNUNET_STRINGS_conv (input, len, "UTF-8", charset); | 480 | return GNUNET_STRINGS_conv (input, len, "UTF-8", charset); |
464 | } | 481 | } |
@@ -689,9 +706,10 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, | |||
689 | 706 | ||
690 | 707 | ||
691 | /** | 708 | /** |
692 | * "asctime", except for GNUnet time. | 709 | * "asctime", except for GNUnet time. Converts a GNUnet internal |
693 | * This is one of the very few calls in the entire API that is | 710 | * absolute time (which is in UTC) to a string in local time. |
694 | * NOT reentrant! | 711 | * Note that the returned value will be overwritten if this function |
712 | * is called again. | ||
695 | * | 713 | * |
696 | * @param t time to convert | 714 | * @param t time to convert |
697 | * @return absolute time in human-readable format | 715 | * @return absolute time in human-readable format |