examples: warn on invalid numeric parameters
add ExUtilGet[U]Int / ExUtilGetFloat which print an error message on
parse failure.
fixes issue #219.
(cherry picked from commit 96d43a873a61886e0642ec50f25cadccc21a5086)
Conflicts:
examples/cwebp.c
examples/dwebp.c
Change-Id: Ie537f5aebd138925bf1a48289b6b5e261b3af2ca
diff --git a/examples/example_util.h b/examples/example_util.h
index 4ef703d..8e8e801 100644
--- a/examples/example_util.h
+++ b/examples/example_util.h
@@ -20,6 +20,19 @@
extern "C" {
#endif
+//------------------------------------------------------------------------------
+// String parsing
+
+// Parses 'v' using strto(ul|l|d)(). If error is non-NULL, '*error' is set to
+// true on failure while on success it is left unmodified to allow chaining of
+// calls. An error is only printed on the first occurrence.
+uint32_t ExUtilGetUInt(const char* const v, int base, int* const error);
+int ExUtilGetInt(const char* const v, int base, int* const error);
+float ExUtilGetFloat(const char* const v, int* const error);
+
+//------------------------------------------------------------------------------
+// File I/O
+
// Reopen file in binary (O_BINARY) mode.
// Returns 'file' on success, NULL otherwise.
FILE* ExUtilSetBinaryMode(FILE* file);