+bool try_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;
+}
+