Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
Lev Walkin | 4ca03ac | 2005-02-28 15:20:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved. |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef _INTEGER_H_ |
| 6 | #define _INTEGER_H_ |
| 7 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
Lev Walkin | d703ff4 | 2004-10-21 11:21:25 +0000 | [diff] [blame] | 9 | #include <asn_codecs_prim.h> |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 10 | |
Lev Walkin | 8e8078a | 2004-09-26 13:10:40 +0000 | [diff] [blame] | 11 | typedef ASN__PRIMITIVE_TYPE_t INTEGER_t; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 12 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 13 | extern asn_TYPE_descriptor_t asn_DEF_INTEGER; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 14 | |
Lev Walkin | e0b56e0 | 2005-02-25 12:10:27 +0000 | [diff] [blame] | 15 | /* Map with <tag> to integer value association */ |
| 16 | typedef struct asn_INTEGER_enum_map_s { |
| 17 | long nat_value; /* associated native integer value */ |
| 18 | size_t enum_len; /* strlen("tag") */ |
| 19 | const char *enum_name; /* "tag" */ |
| 20 | } asn_INTEGER_enum_map_t; |
| 21 | |
| 22 | /* This type describes an enumeration for INTEGER and ENUMERATED types */ |
| 23 | typedef struct asn_INTEGER_specifics_s { |
| 24 | asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */ |
| 25 | unsigned int *enum2value; /* "tag" => N; sorted by tag */ |
| 26 | int map_count; /* Elements in either map */ |
| 27 | int extensible; /* This map is extensible */ |
| 28 | int strict_enumeration; /* Enumeration set is fixed */ |
| 29 | } asn_INTEGER_specifics_t; |
| 30 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 31 | asn_struct_print_f INTEGER_print; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 32 | ber_type_decoder_f INTEGER_decode_ber; |
| 33 | der_type_encoder_f INTEGER_encode_der; |
Lev Walkin | d703ff4 | 2004-10-21 11:21:25 +0000 | [diff] [blame] | 34 | xer_type_decoder_f INTEGER_decode_xer; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 35 | xer_type_encoder_f INTEGER_encode_xer; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 36 | |
| 37 | /*********************************** |
| 38 | * Some handy conversion routines. * |
| 39 | ***********************************/ |
| 40 | |
| 41 | /* |
| 42 | * Returns 0 if it was possible to convert, -1 otherwise. |
| 43 | * -1/EINVAL: Mandatory argument missing |
| 44 | * -1/ERANGE: Value encoded is out of range for long representation |
Lev Walkin | d703ff4 | 2004-10-21 11:21:25 +0000 | [diff] [blame] | 45 | * -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()). |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 46 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 47 | int asn_INTEGER2long(const INTEGER_t *i, long *l); |
Lev Walkin | d703ff4 | 2004-10-21 11:21:25 +0000 | [diff] [blame] | 48 | int asn_long2INTEGER(INTEGER_t *i, long l); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 49 | |
| 50 | #endif /* _INTEGER_H_ */ |