mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
time: add support for time64 libcs
Treat time_t's as entirely unique and use the POSIX API's for converting to/from strings. Lastly, a 64-bit integer formats as 20 digits at most in base10. Don't need to have any 100 byte buffers to hold that. ASTERISK-29674 #close Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Change-Id: Id7b25bdca8f92e34229f6454f6c3e500f2cd6f56
This commit is contained in:
committed by
Kevin Harwell
parent
96a3ff9edd
commit
f50e793665
@@ -35,6 +35,13 @@
|
||||
|
||||
#include "asterisk/inline_api.h"
|
||||
|
||||
/* A time_t can be represented as an unsigned long long (or uint64_t).
|
||||
* Formatted in base 10, UINT64_MAX is 20 digits long, plus one for NUL.
|
||||
* This should be the size of the receiving char buffer for calls to
|
||||
* ast_time_t_to_string().
|
||||
*/
|
||||
#define AST_TIME_T_LEN 21
|
||||
|
||||
/* We have to let the compiler learn what types to use for the elements of a
|
||||
struct timeval since on linux, it's time_t and suseconds_t, but on *BSD,
|
||||
they are just a long.
|
||||
@@ -316,4 +323,17 @@ struct timeval ast_time_create_by_unit(unsigned long val, enum TIME_UNIT unit);
|
||||
*/
|
||||
struct timeval ast_time_create_by_unit_str(unsigned long val, const char *unit);
|
||||
|
||||
/*!
|
||||
* \brief Converts to a string representation of a time_t as decimal
|
||||
* seconds since the epoch. Returns -1 on failure, zero otherwise.
|
||||
*
|
||||
* The buffer should be at least 22 bytes long.
|
||||
*/
|
||||
int ast_time_t_to_string(time_t time, char *buf, size_t length);
|
||||
|
||||
/*!
|
||||
* \brief Returns a time_t from a string containing seconds since the epoch.
|
||||
*/
|
||||
time_t ast_string_to_time_t(const char *str);
|
||||
|
||||
#endif /* _ASTERISK_TIME_H */
|
||||
|
Reference in New Issue
Block a user