mirror of https://gerrit.osmocom.org/asn1c
support parsing realnumber tokens in constraints
parent
3cf7c3a1e7
commit
adf863fc8f
|
@ -9,6 +9,9 @@ int
|
|||
asn1constraint_compatible(asn1p_expr_type_e expr_type,
|
||||
enum asn1p_constraint_type_e constr_type, int fbless_SIZE) {
|
||||
|
||||
if(expr_type == ASN_BASIC_REAL)
|
||||
return -1; /* Not yet supported */
|
||||
|
||||
/*
|
||||
* X.680-0207, Table 9.
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,7 @@ int asn1p_lexer_constructs_year = 0;
|
|||
int asn1p_as_pointer;
|
||||
|
||||
static asn1c_integer_t _lex_atoi(const char *ptr);
|
||||
static double _lex_atod(const char *ptr);
|
||||
|
||||
/*
|
||||
* Check that the type is defined in the year of the standard choosen.
|
||||
|
@ -240,6 +241,13 @@ WSP [\t\r\v\f\n ]
|
|||
return TOK_number;
|
||||
}
|
||||
|
||||
[-+]?[0-9]+[.]?([eE][-+]?)?[0-9]+ {
|
||||
asn1p_lval.a_dbl = _lex_atod(yytext);
|
||||
if(errno == ERANGE)
|
||||
return -1;
|
||||
return TOK_realnumber;
|
||||
}
|
||||
|
||||
ABSENT return TOK_ABSENT;
|
||||
ALL return TOK_ALL;
|
||||
ANY {
|
||||
|
@ -564,3 +572,19 @@ _lex_atoi(const char *ptr) {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static double
|
||||
_lex_atod(const char *ptr) {
|
||||
double value;
|
||||
errno = 0;
|
||||
value = strtod(ptr, 0);
|
||||
if(errno) {
|
||||
fprintf(stderr,
|
||||
"Value \"%s\" at line %d is outside of `double` range "
|
||||
"in this compiler! Please contact the asn1c author.\n",
|
||||
ptr, yylineno);
|
||||
errno = ERANGE;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,100 +40,101 @@
|
|||
TOK_hstring = 263,
|
||||
TOK_identifier = 264,
|
||||
TOK_number = 265,
|
||||
TOK_tuple = 266,
|
||||
TOK_quadruple = 267,
|
||||
TOK_number_negative = 268,
|
||||
TOK_typereference = 269,
|
||||
TOK_capitalreference = 270,
|
||||
TOK_typefieldreference = 271,
|
||||
TOK_valuefieldreference = 272,
|
||||
TOK_Literal = 273,
|
||||
TOK_ABSENT = 274,
|
||||
TOK_ABSTRACT_SYNTAX = 275,
|
||||
TOK_ALL = 276,
|
||||
TOK_ANY = 277,
|
||||
TOK_APPLICATION = 278,
|
||||
TOK_AUTOMATIC = 279,
|
||||
TOK_BEGIN = 280,
|
||||
TOK_BIT = 281,
|
||||
TOK_BMPString = 282,
|
||||
TOK_BOOLEAN = 283,
|
||||
TOK_BY = 284,
|
||||
TOK_CHARACTER = 285,
|
||||
TOK_CHOICE = 286,
|
||||
TOK_CLASS = 287,
|
||||
TOK_COMPONENT = 288,
|
||||
TOK_COMPONENTS = 289,
|
||||
TOK_CONSTRAINED = 290,
|
||||
TOK_CONTAINING = 291,
|
||||
TOK_DEFAULT = 292,
|
||||
TOK_DEFINITIONS = 293,
|
||||
TOK_DEFINED = 294,
|
||||
TOK_EMBEDDED = 295,
|
||||
TOK_ENCODED = 296,
|
||||
TOK_ENCODING_CONTROL = 297,
|
||||
TOK_END = 298,
|
||||
TOK_ENUMERATED = 299,
|
||||
TOK_EXPLICIT = 300,
|
||||
TOK_EXPORTS = 301,
|
||||
TOK_EXTENSIBILITY = 302,
|
||||
TOK_EXTERNAL = 303,
|
||||
TOK_FALSE = 304,
|
||||
TOK_FROM = 305,
|
||||
TOK_GeneralizedTime = 306,
|
||||
TOK_GeneralString = 307,
|
||||
TOK_GraphicString = 308,
|
||||
TOK_IA5String = 309,
|
||||
TOK_IDENTIFIER = 310,
|
||||
TOK_IMPLICIT = 311,
|
||||
TOK_IMPLIED = 312,
|
||||
TOK_IMPORTS = 313,
|
||||
TOK_INCLUDES = 314,
|
||||
TOK_INSTANCE = 315,
|
||||
TOK_INSTRUCTIONS = 316,
|
||||
TOK_INTEGER = 317,
|
||||
TOK_ISO646String = 318,
|
||||
TOK_MAX = 319,
|
||||
TOK_MIN = 320,
|
||||
TOK_MINUS_INFINITY = 321,
|
||||
TOK_NULL = 322,
|
||||
TOK_NumericString = 323,
|
||||
TOK_OBJECT = 324,
|
||||
TOK_ObjectDescriptor = 325,
|
||||
TOK_OCTET = 326,
|
||||
TOK_OF = 327,
|
||||
TOK_OPTIONAL = 328,
|
||||
TOK_PATTERN = 329,
|
||||
TOK_PDV = 330,
|
||||
TOK_PLUS_INFINITY = 331,
|
||||
TOK_PRESENT = 332,
|
||||
TOK_PrintableString = 333,
|
||||
TOK_PRIVATE = 334,
|
||||
TOK_REAL = 335,
|
||||
TOK_RELATIVE_OID = 336,
|
||||
TOK_SEQUENCE = 337,
|
||||
TOK_SET = 338,
|
||||
TOK_SIZE = 339,
|
||||
TOK_STRING = 340,
|
||||
TOK_SYNTAX = 341,
|
||||
TOK_T61String = 342,
|
||||
TOK_TAGS = 343,
|
||||
TOK_TeletexString = 344,
|
||||
TOK_TRUE = 345,
|
||||
TOK_TYPE_IDENTIFIER = 346,
|
||||
TOK_UNIQUE = 347,
|
||||
TOK_UNIVERSAL = 348,
|
||||
TOK_UniversalString = 349,
|
||||
TOK_UTCTime = 350,
|
||||
TOK_UTF8String = 351,
|
||||
TOK_VideotexString = 352,
|
||||
TOK_VisibleString = 353,
|
||||
TOK_WITH = 354,
|
||||
TOK_EXCEPT = 355,
|
||||
TOK_INTERSECTION = 356,
|
||||
TOK_UNION = 357,
|
||||
TOK_TwoDots = 358,
|
||||
TOK_ThreeDots = 359
|
||||
TOK_number_negative = 266,
|
||||
TOK_realnumber = 267,
|
||||
TOK_tuple = 268,
|
||||
TOK_quadruple = 269,
|
||||
TOK_typereference = 270,
|
||||
TOK_capitalreference = 271,
|
||||
TOK_typefieldreference = 272,
|
||||
TOK_valuefieldreference = 273,
|
||||
TOK_Literal = 274,
|
||||
TOK_ABSENT = 275,
|
||||
TOK_ABSTRACT_SYNTAX = 276,
|
||||
TOK_ALL = 277,
|
||||
TOK_ANY = 278,
|
||||
TOK_APPLICATION = 279,
|
||||
TOK_AUTOMATIC = 280,
|
||||
TOK_BEGIN = 281,
|
||||
TOK_BIT = 282,
|
||||
TOK_BMPString = 283,
|
||||
TOK_BOOLEAN = 284,
|
||||
TOK_BY = 285,
|
||||
TOK_CHARACTER = 286,
|
||||
TOK_CHOICE = 287,
|
||||
TOK_CLASS = 288,
|
||||
TOK_COMPONENT = 289,
|
||||
TOK_COMPONENTS = 290,
|
||||
TOK_CONSTRAINED = 291,
|
||||
TOK_CONTAINING = 292,
|
||||
TOK_DEFAULT = 293,
|
||||
TOK_DEFINITIONS = 294,
|
||||
TOK_DEFINED = 295,
|
||||
TOK_EMBEDDED = 296,
|
||||
TOK_ENCODED = 297,
|
||||
TOK_ENCODING_CONTROL = 298,
|
||||
TOK_END = 299,
|
||||
TOK_ENUMERATED = 300,
|
||||
TOK_EXPLICIT = 301,
|
||||
TOK_EXPORTS = 302,
|
||||
TOK_EXTENSIBILITY = 303,
|
||||
TOK_EXTERNAL = 304,
|
||||
TOK_FALSE = 305,
|
||||
TOK_FROM = 306,
|
||||
TOK_GeneralizedTime = 307,
|
||||
TOK_GeneralString = 308,
|
||||
TOK_GraphicString = 309,
|
||||
TOK_IA5String = 310,
|
||||
TOK_IDENTIFIER = 311,
|
||||
TOK_IMPLICIT = 312,
|
||||
TOK_IMPLIED = 313,
|
||||
TOK_IMPORTS = 314,
|
||||
TOK_INCLUDES = 315,
|
||||
TOK_INSTANCE = 316,
|
||||
TOK_INSTRUCTIONS = 317,
|
||||
TOK_INTEGER = 318,
|
||||
TOK_ISO646String = 319,
|
||||
TOK_MAX = 320,
|
||||
TOK_MIN = 321,
|
||||
TOK_MINUS_INFINITY = 322,
|
||||
TOK_NULL = 323,
|
||||
TOK_NumericString = 324,
|
||||
TOK_OBJECT = 325,
|
||||
TOK_ObjectDescriptor = 326,
|
||||
TOK_OCTET = 327,
|
||||
TOK_OF = 328,
|
||||
TOK_OPTIONAL = 329,
|
||||
TOK_PATTERN = 330,
|
||||
TOK_PDV = 331,
|
||||
TOK_PLUS_INFINITY = 332,
|
||||
TOK_PRESENT = 333,
|
||||
TOK_PrintableString = 334,
|
||||
TOK_PRIVATE = 335,
|
||||
TOK_REAL = 336,
|
||||
TOK_RELATIVE_OID = 337,
|
||||
TOK_SEQUENCE = 338,
|
||||
TOK_SET = 339,
|
||||
TOK_SIZE = 340,
|
||||
TOK_STRING = 341,
|
||||
TOK_SYNTAX = 342,
|
||||
TOK_T61String = 343,
|
||||
TOK_TAGS = 344,
|
||||
TOK_TeletexString = 345,
|
||||
TOK_TRUE = 346,
|
||||
TOK_TYPE_IDENTIFIER = 347,
|
||||
TOK_UNIQUE = 348,
|
||||
TOK_UNIVERSAL = 349,
|
||||
TOK_UniversalString = 350,
|
||||
TOK_UTCTime = 351,
|
||||
TOK_UTF8String = 352,
|
||||
TOK_VideotexString = 353,
|
||||
TOK_VisibleString = 354,
|
||||
TOK_WITH = 355,
|
||||
TOK_EXCEPT = 356,
|
||||
TOK_INTERSECTION = 357,
|
||||
TOK_UNION = 358,
|
||||
TOK_TwoDots = 359,
|
||||
TOK_ThreeDots = 360
|
||||
};
|
||||
#endif
|
||||
#define TOK_PPEQ 258
|
||||
|
@ -144,100 +145,101 @@
|
|||
#define TOK_hstring 263
|
||||
#define TOK_identifier 264
|
||||
#define TOK_number 265
|
||||
#define TOK_tuple 266
|
||||
#define TOK_quadruple 267
|
||||
#define TOK_number_negative 268
|
||||
#define TOK_typereference 269
|
||||
#define TOK_capitalreference 270
|
||||
#define TOK_typefieldreference 271
|
||||
#define TOK_valuefieldreference 272
|
||||
#define TOK_Literal 273
|
||||
#define TOK_ABSENT 274
|
||||
#define TOK_ABSTRACT_SYNTAX 275
|
||||
#define TOK_ALL 276
|
||||
#define TOK_ANY 277
|
||||
#define TOK_APPLICATION 278
|
||||
#define TOK_AUTOMATIC 279
|
||||
#define TOK_BEGIN 280
|
||||
#define TOK_BIT 281
|
||||
#define TOK_BMPString 282
|
||||
#define TOK_BOOLEAN 283
|
||||
#define TOK_BY 284
|
||||
#define TOK_CHARACTER 285
|
||||
#define TOK_CHOICE 286
|
||||
#define TOK_CLASS 287
|
||||
#define TOK_COMPONENT 288
|
||||
#define TOK_COMPONENTS 289
|
||||
#define TOK_CONSTRAINED 290
|
||||
#define TOK_CONTAINING 291
|
||||
#define TOK_DEFAULT 292
|
||||
#define TOK_DEFINITIONS 293
|
||||
#define TOK_DEFINED 294
|
||||
#define TOK_EMBEDDED 295
|
||||
#define TOK_ENCODED 296
|
||||
#define TOK_ENCODING_CONTROL 297
|
||||
#define TOK_END 298
|
||||
#define TOK_ENUMERATED 299
|
||||
#define TOK_EXPLICIT 300
|
||||
#define TOK_EXPORTS 301
|
||||
#define TOK_EXTENSIBILITY 302
|
||||
#define TOK_EXTERNAL 303
|
||||
#define TOK_FALSE 304
|
||||
#define TOK_FROM 305
|
||||
#define TOK_GeneralizedTime 306
|
||||
#define TOK_GeneralString 307
|
||||
#define TOK_GraphicString 308
|
||||
#define TOK_IA5String 309
|
||||
#define TOK_IDENTIFIER 310
|
||||
#define TOK_IMPLICIT 311
|
||||
#define TOK_IMPLIED 312
|
||||
#define TOK_IMPORTS 313
|
||||
#define TOK_INCLUDES 314
|
||||
#define TOK_INSTANCE 315
|
||||
#define TOK_INSTRUCTIONS 316
|
||||
#define TOK_INTEGER 317
|
||||
#define TOK_ISO646String 318
|
||||
#define TOK_MAX 319
|
||||
#define TOK_MIN 320
|
||||
#define TOK_MINUS_INFINITY 321
|
||||
#define TOK_NULL 322
|
||||
#define TOK_NumericString 323
|
||||
#define TOK_OBJECT 324
|
||||
#define TOK_ObjectDescriptor 325
|
||||
#define TOK_OCTET 326
|
||||
#define TOK_OF 327
|
||||
#define TOK_OPTIONAL 328
|
||||
#define TOK_PATTERN 329
|
||||
#define TOK_PDV 330
|
||||
#define TOK_PLUS_INFINITY 331
|
||||
#define TOK_PRESENT 332
|
||||
#define TOK_PrintableString 333
|
||||
#define TOK_PRIVATE 334
|
||||
#define TOK_REAL 335
|
||||
#define TOK_RELATIVE_OID 336
|
||||
#define TOK_SEQUENCE 337
|
||||
#define TOK_SET 338
|
||||
#define TOK_SIZE 339
|
||||
#define TOK_STRING 340
|
||||
#define TOK_SYNTAX 341
|
||||
#define TOK_T61String 342
|
||||
#define TOK_TAGS 343
|
||||
#define TOK_TeletexString 344
|
||||
#define TOK_TRUE 345
|
||||
#define TOK_TYPE_IDENTIFIER 346
|
||||
#define TOK_UNIQUE 347
|
||||
#define TOK_UNIVERSAL 348
|
||||
#define TOK_UniversalString 349
|
||||
#define TOK_UTCTime 350
|
||||
#define TOK_UTF8String 351
|
||||
#define TOK_VideotexString 352
|
||||
#define TOK_VisibleString 353
|
||||
#define TOK_WITH 354
|
||||
#define TOK_EXCEPT 355
|
||||
#define TOK_INTERSECTION 356
|
||||
#define TOK_UNION 357
|
||||
#define TOK_TwoDots 358
|
||||
#define TOK_ThreeDots 359
|
||||
#define TOK_number_negative 266
|
||||
#define TOK_realnumber 267
|
||||
#define TOK_tuple 268
|
||||
#define TOK_quadruple 269
|
||||
#define TOK_typereference 270
|
||||
#define TOK_capitalreference 271
|
||||
#define TOK_typefieldreference 272
|
||||
#define TOK_valuefieldreference 273
|
||||
#define TOK_Literal 274
|
||||
#define TOK_ABSENT 275
|
||||
#define TOK_ABSTRACT_SYNTAX 276
|
||||
#define TOK_ALL 277
|
||||
#define TOK_ANY 278
|
||||
#define TOK_APPLICATION 279
|
||||
#define TOK_AUTOMATIC 280
|
||||
#define TOK_BEGIN 281
|
||||
#define TOK_BIT 282
|
||||
#define TOK_BMPString 283
|
||||
#define TOK_BOOLEAN 284
|
||||
#define TOK_BY 285
|
||||
#define TOK_CHARACTER 286
|
||||
#define TOK_CHOICE 287
|
||||
#define TOK_CLASS 288
|
||||
#define TOK_COMPONENT 289
|
||||
#define TOK_COMPONENTS 290
|
||||
#define TOK_CONSTRAINED 291
|
||||
#define TOK_CONTAINING 292
|
||||
#define TOK_DEFAULT 293
|
||||
#define TOK_DEFINITIONS 294
|
||||
#define TOK_DEFINED 295
|
||||
#define TOK_EMBEDDED 296
|
||||
#define TOK_ENCODED 297
|
||||
#define TOK_ENCODING_CONTROL 298
|
||||
#define TOK_END 299
|
||||
#define TOK_ENUMERATED 300
|
||||
#define TOK_EXPLICIT 301
|
||||
#define TOK_EXPORTS 302
|
||||
#define TOK_EXTENSIBILITY 303
|
||||
#define TOK_EXTERNAL 304
|
||||
#define TOK_FALSE 305
|
||||
#define TOK_FROM 306
|
||||
#define TOK_GeneralizedTime 307
|
||||
#define TOK_GeneralString 308
|
||||
#define TOK_GraphicString 309
|
||||
#define TOK_IA5String 310
|
||||
#define TOK_IDENTIFIER 311
|
||||
#define TOK_IMPLICIT 312
|
||||
#define TOK_IMPLIED 313
|
||||
#define TOK_IMPORTS 314
|
||||
#define TOK_INCLUDES 315
|
||||
#define TOK_INSTANCE 316
|
||||
#define TOK_INSTRUCTIONS 317
|
||||
#define TOK_INTEGER 318
|
||||
#define TOK_ISO646String 319
|
||||
#define TOK_MAX 320
|
||||
#define TOK_MIN 321
|
||||
#define TOK_MINUS_INFINITY 322
|
||||
#define TOK_NULL 323
|
||||
#define TOK_NumericString 324
|
||||
#define TOK_OBJECT 325
|
||||
#define TOK_ObjectDescriptor 326
|
||||
#define TOK_OCTET 327
|
||||
#define TOK_OF 328
|
||||
#define TOK_OPTIONAL 329
|
||||
#define TOK_PATTERN 330
|
||||
#define TOK_PDV 331
|
||||
#define TOK_PLUS_INFINITY 332
|
||||
#define TOK_PRESENT 333
|
||||
#define TOK_PrintableString 334
|
||||
#define TOK_PRIVATE 335
|
||||
#define TOK_REAL 336
|
||||
#define TOK_RELATIVE_OID 337
|
||||
#define TOK_SEQUENCE 338
|
||||
#define TOK_SET 339
|
||||
#define TOK_SIZE 340
|
||||
#define TOK_STRING 341
|
||||
#define TOK_SYNTAX 342
|
||||
#define TOK_T61String 343
|
||||
#define TOK_TAGS 344
|
||||
#define TOK_TeletexString 345
|
||||
#define TOK_TRUE 346
|
||||
#define TOK_TYPE_IDENTIFIER 347
|
||||
#define TOK_UNIQUE 348
|
||||
#define TOK_UNIVERSAL 349
|
||||
#define TOK_UniversalString 350
|
||||
#define TOK_UTCTime 351
|
||||
#define TOK_UTF8String 352
|
||||
#define TOK_VideotexString 353
|
||||
#define TOK_VisibleString 354
|
||||
#define TOK_WITH 355
|
||||
#define TOK_EXCEPT 356
|
||||
#define TOK_INTERSECTION 357
|
||||
#define TOK_UNION 358
|
||||
#define TOK_TwoDots 359
|
||||
#define TOK_ThreeDots 360
|
||||
|
||||
|
||||
|
||||
|
@ -267,6 +269,7 @@ typedef union {
|
|||
struct asn1p_expr_marker_s a_marker; /* OPTIONAL/DEFAULT */
|
||||
enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */
|
||||
asn1c_integer_t a_int;
|
||||
double a_dbl;
|
||||
char *tv_str;
|
||||
struct {
|
||||
char *buf;
|
||||
|
@ -278,7 +281,7 @@ typedef union {
|
|||
} tv_nametag;
|
||||
} yystype;
|
||||
/* Line 1281 of /usr/local/share/bison/yacc.c. */
|
||||
#line 282 "asn1p_y.h"
|
||||
#line 285 "asn1p_y.h"
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
|
|||
struct asn1p_expr_marker_s a_marker; /* OPTIONAL/DEFAULT */
|
||||
enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */
|
||||
asn1c_integer_t a_int;
|
||||
double a_dbl;
|
||||
char *tv_str;
|
||||
struct {
|
||||
char *buf;
|
||||
|
@ -114,9 +115,10 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
|
|||
%token <tv_str> TOK_hstring
|
||||
%token <tv_str> TOK_identifier
|
||||
%token <a_int> TOK_number
|
||||
%token <a_int> TOK_number_negative
|
||||
%token <a_dbl> TOK_realnumber
|
||||
%token <a_int> TOK_tuple
|
||||
%token <a_int> TOK_quadruple
|
||||
%token <a_int> TOK_number_negative
|
||||
%token <tv_str> TOK_typereference
|
||||
%token <tv_str> TOK_capitalreference /* "CLASS1" */
|
||||
%token <tv_str> TOK_typefieldreference /* "&Pork" */
|
||||
|
@ -258,6 +260,7 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
|
|||
%type <a_value> SimpleValue
|
||||
%type <a_value> DefinedValue
|
||||
%type <a_value> SignedNumber
|
||||
%type <a_value> RealValue
|
||||
%type <a_expr> optComponentTypeLists
|
||||
%type <a_expr> ComponentTypeLists
|
||||
%type <a_expr> ComponentType
|
||||
|
@ -1838,12 +1841,8 @@ SingleValue:
|
|||
checkmem($$);
|
||||
$$->type = ATV_TRUE;
|
||||
}
|
||||
| SignedNumber {
|
||||
$$ = $1;
|
||||
}
|
||||
| RestrictedCharacterStringValue {
|
||||
$$ = $1;
|
||||
}
|
||||
| RealValue
|
||||
| RestrictedCharacterStringValue
|
||||
| Identifier {
|
||||
asn1p_ref_t *ref;
|
||||
int ret;
|
||||
|
@ -2136,6 +2135,14 @@ SignedNumber:
|
|||
}
|
||||
;
|
||||
|
||||
RealValue:
|
||||
SignedNumber
|
||||
| TOK_realnumber {
|
||||
$$ = asn1p_value_fromdouble($1);
|
||||
checkmem($$);
|
||||
}
|
||||
;
|
||||
|
||||
/*
|
||||
* SEQUENCE definition.
|
||||
* === EXAMPLE ===
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
|
||||
* Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
|
@ -121,7 +121,10 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
int edx; /* SET element's index */
|
||||
|
||||
ASN_DEBUG("Decoding %s as SET", td->name);
|
||||
|
||||
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
_ASN_DECODE_FAILED;
|
||||
|
||||
/*
|
||||
* Create the target structure if it is not present already.
|
||||
*/
|
||||
|
@ -862,6 +865,144 @@ cb_failed:
|
|||
_ASN_ENCODE_FAILED;
|
||||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
SET_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_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics;
|
||||
void *st = *sptr; /* Target structure. */
|
||||
int extpresent = 0; /* 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;
|
||||
|
||||
ASN_DEBUG("Decoding %s as SET", td->name);
|
||||
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
_ASN_DECODE_FAILED;
|
||||
|
||||
if(!st) {
|
||||
st = *sptr = 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_FAILED;
|
||||
}
|
||||
|
||||
/* Prepare a place and read-in the presence bitmap */
|
||||
if(specs->roms_count) {
|
||||
opres = (uint8_t *)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)) {
|
||||
FREEMEM(opres);
|
||||
_ASN_DECODE_FAILED;
|
||||
}
|
||||
opmd.buffer = opres;
|
||||
opmd.nboff = 0;
|
||||
opmd.nbits = specs->roms_count;
|
||||
ASN_DEBUG("Read in presence bitmap for %s of %d bits (%x..)",
|
||||
td->name, specs->roms_count, *opres);
|
||||
} else {
|
||||
opres = 0;
|
||||
memset(&opmd, 0, sizeof opmd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the sequence ROOT elements.
|
||||
*/
|
||||
for(edx = 0; edx < ((specs->ext_before < 0)
|
||||
? td->elements_count : specs->ext_before + 1); edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
|
||||
} else {
|
||||
memb_ptr = (char *)st + elm->memb_offset;
|
||||
memb_ptr2 = &memb_ptr;
|
||||
}
|
||||
|
||||
/* Deal with optionality */
|
||||
if(elm->optional) {
|
||||
int present = per_get_few_bits(&opmd, 1);
|
||||
ASN_DEBUG("Member %s->%s is optional, p=%d (%d->%d)",
|
||||
td->name, elm->name, present,
|
||||
(int)opmd.nboff, (int)opmd.nbits);
|
||||
if(present == 0) {
|
||||
/* This element is not present */
|
||||
if(elm->default_value) {
|
||||
/* Fill-in DEFAULT */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
FREEMEM(opres);
|
||||
_ASN_DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
/* The member is just not present */
|
||||
continue;
|
||||
}
|
||||
/* Fall through */
|
||||
}
|
||||
|
||||
/* Fetch the member from the stream */
|
||||
ASN_DEBUG("Decoding member %s in %s", elm->name, td->name);
|
||||
rv = elm->type->uper_decoder(opt_codec_ctx, elm->type,
|
||||
elm->per_constraints, memb_ptr2, pd);
|
||||
if(rv.code != RC_OK) {
|
||||
ASN_DEBUG("Failed decode %s in %s",
|
||||
elm->name, td->name);
|
||||
FREEMEM(opres);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Deal with extensions.
|
||||
*/
|
||||
if(extpresent) {
|
||||
ASN_DEBUG("Extensibility for %s: NOT IMPLEMENTED", td->name);
|
||||
_ASN_DECODE_FAILED;
|
||||
} else {
|
||||
for(edx = specs->roms_count; edx < specs->roms_count
|
||||
+ specs->aoms_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
if(!elm->default_value) continue;
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)st
|
||||
+ elm->memb_offset);
|
||||
} else {
|
||||
memb_ptr = (char *)st + elm->memb_offset;
|
||||
memb_ptr2 = &memb_ptr;
|
||||
}
|
||||
|
||||
/* Set default value */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
FREEMEM(opres);
|
||||
_ASN_DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv.consumed = 0;
|
||||
rv.code = RC_OK;
|
||||
FREEMEM(opres);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
|
|
@ -52,6 +52,8 @@ ber_type_decoder_f SET_decode_ber;
|
|||
der_type_encoder_f SET_encode_der;
|
||||
xer_type_decoder_f SET_decode_xer;
|
||||
xer_type_encoder_f SET_encode_xer;
|
||||
per_type_decoder_f SET_decode_uper;
|
||||
per_type_encoder_f SET_encode_uper;
|
||||
|
||||
/***********************
|
||||
* Some handy helpers. *
|
||||
|
|
Loading…
Reference in New Issue