diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/misc.c | 16 | ||||
-rw-r--r-- | lib/misc.h | 1 |
2 files changed, 17 insertions, 0 deletions
@@ -750,3 +750,19 @@ int truncate_utf8(char *string, int maxlen) *end = '\0'; return end - string; } + +/* Parses a guint64 from string, returns TRUE on success */ +gboolean parse_int64(char *string, int base, guint64 *number) +{ + guint64 parsed; + char *endptr; + + errno = 0; + parsed = g_ascii_strtoull(string, &endptr, base); + if (errno || endptr == string || *endptr != '\0') { + return FALSE; + } + *number = parsed; + return TRUE; +} + @@ -148,5 +148,6 @@ G_MODULE_EXPORT int md5_verify_password(char *password, char *hash); G_MODULE_EXPORT char **split_command_parts(char *command, int limit); G_MODULE_EXPORT char *get_rfc822_header(const char *text, const char *header, int len); G_MODULE_EXPORT int truncate_utf8(char *string, int maxlen); +G_MODULE_EXPORT gboolean parse_int64(char *string, int base, guint64 *number); #endif |