mirror of https://gerrit.osmocom.org/asn1c
C++ compatibility
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@92 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
parent
f5202a5df6
commit
da67468269
|
@ -32,7 +32,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING = {
|
|||
int
|
||||
BIT_STRING_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const BIT_STRING_t *st = sptr;
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
if(st->size) {
|
||||
|
@ -61,7 +61,7 @@ BIT_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
char scratch[64];
|
||||
const BIT_STRING_t *st = sptr;
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
uint8_t *buf;
|
||||
uint8_t *end;
|
||||
char *p = scratch;
|
||||
|
|
|
@ -32,7 +32,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
|
|||
int
|
||||
BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = sptr;
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
uint16_t *wchar;
|
||||
uint16_t *wend;
|
||||
char scratch[128]; /* Scratchpad buffer */
|
||||
|
|
|
@ -32,14 +32,14 @@ ber_dec_rval_t
|
|||
BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **bool_structure, void *buf_ptr, size_t size,
|
||||
int tag_mode) {
|
||||
BOOLEAN_t *st = *bool_structure;
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)*bool_structure;
|
||||
ber_dec_rval_t rval;
|
||||
ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
|
||||
ber_tlv_len_t length;
|
||||
ber_tlv_len_t lidx;
|
||||
|
||||
if(st == NULL) {
|
||||
st = *bool_structure = CALLOC(1, sizeof(*st));
|
||||
(void *)st = *bool_structure = CALLOC(1, sizeof(*st));
|
||||
if(st == NULL) {
|
||||
rval.code = RC_FAIL;
|
||||
rval.consumed = 0;
|
||||
|
@ -96,7 +96,7 @@ BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
|
|||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
BOOLEAN_t *st = sptr;
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)sptr;
|
||||
|
||||
erval.encoded = der_write_tags(td, 1, tag_mode, tag, cb, app_key);
|
||||
if(erval.encoded == -1) {
|
||||
|
@ -127,7 +127,7 @@ BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
|
|||
int
|
||||
BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BOOLEAN_t *st = sptr;
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -49,7 +49,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = {
|
|||
int
|
||||
GeneralizedTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const GeneralizedTime_t *st = sptr;
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
time_t tloc;
|
||||
|
||||
errno = EPERM; /* Just an unlikely error code */
|
||||
|
@ -67,7 +67,7 @@ der_enc_rval_t
|
|||
GeneralizedTime_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
GeneralizedTime_t *st = ptr;
|
||||
GeneralizedTime_t *st = (GeneralizedTime_t *)ptr;
|
||||
der_enc_rval_t erval;
|
||||
|
||||
/* If not canonical DER, re-encode into canonical DER. */
|
||||
|
@ -107,7 +107,7 @@ GeneralizedTime_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
|
|||
int
|
||||
GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const GeneralizedTime_t *st = sptr;
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
@ -390,7 +390,7 @@ asn_time2GT(GeneralizedTime_t *opt_gt, const struct tm *tm, int force_gmt) {
|
|||
}
|
||||
|
||||
/* Pre-allocate a buffer of sufficient yet small length */
|
||||
buf = MALLOC(buf_size);
|
||||
(void *)buf = MALLOC(buf_size);
|
||||
if(!buf) return 0;
|
||||
|
||||
gmtoff = GMTOFF(*tm);
|
||||
|
@ -433,7 +433,7 @@ asn_time2GT(GeneralizedTime_t *opt_gt, const struct tm *tm, int force_gmt) {
|
|||
if(opt_gt->buf)
|
||||
FREEMEM(opt_gt->buf);
|
||||
} else {
|
||||
opt_gt = CALLOC(1, sizeof *opt_gt);
|
||||
(void *)opt_gt = CALLOC(1, sizeof *opt_gt);
|
||||
if(!opt_gt) { free(buf); return 0; }
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_IA5String = {
|
|||
int
|
||||
IA5String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const IA5String_t *st = sptr;
|
||||
const IA5String_t *st = (const IA5String_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -33,7 +33,7 @@ asn1_TYPE_descriptor_t asn1_DEF_INTEGER = {
|
|||
ber_dec_rval_t
|
||||
INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **int_structure, void *buf_ptr, size_t size, int tag_mode) {
|
||||
INTEGER_t *st = *int_structure;
|
||||
INTEGER_t *st = (INTEGER_t *)*int_structure;
|
||||
ber_dec_rval_t rval;
|
||||
ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
|
||||
ber_tlv_len_t length;
|
||||
|
@ -42,7 +42,7 @@ INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
* If the structure is not there, allocate it.
|
||||
*/
|
||||
if(st == NULL) {
|
||||
st = *int_structure = CALLOC(1, sizeof(*st));
|
||||
(void *)st = *int_structure = CALLOC(1, sizeof(*st));
|
||||
if(st == NULL) {
|
||||
rval.code = RC_FAIL;
|
||||
rval.consumed = 0;
|
||||
|
@ -74,7 +74,7 @@ INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
return rval;
|
||||
}
|
||||
|
||||
st->buf = MALLOC(length);
|
||||
st->buf = (uint8_t *)MALLOC(length);
|
||||
if(st->buf) {
|
||||
st->size = length;
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ INTEGER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
INTEGER_t *st = ptr;
|
||||
INTEGER_t *st = (INTEGER_t *)ptr;
|
||||
|
||||
ASN_DEBUG("%s %s as INTEGER (tm=%d)",
|
||||
cb?"Encoding":"Estimating", sd->name, tag_mode);
|
||||
|
@ -187,7 +187,7 @@ int
|
|||
INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
char scratch[32]; /* Enough for 64-bit integer */
|
||||
const INTEGER_t *st = sptr;
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
uint8_t *buf = st->buf;
|
||||
uint8_t *buf_end = st->buf + st->size;
|
||||
signed long accum;
|
||||
|
@ -249,7 +249,7 @@ INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|
||||
void
|
||||
INTEGER_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||
INTEGER_t *st = ptr;
|
||||
INTEGER_t *st = (INTEGER_t *)ptr;
|
||||
|
||||
if(!td || !st)
|
||||
return;
|
||||
|
|
|
@ -40,7 +40,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = {
|
|||
ber_dec_rval_t
|
||||
NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **int_ptr, void *buf_ptr, size_t size, int tag_mode) {
|
||||
int *Int = *int_ptr;
|
||||
int *Int = (int *)*int_ptr;
|
||||
ber_dec_rval_t rval;
|
||||
ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
|
||||
ber_tlv_len_t length;
|
||||
|
@ -49,7 +49,7 @@ NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
* If the structure is not there, allocate it.
|
||||
*/
|
||||
if(Int == NULL) {
|
||||
Int = *int_ptr = CALLOC(1, sizeof(*Int));
|
||||
(void *)Int = *int_ptr = CALLOC(1, sizeof(*Int));
|
||||
if(Int == NULL) {
|
||||
rval.code = RC_FAIL;
|
||||
rval.consumed = 0;
|
||||
|
@ -89,7 +89,7 @@ NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
{
|
||||
INTEGER_t tmp;
|
||||
long l;
|
||||
tmp.buf = buf_ptr;
|
||||
tmp.buf = (uint8_t *)buf_ptr;
|
||||
tmp.size = length;
|
||||
|
||||
if(asn1_INTEGER2long(&tmp, &l)) {
|
||||
|
@ -165,7 +165,7 @@ NativeInteger_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int
|
||||
NativeInteger_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const int *Int = sptr;
|
||||
const int *Int = (const int *)sptr;
|
||||
char scratch[32]; /* Enough for 64-bit int */
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NumericString = {
|
|||
int
|
||||
NumericString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const NumericString_t *st = sptr;
|
||||
const NumericString_t *st = (const NumericString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -38,7 +38,7 @@ OBJECT_IDENTIFIER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
OBJECT_IDENTIFIER_t *st = ptr;
|
||||
OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)ptr;
|
||||
|
||||
ASN_DEBUG("%s %s as OBJECT IDENTIFIER (tm=%d)",
|
||||
cb?"Encoding":"Estimating", sd->name, tag_mode);
|
||||
|
@ -75,7 +75,7 @@ OBJECT_IDENTIFIER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int
|
||||
OBJECT_IDENTIFIER_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = sptr;
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
if(st->size < 1) {
|
||||
|
@ -231,7 +231,7 @@ OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add,
|
|||
int
|
||||
OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = sptr;
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
int startn;
|
||||
int add = 0;
|
||||
int i;
|
||||
|
@ -372,7 +372,7 @@ OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, void *arcval, unsigned int arc
|
|||
|
||||
if(isLittleEndian && !prepared_order) {
|
||||
uint8_t *a = (unsigned char *)arcval + arcval_size - 1;
|
||||
uint8_t *aend = arcval;
|
||||
uint8_t *aend = (uint8_t *)arcval;
|
||||
uint8_t *msb = buffer + arcval_size - 1;
|
||||
for(tp = buffer; a >= aend; tp++, a--)
|
||||
if((*tp = *a) && (tp < msb))
|
||||
|
@ -382,7 +382,7 @@ OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, void *arcval, unsigned int arc
|
|||
} else {
|
||||
/* Look for most significant non-zero byte */
|
||||
tend = (unsigned char *)arcval + arcval_size;
|
||||
for(tp = arcval; tp < tend - 1; tp++)
|
||||
for(tp = (uint8_t *)arcval; tp < tend - 1; tp++)
|
||||
if(*tp) break;
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid, void *arcs, unsigned int ar
|
|||
unsigned char *ps, *pe;
|
||||
/* If more significant bytes are present,
|
||||
* make them > 255 quick */
|
||||
for(ps = arcs, pe = ps+arc_type_size - 1; ps < pe; ps++)
|
||||
for(ps = (unsigned char *)arcs, pe = ps+arc_type_size - 1; ps < pe; ps++)
|
||||
arc0 |= *ps, arc1 |= *(ps + arc_type_size);
|
||||
arc0 = *((unsigned char *)arcs + arc_type_size - 1);
|
||||
arc1 = *((unsigned char *)arcs +(arc_type_size<< 1)-1);
|
||||
|
@ -499,7 +499,7 @@ OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid, void *arcs, unsigned int ar
|
|||
* * the value of the first arc which is in range (0..2)
|
||||
*/
|
||||
size = ((arc_type_size * CHAR_BIT + 6) / 7) * arc_slots;
|
||||
bp = buf = MALLOC(size + 1);
|
||||
bp = buf = (uint8_t *)MALLOC(size + 1);
|
||||
if(!buf) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
|
@ -534,7 +534,7 @@ OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid, void *arcs, unsigned int ar
|
|||
uint8_t *a1 = (unsigned char *)arcs + arc_type_size - 1;
|
||||
for(; a1 > aend; fv++, a1--) *fv = *a1;
|
||||
} else {
|
||||
uint8_t *a1 = arcs;
|
||||
uint8_t *a1 = (uint8_t *)arcs;
|
||||
uint8_t *aend = a1 + arc_type_size;
|
||||
for(; a1 < aend; fv++, a1++) *fv = *a1;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
|
|||
while(_ns <= (size_t)(st->size + bufsize)); \
|
||||
ptr = REALLOC(st->buf, _ns); \
|
||||
if(ptr) { \
|
||||
st->buf = ptr; \
|
||||
st->buf = (uint8_t *)ptr; \
|
||||
ctx->step = _ns; \
|
||||
} else { \
|
||||
RETURN(RC_FAIL); \
|
||||
|
@ -100,7 +100,7 @@ _add_stack_el(struct _stack *st) {
|
|||
nel->want_nulls = 0;
|
||||
nel->bits_chopped = 0;
|
||||
} else {
|
||||
nel = CALLOC(1, sizeof(struct _stack_el));
|
||||
(void *)nel = CALLOC(1, sizeof(struct _stack_el));
|
||||
if(nel == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -119,7 +119,7 @@ _add_stack_el(struct _stack *st) {
|
|||
static struct _stack *
|
||||
_new_stack() {
|
||||
struct _stack *st;
|
||||
st = CALLOC(1, sizeof(struct _stack));
|
||||
(void *)st = CALLOC(1, sizeof(struct _stack));
|
||||
if(st == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -138,7 +138,7 @@ _new_stack() {
|
|||
ber_dec_rval_t
|
||||
OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
||||
void **os_structure, void *buf_ptr, size_t size, int tag_mode) {
|
||||
OCTET_STRING_t *st = *os_structure;
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)*os_structure;
|
||||
ber_dec_rval_t rval;
|
||||
ber_dec_ctx_t *ctx;
|
||||
ssize_t consumed_myself = 0;
|
||||
|
@ -160,7 +160,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
* Create the string if does not exist.
|
||||
*/
|
||||
if(st == NULL) {
|
||||
st = *os_structure = CALLOC(1, sizeof(*st));
|
||||
(void *)st = *os_structure = CALLOC(1, sizeof(*st));
|
||||
if(st == NULL)
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
*/
|
||||
ctx->ptr = _new_stack();
|
||||
if(ctx->ptr) {
|
||||
stck = ctx->ptr;
|
||||
(void *)stck = ctx->ptr;
|
||||
if(ctx->left < 0) {
|
||||
stck->cur_ptr->want_nulls = -ctx->left;
|
||||
stck->cur_ptr->left = -1;
|
||||
|
@ -223,7 +223,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Fill the stack with expectations.
|
||||
*/
|
||||
stck = ctx->ptr;
|
||||
(void *)stck = ctx->ptr;
|
||||
sel = stck->cur_ptr;
|
||||
do {
|
||||
ber_tlv_tag_t tlv_tag;
|
||||
|
@ -307,7 +307,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
|
|||
NEXT_PHASE(ctx);
|
||||
/* Fall through */
|
||||
case 2:
|
||||
stck = ctx->ptr;
|
||||
(void *)stck = ctx->ptr;
|
||||
sel = stck->cur_ptr;
|
||||
ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld",
|
||||
(long)sel->left, (long)size);
|
||||
|
@ -391,7 +391,7 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
der_enc_rval_t erval;
|
||||
OCTET_STRING_t *st = ptr;
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)ptr;
|
||||
int add_byte = 0;
|
||||
|
||||
ASN_DEBUG("%s %s as OCTET STRING",
|
||||
|
@ -458,7 +458,7 @@ int
|
|||
OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
const OCTET_STRING_t *st = sptr;
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
char scratch[16 * 3 + 4];
|
||||
char *p = scratch;
|
||||
uint8_t *buf;
|
||||
|
@ -495,7 +495,7 @@ OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
int
|
||||
OCTET_STRING_print_ascii(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OCTET_STRING_t *st = sptr;
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
@ -509,8 +509,8 @@ OCTET_STRING_print_ascii(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
|
||||
void
|
||||
OCTET_STRING_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) {
|
||||
OCTET_STRING_t *st = sptr;
|
||||
struct _stack *stck = st->_ber_dec_ctx.ptr;
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
|
||||
struct _stack *stck = (struct _stack *)st->_ber_dec_ctx.ptr;
|
||||
|
||||
if(!td || !st)
|
||||
return;
|
||||
|
@ -569,7 +569,7 @@ OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len) {
|
|||
if(buf == NULL) {
|
||||
return -1;
|
||||
} else {
|
||||
st->buf = buf;
|
||||
st->buf = (uint8_t *)buf;
|
||||
st->size = len;
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ OCTET_STRING_t *
|
|||
OCTET_STRING_new_fromBuf(const char *str, int len) {
|
||||
OCTET_STRING_t *st;
|
||||
|
||||
st = CALLOC(1, sizeof(*st));
|
||||
(void *)st = CALLOC(1, sizeof(*st));
|
||||
if(st && str && OCTET_STRING_fromBuf(st, str, len)) {
|
||||
free(st);
|
||||
st = NULL;
|
||||
|
|
|
@ -52,7 +52,7 @@ static int _PrintableString_alphabet[256] = {
|
|||
int
|
||||
PrintableString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const PrintableString_t *st = sptr;
|
||||
const PrintableString_t *st = (const PrintableString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -32,7 +32,7 @@ asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
|
|||
int
|
||||
RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const RELATIVE_OID_t *st = sptr;
|
||||
const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
|
||||
int startn;
|
||||
int i;
|
||||
|
||||
|
@ -112,7 +112,7 @@ RELATIVE_OID_set_arcs(RELATIVE_OID_t *roid, void *arcs, unsigned int arc_type_si
|
|||
* Roughly estimate the maximum size necessary to encode these arcs.
|
||||
*/
|
||||
size = ((arc_type_size * CHAR_BIT + 6) / 7) * arcs_slots;
|
||||
bp = buf = MALLOC(size + 1);
|
||||
bp = buf = (uint8_t *)MALLOC(size + 1);
|
||||
if(!buf) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
|
|
|
@ -40,7 +40,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTCTime = {
|
|||
int
|
||||
UTCTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const UTCTime_t *st = sptr;
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
time_t tloc;
|
||||
|
||||
errno = EPERM; /* Just an unlikely error code */
|
||||
|
@ -57,7 +57,7 @@ UTCTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
int
|
||||
UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTCTime_t *st = sptr;
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -39,7 +39,8 @@ int
|
|||
UTF8String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
ssize_t len;
|
||||
len = UTF8String_length(sptr, td->name, app_errlog, app_key);
|
||||
len = UTF8String_length((const UTF8String_t *)sptr, td->name,
|
||||
app_errlog, app_key);
|
||||
if(len > 0) len = 0;
|
||||
return len;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ UTF8String_length(const UTF8String_t *st, const char *opt_type_name,
|
|||
int
|
||||
UTF8String_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTF8String_t *st = sptr;
|
||||
const UTF8String_t *st = (const UTF8String_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -30,7 +30,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
|
|||
int
|
||||
UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = sptr;
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
uint32_t *wchar;
|
||||
uint32_t *wend;
|
||||
char scratch[128]; /* Scratchpad buffer */
|
||||
|
|
|
@ -52,7 +52,7 @@ static int _VisibleString_alphabet[256] = {
|
|||
int
|
||||
VisibleString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
const VisibleString_t *st = sptr;
|
||||
const VisibleString_t *st = (const VisibleString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -9,7 +9,7 @@ typedef A_SEQUENCE_OF(void) asn_sequence;
|
|||
|
||||
void
|
||||
asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) {
|
||||
asn_sequence *as = asn_sequence_of_x;
|
||||
asn_sequence *as = (asn_sequence *)asn_sequence_of_x;
|
||||
|
||||
if(as) {
|
||||
void *ptr;
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef A_SET_OF(void) asn_set;
|
|||
*/
|
||||
int
|
||||
asn_set_add(void *asn_set_of_x, void *ptr) {
|
||||
asn_set *as = asn_set_of_x;
|
||||
asn_set *as = (asn_set *)asn_set_of_x;
|
||||
|
||||
if(as == 0 || ptr == 0) {
|
||||
errno = EINVAL; /* Invalid arguments */
|
||||
|
@ -28,7 +28,7 @@ asn_set_add(void *asn_set_of_x, void *ptr) {
|
|||
void *_new_arr;
|
||||
_new_arr = REALLOC(as->array, _newsize * sizeof(as->array[0]));
|
||||
if(_new_arr) {
|
||||
as->array = _new_arr;
|
||||
as->array = (void **)_new_arr;
|
||||
as->size = _newsize;
|
||||
} else {
|
||||
/* ENOMEM */
|
||||
|
@ -43,7 +43,7 @@ asn_set_add(void *asn_set_of_x, void *ptr) {
|
|||
|
||||
void
|
||||
asn_set_del(void *asn_set_of_x, int number, int _do_free) {
|
||||
asn_set *as = asn_set_of_x;
|
||||
asn_set *as = (asn_set *)asn_set_of_x;
|
||||
|
||||
if(as) {
|
||||
void *ptr;
|
||||
|
@ -71,7 +71,7 @@ asn_set_del(void *asn_set_of_x, int number, int _do_free) {
|
|||
*/
|
||||
void
|
||||
asn_set_empty(void *asn_set_of_x) {
|
||||
asn_set *as = asn_set_of_x;
|
||||
asn_set *as = (asn_set *)asn_set_of_x;
|
||||
|
||||
if(as) {
|
||||
if(as->array) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
ssize_t
|
||||
ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
|
||||
ber_tlv_len_t *len_r) {
|
||||
uint8_t *buf = bufptr;
|
||||
uint8_t *buf = (uint8_t *)bufptr;
|
||||
unsigned oct;
|
||||
|
||||
if(size == 0)
|
||||
|
@ -119,7 +119,7 @@ ber_skip_length(int _is_constructed, void *ptr, size_t size) {
|
|||
ssize_t
|
||||
der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) {
|
||||
size_t computed_size; /* Size of len encoding */
|
||||
uint8_t *buf = bufp;
|
||||
uint8_t *buf = (uint8_t *)bufp;
|
||||
uint8_t *end;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ ssize_t
|
|||
der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
|
||||
int tclass = BER_TAG_CLASS(tag);
|
||||
ber_tlv_tag_t tval = BER_TAG_VALUE(tag);
|
||||
uint8_t *buf = bufp;
|
||||
uint8_t *buf = (uint8_t *)bufp;
|
||||
uint8_t *end;
|
||||
size_t computed_size;
|
||||
int i;
|
||||
|
|
|
@ -66,8 +66,9 @@ static inline void _set_present_idx(void *sptr, int offset, int size, int pres);
|
|||
*/
|
||||
static int
|
||||
_search4tag(const void *ap, const void *bp) {
|
||||
const asn1_TYPE_tag2member_t *a = ap;
|
||||
const asn1_TYPE_tag2member_t *b = bp;
|
||||
const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
|
||||
const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
|
||||
|
||||
int a_class = BER_TAG_CLASS(a->el_tag);
|
||||
int b_class = BER_TAG_CLASS(b->el_tag);
|
||||
|
||||
|
@ -97,7 +98,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
asn1_CHOICE_specifics_t *specs = sd->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)sd->specifics;
|
||||
asn1_CHOICE_element_t *elements = specs->elements;
|
||||
|
||||
/*
|
||||
|
@ -183,7 +184,8 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
asn1_TYPE_tag2member_t key;
|
||||
|
||||
key.el_tag = tlv_tag;
|
||||
t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
|
||||
(void *)t2m = bsearch(&key,
|
||||
specs->tag2el, specs->tag2el_count,
|
||||
sizeof(specs->tag2el[0]), _search4tag);
|
||||
if(t2m) {
|
||||
/*
|
||||
|
@ -227,7 +229,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
do {
|
||||
asn1_CHOICE_element_t *elm; /* CHOICE's element */
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void *memb_ptr2; /* Pointer to that pointer */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
elm = &elements[ctx->step];
|
||||
|
||||
|
@ -238,7 +240,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
*/
|
||||
if(elm->optional) {
|
||||
/* Optional member, hereby, a simple pointer */
|
||||
memb_ptr2 = (char *)st + elm->memb_offset;
|
||||
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
|
||||
} else {
|
||||
/*
|
||||
* A pointer to a pointer
|
||||
|
@ -250,8 +252,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Invoke the member fetch routine according to member's type
|
||||
*/
|
||||
rval = elm->type->ber_decoder(
|
||||
(void *)elm->type,
|
||||
rval = elm->type->ber_decoder(elm->type,
|
||||
memb_ptr2, ptr, LEFT,
|
||||
elm->tag_mode);
|
||||
switch(rval.code) {
|
||||
|
@ -352,7 +353,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
|
|||
void *struct_ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_CHOICE_specifics_t *specs = sd->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)sd->specifics;
|
||||
asn1_CHOICE_element_t *elm; /* CHOICE element */
|
||||
der_enc_rval_t erval;
|
||||
void *memb_ptr;
|
||||
|
@ -442,7 +443,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
|
|||
|
||||
ber_tlv_tag_t
|
||||
CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
|
||||
asn1_CHOICE_specifics_t *specs = td->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
|
||||
int present;
|
||||
|
||||
assert(tag_mode == 0);
|
||||
|
@ -475,7 +476,7 @@ CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, be
|
|||
int
|
||||
CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
asn1_CHOICE_specifics_t *specs = td->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
|
||||
int present;
|
||||
|
||||
if(!sptr) {
|
||||
|
@ -509,7 +510,7 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
int
|
||||
CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_CHOICE_specifics_t *specs = td->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
|
||||
int present;
|
||||
|
||||
if(!sptr) return cb("<absent>", 8, app_key);
|
||||
|
@ -547,7 +548,7 @@ CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|
||||
void
|
||||
CHOICE_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||
asn1_CHOICE_specifics_t *specs = td->specifics;
|
||||
asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
|
||||
int present;
|
||||
|
||||
if(!td || !ptr)
|
||||
|
|
|
@ -69,8 +69,9 @@
|
|||
*/
|
||||
static int
|
||||
_t2e_cmp(const void *ap, const void *bp) {
|
||||
const asn1_TYPE_tag2member_t *a = ap;
|
||||
const asn1_TYPE_tag2member_t *b = bp;
|
||||
const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
|
||||
const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
|
||||
|
||||
int a_class = BER_TAG_CLASS(a->el_tag);
|
||||
int b_class = BER_TAG_CLASS(b->el_tag);
|
||||
|
||||
|
@ -107,7 +108,7 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
asn1_SEQUENCE_specifics_t *specs = sd->specifics;
|
||||
asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)sd->specifics;
|
||||
asn1_SEQUENCE_element_t *elements = specs->elements;
|
||||
|
||||
/*
|
||||
|
@ -184,7 +185,7 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
for(edx = (ctx->step >> 1); edx < specs->elements_count;
|
||||
edx++, ctx->step = (ctx->step & ~1) + 2) {
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void *memb_ptr2; /* Pointer to that pointer */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
ssize_t tag_len; /* Length of TLV's T */
|
||||
int opt_edx_end; /* Next non-optional element */
|
||||
int use_bsearch;
|
||||
|
@ -267,7 +268,8 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
asn1_TYPE_tag2member_t key;
|
||||
key.el_tag = tlv_tag;
|
||||
key.el_no = edx;
|
||||
t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
|
||||
(void *)t2m = bsearch(&key,
|
||||
specs->tag2el, specs->tag2el_count,
|
||||
sizeof(specs->tag2el[0]), _t2e_cmp);
|
||||
if(t2m) {
|
||||
asn1_TYPE_tag2member_t *best = 0;
|
||||
|
@ -366,7 +368,7 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
*/
|
||||
if(elements[edx].optional) {
|
||||
/* Optional member, hereby, a simple pointer */
|
||||
memb_ptr2 = (char *)st + elements[edx].memb_offset;
|
||||
memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
|
||||
} else {
|
||||
/*
|
||||
* A pointer to a pointer
|
||||
|
@ -379,7 +381,7 @@ SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
* Invoke the member fetch routine according to member's type
|
||||
*/
|
||||
rval = elements[edx].type->ber_decoder(
|
||||
(void *)elements[edx].type,
|
||||
elements[edx].type,
|
||||
memb_ptr2, ptr, LEFT,
|
||||
elements[edx].tag_mode);
|
||||
ASN_DEBUG("In %s SEQUENCE decoded %d %s in %d bytes code %d",
|
||||
|
@ -479,7 +481,7 @@ der_enc_rval_t
|
|||
SEQUENCE_encode_der(asn1_TYPE_descriptor_t *sd,
|
||||
void *ptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SEQUENCE_specifics_t *specs = sd->specifics;
|
||||
asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)sd->specifics;
|
||||
size_t computed_size = 0;
|
||||
der_enc_rval_t erval;
|
||||
ssize_t ret;
|
||||
|
@ -564,7 +566,7 @@ SEQUENCE_encode_der(asn1_TYPE_descriptor_t *sd,
|
|||
int
|
||||
SEQUENCE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SEQUENCE_specifics_t *specs = td->specifics;
|
||||
asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
int ret;
|
||||
|
||||
|
@ -612,7 +614,7 @@ SEQUENCE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|
||||
void
|
||||
SEQUENCE_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) {
|
||||
asn1_SEQUENCE_specifics_t *specs = td->specifics;
|
||||
asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
|
||||
if(!td || !sptr)
|
||||
|
@ -641,7 +643,7 @@ SEQUENCE_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) {
|
|||
int
|
||||
SEQUENCE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
asn1_SEQUENCE_specifics_t *specs = td->specifics;
|
||||
asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
|
||||
if(!sptr) {
|
||||
|
|
|
@ -12,9 +12,9 @@ der_enc_rval_t
|
|||
SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_OF_specifics_t *specs = sd->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
|
||||
asn1_SET_OF_element_t *elm = specs->element;
|
||||
A_SEQUENCE_OF(void) *list = ptr;
|
||||
A_SEQUENCE_OF(void) *list;
|
||||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
der_enc_rval_t erval;
|
||||
|
@ -25,6 +25,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
/*
|
||||
* Gather the length of the underlying members sequence.
|
||||
*/
|
||||
(void *)list = ptr;
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
erval = elm->type->der_encoder(elm->type, memb_ptr,
|
||||
|
|
|
@ -66,8 +66,9 @@
|
|||
*/
|
||||
static int
|
||||
_t2e_cmp(const void *ap, const void *bp) {
|
||||
const asn1_TYPE_tag2member_t *a = ap;
|
||||
const asn1_TYPE_tag2member_t *b = bp;
|
||||
const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
|
||||
const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
|
||||
|
||||
int a_class = BER_TAG_CLASS(a->el_tag);
|
||||
int b_class = BER_TAG_CLASS(b->el_tag);
|
||||
|
||||
|
@ -97,7 +98,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
asn1_SET_specifics_t *specs = sd->specifics;
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)sd->specifics;
|
||||
asn1_SET_element_t *elements = specs->elements;
|
||||
|
||||
/*
|
||||
|
@ -179,7 +180,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
ctx->step = (ctx->step & ~1) + 2,
|
||||
edx = (ctx->step >> 1)) {
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void *memb_ptr2; /* Pointer to that pointer */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
ssize_t tag_len; /* Length of TLV's T */
|
||||
|
||||
if(ctx->step & 1)
|
||||
|
@ -234,7 +235,8 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
asn1_TYPE_tag2member_t key;
|
||||
|
||||
key.el_tag = tlv_tag;
|
||||
t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
|
||||
(void *)t2m = bsearch(&key,
|
||||
specs->tag2el, specs->tag2el_count,
|
||||
sizeof(specs->tag2el[0]), _t2e_cmp);
|
||||
if(t2m) {
|
||||
/*
|
||||
|
@ -294,7 +296,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
*/
|
||||
if(elements[edx].optional) {
|
||||
/* Optional member, hereby, a simple pointer */
|
||||
memb_ptr2 = (char *)st + elements[edx].memb_offset;
|
||||
memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
|
||||
} else {
|
||||
/*
|
||||
* A pointer to a pointer
|
||||
|
@ -307,7 +309,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
* Invoke the member fetch routine according to member's type
|
||||
*/
|
||||
rval = elements[edx].type->ber_decoder(
|
||||
(void *)elements[edx].type,
|
||||
elements[edx].type,
|
||||
memb_ptr2, ptr, LEFT,
|
||||
elements[edx].tag_mode);
|
||||
switch(rval.code) {
|
||||
|
@ -432,7 +434,7 @@ der_enc_rval_t
|
|||
SET_encode_der(asn1_TYPE_descriptor_t *sd,
|
||||
void *ptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_specifics_t *specs = sd->specifics;
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)sd->specifics;
|
||||
size_t computed_size = 0;
|
||||
der_enc_rval_t my_erval;
|
||||
int t2m_build_own = (specs->tag2el_count != specs->elements_count);
|
||||
|
@ -445,14 +447,14 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
|
|||
* Use existing, or build our own tags map.
|
||||
*/
|
||||
if(t2m_build_own) {
|
||||
t2m = alloca(specs->elements_count * sizeof(t2m[0]));
|
||||
t2m_count = 0;
|
||||
(void *)t2m = alloca(specs->elements_count * sizeof(t2m[0]));
|
||||
if(!t2m) { /* There are such platforms */
|
||||
my_erval.encoded = -1;
|
||||
my_erval.failed_type = sd;
|
||||
my_erval.structure_ptr = ptr;
|
||||
return my_erval;
|
||||
}
|
||||
t2m_count = 0;
|
||||
} else {
|
||||
/*
|
||||
* There is no untagged CHOICE in this SET.
|
||||
|
@ -578,7 +580,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
|
|||
int
|
||||
SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_specifics_t *specs = td->specifics;
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
int ret;
|
||||
|
||||
|
@ -625,7 +627,7 @@ SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|
||||
void
|
||||
SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||
asn1_SET_specifics_t *specs = td->specifics;
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
|
||||
if(!td || !ptr)
|
||||
|
@ -654,7 +656,7 @@ SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
int
|
||||
SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
asn1_SET_specifics_t *specs = td->specifics;
|
||||
asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
|
||||
int edx;
|
||||
|
||||
if(!sptr) {
|
||||
|
|
|
@ -65,7 +65,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
asn1_SET_OF_specifics_t *specs = sd->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
|
||||
asn1_SET_OF_element_t *element = specs->element;
|
||||
|
||||
/*
|
||||
|
@ -201,8 +201,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
/*
|
||||
* Invoke the member fetch routine according to member's type
|
||||
*/
|
||||
rval = element->type->ber_decoder(
|
||||
(void *)element->type,
|
||||
rval = element->type->ber_decoder(element->type,
|
||||
&ctx->ptr, ptr, LEFT, 0);
|
||||
ASN_DEBUG("In %s SET OF %s code %d consumed %d",
|
||||
sd->name, element->type->name,
|
||||
|
@ -210,7 +209,8 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
|
|||
switch(rval.code) {
|
||||
case RC_OK:
|
||||
{
|
||||
A_SET_OF(void) *list = st;
|
||||
A_SET_OF(void) *list;
|
||||
(void *)list = st;
|
||||
if(ASN_SET_ADD(list, ctx->ptr) != 0)
|
||||
RETURN(RC_FAIL);
|
||||
else
|
||||
|
@ -269,7 +269,7 @@ struct _el_buffer {
|
|||
};
|
||||
/* Append bytes to the above structure */
|
||||
static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) {
|
||||
struct _el_buffer *el_buf = el_buf_ptr;
|
||||
struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
|
||||
|
||||
if(el_buf->length + size > el_buf->size)
|
||||
return -1;
|
||||
|
@ -280,8 +280,8 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) {
|
|||
return 0;
|
||||
}
|
||||
static int _el_buf_cmp(const void *ap, const void *bp) {
|
||||
const struct _el_buffer *a = ap;
|
||||
const struct _el_buffer *b = bp;
|
||||
const struct _el_buffer *a = (const struct _el_buffer *)ap;
|
||||
const struct _el_buffer *b = (const struct _el_buffer *)bp;
|
||||
int ret;
|
||||
size_t common_len;
|
||||
|
||||
|
@ -308,11 +308,11 @@ der_enc_rval_t
|
|||
SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_OF_specifics_t *specs = sd->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
|
||||
asn1_SET_OF_element_t *elm = specs->element;
|
||||
asn1_TYPE_descriptor_t *elm_type = elm->type;
|
||||
der_type_encoder_f *der_encoder = elm_type->der_encoder;
|
||||
A_SET_OF(void) *list = ptr;
|
||||
A_SET_OF(void) *list;
|
||||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
struct _el_buffer *encoded_els;
|
||||
|
@ -326,6 +326,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
/*
|
||||
* Gather the length of the underlying members sequence.
|
||||
*/
|
||||
(void *)list = ptr;
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
||||
|
@ -361,7 +362,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
* according to their encodings. Build an array of the
|
||||
* encoded elements.
|
||||
*/
|
||||
encoded_els = MALLOC(list->count * sizeof(encoded_els[0]));
|
||||
(void *)encoded_els = MALLOC(list->count * sizeof(encoded_els[0]));
|
||||
if(encoded_els == NULL) {
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = sd;
|
||||
|
@ -381,7 +382,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
/*
|
||||
* Prepare space for encoding.
|
||||
*/
|
||||
encoded_el->buf = MALLOC(max_encoded_len);
|
||||
encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len);
|
||||
if(encoded_el->buf) {
|
||||
encoded_el->length = 0;
|
||||
encoded_el->size = max_encoded_len;
|
||||
|
@ -447,9 +448,9 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
|
|||
int
|
||||
SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn1_SET_OF_specifics_t *specs = td->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
|
||||
asn1_SET_OF_element_t *element = specs->element;
|
||||
const A_SET_OF(void) *list = sptr;
|
||||
const A_SET_OF(void) *list;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
|
@ -460,6 +461,7 @@ SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|| cb(" ::= {\n", 7, app_key))
|
||||
return -1;
|
||||
|
||||
(void *)list = sptr;
|
||||
for(i = 0; i < list->count; i++) {
|
||||
const void *memb_ptr = list->array[i];
|
||||
if(!memb_ptr) continue;
|
||||
|
@ -484,15 +486,16 @@ SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
void
|
||||
SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||
if(td && ptr) {
|
||||
asn1_SET_OF_specifics_t *specs = td->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
|
||||
asn1_SET_OF_element_t *element = specs->element;
|
||||
A_SET_OF(void) *list = ptr;
|
||||
A_SET_OF(void) *list;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Could not use set_of_empty() because of (*free)
|
||||
* incompatibility.
|
||||
*/
|
||||
(void *)list = ptr;
|
||||
for(i = 0; i < list->count; i++) {
|
||||
void *memb_ptr = list->array[i];
|
||||
if(memb_ptr)
|
||||
|
@ -511,9 +514,9 @@ SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
int
|
||||
SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
asn1_SET_OF_specifics_t *specs = td->specifics;
|
||||
asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
|
||||
asn1_SET_OF_element_t *element = specs->element;
|
||||
const A_SET_OF(void) *list = sptr;
|
||||
const A_SET_OF(void) *list;
|
||||
int i;
|
||||
|
||||
if(!sptr) {
|
||||
|
@ -521,6 +524,8 @@ SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
|
|||
return -1;
|
||||
}
|
||||
|
||||
(void *)list = sptr;
|
||||
|
||||
for(i = 0; i < list->count; i++) {
|
||||
const void *memb_ptr = list->array[i];
|
||||
if(!memb_ptr) continue;
|
||||
|
|
|
@ -48,7 +48,7 @@ asn_fprint(FILE *stream, asn1_TYPE_descriptor_t *td, const void *struct_ptr) {
|
|||
/* Dump the data into the specified stdio stream */
|
||||
static int
|
||||
_print2fp(const void *buffer, size_t size, void *app_key) {
|
||||
FILE *stream = app_key;
|
||||
FILE *stream = (FILE *)app_key;
|
||||
|
||||
if(fwrite(buffer, 1, size, stream) != size)
|
||||
return -1;
|
||||
|
|
|
@ -35,7 +35,7 @@ struct __fill_errbuf_arg {
|
|||
|
||||
static int
|
||||
__fill_errbuf(const void *buffer, size_t size, void *app_key) {
|
||||
struct __fill_errbuf_arg *arg = app_key;
|
||||
struct __fill_errbuf_arg *arg = (struct __fill_errbuf_arg *)app_key;
|
||||
size_t avail = arg->errlen - arg->erroff;
|
||||
|
||||
if(avail > size)
|
||||
|
@ -107,7 +107,7 @@ _asn_i_log_error(asn_app_consume_bytes_f *cb, void *key, const char *fmt, ...) {
|
|||
* More space required to hold the message.
|
||||
*/
|
||||
len = ret + 1;
|
||||
p = alloca(len);
|
||||
p = (char *)alloca(len);
|
||||
if(!p) return; /* Can fail on !x86. */
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ der_write_tags(asn1_TYPE_descriptor_t *sd,
|
|||
* and initialize it appropriately.
|
||||
*/
|
||||
int stag_offset;
|
||||
tags = alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
|
||||
tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
|
||||
if(!tags) { /* Can fail on !x86 */
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
|
@ -82,7 +82,7 @@ der_write_tags(asn1_TYPE_descriptor_t *sd,
|
|||
if(tags_count == 0)
|
||||
return 0;
|
||||
|
||||
lens = alloca(tags_count * sizeof(lens[0]));
|
||||
lens = (ssize_t *)alloca(tags_count * sizeof(lens[0]));
|
||||
if(!lens) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue