Skip to content

Commit

Permalink
Refine enable_disable_logic vlm#2
Browse files Browse the repository at this point in the history
  • Loading branch information
brchiu committed Mar 24, 2017
1 parent fa1d1ab commit e279679
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 143 deletions.
1 change: 0 additions & 1 deletion examples/sample.source.PKIX1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ $(TARGET): ${OBJS}
.SUFFIXES: .c .o

.c.o:
$(CC) $(CFLAGS) -E -o $@.i -c $<
$(CC) $(CFLAGS) -o $@ -c $<

clean:
Expand Down
4 changes: 2 additions & 2 deletions libasn1compiler/asn1c_C.c
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char *
if(!tag2el_count) return 0; /* No top level tags */

OUT("\n");
OUT("#if (ASN_OP_MASK & ASN_OP_BER_DER)\n");
OUT("#if (ASN_OP_MASK & (ASN_OP_BER_DER | ASN_OP_XER))\n");
OUT("static const asn_TYPE_tag2member_t asn_MAP_%s_tag2el%s_%d[] = {\n",
MKID(expr), opt_modifier?opt_modifier:"",
expr->_type_unique_index);
Expand All @@ -1760,7 +1760,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char *
OUT(" */\n");
}
OUT("};\n");
OUT("#endif /* (ASN_OP_MASK & ASN_OP_BER_DER) */\n");
OUT("#endif /* (ASN_OP_MASK & (ASN_OP_BER_DER | ASN_OP_XER)) */\n");
OUT("\n");

return 0;
Expand Down
4 changes: 2 additions & 2 deletions skeletons/BIT_STRING.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|| st->bits_unused < 0 || st->bits_unused > 7) {
ASN__CTFAIL(app_key, td, sptr,
"%s: invalid padding byte (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}

Expand Down
6 changes: 3 additions & 3 deletions skeletons/BOOLEAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}

ASN_DEBUG("Decoding %s as BOOLEAN (tm=%d)",
td->name, tag_mode);
TYPE_NAME(td), tag_mode);

/*
* Check tags.
Expand Down Expand Up @@ -124,7 +124,7 @@ BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,

ASN_DEBUG("Took %ld/%ld bytes to encode %s, value=%d",
(long)rval.consumed, (long)length,
td->name, *st);
TYPE_NAME(td), *st);

return rval;
}
Expand Down Expand Up @@ -291,7 +291,7 @@ BOOLEAN_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
case -1: default: ASN__DECODE_STARVED;
}

ASN_DEBUG("%s decoded as %s", td->name, *st ? "TRUE" : "FALSE");
ASN_DEBUG("%s decoded as %s", TYPE_NAME(td), *st ? "TRUE" : "FALSE");

rv.code = RC_OK;
rv.consumed = 1;
Expand Down
2 changes: 1 addition & 1 deletion skeletons/GeneralizedTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
if(tloc == -1 && errno != EPERM) {
ASN__CTFAIL(app_key, td, sptr,
"%s: Invalid time format: %s (%s:%d)",
td->name, strerror(errno), __FILE__, __LINE__);
TYPE_NAME(td), strerror(errno), __FILE__, __LINE__);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions skeletons/IA5String.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ IA5String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
ASN__CTFAIL(app_key, td, sptr,
"%s: value byte %ld out of range: "
"%d > 127 (%s:%d)",
td->name,
TYPE_NAME(td),
(long)((buf - st->buf) + 1),
*buf,
__FILE__, __LINE__);
Expand All @@ -99,7 +99,7 @@ IA5String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions skeletons/INTEGER.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
INTEGER_t *st = (INTEGER_t *)sptr;

ASN_DEBUG("%s %s as INTEGER (tm=%d)",
cb?"Encoding":"Estimating", td->name, tag_mode);
cb?"Encoding":"Estimating", TYPE_NAME(td), tag_mode);

/*
* Canonicalize integer in the buffer.
Expand Down Expand Up @@ -662,7 +662,7 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
return rval;
}
} else {
ASN_DEBUG("Decoding unconstrained integer %s", td->name);
ASN_DEBUG("Decoding unconstrained integer %s", TYPE_NAME(td));
}

/* X.691, #12.2.3, #12.2.4 */
Expand Down
6 changes: 3 additions & 3 deletions skeletons/NativeEnumerated.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
if(!native) ASN__DECODE_FAILED;
}

ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
ASN_DEBUG("Decoding %s as NativeEnumerated", TYPE_NAME(td));

if(ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
Expand Down Expand Up @@ -151,7 +151,7 @@ NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
}

*native = specs->value2enum[value].nat_value;
ASN_DEBUG("Decoded %s = %ld", td->name, *native);
ASN_DEBUG("Decoded %s = %ld", TYPE_NAME(td), *native);

return rval;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
else if(td->per_constraints) ct = &td->per_constraints->value;
else ASN__ENCODE_FAILED; /* Mandatory! */

ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
ASN_DEBUG("Encoding %s as NativeEnumerated", TYPE_NAME(td));

er.encoded = 0;

Expand Down
14 changes: 7 additions & 7 deletions skeletons/NativeInteger.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}

ASN_DEBUG("Decoding %s as INTEGER (tm=%d)",
td->name, tag_mode);
TYPE_NAME(td), tag_mode);

/*
* Check tags.
Expand All @@ -105,7 +105,7 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
if(rval.code != RC_OK)
return rval;

ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
ASN_DEBUG("%s length is %d bytes", TYPE_NAME(td), (int)length);

/*
* Make sure we have this length.
Expand Down Expand Up @@ -150,7 +150,7 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
rval.consumed += length;

ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)",
(long)rval.consumed, (long)length, td->name, (long)*native);
(long)rval.consumed, (long)length, TYPE_NAME(td), (long)*native);

return rval;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
void *tmpintptr = &tmpint;

(void)opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name);
ASN_DEBUG("Decoding NativeInteger %s (UPER)", TYPE_NAME(td));

if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
Expand All @@ -293,7 +293,7 @@ NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
rval.code = RC_FAIL;
else
ASN_DEBUG("NativeInteger %s got value %ld",
td->name, *native);
TYPE_NAME(td), *native);
}
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);

Expand All @@ -312,7 +312,7 @@ NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,

native = *(long *)sptr;

ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", TYPE_NAME(td), native);

memset(&tmpint, 0, sizeof(tmpint));
if((specs&&specs->field_unsigned)
Expand Down Expand Up @@ -360,7 +360,7 @@ NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
return;

ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)",
td->name, contents_only, ptr);
TYPE_NAME(td), contents_only, ptr);

if(!contents_only) {
FREEMEM(ptr);
Expand Down
8 changes: 4 additions & 4 deletions skeletons/NativeReal.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}

ASN_DEBUG("Decoding %s as REAL (tm=%d)",
td->name, tag_mode);
TYPE_NAME(td), tag_mode);

/*
* Check tags.
Expand All @@ -106,7 +106,7 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
if(rval.code != RC_OK)
return rval;

ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
ASN_DEBUG("%s length is %d bytes", TYPE_NAME(td), (int)length);

/*
* Make sure we have this length.
Expand Down Expand Up @@ -178,7 +178,7 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
rval.consumed += length;

ASN_DEBUG("Took %ld/%ld bytes to encode %s (%f)",
(long)rval.consumed, (long)length, td->name, *Dbl);
(long)rval.consumed, (long)length, TYPE_NAME(td), *Dbl);

return rval;
}
Expand Down Expand Up @@ -369,7 +369,7 @@ NativeReal_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
return;

ASN_DEBUG("Freeing %s as REAL (%d, %p, Native)",
td->name, contents_only, ptr);
TYPE_NAME(td), contents_only, ptr);

if(!contents_only) {
FREEMEM(ptr);
Expand Down
4 changes: 2 additions & 2 deletions skeletons/NumericString.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ NumericString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
ASN__CTFAIL(app_key, td, sptr,
"%s: value byte %ld (%d) "
"not in NumericString alphabet (%s:%d)",
td->name,
TYPE_NAME(td),
(long)((buf - st->buf) + 1),
*buf,
__FILE__, __LINE__);
Expand All @@ -124,7 +124,7 @@ NumericString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions skeletons/OBJECT_IDENTIFIER.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ OBJECT_IDENTIFIER_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
ASN__CTFAIL(app_key, td, sptr,
"%s: at least one numerical value "
"expected (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}

Expand Down
12 changes: 6 additions & 6 deletions skeletons/OCTET_STRING.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
enum asn_OS_Subvariant type_variant = specs->subvariant;

ASN_DEBUG("Decoding %s as %s (frame %ld)",
td->name,
TYPE_NAME(td),
(type_variant == ASN_OSUBV_STR) ?
"OCTET STRING" : "OS-SpecialCase",
(long)size);
Expand Down Expand Up @@ -532,7 +532,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}

ASN_DEBUG("Took %ld bytes to encode %s: [%s]:%ld",
(long)consumed_myself, td->name,
(long)consumed_myself, TYPE_NAME(td),
(type_variant == ASN_OSUBV_STR) ? (char *)st->buf : "<data>",
(long)st->size);

Expand All @@ -556,7 +556,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
int fix_last_byte = 0;

ASN_DEBUG("%s %s as OCTET STRING",
cb?"Estimating":"Encoding", td->name);
cb?"Estimating":"Encoding", TYPE_NAME(td));

/*
* Write tags.
Expand Down Expand Up @@ -1495,7 +1495,7 @@ OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,

ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)",
(long)csiz->effective_bits, (long)raw_len,
repeat ? "repeat" : "once", td->name);
repeat ? "repeat" : "once", TYPE_NAME(td));
if(bpc) {
len_bytes = raw_len * bpc;
len_bits = len_bytes * unit_bits;
Expand Down Expand Up @@ -1602,7 +1602,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,

ASN_DEBUG("Encoding %s into %d units of %d bits"
" (%ld..%ld, effective %d)%s",
td->name, sizeinunits, unit_bits,
TYPE_NAME(td), sizeinunits, unit_bits,
csiz->lower_bound, csiz->upper_bound,
csiz->effective_bits, ct_extensible ? " EXT" : "");

Expand Down Expand Up @@ -1762,7 +1762,7 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
: &asn_SPC_OCTET_STRING_specs;
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);

ASN_DEBUG("Freeing %s as OCTET STRING", td->name);
ASN_DEBUG("Freeing %s as OCTET STRING", TYPE_NAME(td));

if(st->buf) {
FREEMEM(st->buf);
Expand Down
4 changes: 2 additions & 2 deletions skeletons/PrintableString.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ PrintableString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
"%s: value byte %ld (%d) "
"not in PrintableString alphabet "
"(%s:%d)",
td->name,
TYPE_NAME(td),
(long)((buf - st->buf) + 1),
*buf,
__FILE__, __LINE__);
Expand All @@ -133,7 +133,7 @@ PrintableString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion skeletons/UTCTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ UTCTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
if(tloc == -1 && errno != EPERM) {
ASN__CTFAIL(app_key, td, sptr,
"%s: Invalid time format: %s (%s:%d)",
td->name, strerror(errno), __FILE__, __LINE__);
TYPE_NAME(td), strerror(errno), __FILE__, __LINE__);
return -1;
}

Expand Down
10 changes: 5 additions & 5 deletions skeletons/UTF8String.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,27 @@ UTF8String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
switch(len) {
case U8E_EINVAL:
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given", td->name);
"%s: value not given", TYPE_NAME(td));
break;
case U8E_TRUNC:
ASN__CTFAIL(app_key, td, sptr,
"%s: truncated UTF-8 sequence (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
break;
case U8E_ILLSTART:
ASN__CTFAIL(app_key, td, sptr,
"%s: UTF-8 illegal start of encoding (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
break;
case U8E_NOTCONT:
ASN__CTFAIL(app_key, td, sptr,
"%s: UTF-8 not continuation (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
break;
case U8E_NOTMIN:
ASN__CTFAIL(app_key, td, sptr,
"%s: UTF-8 not minimal sequence (%s:%d)",
td->name, __FILE__, __LINE__);
TYPE_NAME(td), __FILE__, __LINE__);
break;
}
return (len < 0) ? -1 : 0;
Expand Down
Loading

0 comments on commit e279679

Please sign in to comment.