Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Brian Smith
nettle
Commits
899af3c0
Commit
899af3c0
authored
22 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(sexp_iterator_get_uint32): New function.
Rev: src/nettle/sexp.c:1.12 Rev: src/nettle/sexp.h:1.9
parent
f75832a1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sexp.c
+44
-0
44 additions, 0 deletions
sexp.c
sexp.h
+4
-0
4 additions, 0 deletions
sexp.h
with
48 additions
and
0 deletions
sexp.c
+
44
−
0
View file @
899af3c0
...
...
@@ -25,6 +25,8 @@
#include
"sexp.h"
#include
"macros.h"
#include
<stdlib.h>
#include
<string.h>
...
...
@@ -222,6 +224,48 @@ sexp_iterator_subexpr(struct sexp_iterator *iterator,
return
iterator
->
buffer
+
start
;
}
int
sexp_iterator_get_uint32
(
struct
sexp_iterator
*
iterator
,
uint32_t
*
x
)
{
if
(
iterator
->
type
==
SEXP_ATOM
&&
!
iterator
->
display
&&
iterator
->
atom_length
&&
iterator
->
atom
[
0
]
<
0x80
)
{
unsigned
length
=
iterator
->
atom_length
;
const
uint8_t
*
p
=
iterator
->
atom
;
/* Skip leading zeros. */
while
(
length
&&
!*
p
)
{
length
--
;
p
++
;
}
switch
(
length
)
{
case
0
:
*
x
=
0
;
break
;
case
1
:
*
x
=
p
[
0
];
break
;
case
2
:
*
x
=
READ_UINT16
(
p
);
break
;
case
3
:
*
x
=
READ_UINT24
(
p
);
break
;
case
4
:
*
x
=
READ_UINT32
(
p
);
break
;
default:
return
0
;
}
return
sexp_iterator_next
(
iterator
);
}
return
0
;
}
int
sexp_iterator_check_type
(
struct
sexp_iterator
*
iterator
,
...
...
This diff is collapsed.
Click to expand it.
sexp.h
+
4
−
0
View file @
899af3c0
...
...
@@ -83,6 +83,10 @@ const uint8_t *
sexp_iterator_subexpr
(
struct
sexp_iterator
*
iterator
,
unsigned
*
length
);
int
sexp_iterator_get_uint32
(
struct
sexp_iterator
*
iterator
,
uint32_t
*
x
);
/* Checks the type of the current expression, which should be a list
*
...
...
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