#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
+#include <stdbool.h>
+
+#include <log.h>
char *get_as_hex_str(const char *byte_arr, int byte_count) {
int ii;
}
return ret_val;
}
+
+bool parse_long(const char *str, long *result) {
+ int new_result;
+ char *endptr;
+ bool ret_val;
+
+ ret_val = false;
+ errno = 0;
+ new_result = strtol(str, &endptr, 10);
+ if (errno != 0) {
+ log_error("invalid input %s, could not convert to integer.\n", str);
+ }
+ else {
+ if (endptr == str) {
+ log_error("invalid input %s, could not convert to integer.\n", str);
+ }
+ else {
+ *result = new_result;
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}