50 void **nint_ptr,
const void *buf_ptr,
size_t size,
int tag_mode) {
52 long *native = (
long *)*nint_ptr;
60 native = (
long *)(*nint_ptr =
CALLOC(1,
sizeof(*native)));
68 ASN_DEBUG(
"Decoding %s as INTEGER (tm=%d)",
75 tag_mode, 0, &length, 0);
84 buf_ptr = ((
const char *)buf_ptr) + rval.
consumed;
100 const void *constbuf;
105 unconst_buf.constbuf = buf_ptr;
106 tmp.
buf = (uint8_t *)unconst_buf.nonconstbuf;
123 ASN_DEBUG(
"Took %ld/%ld bytes to encode %s (%ld)",
124 (
long)rval.
consumed, (
long)length, td->
name, (
long)*native);
136 unsigned long native = *(
unsigned long *)ptr;
140 #ifdef WORDS_BIGENDIAN 142 tmp.
buf = (uint8_t *)&native;
143 tmp.
size =
sizeof(native);
146 uint8_t buf[
sizeof(native)];
150 for(p = buf +
sizeof(buf) - 1; p >= buf; p--, native >>= 8)
151 *p = (uint8_t)native;
154 tmp.
size =
sizeof(buf);
172 const void *buf_ptr,
size_t size) {
176 void *st_ptr = (
void *)&st;
177 long *native = (
long *)*sptr;
180 native = (
long *)(*sptr =
CALLOC(1,
sizeof(*native)));
184 memset(&st, 0,
sizeof(st));
186 opt_mname, buf_ptr, size);
187 if(rval.code ==
RC_OK) {
217 const long *native = (
const long *)sptr;
224 er.encoded = snprintf(scratch,
sizeof(scratch),
226 ?
"%lu" :
"%ld", *native);
227 if(er.encoded <= 0 || (
size_t)er.encoded >=
sizeof(scratch)
228 || cb(scratch, er.encoded, app_key) < 0)
241 long *native = (
long *)*sptr;
243 void *tmpintptr = &tmpint;
249 native = (
long *)(*sptr =
CALLOC(1,
sizeof(*native)));
253 memset(&tmpint, 0,
sizeof tmpint);
256 if(rval.code ==
RC_OK) {
262 ASN_DEBUG(
"NativeInteger %s got value %ld",
280 native = *(
long *)sptr;
282 ASN_DEBUG(
"Encoding NativeInteger %s %ld (UPER)", td->
name, native);
284 memset(&tmpint, 0,
sizeof(tmpint));
301 const long *native = (
const long *)sptr;
309 ret = snprintf(scratch,
sizeof(scratch),
311 ?
"%lu" :
"%ld", *native);
312 assert(ret > 0 && (
size_t)ret <
sizeof(scratch));
313 return (cb(scratch, ret, app_key) < 0) ? -1 : 0;
315 return (cb(
"<absent>", 8, app_key) < 0) ? -1 : 0;
325 ASN_DEBUG(
"Freeing %s as INTEGER (%d, %p, Native)",
326 td->
name, contents_only, ptr);
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l)
xer_type_decoder_f INTEGER_decode_xer
static ber_tlv_tag_t asn_DEF_NativeInteger_tags[]
asn_TYPE_descriptor_t asn_DEF_NativeInteger
asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd)
der_type_encoder_f INTEGER_encode_der
asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po)
asn_dec_rval_t NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode)
void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
per_type_encoder_f INTEGER_encode_uper
asn_constr_check_f asn_generic_no_constraint
asn_enc_rval_t NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key)
int asn_long2INTEGER(INTEGER_t *i, long l)
#define ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF, ptr)
#define CALLOC(nmemb, size)
#define _ASN_ENCODED_OK(rval)
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l)
asn_dec_rval_t ber_check_tags(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, asn_struct_ctx_t *opt_ctx, const void *ptr, size_t size, int tag_mode, int last_tag_form, ber_tlv_len_t *last_length, int *opt_tlv_form)
int asn_INTEGER2long(const INTEGER_t *i, long *l)
#define _ASN_ENCODE_FAILED
asn_enc_rval_t NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key)
int() asn_app_consume_bytes_f(const void *buffer, size_t size, void *application_specific_key)
enum asn_dec_rval_code_e code
static void ASN_DEBUG(const char *fmt,...)
int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key)
per_type_decoder_f INTEGER_decode_uper
asn_dec_rval_t NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size)
asn_TYPE_descriptor_t asn_DEF_INTEGER
#define _ASN_DECODE_FAILED