blob: 62832b12e1271e1f27a5edd5b4a0f82986ff2fc3 [file] [log] [blame]
Harald Welte92c45f32010-06-12 18:59:38 +02001/*-
2 * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _INTEGER_H_
6#define _INTEGER_H_
7
8#include <asn_application.h>
9#include <asn_codecs_prim.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15typedef ASN__PRIMITIVE_TYPE_t INTEGER_t;
16
17extern asn_TYPE_descriptor_t asn_DEF_INTEGER;
18
19/* Map with <tag> to integer value association */
20typedef struct asn_INTEGER_enum_map_s {
21 long nat_value; /* associated native integer value */
22 size_t enum_len; /* strlen("tag") */
23 const char *enum_name; /* "tag" */
24} asn_INTEGER_enum_map_t;
25
26/* This type describes an enumeration for INTEGER and ENUMERATED types */
27typedef struct asn_INTEGER_specifics_s {
28 asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
29 unsigned int *enum2value; /* "tag" => N; sorted by tag */
30 int map_count; /* Elements in either map */
31 int extension; /* This map is extensible */
32 int strict_enumeration; /* Enumeration set is fixed */
33} asn_INTEGER_specifics_t;
34
35asn_struct_print_f INTEGER_print;
36ber_type_decoder_f INTEGER_decode_ber;
37der_type_encoder_f INTEGER_encode_der;
38xer_type_decoder_f INTEGER_decode_xer;
39xer_type_encoder_f INTEGER_encode_xer;
40per_type_decoder_f INTEGER_decode_uper;
41per_type_encoder_f INTEGER_encode_uper;
42
43/***********************************
44 * Some handy conversion routines. *
45 ***********************************/
46
47/*
48 * Returns 0 if it was possible to convert, -1 otherwise.
49 * -1/EINVAL: Mandatory argument missing
50 * -1/ERANGE: Value encoded is out of range for long representation
51 * -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()).
52 */
53int asn_INTEGER2long(const INTEGER_t *i, long *l);
54int asn_long2INTEGER(INTEGER_t *i, long l);
55
56/*
57 * Convert the integer value into the corresponding enumeration map entry.
58 */
59const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value);
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif /* _INTEGER_H_ */