blob: b87c794c0ba7fa18bd80001b6f76aee5ef01a550 [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 */
33} asn_INTEGER_specifics_t;
34
vlm39ba4c42004-09-22 16:06:28 +000035asn_struct_print_f INTEGER_print;
vlmfa67ddc2004-06-03 03:38:44 +000036ber_type_decoder_f INTEGER_decode_ber;
37der_type_encoder_f INTEGER_encode_der;
vlma4799a62004-10-21 11:21:25 +000038xer_type_decoder_f INTEGER_decode_xer;
vlm39ba4c42004-09-22 16:06:28 +000039xer_type_encoder_f INTEGER_encode_xer;
vlm337167e2005-11-26 11:25:14 +000040per_type_decoder_f INTEGER_decode_uper;
vlm18dd82c2006-08-18 01:34:18 +000041per_type_encoder_f INTEGER_encode_uper;
vlmfa67ddc2004-06-03 03:38:44 +000042
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
vlma4799a62004-10-21 11:21:25 +000051 * -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()).
vlmfa67ddc2004-06-03 03:38:44 +000052 */
vlmef6355b2004-09-29 13:26:15 +000053int asn_INTEGER2long(const INTEGER_t *i, long *l);
vlmb6053b42007-11-06 06:23:31 +000054int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
vlma4799a62004-10-21 11:21:25 +000055int asn_long2INTEGER(INTEGER_t *i, long l);
vlmb6053b42007-11-06 06:23:31 +000056int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
vlmfa67ddc2004-06-03 03:38:44 +000057
vlm5ec2fe12005-03-29 17:21:14 +000058/*
59 * Convert the integer value into the corresponding enumeration map entry.
60 */
61const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value);
62
vlm3a417582005-07-24 09:03:44 +000063#ifdef __cplusplus
64}
65#endif
66
vlmfa67ddc2004-06-03 03:38:44 +000067#endif /* _INTEGER_H_ */