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
d866a059
Commit
d866a059
authored
Sep 07, 2023
by
v0-e
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BIT STRING JER hex encoding from sprintf to lookup
parent
f195b2cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
skeletons/BIT_STRING_jer.c
skeletons/BIT_STRING_jer.c
+11
-15
No files found.
skeletons/BIT_STRING_jer.c
View file @
d866a059
...
@@ -11,11 +11,10 @@ BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -11,11 +11,10 @@ BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
int
ilevel
,
enum
jer_encoder_flags_e
flags
,
int
ilevel
,
enum
jer_encoder_flags_e
flags
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
asn_enc_rval_t
er
=
{
0
,
0
,
0
};
char
scratch
[
128
];
const
char
*
const
h2c
=
"0123456789ABCDEF"
;
char
scratch
[
16
*
3
+
4
];
char
*
p
=
scratch
;
char
*
p
=
scratch
;
char
*
scend
=
scratch
+
(
sizeof
(
scratch
)
-
4
);
const
BIT_STRING_t
*
st
=
(
const
BIT_STRING_t
*
)
sptr
;
const
BIT_STRING_t
*
st
=
(
const
BIT_STRING_t
*
)
sptr
;
int
xcan
=
1
;
uint8_t
*
buf
;
uint8_t
*
buf
;
uint8_t
*
end
;
uint8_t
*
end
;
...
@@ -28,29 +27,26 @@ BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -28,29 +27,26 @@ BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
end
=
buf
+
st
->
size
-
1
;
/* Last byte is special */
end
=
buf
+
st
->
size
-
1
;
/* Last byte is special */
/*
/*
*
Binary
dump
*
Hex
dump
*/
*/
*
p
++
=
'"'
;
*
p
++
=
'"'
;
for
(;
buf
<
end
;
buf
++
)
{
for
(
int
i
=
0
;
buf
<
end
;
buf
++
,
i
++
)
{
int
v
=
*
buf
;
if
(
!
(
i
%
16
)
&&
(
i
||
st
->
size
>
16
))
{
int
nline
=
xcan
?
0
:
(((
buf
-
st
->
buf
)
%
8
)
==
0
);
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
if
(
p
>=
scend
||
nline
)
{
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
p
=
scratch
;
p
=
scratch
;
if
(
nline
)
ASN__TEXT_INDENT
(
1
,
ilevel
);
}
}
p
+=
sprintf
(
p
,
"%02x"
,
v
);
*
p
++
=
h2c
[
*
buf
>>
4
];
*
p
++
=
h2c
[
*
buf
&
0x0F
];
}
}
if
(
!
xcan
&&
((
buf
-
st
->
buf
)
%
8
)
==
0
)
ASN__TEXT_INDENT
(
1
,
ilevel
);
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
p
=
scratch
;
p
=
scratch
;
if
(
buf
==
end
)
{
if
(
buf
==
end
)
{
uint8_t
v
=
*
buf
;
int
ubits
=
st
->
bits_unused
;
int
ubits
=
st
->
bits_unused
;
p
+=
sprintf
(
p
,
"%02x"
,
v
&
(
0xff
<<
ubits
));
uint8_t
v
=
*
buf
&
(
0xff
<<
ubits
);
*
p
++
=
h2c
[
v
>>
4
];
*
p
++
=
h2c
[
v
&
0x0F
];
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
ASN__CALLBACK
(
scratch
,
p
-
scratch
);
p
=
scratch
;
p
=
scratch
;
}
}
...
...
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