mirror of https://gerrit.osmocom.org/asn1c
*** empty log message ***
This commit is contained in:
parent
5af1a6993b
commit
c46b7cb500
|
@ -47,6 +47,7 @@ buf2_fill(const void *buffer, size_t size, void *app_key) {
|
|||
static void
|
||||
check(int is_ok, uint8_t *buf, int size, size_t consumed) {
|
||||
T1_t t, *tp;
|
||||
void *tpp = &tp;
|
||||
asn_dec_rval_t rval;
|
||||
asn_enc_rval_t erval;
|
||||
int ret;
|
||||
|
@ -55,7 +56,7 @@ check(int is_ok, uint8_t *buf, int size, size_t consumed) {
|
|||
tp = memset(&t, 0, sizeof(t));
|
||||
|
||||
fprintf(stderr, "Buf %p\n", buf);
|
||||
rval = ber_decode(0, &asn_DEF_T1, (void **)&tp, buf, size);
|
||||
rval = ber_decode(0, &asn_DEF_T1, (void **)tpp, buf, size);
|
||||
fprintf(stderr, "Returned code %d, consumed %d\n",
|
||||
(int)rval.code, (int)rval.consumed);
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ main(int ac, char **av) {
|
|||
asn_enc_rval_t erv;
|
||||
asn_dec_rval_t drv;
|
||||
char buf[128];
|
||||
size_t bufsize = sizeof(buf);
|
||||
|
||||
(void)ac; /* Unused argument */
|
||||
(void)av; /* Unused argument */
|
||||
|
@ -44,35 +43,36 @@ main(int ac, char **av) {
|
|||
* Encode the sequence.
|
||||
*/
|
||||
erv = der_encode_to_buffer(&asn_DEF_SeqWithMandatory,
|
||||
&swm, buf, &bufsize);
|
||||
assert(erv.encoded == bufsize);
|
||||
&swm, buf, sizeof buf);
|
||||
assert(erv.encoded > 0);
|
||||
buf[erv.encoded] = '\0';
|
||||
|
||||
/*
|
||||
* Try to decode it using a compatible type.
|
||||
*/
|
||||
drv = ber_decode(0, &asn_DEF_SeqWithOptional, (void **)&swo,
|
||||
buf, bufsize);
|
||||
buf, erv.encoded);
|
||||
assert(drv.code == RC_OK);
|
||||
assert(drv.consumed == bufsize);
|
||||
assert(drv.consumed == erv.encoded);
|
||||
assert(swo->seqOfOpt != 0);
|
||||
|
||||
xer_fprint(stderr, &asn_DEF_SeqWithOptional, swo);
|
||||
swo->seqOfOpt = 0;
|
||||
|
||||
bufsize = sizeof(buf);
|
||||
erv = der_encode_to_buffer(&asn_DEF_SeqWithOptional,
|
||||
swo, buf, &bufsize);
|
||||
assert(erv.encoded == bufsize);
|
||||
swo, buf, sizeof buf);
|
||||
assert(erv.encoded > 0);
|
||||
buf[erv.encoded] = '\0';
|
||||
|
||||
swo = 0;
|
||||
drv = ber_decode(0, &asn_DEF_SeqWithMandatory, (void **)&swo,
|
||||
buf, bufsize);
|
||||
buf, erv.encoded);
|
||||
assert(drv.code != RC_OK);
|
||||
swo = 0;
|
||||
drv = ber_decode(0, &asn_DEF_SeqWithOptional, (void **)&swo,
|
||||
buf, bufsize);
|
||||
buf, erv.encoded);
|
||||
assert(drv.code == RC_OK);
|
||||
assert(drv.consumed == bufsize);
|
||||
assert(drv.consumed == erv.encoded);
|
||||
assert(swo->seqOfOpt == 0);
|
||||
|
||||
xer_fprint(stderr, &asn_DEF_SeqWithOptional, swo);
|
||||
|
|
|
@ -26,9 +26,6 @@ AC_SUBST(CONFIGURE_DEPENDS)
|
|||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CXXCPP
|
||||
AM_CONDITIONAL(CPLUSPLUS_FOUND, test -n "$ac_ct_CXX")
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
|
|
@ -1784,7 +1784,8 @@ emit_single_member_PER_constraint(arg_t *arg, asn1cnst_range_t *range, char *typ
|
|||
asn1c_integer_t cover = 1;
|
||||
asn1c_integer_t r = 1 + range->right.value
|
||||
- range->left.value;
|
||||
int rbits, ebits;
|
||||
size_t rbits; /* Value range bits */
|
||||
ssize_t ebits; /* Value effective range bits */
|
||||
|
||||
if(range->empty_constraint)
|
||||
r = 0;
|
||||
|
|
|
@ -32,7 +32,7 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
|
|||
fname = alloca(len);
|
||||
ret = snprintf(fname, len, "%s%s%s", name, ext,
|
||||
opt_tmpname ? ".XXXXXX" : "");
|
||||
assert(ret > 0 && ret < len);
|
||||
assert(ret > 0 && ret < (ssize_t)len);
|
||||
|
||||
if(opt_tmpname) {
|
||||
/*
|
||||
|
|
|
@ -20,7 +20,7 @@ static char *res_kwd[] = {
|
|||
};
|
||||
static int
|
||||
reserved_keyword(const char *str) {
|
||||
int i;
|
||||
size_t i;
|
||||
for(i = 0 ; i < sizeof(res_kwd)/sizeof(res_kwd[0]); i++) {
|
||||
if(strcmp(str, res_kwd[i]) == 0)
|
||||
return 1;
|
||||
|
@ -42,7 +42,7 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
char *nextstr;
|
||||
char *first = 0;
|
||||
char *second = 0;
|
||||
size_t size;
|
||||
ssize_t size;
|
||||
char *p;
|
||||
|
||||
if(expr) {
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
#include "asn1c_save.h"
|
||||
#include "asn1c_out.h"
|
||||
|
||||
static int asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *, int, int, char **);
|
||||
static int asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *, int, char **);
|
||||
static int asn1c_print_streams(arg_t *arg);
|
||||
static int asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *, int, int, char **);
|
||||
static int asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *, int, char **);
|
||||
static int asn1c_copy_over(arg_t *arg, char *path);
|
||||
static int identical_files(const char *fname1, const char *fname2);
|
||||
static int generate_pdu_collection_file(arg_t *arg);
|
||||
static int generate_preamble(arg_t *, FILE *, int argc, int optc, char **argv);
|
||||
static int generate_preamble(arg_t *, FILE *, int optc, char **argv);
|
||||
|
||||
int
|
||||
asn1c_save_compiled_output(arg_t *arg, const char *datadir,
|
||||
|
@ -33,8 +33,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
|
|||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(asn1_lang_map[arg->expr->meta_type]
|
||||
[arg->expr->expr_type].type_cb) {
|
||||
if(asn1c_dump_streams(arg, deps,
|
||||
argc, optc, argv))
|
||||
if(asn1c_dump_streams(arg, deps, optc, argv))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -155,11 +154,11 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
|
|||
* Dump the streams.
|
||||
*/
|
||||
static int
|
||||
asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **argv) {
|
||||
asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
||||
if(arg->flags & A1C_PRINT_COMPILED) {
|
||||
return asn1c_print_streams(arg);
|
||||
} else {
|
||||
return asn1c_save_streams(arg, deps, argc, optc, argv);
|
||||
return asn1c_save_streams(arg, deps, optc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +186,7 @@ asn1c_print_streams(arg_t *arg) {
|
|||
}
|
||||
|
||||
static int
|
||||
asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **argv) {
|
||||
asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
compiler_streams_t *cs = expr->data;
|
||||
out_chunk_t *ot;
|
||||
|
@ -212,8 +211,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **a
|
|||
return -1;
|
||||
}
|
||||
|
||||
generate_preamble(arg, fp_c, argc, optc, argv);
|
||||
generate_preamble(arg, fp_h, argc, optc, argv);
|
||||
generate_preamble(arg, fp_c, optc, argv);
|
||||
generate_preamble(arg, fp_h, optc, argv);
|
||||
|
||||
header_id = asn1c_make_identifier(0, expr, NULL);
|
||||
fprintf(fp_h,
|
||||
|
@ -303,7 +302,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **a
|
|||
}
|
||||
|
||||
static int
|
||||
generate_preamble(arg_t *arg, FILE *fp, int argc, int optc, char **argv) {
|
||||
generate_preamble(arg_t *arg, FILE *fp, int optc, char **argv) {
|
||||
fprintf(fp,
|
||||
"/*\n"
|
||||
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\n"
|
||||
|
|
|
@ -169,6 +169,7 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_row_s *row, struct asn1p_i
|
|||
uint8_t *buf, const uint8_t *bend) {
|
||||
asn1p_expr_t *expr;
|
||||
asn1p_ref_t *ref;
|
||||
int idLength;
|
||||
char *p;
|
||||
|
||||
if((bend - buf) <= 0) {
|
||||
|
@ -220,8 +221,9 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_row_s *row, struct asn1p_i
|
|||
|
||||
cell->value = expr;
|
||||
|
||||
if(row->max_identifier_length < strlen(expr->Identifier))
|
||||
row->max_identifier_length = strlen(expr->Identifier);
|
||||
idLength = strlen(expr->Identifier);
|
||||
if(row->max_identifier_length < idLength)
|
||||
row->max_identifier_length = idLength;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -154,19 +154,19 @@ asn1p_wsyntx_clone(asn1p_wsyntx_t *wx) {
|
|||
}
|
||||
|
||||
asn1p_wsyntx_chunk_t *
|
||||
asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy) {
|
||||
asn1p_wsyntx_chunk_fromstring(char *token, int do_copy) {
|
||||
asn1p_wsyntx_chunk_t *wc;
|
||||
|
||||
if(do_copy) {
|
||||
static asn1p_wsyntx_chunk_t tmp;
|
||||
tmp.type = WC_LITERAL;
|
||||
tmp.content.token = buf;
|
||||
tmp.content.token = token;
|
||||
wc = asn1p_wsyntx_chunk_clone(&tmp);
|
||||
} else {
|
||||
wc = asn1p_wsyntx_chunk_new();
|
||||
if(wc) {
|
||||
wc->type = WC_LITERAL;
|
||||
wc->content.token = buf;
|
||||
wc->content.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *);
|
|||
* 0: Component has been added
|
||||
* -1: Failure to add component (refer to errno)
|
||||
*/
|
||||
asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_frombuf(char *buf, int len, int _copy);
|
||||
asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromstring(char *token, int _copy);
|
||||
asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromsyntax(asn1p_wsyntx_t *syntax);
|
||||
|
||||
|
||||
|
|
|
@ -2785,7 +2785,7 @@ yyreduce:
|
|||
case 109:
|
||||
#line 1125 "asn1p_y.y"
|
||||
{
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0);
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_fromstring(yyvsp[0].tv_opaque.buf, 0);
|
||||
yyval.a_wchunk->type = WC_WHITESPACE;
|
||||
}
|
||||
break;
|
||||
|
@ -2793,14 +2793,14 @@ yyreduce:
|
|||
case 110:
|
||||
#line 1129 "asn1p_y.y"
|
||||
{
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_frombuf(yyvsp[0].tv_str, strlen(yyvsp[0].tv_str), 0);
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_fromstring(yyvsp[0].tv_str, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 111:
|
||||
#line 1132 "asn1p_y.y"
|
||||
{
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_frombuf(yyvsp[0].a_refcomp.name, strlen(yyvsp[0].a_refcomp.name), 0);
|
||||
yyval.a_wchunk = asn1p_wsyntx_chunk_fromstring(yyvsp[0].a_refcomp.name, 0);
|
||||
yyval.a_wchunk->type = WC_FIELD;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -278,7 +278,7 @@ typedef union {
|
|||
} tv_nametag;
|
||||
} yystype;
|
||||
/* Line 1281 of /usr/local/share/bison/yacc.c. */
|
||||
#line 282 "y.tab.h"
|
||||
#line 282 "asn1p_y.h"
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1123,14 +1123,14 @@ WithSyntaxList:
|
|||
|
||||
WithSyntaxToken:
|
||||
TOK_whitespace {
|
||||
$$ = asn1p_wsyntx_chunk_frombuf($1.buf, $1.len, 0);
|
||||
$$ = asn1p_wsyntx_chunk_fromstring($1.buf, 0);
|
||||
$$->type = WC_WHITESPACE;
|
||||
}
|
||||
| TOK_Literal {
|
||||
$$ = asn1p_wsyntx_chunk_frombuf($1, strlen($1), 0);
|
||||
$$ = asn1p_wsyntx_chunk_fromstring($1, 0);
|
||||
}
|
||||
| PrimitiveFieldReference {
|
||||
$$ = asn1p_wsyntx_chunk_frombuf($1.name, strlen($1.name), 0);
|
||||
$$ = asn1p_wsyntx_chunk_fromstring($1.name, 0);
|
||||
$$->type = WC_FIELD;
|
||||
}
|
||||
| '[' WithSyntaxList ']' {
|
||||
|
|
|
@ -1180,12 +1180,14 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
|
||||
/* Encode a presence bitmap */
|
||||
for(i = 0; i < specs->roms_count; i++) {
|
||||
asn_TYPE_member_t *elm;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
edx = specs->oms[i];
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
int present;
|
||||
|
||||
edx = specs->oms[i];
|
||||
elm = &td->elements[edx];
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
|
|
|
@ -25,27 +25,6 @@ asn_dec_rval_t uper_decode(struct asn_codec_ctx_s *opt_codec_ctx,
|
|||
);
|
||||
|
||||
|
||||
/*
|
||||
* Pre-computed PER constraints.
|
||||
*/
|
||||
enum asn_per_constraint_flags {
|
||||
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
|
||||
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
|
||||
APC_CONSTRAINED = 0x2, /* Fully constrained */
|
||||
APC_EXTENSIBLE = 0x4 /* May have extension */
|
||||
};
|
||||
typedef struct asn_per_constraint_s {
|
||||
enum asn_per_constraint_flags flags;
|
||||
int range_bits; /* Full number of bits in the range */
|
||||
int effective_bits; /* Effective bits */
|
||||
long lower_bound; /* "lb" value */
|
||||
long upper_bound; /* "ub" value */
|
||||
} asn_per_constraint_t;
|
||||
typedef struct asn_per_constraints_s {
|
||||
asn_per_constraint_t value;
|
||||
asn_per_constraint_t size;
|
||||
} asn_per_constraints_t;
|
||||
|
||||
/*
|
||||
* Type of the type-specific PER decoder function.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2005, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _PER_SUPPORT_H_
|
||||
|
@ -11,6 +11,26 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pre-computed PER constraints.
|
||||
*/
|
||||
typedef struct asn_per_constraint_s {
|
||||
enum asn_per_constraint_flags {
|
||||
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
|
||||
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
|
||||
APC_CONSTRAINED = 0x2, /* Fully constrained */
|
||||
APC_EXTENSIBLE = 0x4 /* May have extension */
|
||||
} flags;
|
||||
int range_bits; /* Full number of bits in the range */
|
||||
int effective_bits; /* Effective bits */
|
||||
long lower_bound; /* "lb" value */
|
||||
long upper_bound; /* "ub" value */
|
||||
} asn_per_constraint_t;
|
||||
typedef struct asn_per_constraints_s {
|
||||
asn_per_constraint_t value;
|
||||
asn_per_constraint_t size;
|
||||
} asn_per_constraints_t;
|
||||
|
||||
/*
|
||||
* This structure describes a position inside an incoming PER bit stream.
|
||||
*/
|
||||
|
@ -20,6 +40,33 @@ typedef struct asn_per_data_s {
|
|||
size_t nbits; /* Number of bits in the stream */
|
||||
} asn_per_data_t;
|
||||
|
||||
/*
|
||||
* Extract a small number of bits (<= 31) from the specified PER data pointer.
|
||||
* This function returns -1 if the specified number of bits could not be
|
||||
* extracted due to EOD or other conditions.
|
||||
*/
|
||||
int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits);
|
||||
|
||||
/*
|
||||
* Extract a large number of bits from the specified PER data pointer.
|
||||
* This function returns -1 if the specified number of bits could not be
|
||||
* extracted due to EOD or other conditions.
|
||||
*/
|
||||
int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align,
|
||||
int get_nbits);
|
||||
|
||||
/*
|
||||
* Get the length "n" from the Unaligned PER stream.
|
||||
*/
|
||||
ssize_t uper_get_length(asn_per_data_t *pd,
|
||||
int effective_bound_bits,
|
||||
int *repeat);
|
||||
|
||||
/*
|
||||
* Get the normally small non-negative whole number.
|
||||
*/
|
||||
ssize_t uper_get_nsnnwn(asn_per_data_t *pd);
|
||||
|
||||
/*
|
||||
* This structure supports forming PER output.
|
||||
*/
|
||||
|
@ -32,34 +79,12 @@ typedef struct asn_per_outp_s {
|
|||
void *op_key;
|
||||
} asn_per_outp_t;
|
||||
|
||||
/*
|
||||
* Extract a small number of bits (<= 31) from the specified PER data pointer.
|
||||
* This function returns -1 if the specified number of bits could not be
|
||||
* extracted due to EOD or other conditions.
|
||||
*/
|
||||
int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits);
|
||||
|
||||
/* Output a small number of bits (<= 31) */
|
||||
int per_put_few_bits(asn_per_outp_t *per_data, uint32_t bits, int obits);
|
||||
|
||||
/*
|
||||
* Extract a large number of bits from the specified PER data pointer.
|
||||
* This function returns -1 if the specified number of bits could not be
|
||||
* extracted due to EOD or other conditions.
|
||||
*/
|
||||
int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align,
|
||||
int get_nbits);
|
||||
|
||||
/* Output a large number of bits */
|
||||
int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits);
|
||||
|
||||
/*
|
||||
* Get the length "n" from the Unaligned PER stream.
|
||||
*/
|
||||
ssize_t uper_get_length(asn_per_data_t *pd,
|
||||
int effective_bound_bits,
|
||||
int *repeat);
|
||||
|
||||
/*
|
||||
* Put the length "n" to the Unaligned PER stream.
|
||||
* This function returns the number of units which may be flushed
|
||||
|
@ -67,11 +92,6 @@ ssize_t uper_get_length(asn_per_data_t *pd,
|
|||
*/
|
||||
ssize_t uper_put_length(asn_per_outp_t *po, size_t whole_length);
|
||||
|
||||
/*
|
||||
* Get the normally small non-negative whole number.
|
||||
*/
|
||||
ssize_t uper_get_nsnnwn(asn_per_data_t *pd);
|
||||
|
||||
/*
|
||||
* Put the normally small non-negative whole number.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue