blob: 8411bfcdd707e46f08a4df60ec9ae782682b61bf [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*-
vlmed5f7fc2005-02-28 15:20:27 +00002 * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
vlmfa67ddc2004-06-03 03:38:44 +00003 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _INTEGER_H_
6#define _INTEGER_H_
7
vlmd1579582004-09-24 21:00:50 +00008#include <asn_application.h>
vlma4799a62004-10-21 11:21:25 +00009#include <asn_codecs_prim.h>
vlmfa67ddc2004-06-03 03:38:44 +000010
vlm3a417582005-07-24 09:03:44 +000011#ifdef __cplusplus
12extern "C" {
13#endif
14
vlm6678cb12004-09-26 13:10:40 +000015typedef ASN__PRIMITIVE_TYPE_t INTEGER_t;
vlmfa67ddc2004-06-03 03:38:44 +000016
vlmef6355b2004-09-29 13:26:15 +000017extern asn_TYPE_descriptor_t asn_DEF_INTEGER;
vlmfa67ddc2004-06-03 03:38:44 +000018
vlm80a48592005-02-25 12:10:27 +000019/* 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 */
vlm337167e2005-11-26 11:25:14 +000031 int extension; /* This map is extensible */
vlm80a48592005-02-25 12:10:27 +000032 int strict_enumeration; /* Enumeration set is fixed */
vlm12164c42007-12-03 13:41:36 +000033 int field_width; /* Size of native integer */
34 int field_unsigned; /* Signed=0, unsigned=1 */
vlm80a48592005-02-25 12:10:27 +000035} asn_INTEGER_specifics_t;
36
vlm39ba4c42004-09-22 16:06:28 +000037asn_struct_print_f INTEGER_print;
vlmfa67ddc2004-06-03 03:38:44 +000038ber_type_decoder_f INTEGER_decode_ber;
39der_type_encoder_f INTEGER_encode_der;
vlma4799a62004-10-21 11:21:25 +000040xer_type_decoder_f INTEGER_decode_xer;
vlm39ba4c42004-09-22 16:06:28 +000041xer_type_encoder_f INTEGER_encode_xer;
vlm337167e2005-11-26 11:25:14 +000042per_type_decoder_f INTEGER_decode_uper;
vlm18dd82c2006-08-18 01:34:18 +000043per_type_encoder_f INTEGER_encode_uper;
vlmfa67ddc2004-06-03 03:38:44 +000044
45/***********************************
46 * Some handy conversion routines. *
47 ***********************************/
48
49/*
50 * Returns 0 if it was possible to convert, -1 otherwise.
51 * -1/EINVAL: Mandatory argument missing
52 * -1/ERANGE: Value encoded is out of range for long representation
vlma4799a62004-10-21 11:21:25 +000053 * -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()).
vlmfa67ddc2004-06-03 03:38:44 +000054 */
vlmef6355b2004-09-29 13:26:15 +000055int asn_INTEGER2long(const INTEGER_t *i, long *l);
vlmb6053b42007-11-06 06:23:31 +000056int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
vlma4799a62004-10-21 11:21:25 +000057int asn_long2INTEGER(INTEGER_t *i, long l);
vlmb6053b42007-11-06 06:23:31 +000058int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
vlmfa67ddc2004-06-03 03:38:44 +000059
vlm5ec2fe12005-03-29 17:21:14 +000060/*
61 * Convert the integer value into the corresponding enumeration map entry.
62 */
63const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value);
64
vlm3a417582005-07-24 09:03:44 +000065#ifdef __cplusplus
66}
67#endif
68
vlmfa67ddc2004-06-03 03:38:44 +000069#endif /* _INTEGER_H_ */