Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 1 | /*- |
Lev Walkin | 20696a4 | 2017-10-17 21:27:33 -0700 | [diff] [blame] | 2 | * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved. |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef ASN_TYPE_REAL_H |
| 6 | #define ASN_TYPE_REAL_H |
| 7 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
Lev Walkin | 3256d6f | 2004-10-21 11:22:12 +0000 | [diff] [blame] | 9 | #include <asn_codecs_prim.h> |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 10 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
Lev Walkin | 8e8078a | 2004-09-26 13:10:40 +0000 | [diff] [blame] | 15 | typedef ASN__PRIMITIVE_TYPE_t REAL_t; |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 16 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 17 | extern asn_TYPE_descriptor_t asn_DEF_REAL; |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 18 | extern asn_TYPE_operation_t asn_OP_REAL; |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 19 | |
| 20 | asn_struct_print_f REAL_print; |
Lev Walkin | cd2f48e | 2017-08-10 02:14:59 -0700 | [diff] [blame] | 21 | asn_struct_compare_f REAL_compare; |
Lev Walkin | 4329272 | 2017-10-05 00:33:32 -0700 | [diff] [blame] | 22 | oer_type_decoder_f REAL_decode_oer; |
| 23 | oer_type_encoder_f REAL_encode_oer; |
Lev Walkin | 725883b | 2006-10-09 12:07:58 +0000 | [diff] [blame] | 24 | per_type_decoder_f REAL_decode_uper; |
| 25 | per_type_encoder_f REAL_encode_uper; |
Lev Walkin | 4329272 | 2017-10-05 00:33:32 -0700 | [diff] [blame] | 26 | xer_type_decoder_f REAL_decode_xer; |
| 27 | xer_type_encoder_f REAL_encode_xer; |
Lev Walkin | a5972be | 2017-09-29 23:15:58 -0700 | [diff] [blame] | 28 | asn_random_fill_f REAL_random_fill; |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 29 | |
Bi-Ruei, Chiu | 1fa31c9 | 2016-05-16 13:50:09 +0800 | [diff] [blame] | 30 | #define REAL_free ASN__PRIMITIVE_TYPE_free, |
| 31 | #define REAL_constraint asn_generic_no_constraint |
| 32 | #define REAL_decode_ber ber_decode_primitive |
| 33 | #define REAL_encode_der der_encode_primitive |
| 34 | |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 35 | /*********************************** |
| 36 | * Some handy conversion routines. * |
| 37 | ***********************************/ |
| 38 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 39 | ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key); |
| 40 | |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 41 | /* |
| 42 | * Convert between native double type and REAL representation (DER). |
| 43 | * RETURN VALUES: |
| 44 | * 0: Value converted successfully |
| 45 | * -1: An error occured while converting the value: invalid format. |
| 46 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 47 | int asn_REAL2double(const REAL_t *real_ptr, double *d); |
| 48 | int asn_double2REAL(REAL_t *real_ptr, double d); |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 49 | |
Lev Walkin | 68079d3 | 2017-10-08 15:41:20 -0700 | [diff] [blame] | 50 | /* |
| 51 | * Downcast double to float while checking that no overflow occurs. |
| 52 | * This allows stricter control of the input data. |
| 53 | * RETURN VALUES: |
| 54 | * 0: The conversion was successful (perhaps with a loss of precision) |
| 55 | * -1: The conversion created overflow into infinities. |
| 56 | * The (outcome) is ALWAYS set to a value you'd expect from the |
| 57 | * standard silent float to double conversion behavior. |
| 58 | */ |
| 59 | int asn_double2float(double d, float *outcome); |
| 60 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 61 | #ifdef __cplusplus |
| 62 | } |
| 63 | #endif |
| 64 | |
Lev Walkin | 41ba1f2 | 2004-09-14 12:46:35 +0000 | [diff] [blame] | 65 | #endif /* ASN_TYPE_REAL_H */ |