Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Brian Smith
nettle
Commits
899af3c0
Commit
899af3c0
authored
Nov 15, 2002
by
Niels Möller
Browse files
(sexp_iterator_get_uint32): New function.
Rev: src/nettle/sexp.c:1.12 Rev: src/nettle/sexp.h:1.9
parent
f75832a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
sexp.c
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
,
...
...
sexp.h
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
*
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment