Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asn1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
qwebaby3
asn1c
Commits
958d7a80
Commit
958d7a80
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
BOOLEAN and NULL have changed their types
parent
7f7d46ac
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
skeletons/BOOLEAN.c
+10
-10
10 additions, 10 deletions
skeletons/BOOLEAN.c
skeletons/BOOLEAN.h
+6
-3
6 additions, 3 deletions
skeletons/BOOLEAN.h
skeletons/NULL.h
+8
-6
8 additions, 6 deletions
skeletons/NULL.h
with
24 additions
and
19 deletions
skeletons/BOOLEAN.c
+
10
−
10
View file @
958d7a80
...
...
@@ -30,16 +30,16 @@ asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
*/
ber_dec_rval_t
BOOLEAN_decode_ber
(
asn1_TYPE_descriptor_t
*
td
,
void
**
bool_
structur
e
,
void
*
buf_ptr
,
size_t
size
,
void
**
bool_
valu
e
,
void
*
buf_ptr
,
size_t
size
,
int
tag_mode
)
{
BOOLEAN_t
*
st
=
(
BOOLEAN_t
*
)
*
bool_
structur
e
;
BOOLEAN_t
*
st
=
(
BOOLEAN_t
*
)
*
bool_
valu
e
;
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
)
{
(
void
*
)
st
=
*
bool_
structur
e
=
CALLOC
(
1
,
sizeof
(
*
st
));
(
void
*
)
st
=
*
bool_
valu
e
=
CALLOC
(
1
,
sizeof
(
*
st
));
if
(
st
==
NULL
)
{
rval
.
code
=
RC_FAIL
;
rval
.
consumed
=
0
;
...
...
@@ -71,22 +71,22 @@ BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
/*
* Compute boolean value.
*/
for
(
st
->
value
=
0
,
lidx
=
0
;
(
lidx
<
length
)
&&
st
->
value
==
0
;
lidx
++
)
{
for
(
*
st
=
0
,
lidx
=
0
;
(
lidx
<
length
)
&&
*
st
==
0
;
lidx
++
)
{
/*
* Very simple approach: read bytes until the end or
* value is already TRUE.
* BOOLEAN is not supposed to contain meaningful data anyway.
*/
st
->
value
|=
((
uint8_t
*
)
buf_ptr
)[
lidx
];
*
st
|=
((
uint8_t
*
)
buf_ptr
)[
lidx
];
}
rval
.
code
=
RC_OK
;
rval
.
consumed
+=
length
;
ASN_DEBUG
(
"Took %ld/%ld bytes to encode %s, value=%
l
d"
,
ASN_DEBUG
(
"Took %ld/%ld bytes to encode %s, value=%d"
,
(
long
)
rval
.
consumed
,
(
long
)
length
,
td
->
name
,
(
long
)
st
->
value
);
td
->
name
,
*
st
);
return
rval
;
}
...
...
@@ -109,7 +109,7 @@ BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
uint8_t
bool_value
;
ssize_t
ret
;
bool_value
=
st
->
value
?
0xff
:
0
;
/* 0xff mandated by DER */
bool_value
=
*
st
?
0xff
:
0
;
/* 0xff mandated by DER */
ret
=
cb
(
&
bool_value
,
1
,
app_key
);
if
(
ret
==
-
1
)
{
erval
.
encoded
=
-
1
;
...
...
@@ -133,7 +133,7 @@ BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
(
void
)
ilevel
;
/* Unused argument */
if
(
st
)
{
if
(
st
->
value
)
if
(
*
st
)
return
cb
(
"TRUE"
,
4
,
app_key
);
else
return
cb
(
"FALSE"
,
5
,
app_key
);
...
...
This diff is collapsed.
Click to expand it.
skeletons/BOOLEAN.h
+
6
−
3
View file @
958d7a80
...
...
@@ -7,9 +7,12 @@
#include
<constr_TYPE.h>
typedef
struct
BOOLEAN
{
int
value
;
}
BOOLEAN_t
;
/*
* The underlying integer may contain various values, but everything
* non-zero is capped to 0xff by the DER encoder. The BER decoder may
* yield non-zero values different from 1, beware.
*/
typedef
int
BOOLEAN_t
;
extern
asn1_TYPE_descriptor_t
asn1_DEF_BOOLEAN
;
...
...
This diff is collapsed.
Click to expand it.
skeletons/NULL.h
+
8
−
6
View file @
958d7a80
...
...
@@ -2,18 +2,20 @@
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _NULL_H
_
#define _NULL_H
_
#ifndef
ASN_TYPE
_NULL_H
#define
ASN_TYPE
_NULL_H
#include
<constr_TYPE.h>
typedef
struct
NULL_s
{
int
value
;
}
NULL_t
;
/*
* The value of the NULL type is meaningless: see BOOLEAN if you want to
* carry true/false semantics.
*/
typedef
int
NULL_t
;
extern
asn1_TYPE_descriptor_t
asn1_DEF_NULL
;
der_type_encoder_f
NULL_encode_der
;
asn_struct_print_f
NULL_print
;
#endif
/*
_
NULL_H
_
*/
#endif
/* NULL_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment