parsing WITH SYNTAX clauses
diff --git a/libasn1parser/asn1parser.c b/libasn1parser/asn1parser.c
index f59d1af..bd712b3 100644
--- a/libasn1parser/asn1parser.c
+++ b/libasn1parser/asn1parser.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -184,3 +185,21 @@
}
+int
+asn1p_atoi(const char *ptr, asn1c_integer_t *value) {
+ errno = 0; /* Clear the error code */
+
+ if(sizeof(*value) <= sizeof(int)) {
+ *value = strtol(ptr, 0, 10);
+ } else {
+#ifdef HAVE_STRTOIMAX
+ *value = strtoimax(ptr, 0, 10);
+#elif HAVE_STRTOLL
+ *value = strtoll(ptr, 0, 10);
+#else
+ *value = strtol(ptr, 0, 10);
+#endif
+ }
+
+ return errno == 0 ? 0 : -1;
+}