1 #ifndef ASN1P_INTEGER_H
2 #define ASN1P_INTEGER_H
6 #endif /* HAVE_CONFIG_H */
8 #include <asn1_buffer.h>
10 #ifdef HAVE_SYS_TYPES_H
11 #include <sys/types.h>
12 #endif /* HAVE_SYS_TYPES_H */
13 #ifdef HAVE_INTTYPES_H
14 #include <inttypes.h> /* POSIX 1003.1-2001, C99 */
15 #else /* HAVE_INTTYPES_H */
17 #include <stdint.h> /* SUSv2+ */
18 #endif /* HAVE_STDINT_H */
19 #endif /* HAVE_INTTYPES_H */
22 * Basic integer type used in numerous places.
23 * ASN.1 does not define any limits on this number, so it must be sufficiently
24 * large to accomodate typical inputs. It does not have to be a dynamically
25 * allocated type with potentially unlimited width: consider the width of
26 * an integer defined here as one of the "compiler limitations".
27 * NOTE: this is NOT a type for ASN.1 "INTEGER" type representation, this
28 * type is used by the compiler itself to handle large integer values
29 * specified inside ASN.1 grammar.
31 #ifdef HAVE_128_BIT_INT
32 typedef __int128 asn1c_integer_t;
34 typedef intmax_t asn1c_integer_t;
37 int asn1p_atoi(const char *ptr, asn1c_integer_t *r_value);
38 const char *asn1p_itoa(asn1c_integer_t value); /* Ptr to a static buf */
41 * -1: The value did not fit in the buffer.
42 * >0: The length in bytes of the stringified numeric value.
44 int asn1p_itoa_s(char *buf, size_t size,
45 asn1c_integer_t value); /* Return -1 on error, or length. */
48 * Convert asn1c_integer_t into INTEGER_t structure.
50 abuf *asn1p_integer_as_INTEGER(asn1c_integer_t value);
52 #endif /* ASN1P_INTEGER_H */