本文整理汇总了C++中ASN_DEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ ASN_DEBUG函数的具体用法?C++ ASN_DEBUG怎么用?C++ ASN_DEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASN_DEBUG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: der_encode_primitive
/*
* Encode an always-primitive type using DER.
*/
asn_enc_rval_t
der_encode_primitive(asn_TYPE_descriptor_t *td, void *sptr,
int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_enc_rval_t erval;
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
ASN_DEBUG("%s %s as a primitive type (tm=%d)",
cb?"Encoding":"Estimating", td->name, tag_mode);
erval.encoded = der_write_tags(td, st->size, tag_mode, 0, tag,
cb, app_key);
ASN_DEBUG("%s wrote tags %d", td->name, (int)erval.encoded);
if(erval.encoded == -1) {
erval.failed_type = td;
erval.structure_ptr = sptr;
return erval;
}
if(cb && st->buf) {
if(cb(st->buf, st->size, app_key) < 0) {
erval.encoded = -1;
erval.failed_type = td;
erval.structure_ptr = sptr;
return erval;
}
} else {
assert(st->buf || st->size == 0);
}
erval.encoded += st->size;
_ASN_ENCODED_OK(erval);
}
开发者ID:osmocom,项目名称:libasn1c,代码行数:36,代码来源:asn_codecs_prim.c
示例2: uper_open_type_put
/*
* Encode an "open type field".
* #10.1, #10.2
*/
int
uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) {
void *buf;
void *bptr;
ssize_t size;
size_t toGo;
ASN_DEBUG("Open type put %s ...", td->name);
size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
if(size <= 0) return -1;
for(bptr = buf, toGo = size; toGo;) {
ssize_t maySave = uper_put_length(po, toGo);
ASN_DEBUG("Prepending length %d to %s and allowing to save %d",
(int)size, td->name, (int)maySave);
if(maySave < 0) break;
if(per_put_many_bits(po, bptr, maySave * 8)) break;
bptr = (char *)bptr + maySave;
toGo -= maySave;
}
FREEMEM(buf);
if(toGo) return -1;
ASN_DEBUG("Open type put %s of length %ld + overhead (1byte?)",
td->name, (long)size);
return 0;
}
开发者ID:andrepuschmann,项目名称:v2x-lte,代码行数:34,代码来源:per_opentype.c
示例3: NativeInteger_decode_aper
asn_dec_rval_t
NativeInteger_decode_aper(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval;
long *native = (long *)*sptr;
INTEGER_t tmpint;
void *tmpintptr = &tmpint;
(void)opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) _ASN_DECODE_FAILED;
}
memset(&tmpint, 0, sizeof tmpint);
rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints,
&tmpintptr, pd);
if(rval.code == RC_OK) {
if((specs&&specs->field_unsigned)
? asn_INTEGER2ulong(&tmpint, (unsigned long *)native)
: asn_INTEGER2long(&tmpint, native))
rval.code = RC_FAIL;
else
ASN_DEBUG("NativeInteger %s got value %ld",
td->name, *native);
}
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return rval;
}
开发者ID:osmocom,项目名称:libasn1c,代码行数:35,代码来源:NativeInteger.c
示例4: BOOLEAN_decode_ber
asn_dec_rval_t
BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **bool_value, const void *buf_ptr, size_t size,
int tag_mode) {
_BOOLEANType *st = &static_cast<Type*>(static_cast<AsnAbstractType*>(*bool_value))->value;
asn_dec_rval_t rval;
ber_tlv_len_t length;
ber_tlv_len_t lidx;
if(st == NULL) {
ASN_DEBUG("No allocated memory for BOOLEAN_decode_ber");
rval.code = RC_FAIL;
rval.consumed = 0;
return rval;
}
ASN_DEBUG("Decoding %s as BOOLEAN (tm=%d)",
td->name, tag_mode);
/*
* Check tags.
*/
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size,
tag_mode, 0, &length, 0);
if(rval.code != RC_OK)
return rval;
ASN_DEBUG("Boolean length is %d bytes", (int)length);
buf_ptr = ((const char *)buf_ptr) + rval.consumed;
size -= rval.consumed;
if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
rval.consumed = 0;
return rval;
}
/*
* Compute boolean value.
*/
for(*st = 0, lidx = 0;
(lidx < length) && *st == 0; lidx++) {
/*
* Very simple approach: read bytes until the end or
* value is already TRUE.
* BOOLEAN is not supposed to contain meaningful data anyway.
*/
*st |= ((const uint8_t *)buf_ptr)[lidx];
}
rval.code = RC_OK;
rval.consumed += length;
ASN_DEBUG("Took %ld/%ld bytes to encode %s, value=%d",
(long)rval.consumed, (long)length,
td->name, *st);
return rval;
}
开发者ID:d-chugunov,项目名称:asn1cpp,代码行数:60,代码来源:BOOLEAN.hpp
示例5: NativeEnumerated_decode_uper
asn_dec_rval_t
NativeEnumerated_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) {
asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval = { RC_OK, 0 };
long *native = (long *)*sptr;
asn_per_constraint_t *ct;
long value;
(void)opt_codec_ctx;
if(constraints) ct = &constraints->value;
else if(td->per_constraints) ct = &td->per_constraints->value;
else _ASN_DECODE_FAILED; /* Mandatory! */
if(!specs) _ASN_DECODE_FAILED;
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) _ASN_DECODE_FAILED;
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if(ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
if(inext < 0) _ASN_DECODE_STARVED;
if(inext) ct = 0;
}
if(ct && ct->range_bits >= 0) {
value = per_get_few_bits(pd, ct->range_bits);
if(value < 0) _ASN_DECODE_STARVED;
if(value >= (specs->extension
? specs->extension - 1 : specs->map_count))
_ASN_DECODE_FAILED;
} else {
if(!specs->extension)
_ASN_DECODE_FAILED;
/*
* X.691, #10.6: normally small non-negative whole number;
*/
value = uper_get_nsnnwn(pd);
if(value < 0) _ASN_DECODE_STARVED;
value += specs->extension - 1;
if(value >= specs->map_count)
_ASN_DECODE_FAILED;
}
*native = specs->value2enum[value].nat_value;
ASN_DEBUG("Decoded %s = %ld", td->name, *native);
return rval;
}
开发者ID:duchuan1,项目名称:libIEC61850,代码行数:54,代码来源:NativeEnumerated.c
示例6: NativeInteger_encode_aper
asn_enc_rval_t
NativeInteger_encode_aper(
asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) {
asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
long native;
INTEGER_t tmpint;
if(!sptr) _ASN_ENCODE_FAILED;
native = *(long *)sptr;
ASN_DEBUG("Encoding NativeInteger %s %ld (APER)", td->name, native);
memset(&tmpint, 0, sizeof(tmpint));
if((specs&&specs->field_unsigned)
? asn_ulong2INTEGER(&tmpint, native)
: asn_long2INTEGER(&tmpint, native))
_ASN_ENCODE_FAILED;
er = INTEGER_encode_aper(td, constraints, &tmpint, po);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return er;
}
开发者ID:osmocom,项目名称:libasn1c,代码行数:25,代码来源:NativeInteger.c
示例7: SEQUENCE_free
void
SEQUENCE_free(Allocator * allocator, asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
int edx;
if(!td || !sptr)
return;
ASN_DEBUG("Freeing %s as SEQUENCE", td->name);
for(edx = 0; edx < td->elements_count; edx++) {
asn_TYPE_member_t *elm = &td->elements[edx];
void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(memb_ptr)
ASN_STRUCT_FREE(allocator, *elm->type, memb_ptr);
} else {
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
ASN_STRUCT_FREE_CONTENTS_ONLY(allocator, *elm->type, memb_ptr);
}
}
if(!contents_only) {
CXX_ALLOC_WRAP FREEMEM(sptr);
}
}
开发者ID:mojmir-svoboda,项目名称:BlackBoxTT,代码行数:26,代码来源:constr_SEQUENCE.c
示例8: oer_encode_to_buffer
/*
* A variant of the oer_encode() which encodes the data into the provided buffer
*/
asn_enc_rval_t
oer_encode_to_buffer(const asn_TYPE_descriptor_t *type_descriptor,
const asn_oer_constraints_t *constraints,
const void *struct_ptr, /* Structure to be encoded */
void *buffer, /* Pre-allocated buffer */
size_t buffer_size /* Initial buffer size (maximum) */
) {
enc_to_buf_arg arg;
asn_enc_rval_t ec;
arg.buffer = buffer;
arg.left = buffer_size;
if(type_descriptor->op->oer_encoder == NULL) {
ec.encoded = -1;
ec.failed_type = type_descriptor;
ec.structure_ptr = struct_ptr;
ASN_DEBUG("OER encoder is not defined for %s",
type_descriptor->name);
} else {
ec = type_descriptor->op->oer_encoder(
type_descriptor, constraints,
struct_ptr, /* Pointer to the destination structure */
encode_to_buffer_cb, &arg);
if(ec.encoded != -1) {
assert(ec.encoded == (ssize_t)(buffer_size - arg.left));
/* Return the encoded contents size */
}
}
return ec;
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:34,代码来源:oer_encoder.c
示例9: oer_encode_primitive
asn_enc_rval_t
oer_encode_primitive(const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints, const void *sptr,
asn_app_consume_bytes_f *cb, void *app_key) {
const ASN__PRIMITIVE_TYPE_t *st = (const ASN__PRIMITIVE_TYPE_t *)sptr;
asn_enc_rval_t er = {0, 0, 0};
ssize_t ret;
(void)constraints;
if(!st) ASN__ENCODE_FAILED;
ASN_DEBUG("Encoding %s (%" ASN_PRI_SIZE " bytes)", td ? td->name : "", st->size);
/*
* X.696 (08/2015) #27.2
*/
ret = oer_serialize_length(st->size, cb, app_key);
if(ret < 0) {
ASN__ENCODE_FAILED;
}
er.encoded += ret;
er.encoded += st->size;
if(cb(st->buf, st->size, app_key) < 0) {
ASN__ENCODE_FAILED;
} else {
ASN__ENCODED_OK(er);
}
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:30,代码来源:oer_encoder.c
示例10: BOOLEAN_decode_uper
asn_dec_rval_t
BOOLEAN_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) {
asn_dec_rval_t rv;
BOOLEAN_t *st = (BOOLEAN_t *)*sptr;
(void)opt_codec_ctx;
(void)constraints;
if(!st) {
st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st)));
if(!st) ASN__DECODE_FAILED;
}
/*
* Extract a single bit
*/
switch(per_get_few_bits(pd, 1)) {
case 1: *st = 1; break;
case 0: *st = 0; break;
case -1: default: ASN__DECODE_STARVED;
}
ASN_DEBUG("%s decoded as %s", td->name, *st ? "TRUE" : "FALSE");
rv.code = RC_OK;
rv.consumed = 1;
return rv;
}
开发者ID:SteveDCronin,项目名称:asn1c,代码行数:29,代码来源:BOOLEAN.c
示例11: asn_encode_to_new_buffer
asn_encode_to_new_buffer_result_t
asn_encode_to_new_buffer(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax,
const asn_TYPE_descriptor_t *td, const void *sptr) {
struct dynamic_encoder_key buf_key;
asn_encode_to_new_buffer_result_t res;
buf_key.buffer_size = 16;
buf_key.buffer = MALLOC(buf_key.buffer_size);
buf_key.computed_size = 0;
res.result = asn_encode_internal(opt_codec_ctx, syntax, td, sptr,
dynamic_encoder_cb, &buf_key);
if(res.result.encoded >= 0
&& (size_t)res.result.encoded != buf_key.computed_size) {
ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE
" yet produced %" ASN_PRI_SIZE " bytes",
res.result.encoded, buf_key.computed_size);
assert(res.result.encoded < 0
|| (size_t)res.result.encoded == buf_key.computed_size);
}
res.buffer = buf_key.buffer;
/* 0-terminate just in case. */
if(res.buffer) {
assert(buf_key.computed_size < buf_key.buffer_size);
((char *)res.buffer)[buf_key.computed_size] = '\0';
}
return res;
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:33,代码来源:asn_application.c
示例12: asn_encode_to_buffer
asn_enc_rval_t
asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax,
const asn_TYPE_descriptor_t *td, const void *sptr,
void *buffer, size_t buffer_size) {
struct overrun_encoder_key buf_key;
asn_enc_rval_t er;
if(buffer_size > 0 && !buffer) {
errno = EINVAL;
ASN__ENCODE_FAILED;
}
buf_key.buffer = buffer;
buf_key.buffer_size = buffer_size;
buf_key.computed_size = 0;
er = asn_encode_internal(opt_codec_ctx, syntax, td, sptr,
overrun_encoder_cb, &buf_key);
if(er.encoded >= 0 && (size_t)er.encoded != buf_key.computed_size) {
ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE
" yet produced %" ASN_PRI_SIZE " bytes",
er.encoded, buf_key.computed_size);
assert(er.encoded < 0 || (size_t)er.encoded == buf_key.computed_size);
}
return er;
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:29,代码来源:asn_application.c
示例13: NativeEnumerated_encode_xer
asn_enc_rval_t
NativeEnumerated_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) {
asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
const long *native = (const long *)sptr;
const asn_INTEGER_enum_map_t *el;
(void)ilevel;
(void)flags;
if(!native) _ASN_ENCODE_FAILED;
el = INTEGER_map_value2enum(specs, *native);
if(el) {
size_t srcsize = el->enum_len + 5;
char *src = (char *)alloca(srcsize);
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
if(cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED;
_ASN_ENCODED_OK(er);
} else {
ASN_DEBUG("ASN.1 forbids dealing with "
"unknown value of ENUMERATED type");
_ASN_ENCODE_FAILED;
}
}
开发者ID:duchuan1,项目名称:libIEC61850,代码行数:29,代码来源:NativeEnumerated.c
示例14: uper_get_length
/*
* X.691-201508 #10.9 General rules for encoding a length determinant.
* Get the optionally constrained length "n" from the stream.
*/
ssize_t
uper_get_length(asn_per_data_t *pd, int ebits, size_t lower_bound,
int *repeat) {
ssize_t value;
*repeat = 0;
/* #11.9.4.1 Encoding if constrained (according to effective bits) */
if(ebits >= 0 && ebits <= 16) {
value = per_get_few_bits(pd, ebits);
if(value >= 0) value += lower_bound;
return value;
}
value = per_get_few_bits(pd, 8);
if((value & 0x80) == 0) { /* #11.9.3.6 */
return (value & 0x7F);
} else if((value & 0x40) == 0) { /* #11.9.3.7 */
/* bit 8 ... set to 1 and bit 7 ... set to zero */
value = ((value & 0x3f) << 8) | per_get_few_bits(pd, 8);
return value; /* potential -1 from per_get_few_bits passes through. */
} else if(value < 0) {
ASN_DEBUG("END of stream reached for PER");
return -1;
}
value &= 0x3f; /* this is "m" from X.691, #11.9.3.8 */
if(value < 1 || value > 4) {
return -1; /* Prohibited by #11.9.3.8 */
}
*repeat = 1;
return (16384 * value);
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:36,代码来源:per_support.c
示例15: xer_check_tag
xer_check_tag_e
xer_check_tag(const void *buf_ptr, int size, const char *need_tag) {
const char *buf = (const char *)buf_ptr;
const char *end;
xer_check_tag_e ct = XCT_OPENING;
if(size < 2 || buf[0] != LANGLE || buf[size-1] != RANGLE) {
if(size >= 2)
ASN_DEBUG("Broken XML tag: \"%c...%c\"",
buf[0], buf[size - 1]);
return XCT_BROKEN;
}
/*
* Determine the tag class.
*/
if(buf[1] == CSLASH) {
buf += 2; /* advance past "</" */
size -= 3; /* strip "</" and ">" */
ct = XCT_CLOSING;
if(size > 0 && buf[size-1] == CSLASH)
return XCT_BROKEN; /* </abc/> */
} else {
buf++; /* advance past "<" */
size -= 2; /* strip "<" and ">" */
if(size > 0 && buf[size-1] == CSLASH) {
ct = XCT_BOTH;
size--; /* One more, for "/" */
}
}
/* Sometimes we don't care about the tag */
if(!need_tag || !*need_tag)
return (xer_check_tag_e)(XCT__UNK__MASK | ct);
/*
* Determine the tag name.
*/
for(end = buf + size; buf < end; buf++, need_tag++) {
int b = *buf, n = *need_tag;
if(b != n) {
if(n == 0) {
switch(b) {
case 0x09: case 0x0a: case 0x0c: case 0x0d:
case 0x20:
/* "<abc def/>": whitespace is normal */
return ct;
}
}
return (xer_check_tag_e)(XCT__UNK__MASK | ct);
}
if(b == 0)
return XCT_BROKEN; /* Embedded 0 in buf?! */
}
if(*need_tag)
return (xer_check_tag_e)(XCT__UNK__MASK | ct);
return ct;
}
开发者ID:andrepuschmann,项目名称:v2x-lte,代码行数:59,代码来源:xer_decoder.c
示例16: SEQUENCE_decode_uper
asn_dec_rval_t
SEQUENCE_decode_uper(Allocator * allocator, asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics;
void *st = *sptr; /* Target structure. */
int extpresent; /* Extension additions are present */
uint8_t *opres; /* Presence of optional root members */
asn_per_data_t opmd;
asn_dec_rval_t rv;
int edx;
(void)constraints;
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
_ASN_DECODE_FAILED;
if(!st) {
st = *sptr = CXX_ALLOC_WRAP CALLOC(1, specs->struct_size);
if(!st) _ASN_DECODE_FAILED;
}
ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name);
/* Handle extensions */
if(specs->ext_before >= 0) {
extpresent = per_get_few_bits(pd, 1);
if(extpresent < 0) _ASN_DECODE_STARVED;
} else {
extpresent = 0;
}
/* Prepare a place and read-in the presence bitmap */
memset(&opmd, 0, sizeof(opmd));
if(specs->roms_count) {
opres = (uint8_t *)CXX_ALLOC_WRAP MALLOC(((specs->roms_count + 7) >> 3) + 1);
if(!opres) _ASN_DECODE_FAILED;
/* Get the presence map */
if(per_get_many_bits(pd, opres, 0, specs->roms_count)) {
CXX_ALLOC_WRAP FREEMEM(opres);
_ASN_DECODE_STARVED;
}
opmd.buffer = opres;
opmd.nbits = specs->roms_count;
ASN_DEBUG("Read in presence bitmap for %s of %d bits (%x..)",
td->name, specs->roms_count, *opres);
} else {
开发者ID:mojmir-svoboda,项目名称:BlackBoxTT,代码行数:46,代码来源:constr_SEQUENCE.c
示例17: uper_get_nslength
/*
* Get the normally small length "n".
* This procedure used to decode length of extensions bit-maps
* for SET and SEQUENCE types.
*/
ssize_t
uper_get_nslength(asn_per_data_t *pd) {
ssize_t length;
ASN_DEBUG("Getting normally small length");
if(per_get_few_bits(pd, 1) == 0) {
length = per_get_few_bits(pd, 6) + 1;
if(length <= 0) return -1;
ASN_DEBUG("l=%d", (int)length);
return length;
} else {
int repeat;
length = uper_get_length(pd, -1, 0, &repeat);
if(length >= 0 && !repeat) return length;
return -1; /* Error, or do not support >16K extensions */
}
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:23,代码来源:per_support.c
示例18: INTEGER_encode_der
/*
* Encode INTEGER type using DER.
*/
asn_enc_rval_t
INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
INTEGER_t *st = (INTEGER_t *)sptr;
ASN_DEBUG("%s %s as INTEGER (tm=%d)",
cb?"Encoding":"Estimating", td->name, tag_mode);
/*
* Canonicalize integer in the buffer.
* (Remove too long sign extension, remove some first 0x00 bytes)
*/
if(st->buf) {
uint8_t *buf = st->buf;
uint8_t *end1 = buf + st->size - 1;
int shift;
/* Compute the number of superfluous leading bytes */
for(; buf < end1; buf++) {
/*
* If the contents octets of an integer value encoding
* consist of more than one octet, then the bits of the
* first octet and bit 8 of the second octet:
* a) shall not all be ones; and
* b) shall not all be zero.
*/
switch(*buf) {
case 0x00: if((buf[1] & 0x80) == 0)
continue;
break;
case 0xff: if((buf[1] & 0x80))
continue;
break;
}
break;
}
/* Remove leading superfluous bytes from the integer */
shift = buf - st->buf;
if(shift) {
uint8_t *nb = st->buf;
uint8_t *end;
st->size -= shift; /* New size, minus bad bytes */
end = nb + st->size;
for(; nb < end; nb++, buf++)
*nb = *buf;
}
} /* if(1) */
return der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key);
}
开发者ID:elfring,项目名称:asn1c,代码行数:58,代码来源:INTEGER.c
示例19: NativeReal_free
void
NativeReal_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
if(!td || !ptr)
return;
ASN_DEBUG("Freeing %s as REAL (%d, %p, Native)",
td->name, contents_only, ptr);
if(!contents_only) {
FREEMEM(ptr);
}
}
开发者ID:akibsayyed,项目名称:srlabs,代码行数:13,代码来源:NativeReal.c
示例20: oer_encode
/*
* The OER encoder of any type.
*/
asn_enc_rval_t
oer_encode(const asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr,
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
ASN_DEBUG("OER encoder invoked for %s", type_descriptor->name);
/*
* Invoke type-specific encoder.
*/
return type_descriptor->op->oer_encoder(
type_descriptor, 0,
struct_ptr, /* Pointer to the destination structure */
consume_bytes, app_key);
}
开发者ID:Kampbell,项目名称:asn1c,代码行数:16,代码来源:oer_encoder.c
注:本文中的ASN_DEBUG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论