From 326768484a8884767b50fbdf5472eff236ce316c Mon Sep 17 00:00:00 2001 From: Iztok Jeras <iztok.jeras@redpitaya.com> Date: ćšć, 08 10æ 2015 03:00:34 +0800 Subject: [PATCH] integer parser: renamed some more static functions, to add Base or Sign keyword --- libscpi/src/utils.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index c17bb18..8856003 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -261,7 +261,7 @@ * @param val 32bit integer result * @return number of bytes used in string */ -size_t strToInt32(const char * str, int32_t * val, int8_t base) { +size_t strBaseToInt32(const char * str, int32_t * val, int8_t base) { char * endptr; *val = strtol(str, &endptr, base); return endptr - str; @@ -273,9 +273,33 @@ * @param val 32bit integer result * @return number of bytes used in string */ -size_t strToUInt32(const char * str, uint32_t * val, int8_t base) { +size_t strBaseToUInt32(const char * str, uint32_t * val, int8_t base) { char * endptr; *val = strtoul(str, &endptr, base); + return endptr - str; +} + +/** + * Converts string to signed 64bit integer representation + * @param str string value + * @param val 64bit integer result + * @return number of bytes used in string + */ +size_t strBaseToInt64(const char * str, int64_t * val, int8_t base) { + char * endptr; + *val = strtol(str, &endptr, base); + return endptr - str; +} + +/** + * Converts string to unsigned 64bit integer representation + * @param str string value + * @param val 64bit integer result + * @return number of bytes used in string + */ +size_t strBaseToUInt64(const char * str, uint64_t * val, int8_t base) { + char * endptr; + *val = strtoull(str, &endptr, base); return endptr - str; } @@ -336,7 +360,7 @@ //*num = 1; } else { int32_t tmpNum; - i = len1 + strToInt32(str2 + len1, &tmpNum, 10); + i = len1 + strBaseToInt32(str2 + len1, &tmpNum, 10); if (i != len2) { result = FALSE; } else { -- Gitblit v1.9.1