From 770a8737d7dd0772078d4711fce186c6b3915b20 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 16 Sep 2016 10:41:11 -0700 Subject: Add ws_hexstrtou{bits} and use ws_hexstrtou32 in androiddump. Make the reply length unsigned - there's no reason for it to be signed. Change-Id: I5f4d1f027eeddee939547c052220efb89800f4b1 Reviewed-on: https://code.wireshark.org/review/17740 Reviewed-by: Guy Harris --- wsutil/strtoi.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'wsutil/strtoi.h') diff --git a/wsutil/strtoi.h b/wsutil/strtoi.h index 3361da8fc3..eb65fec218 100644 --- a/wsutil/strtoi.h +++ b/wsutil/strtoi.h @@ -30,7 +30,7 @@ #include "ws_symbol_export.h" /* - * \brief Convert a string to a signed/unsigned int, with error checks. + * \brief Convert a decimal string to a signed/unsigned int, with error checks. * \param str The string to convert * \param endptr A pointer that will store a pointer to the first invalid * character in str, allowing a number to be parsed even if there is trailing @@ -51,6 +51,24 @@ WS_DLL_PUBLIC gboolean ws_strtou32(const gchar* str, const gchar** endptr, guint WS_DLL_PUBLIC gboolean ws_strtou16(const gchar* str, const gchar** endptr, guint16* cint); WS_DLL_PUBLIC gboolean ws_strtou8 (const gchar* str, const gchar** endptr, guint8* cint); +/* + * \brief Convert a hexadecimal string to an unsigned int, with error checks. + * \param str The string to convert + * \param endptr A pointer that will store a pointer to the first invalid + * character in str, allowing a number to be parsed even if there is trailing + * whitespace. If NULL, then the string is assumed to contain only valid + * characters (or it will error out). + * \param cint The converted integer + * \return TRUE if the conversion succeeds, FALSE otherwise. + * On error, errno is set to EINVAL for unrecognized input and ERANGE + * if the resulting number does not fit in the type. + */ + +WS_DLL_PUBLIC gboolean ws_hexstrtou64(const gchar* str, const gchar** endptr, guint64* cint); +WS_DLL_PUBLIC gboolean ws_hexstrtou32(const gchar* str, const gchar** endptr, guint32* cint); +WS_DLL_PUBLIC gboolean ws_hexstrtou16(const gchar* str, const gchar** endptr, guint16* cint); +WS_DLL_PUBLIC gboolean ws_hexstrtou8 (const gchar* str, const gchar** endptr, guint8* cint); + #endif /* -- cgit v1.2.1