blob: 64c22a3cf759a611cc2fedbccd12e9b424506aae [file] [log] [blame]
Sylvain Munautd70bee42010-01-03 00:00:47 +01001Index: skeletons/NativeEnumerated.c
2===================================================================
3--- skeletons/NativeEnumerated.c (revision 1407)
4+++ skeletons/NativeEnumerated.c (working copy)
5@@ -22,7 +22,7 @@
6 "ENUMERATED", /* The ASN.1 type is still ENUMERATED */
7 "ENUMERATED",
8 NativeInteger_free,
9- NativeInteger_print,
10+ NativeEnumerated_print,
11 asn_generic_no_constraint,
12 NativeInteger_decode_ber,
13 NativeInteger_encode_der,
14@@ -205,3 +205,30 @@
15 _ASN_ENCODED_OK(er);
16 }
17
18+int
19+NativeEnumerated_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
20+ asn_app_consume_bytes_f *cb, void *app_key) {
21+ asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
22+ const long *native = (const long *)sptr;
23+ char scratch[256];
24+ int ret;
25+
26+ (void)td; /* Unused argument */
27+ (void)ilevel; /* Unused argument */
28+
29+ if(native) {
30+ const asn_INTEGER_enum_map_t *map = INTEGER_map_value2enum(specs, *native);
31+ if (map && map->enum_len && map->enum_name) {
32+ ret = snprintf(scratch, sizeof(scratch),
33+ "%s", map->enum_name);
34+ } else {
35+ ret = snprintf(scratch, sizeof(scratch),
36+ (specs && specs->field_unsigned)
37+ ? "%lu" : "%ld", *native);
38+ }
39+ assert(ret > 0 && (size_t)ret < sizeof(scratch));
40+ return (cb(scratch, ret, app_key) < 0) ? -1 : 0;
41+ } else {
42+ return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
43+ }
44+}
45Index: skeletons/NativeEnumerated.h
46===================================================================
47--- skeletons/NativeEnumerated.h (revision 1407)
48+++ skeletons/NativeEnumerated.h (working copy)
49@@ -24,6 +24,7 @@
50 xer_type_encoder_f NativeEnumerated_encode_xer;
51 per_type_decoder_f NativeEnumerated_decode_uper;
52 per_type_encoder_f NativeEnumerated_encode_uper;
53+asn_struct_print_f NativeEnumerated_print;
54
55 #ifdef __cplusplus
56 }