INTEGER.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2003-2017 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 
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
16 
19 
20 /* Map with <tag> to integer value association */
21 typedef struct asn_INTEGER_enum_map_s {
22  long nat_value; /* associated native integer value */
23  size_t enum_len; /* strlen("tag") */
24  const char *enum_name; /* "tag" */
26 
27 /* This type describes an enumeration for INTEGER and ENUMERATED types */
28 typedef struct asn_INTEGER_specifics_s {
29  const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
30  const unsigned int *enum2value; /* "tag" => N; sorted by tag */
31  int map_count; /* Elements in either map */
32  int extension; /* This map is extensible */
33  int strict_enumeration; /* Enumeration set is fixed */
34  int field_width; /* Size of native integer */
35  int field_unsigned; /* Signed=0, unsigned=1 */
37 
38 ssize_t INTEGER__dump(const asn_TYPE_descriptor_t *td,
39  const INTEGER_t *st,
41  void *app_key, int plainOrXER);
42 
43 #define INTEGER_free ASN__PRIMITIVE_TYPE_free
44 
45 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
47 #endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
48 
51 
52 #define INTEGER_constraint asn_generic_no_constraint
53 
54 #if !defined(ASN_DISABLE_BER_SUPPORT)
55 #define INTEGER_decode_ber ber_decode_primitive
56 der_type_encoder_f INTEGER_encode_der;
57 #endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
58 
59 #if !defined(ASN_DISABLE_XER_SUPPORT)
60 xer_type_decoder_f INTEGER_decode_xer;
61 xer_type_encoder_f INTEGER_encode_xer;
62 #endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
63 
64 #if !defined(ASN_DISABLE_JER_SUPPORT)
67 #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
68 
69 #if !defined(ASN_DISABLE_OER_SUPPORT)
70 oer_type_decoder_f INTEGER_decode_oer;
71 oer_type_encoder_f INTEGER_encode_oer;
72 #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
73 
74 #if !defined(ASN_DISABLE_UPER_SUPPORT)
77 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
78 #if !defined(ASN_DISABLE_APER_SUPPORT)
81 #endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
82 
83 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
85 #endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
86 
87 /***********************************
88  * Some handy conversion routines. *
89  ***********************************/
90 
91 /*
92  * Natiwe size-independent conversion of native integers to/from INTEGER.
93  * (l_size) is in bytes.
94  * Returns 0 if it was possible to convert, -1 otherwise.
95  * -1/EINVAL: Mandatory argument missing
96  * -1/ERANGE: Value encoded is out of range for long representation
97  * -1/ENOMEM: Memory allocation failed (in asn_*2INTEGER()).
98  */
99 int asn_INTEGER2imax(const INTEGER_t *i, intmax_t *l);
100 int asn_INTEGER2umax(const INTEGER_t *i, uintmax_t *l);
101 int asn_imax2INTEGER(INTEGER_t *i, intmax_t l);
102 int asn_umax2INTEGER(INTEGER_t *i, uintmax_t l);
103 
104 /*
105  * Size-specific conversion helpers.
106  */
107 int asn_INTEGER2long(const INTEGER_t *i, long *l);
108 int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
109 int asn_long2INTEGER(INTEGER_t *i, long l);
110 int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
111 int asn_INTEGER2int64(const INTEGER_t *i, int64_t *l);
112 int asn_INTEGER2uint64(const INTEGER_t *i, uint64_t *l);
113 int asn_int642INTEGER(INTEGER_t *i, int64_t l);
114 int asn_uint642INTEGER(INTEGER_t *i, uint64_t l);
115 
116 /* A version of strtol/strtoimax(3) with nicer error reporting. */
118  ASN_STRTOX_ERROR_RANGE = -3, /* Input outside of supported numeric range */
119  ASN_STRTOX_ERROR_INVAL = -2, /* Invalid data encountered (e.g., "+-") */
120  ASN_STRTOX_EXPECT_MORE = -1, /* More data expected (e.g. "+") */
121  ASN_STRTOX_OK = 0, /* Conversion succeeded, number ends at (*end) */
122  ASN_STRTOX_EXTRA_DATA = 1 /* Conversion succeeded, but the string has extra stuff */
123 };
124 enum asn_strtox_result_e asn_strtol_lim(const char *str, const char **end,
125  long *l);
126 enum asn_strtox_result_e asn_strtoul_lim(const char *str, const char **end,
127  unsigned long *l);
128 enum asn_strtox_result_e asn_strtoimax_lim(const char *str, const char **end,
129  intmax_t *l);
130 enum asn_strtox_result_e asn_strtoumax_lim(const char *str, const char **end,
131  uintmax_t *l);
132 
133 /*
134  * Convert the integer value into the corresponding enumeration map entry.
135  */
137  const asn_INTEGER_specifics_t *specs, long value);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif /* _INTEGER_H_ */
asn_INTEGER2imax
int asn_INTEGER2imax(const INTEGER_t *i, intmax_t *l)
Definition: INTEGER.c:219
asn_strtoimax_lim
enum asn_strtox_result_e asn_strtoimax_lim(const char *str, const char **end, intmax_t *l)
Definition: INTEGER.c:538
ASN__PRIMITIVE_TYPE_s
Definition: asn_codecs_prim.h:14
per_type_decoder_f
asn_dec_rval_t() per_type_decoder_f(const asn_codec_ctx_t *opt_codec_ctx, const struct asn_TYPE_descriptor_s *type_descriptor, const asn_per_constraints_t *constraints, void **struct_ptr, asn_per_data_t *per_data)
Definition: per_decoder.h:20
asn_TYPE_operation_s
Definition: constr_TYPE.h:184
asn_INTEGER_specifics_s::extension
int extension
Definition: INTEGER.h:32
ASN_STRTOX_EXPECT_MORE
@ ASN_STRTOX_EXPECT_MORE
Definition: INTEGER.h:120
asn_struct_print_f
int() asn_struct_print_f(const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, int level, asn_app_consume_bytes_f *callback, void *app_key)
Definition: constr_TYPE.h:129
asn_uint642INTEGER
int asn_uint642INTEGER(INTEGER_t *i, uint64_t l)
Definition: INTEGER.c:452
asn_random_fill_f
asn_random_fill_result_t() asn_random_fill_f(const struct asn_TYPE_descriptor_s *td, void **struct_ptr, const struct asn_encoding_constraints_s *memb_constraints, size_t max_length)
Definition: asn_random_fill.h:32
INTEGER_map_value2enum
const asn_INTEGER_enum_map_t * INTEGER_map_value2enum(const asn_INTEGER_specifics_t *specs, long value)
Definition: INTEGER.c:190
INTEGER__dump
ssize_t INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER)
Definition: INTEGER.c:103
asn_INTEGER_specifics_s::field_width
int field_width
Definition: INTEGER.h:34
asn_struct_compare_f
int() asn_struct_compare_f(const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_A, const void *struct_B)
Definition: constr_TYPE.h:141
asn_strtol_lim
enum asn_strtox_result_e asn_strtol_lim(const char *str, const char **end, long *l)
Definition: INTEGER.c:674
asn_INTEGER_specifics_t
struct asn_INTEGER_specifics_s asn_INTEGER_specifics_t
ASN_STRTOX_OK
@ ASN_STRTOX_OK
Definition: INTEGER.h:121
asn_int642INTEGER
int asn_int642INTEGER(INTEGER_t *i, int64_t l)
Definition: INTEGER.c:477
asn_DEF_INTEGER
asn_TYPE_descriptor_t asn_DEF_INTEGER
Definition: INTEGER.c:75
INTEGER_encode_jer
jer_type_encoder_f INTEGER_encode_jer
Definition: INTEGER.h:66
asn_OP_INTEGER
asn_TYPE_operation_t asn_OP_INTEGER
Definition: INTEGER.c:17
asn_INTEGER2umax
int asn_INTEGER2umax(const INTEGER_t *i, uintmax_t *l)
Definition: INTEGER.c:271
asn_INTEGER_enum_map_s::enum_len
size_t enum_len
Definition: INTEGER.h:23
asn_INTEGER_specifics_s::strict_enumeration
int strict_enumeration
Definition: INTEGER.h:33
INTEGER_random_fill
asn_random_fill_f INTEGER_random_fill
Definition: INTEGER.h:84
asn_codecs_prim.h
INTEGER_decode_uper
per_type_decoder_f INTEGER_decode_uper
Definition: INTEGER.h:75
asn_TYPE_descriptor_s
Definition: constr_TYPE.h:224
jer_type_encoder_f
asn_enc_rval_t() jer_type_encoder_f(const struct asn_TYPE_descriptor_s *type_descriptor, const asn_jer_constraints_t *constraints, const void *struct_ptr, int ilevel, enum jer_encoder_flags_e jer_flags, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key)
Definition: jer_encoder.h:73
INTEGER_decode_xer
xer_type_decoder_f INTEGER_decode_xer
Definition: INTEGER.h:60
asn_imax2INTEGER
int asn_imax2INTEGER(INTEGER_t *i, intmax_t l)
Definition: INTEGER.c:329
asn_strtoul_lim
enum asn_strtox_result_e asn_strtoul_lim(const char *str, const char **end, unsigned long *l)
Definition: INTEGER.c:704
asn_INTEGER_specifics_s::map_count
int map_count
Definition: INTEGER.h:31
INTEGER_encode_xer
xer_type_encoder_f INTEGER_encode_xer
Definition: INTEGER.h:61
INTEGER_encode_uper
per_type_encoder_f INTEGER_encode_uper
Definition: INTEGER.h:76
asn_umax2INTEGER
int asn_umax2INTEGER(INTEGER_t *i, uintmax_t l)
Definition: INTEGER.c:303
asn_INTEGER_specifics_s
Definition: INTEGER.h:28
jer_type_decoder_f
asn_dec_rval_t() jer_type_decoder_f(const asn_codec_ctx_t *opt_codec_ctx, const struct asn_TYPE_descriptor_s *type_descriptor, const asn_jer_constraints_t *constraints, void **struct_ptr, const void *buf_ptr, size_t size)
Definition: jer_decoder.h:32
asn_INTEGER2uint64
int asn_INTEGER2uint64(const INTEGER_t *i, uint64_t *l)
Definition: INTEGER.c:437
asn_INTEGER_enum_map_s::nat_value
long nat_value
Definition: INTEGER.h:22
INTEGER_decode_jer
jer_type_decoder_f INTEGER_decode_jer
Definition: INTEGER.h:65
ASN_STRTOX_ERROR_RANGE
@ ASN_STRTOX_ERROR_RANGE
Definition: INTEGER.h:118
INTEGER_encode_der
der_type_encoder_f INTEGER_encode_der
Definition: INTEGER.h:56
per_type_encoder_f
asn_enc_rval_t() per_type_encoder_f(const struct asn_TYPE_descriptor_s *type_descriptor, const asn_per_constraints_t *constraints, const void *struct_ptr, asn_per_outp_t *per_output)
Definition: per_encoder.h:20
ASN_STRTOX_EXTRA_DATA
@ ASN_STRTOX_EXTRA_DATA
Definition: INTEGER.h:122
asn_INTEGER_enum_map_s::enum_name
const char * enum_name
Definition: INTEGER.h:24
asn_INTEGER_specifics_s::enum2value
const unsigned int * enum2value
Definition: INTEGER.h:30
asn_strtoumax_lim
enum asn_strtox_result_e asn_strtoumax_lim(const char *str, const char **end, uintmax_t *l)
Definition: INTEGER.c:613
asn_INTEGER_enum_map_t
struct asn_INTEGER_enum_map_s asn_INTEGER_enum_map_t
INTEGER_decode_aper
per_type_decoder_f INTEGER_decode_aper
Definition: INTEGER.h:79
INTEGER_copy
asn_struct_copy_f INTEGER_copy
Definition: INTEGER.h:50
asn_INTEGER2int64
int asn_INTEGER2int64(const INTEGER_t *i, int64_t *l)
Definition: INTEGER.c:423
INTEGER_decode_oer
oer_type_decoder_f INTEGER_decode_oer
Definition: INTEGER.h:70
asn_app_consume_bytes_f
int() asn_app_consume_bytes_f(const void *buffer, size_t size, void *application_specific_key)
Definition: asn_application.h:124
INTEGER_compare
asn_struct_compare_f INTEGER_compare
Definition: INTEGER.h:49
INTEGER_encode_aper
per_type_encoder_f INTEGER_encode_aper
Definition: INTEGER.h:80
INTEGER_t
ASN__PRIMITIVE_TYPE_t INTEGER_t
Definition: INTEGER.h:15
asn_ulong2INTEGER
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l)
Definition: INTEGER.c:419
asn_INTEGER2ulong
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l)
Definition: INTEGER.c:399
asn_long2INTEGER
int asn_long2INTEGER(INTEGER_t *i, long l)
Definition: INTEGER.c:414
asn_application.h
asn_INTEGER_specifics_s::value2enum
const asn_INTEGER_enum_map_t * value2enum
Definition: INTEGER.h:29
asn_INTEGER_specifics_s::field_unsigned
int field_unsigned
Definition: INTEGER.h:35
asn_struct_copy_f
int() asn_struct_copy_f(const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_A, const void *struct_B)
Definition: constr_TYPE.h:150
asn_strtox_result_e
asn_strtox_result_e
Definition: INTEGER.h:117
INTEGER_print
asn_struct_print_f INTEGER_print
Definition: INTEGER.h:46
INTEGER_encode_oer
oer_type_encoder_f INTEGER_encode_oer
Definition: INTEGER.h:71
asn_INTEGER2long
int asn_INTEGER2long(const INTEGER_t *i, long *l)
Definition: INTEGER.c:384
ASN_STRTOX_ERROR_INVAL
@ ASN_STRTOX_ERROR_INVAL
Definition: INTEGER.h:119
asn_INTEGER_enum_map_s
Definition: INTEGER.h:21


etsi_its_cpm_ts_coding
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:22:38