blob: fce67140b47f7026e071d0b58f05305dfccda5d8 [file] [log] [blame]
rajalakshmisv21b61dd2021-12-07 04:53:03 +00001/*-
2 * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef ASN_TYPE_REAL_H
6#define ASN_TYPE_REAL_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 REAL_t;
16
17extern asn_TYPE_descriptor_t asn_DEF_REAL;
18extern asn_TYPE_operation_t asn_OP_REAL;
19
20asn_struct_print_f REAL_print;
21asn_struct_compare_f REAL_compare;
22oer_type_decoder_f REAL_decode_oer;
23oer_type_encoder_f REAL_encode_oer;
24per_type_decoder_f REAL_decode_uper;
25per_type_encoder_f REAL_encode_uper;
26per_type_decoder_f REAL_decode_aper;
27per_type_encoder_f REAL_encode_aper;
28xer_type_decoder_f REAL_decode_xer;
29xer_type_encoder_f REAL_encode_xer;
30asn_random_fill_f REAL_random_fill;
31
32#define REAL_free ASN__PRIMITIVE_TYPE_free,
33#define REAL_constraint asn_generic_no_constraint
34#define REAL_decode_ber ber_decode_primitive
35#define REAL_encode_der der_encode_primitive
36
37/***********************************
38 * Some handy conversion routines. *
39 ***********************************/
40
41ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key);
42
43/*
44 * Convert between native double type and REAL representation (DER).
45 * RETURN VALUES:
46 * 0: Value converted successfully
47 * -1: An error occured while converting the value: invalid format.
48 */
49int asn_REAL2double(const REAL_t *real_ptr, double *d);
50int asn_double2REAL(REAL_t *real_ptr, double d);
51
52/*
53 * Downcast double to float while checking that no overflow occurs.
54 * This allows stricter control of the input data.
55 * RETURN VALUES:
56 * 0: The conversion was successful (perhaps with a loss of precision)
57 * -1: The conversion created overflow into infinities.
58 * The (outcome) is ALWAYS set to a value you'd expect from the
59 * standard silent float to double conversion behavior.
60 */
61int asn_double2float(double d, float *outcome);
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif /* ASN_TYPE_REAL_H */