NativeInteger_uper.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  */
8 
11  const asn_TYPE_descriptor_t *td,
12  const asn_per_constraints_t *constraints, void **sptr,
13  asn_per_data_t *pd) {
14  const asn_INTEGER_specifics_t *specs =
16  asn_dec_rval_t rval;
17  long *native = (long *)*sptr;
18  INTEGER_t tmpint;
19  void *tmpintptr = &tmpint;
20 
21  (void)opt_codec_ctx;
22  ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name);
23 
24  if(!native) {
25  native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
26  if(!native) ASN__DECODE_FAILED;
27  }
28 
29  memset(&tmpint, 0, sizeof tmpint);
30  rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints,
31  &tmpintptr, pd);
32  if(rval.code == RC_OK) {
33  if((specs&&specs->field_unsigned)
34  ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native)
35  : asn_INTEGER2long(&tmpint, native))
36  rval.code = RC_FAIL;
37  else
38  ASN_DEBUG("NativeInteger %s got value %ld",
39  td->name, *native);
40  }
42 
43  return rval;
44 }
45 
48  const asn_per_constraints_t *constraints,
49  const void *sptr, asn_per_outp_t *po) {
50  const asn_INTEGER_specifics_t *specs =
52  asn_enc_rval_t er = {0,0,0};
53  long native;
54  INTEGER_t tmpint;
55 
56  if(!sptr) ASN__ENCODE_FAILED;
57 
58  native = *(const long *)sptr;
59 
60  ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
61 
62  memset(&tmpint, 0, sizeof(tmpint));
63  if((specs&&specs->field_unsigned)
64  ? asn_ulong2INTEGER(&tmpint, native)
65  : asn_long2INTEGER(&tmpint, native))
67  er = INTEGER_encode_uper(td, constraints, &tmpint, po);
69  return er;
70 }
asn_bit_outp_s
Definition: asn_bit_data.h:56
ASN__PRIMITIVE_TYPE_s
Definition: asn_codecs_prim.h:14
asn_TYPE_descriptor_s::name
const char * name
Definition: constr_TYPE.h:225
asn_enc_rval_s
Definition: asn_codecs.h:41
CALLOC
#define CALLOC(nmemb, size)
Definition: asn_internal.h:37
asn_DEF_INTEGER
asn_TYPE_descriptor_t asn_DEF_INTEGER
Definition: INTEGER.c:75
asn_bit_data_s
Definition: asn_bit_data.h:17
INTEGER_decode_uper
per_type_decoder_f INTEGER_decode_uper
Definition: INTEGER.h:75
ASN__ENCODE_FAILED
#define ASN__ENCODE_FAILED
Definition: asn_codecs.h:59
asn_TYPE_descriptor_s
Definition: constr_TYPE.h:224
asn_TYPE_descriptor_s::specifics
const void * specifics
Definition: constr_TYPE.h:259
NativeInteger_decode_uper
asn_dec_rval_t NativeInteger_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, const asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
Definition: NativeInteger_uper.c:10
INTEGER_encode_uper
per_type_encoder_f INTEGER_encode_uper
Definition: INTEGER.h:76
asn_INTEGER_specifics_s
Definition: INTEGER.h:28
RC_OK
@ RC_OK
Definition: asn_codecs.h:82
asn_internal.h
asn_codec_ctx_s
Definition: asn_codecs.h:23
asn_dec_rval_s
Definition: asn_codecs.h:86
ASN__DECODE_FAILED
#define ASN__DECODE_FAILED
Definition: asn_codecs.h:90
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_per_constraints_s
Definition: per_support.h:30
asn_INTEGER_specifics_s::field_unsigned
int field_unsigned
Definition: INTEGER.h:35
ASN_STRUCT_FREE_CONTENTS_ONLY
#define ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF, ptr)
Definition: constr_TYPE.h:123
asn_INTEGER2long
int asn_INTEGER2long(const INTEGER_t *i, long *l)
Definition: INTEGER.c:384
NativeInteger.h
RC_FAIL
@ RC_FAIL
Definition: asn_codecs.h:84
NativeInteger_encode_uper
asn_enc_rval_t NativeInteger_encode_uper(const asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, const void *sptr, asn_per_outp_t *po)
Definition: NativeInteger_uper.c:47


etsi_its_denm_coding
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:23:48