src
NativeInteger_print.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
3
* All rights reserved.
4
* Redistribution and modifications are permitted subject to BSD license.
5
*/
6
#include <
etsi_its_vam_ts_coding/asn_internal.h
>
7
#include <
etsi_its_vam_ts_coding/NativeInteger.h
>
8
9
/*
10
* INTEGER specific human-readable output.
11
*/
12
int
13
NativeInteger_print
(
const
asn_TYPE_descriptor_t
*td,
const
void
*sptr,
14
int
ilevel,
asn_app_consume_bytes_f
*cb,
void
*app_key) {
15
const
asn_INTEGER_specifics_t
*specs =
16
(
const
asn_INTEGER_specifics_t
*)td->
specifics
;
17
const
long
*native = (
const
long
*)sptr;
18
char
scratch[32];
/* Enough for 64-bit int */
19
int
ret;
20
21
(void)td;
/* Unused argument */
22
(void)ilevel;
/* Unused argument */
23
24
if
(native) {
25
long
value = *native;
26
ret = snprintf(scratch,
sizeof
(scratch),
27
(specs && specs->
field_unsigned
) ?
"%lu"
:
"%ld"
, value);
28
assert(ret > 0 && (
size_t
)ret <
sizeof
(scratch));
29
if
(cb(scratch, ret, app_key) < 0)
return
-1;
30
if
(specs && (value >= 0 || !specs->
field_unsigned
)) {
31
const
asn_INTEGER_enum_map_t
*el =
32
INTEGER_map_value2enum
(specs, value);
33
if
(el) {
34
if
(cb(
" ("
, 2, app_key) < 0)
return
-1;
35
if
(cb(el->
enum_name
, el->
enum_len
, app_key) < 0)
return
-1;
36
if
(cb(
")"
, 1, app_key) < 0)
return
-1;
37
}
38
}
39
return
0;
40
}
else
{
41
return
(cb(
"<absent>"
, 8, app_key) < 0) ? -1 : 0;
42
}
43
}
INTEGER_map_value2enum
const asn_INTEGER_enum_map_t * INTEGER_map_value2enum(const asn_INTEGER_specifics_t *specs, long value)
Definition:
INTEGER.c:190
asn_INTEGER_enum_map_s::enum_len
size_t enum_len
Definition:
INTEGER.h:23
asn_TYPE_descriptor_s
Definition:
constr_TYPE.h:224
asn_TYPE_descriptor_s::specifics
const void * specifics
Definition:
constr_TYPE.h:259
asn_INTEGER_specifics_s
Definition:
INTEGER.h:28
NativeInteger_print
int NativeInteger_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key)
Definition:
NativeInteger_print.c:13
asn_INTEGER_enum_map_s::enum_name
const char * enum_name
Definition:
INTEGER.h:24
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
asn_internal.h
asn_INTEGER_specifics_s::field_unsigned
int field_unsigned
Definition:
INTEGER.h:35
NativeInteger.h
asn_INTEGER_enum_map_s
Definition:
INTEGER.h:21
etsi_its_vam_ts_coding
Author(s): Jean-Pierre Busch
, Guido Küppers
, Lennart Reiher
autogenerated on Sun May 18 2025 02:30:55