Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
9c974183
Commit
9c974183
authored
Sep 15, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEFAULT type support
parent
5498f2d6
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2196 additions
and
2144 deletions
+2196
-2144
libasn1parser/asn1p_l.c
libasn1parser/asn1p_l.c
+1440
-1466
libasn1parser/asn1p_l.l
libasn1parser/asn1p_l.l
+6
-3
libasn1parser/asn1p_value.c
libasn1parser/asn1p_value.c
+29
-8
libasn1parser/asn1p_value.h
libasn1parser/asn1p_value.h
+9
-3
libasn1parser/asn1p_y.c
libasn1parser/asn1p_y.c
+661
-638
libasn1parser/asn1p_y.h
libasn1parser/asn1p_y.h
+1
-1
libasn1parser/asn1p_y.y
libasn1parser/asn1p_y.y
+50
-25
No files found.
libasn1parser/asn1p_l.c
View file @
9c974183
This source diff could not be displayed because it is too large. You can
view the blob
instead.
libasn1parser/asn1p_l.l
View file @
9c974183
...
...
@@ -285,7 +285,9 @@ WSP [\t\r\v\f\n ]
}
ABSENT return TOK_ABSENT;
/*
ABSTRACT-SYNTAX return TOK_ABSTRACT_SYNTAX;
*/
ALL return TOK_ALL;
ANY {
/* Appeared in 1990, removed in 1997 */
...
...
@@ -485,9 +487,10 @@ WITH return TOK_WITH;
yylineno, yytext);
while(YYSTATE != INITIAL)
yy_pop_state();
yy_top_state(); /* Just to use this function. */
yyterminate();
yy_fatal_error("Unexpected token");
if(0) {
yy_top_state(); /* Just to use this function. */
yy_fatal_error("Parse error");
}
return -1;
}
...
...
libasn1parser/asn1p_value.c
View file @
9c974183
...
...
@@ -110,13 +110,12 @@ asn1p_value_fromint(asn1_integer_t i) {
asn1p_value_t
*
asn1p_value_clone
(
asn1p_value_t
*
v
)
{
asn1p_value_t
*
clone
;
asn1p_value_t
*
clone
=
NULL
;
if
(
v
)
{
switch
(
v
->
type
)
{
case
ATV_NOVALUE
:
return
calloc
(
1
,
sizeof
(
*
v
));
case
ATV_REFERENCED
:
return
asn1p_value_fromref
(
v
->
value
.
reference
,
1
);
case
ATV_NULL
:
return
calloc
(
1
,
sizeof
(
*
clone
));
case
ATV_REAL
:
return
asn1p_value_fromdouble
(
v
->
value
.
v_double
);
case
ATV_INTEGER
:
...
...
@@ -140,7 +139,24 @@ asn1p_value_clone(asn1p_value_t *v) {
case
ATV_BITVECTOR
:
return
asn1p_value_frombuf
(
v
->
value
.
binary_vector
.
bits
,
v
->
value
.
binary_vector
.
size_in_bits
,
1
);
case
ATV_REFERENCED
:
return
asn1p_value_fromref
(
v
->
value
.
reference
,
1
);
case
ATV_CHOICE_IDENTIFIER
:
{
char
*
id
=
v
->
value
.
choice_identifier
.
identifier
;
clone
=
calloc
(
1
,
sizeof
(
*
clone
));
if
(
!
clone
)
return
NULL
;
clone
->
type
=
v
->
type
;
id
=
strdup
(
id
);
if
(
!
id
)
{
asn1p_value_free
(
clone
);
return
NULL
;
}
clone
->
value
.
choice_identifier
.
identifier
=
id
;
v
=
asn1p_value_clone
(
v
->
value
.
choice_identifier
.
value
);
if
(
!
v
)
{
asn1p_value_free
(
clone
);
return
NULL
;
}
clone
->
value
.
choice_identifier
.
value
=
v
;
return
clone
;
}
}
assert
(
!
"UNREACHABLE"
);
}
return
v
;
}
...
...
@@ -150,16 +166,14 @@ asn1p_value_free(asn1p_value_t *v) {
if
(
v
)
{
switch
(
v
->
type
)
{
case
ATV_NOVALUE
:
case
ATV_NULL
:
break
;
case
ATV_REFERENCED
:
asn1p_ref_free
(
v
->
value
.
reference
);
break
;
case
ATV_REAL
:
case
ATV_INTEGER
:
case
ATV_MIN
:
case
ATV_MAX
:
case
ATV_FALSE
:
case
ATV_TRUE
:
case
ATV_REAL
:
/* No freeing necessary */
break
;
case
ATV_STRING
:
...
...
@@ -171,6 +185,13 @@ asn1p_value_free(asn1p_value_t *v) {
assert
(
v
->
value
.
binary_vector
.
bits
);
free
(
v
->
value
.
binary_vector
.
bits
);
break
;
case
ATV_REFERENCED
:
asn1p_ref_free
(
v
->
value
.
reference
);
break
;
case
ATV_CHOICE_IDENTIFIER
:
free
(
v
->
value
.
choice_identifier
.
identifier
);
asn1p_value_free
(
v
->
value
.
choice_identifier
.
value
);
break
;
}
free
(
v
);
}
...
...
libasn1parser/asn1p_value.h
View file @
9c974183
...
...
@@ -13,9 +13,9 @@ typedef struct asn1p_value_s {
*/
enum
{
ATV_NOVALUE
,
ATV_
REFERENCED
,
ATV_
INTEGER
,
ATV_
REAL
,
ATV_
NULL
,
/* A "NULL" value of type NULL. */
ATV_
REAL
,
/* A constant floating-point value */
ATV_
INTEGER
,
/* An integer constant */
ATV_MAX
,
ATV_MIN
,
ATV_TRUE
,
...
...
@@ -23,6 +23,8 @@ typedef struct asn1p_value_s {
ATV_STRING
,
ATV_UNPARSED
,
ATV_BITVECTOR
,
ATV_REFERENCED
,
/* Reference to a value defined elsewhere */
ATV_CHOICE_IDENTIFIER
,
/* ChoiceIdentifier value */
}
type
;
/* Value type and location */
union
{
...
...
@@ -40,6 +42,10 @@ typedef struct asn1p_value_s {
uint8_t
*
bits
;
int
size_in_bits
;
}
binary_vector
;
struct
{
char
*
identifier
;
struct
asn1p_value_s
*
value
;
}
choice_identifier
;
}
value
;
}
asn1p_value_t
;
...
...
libasn1parser/asn1p_y.c
View file @
9c974183
This diff is collapsed.
Click to expand it.
libasn1parser/asn1p_y.h
View file @
9c974183
...
...
@@ -17,7 +17,7 @@ typedef union {
asn1p_value_t
*
a_value
;
/* Number, DefinedValue, etc */
struct
asn1p_param_s
a_parg
;
/* A parameter argument */
asn1p_paramlist_t
*
a_plist
;
/* A pargs list */
enum
asn1p_expr_marker_e
a_marker
;
/* OPTIONAL/DEFAULT */
struct
asn1p_expr_marker_s
a_marker
;
/* OPTIONAL/DEFAULT */
enum
asn1p_constr_pres_e
a_pres
;
/* PRESENT/ABSENT/OPTIONAL */
asn1_integer_t
a_int
;
char
*
tv_str
;
...
...
libasn1parser/asn1p_y.y
View file @
9c974183
...
...
@@ -74,7 +74,7 @@ static asn1p_value_t *
asn1p_value_t *a_value; /* Number, DefinedValue, etc */
struct asn1p_param_s a_parg; /* A parameter argument */
asn1p_paramlist_t *a_plist; /* A pargs list */
enum asn1p_expr_marker_e
a_marker; /* OPTIONAL/DEFAULT */
struct asn1p_expr_marker_s
a_marker; /* OPTIONAL/DEFAULT */
enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */
asn1_integer_t a_int;
char *tv_str;
...
...
@@ -236,7 +236,7 @@ static asn1p_value_t *
%type <a_expr> optValueSetBody
%type <a_expr> ValueSetBody
%type <a_expr> ValueSetElement
%type <a_value>
InlineOrDefined
Value
%type <a_value> Value
%type <a_value> DefinedValue
%type <a_value> SignedNumber
%type <a_expr> ComponentTypeLists
...
...
@@ -1178,6 +1178,16 @@ ComplexTypeReference:
checkmem(ret == 0);
free($1);
}
| ObjectClassReference '.' TypeRefName {
int ret;
$$ = asn1p_ref_new(yylineno);
checkmem($$);
ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN);
checkmem(ret == 0);
ret = asn1p_ref_add_component($$, $3, RLT_UNKNOWN);
checkmem(ret == 0);
free($1);
}
| TOK_typereference '.' Identifier {
int ret;
$$ = asn1p_ref_new(yylineno);
...
...
@@ -1258,7 +1268,7 @@ ClassFieldName:
* === EOF ===
*/
ValueDefinition:
Identifier DefinedTypeRef TOK_PPEQ
InlineOrDefined
Value {
Identifier DefinedTypeRef TOK_PPEQ Value {
$$ = $2;
assert($$->Identifier == NULL);
$$->Identifier = $1;
...
...
@@ -1267,13 +1277,34 @@ ValueDefinition:
}
;
InlineOrDefinedValue:
'{' { asn1p_lexer_hack_push_opaque_state(); }
Opaque /* '}' */ {
Value:
Identifier ':' Value {
$$ = asn1p_value_fromint(0);
checkmem($$);
$$->type = ATV_CHOICE_IDENTIFIER;
$$->value.choice_identifier.identifier = $1;
$$->value.choice_identifier.value = $3;
}
| '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ {
$$ = asn1p_value_frombuf($3.buf, $3.len, 0);
checkmem($$);
$$->type = ATV_UNPARSED;
}
| TOK_NULL {
$$ = asn1p_value_fromint(0);
checkmem($$);
$$->type = ATV_NULL;
}
| TOK_FALSE {
$$ = asn1p_value_fromint(0);
checkmem($$);
$$->type = ATV_FALSE;
}
| TOK_TRUE {
$$ = asn1p_value_fromint(0);
checkmem($$);
$$->type = ATV_TRUE;
}
| TOK_bstring {
$$ = _convert_bitstring2binary($1, 'B');
checkmem($$);
...
...
@@ -1394,11 +1425,11 @@ BasicString:
TOK_BMPString { $$ = ASN_STRING_BMPString; }
| TOK_GeneralString {
$$ = ASN_STRING_GeneralString;
fprintf(stderr, "WARNING: GeneralString is not fully supported");
fprintf(stderr, "WARNING: GeneralString is not fully supported
\n
");
}
| TOK_GraphicString {
$$ = ASN_STRING_GraphicString;
fprintf(stderr, "WARNING: GraphicString is not fully supported");
fprintf(stderr, "WARNING: GraphicString is not fully supported
\n
");
}
| TOK_IA5String { $$ = ASN_STRING_IA5String; }
| TOK_ISO646String { $$ = ASN_STRING_ISO646String; }
...
...
@@ -1406,14 +1437,14 @@ BasicString:
| TOK_PrintableString { $$ = ASN_STRING_PrintableString; }
| TOK_T61String {
$$ = ASN_STRING_T61String;
fprintf(stderr, "WARNING: T61String is not fully supported");
fprintf(stderr, "WARNING: T61String is not fully supported
\n
");
}
| TOK_TeletexString { $$ = ASN_STRING_TeletexString; }
| TOK_UniversalString { $$ = ASN_STRING_UniversalString; }
| TOK_UTF8String { $$ = ASN_STRING_UTF8String; }
| TOK_VideotexString {
$$ = ASN_STRING_VideotexString;
fprintf(stderr, "WARNING: VideotexString is not fully supported");
fprintf(stderr, "WARNING: VideotexString is not fully supported
\n
");
}
| TOK_VisibleString { $$ = ASN_STRING_VisibleString; }
| TOK_ObjectDescriptor { $$ = ASN_STRING_ObjectDescriptor; }
...
...
@@ -1589,7 +1620,6 @@ ConstraintValue:
$$ = asn1p_value_frombuf($1.buf, $1.len, 0);
checkmem($$);
}
| TOK_FALSE {
$$ = asn1p_value_fromint(0);
checkmem($$);
...
...
@@ -1754,26 +1784,21 @@ ComponentIdList:
*/
optMarker:
{ $$ = EM_NOMARK; }
{
$$.flags = EM_NOMARK;
$$.default_value = 0;
}
| Marker { $$ = $1; }
;
Marker:
TOK_OPTIONAL {
$$ = EM_OPTIONAL;
}
| TOK_DEFAULT DefaultValue {
$$ = EM_DEFAULT;
/* FIXME: store DefaultValue somewhere */
}
;
DefaultValue:
ConstraintValue {
}
| BasicTypeId {
$$.flags = EM_OPTIONAL;
$$.default_value = 0;
}
| '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ {
| TOK_DEFAULT Value {
$$.flags = EM_DEFAULT;
$$.default_value = $2;
}
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment