aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-05-30 23:31:24 -0300
committerdequis <dx@dxzone.com.ar>2015-05-30 23:31:24 -0300
commit73f0a012a1f6b3e5fa3c7905e4f216b5ac29a30c (patch)
tree432ebfd4e2f953de24be099fc6e796b788242267 /lib
parent6e21525c241d5f70767463577392aac481d3b051 (diff)
Move twitter_parse_id() to parse_int64() in misc.c
Diffstat (limited to 'lib')
-rw-r--r--lib/misc.c16
-rw-r--r--lib/misc.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/misc.c b/lib/misc.c
index c2a42c97..26a604cf 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -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;
+}
+
diff --git a/lib/misc.h b/lib/misc.h
index 39be4548..68b63155 100644
--- a/lib/misc.h
+++ b/lib/misc.h
@@ -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