Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
14047d99
Commit
14047d99
authored
Dec 07, 1999
by
Niels Möller
Browse files
* src/digits.c (simple_decode_hex): New function.
Rev: src/digits.c:1.3 Rev: src/digits.h:1.3
parent
761727e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/digits.c
View file @
14047d99
...
...
@@ -25,6 +25,7 @@
#include "digit_table.h"
#include "werror.h"
#include "xalloc.h"
#include <assert.h>
...
...
@@ -74,3 +75,28 @@ base64_decode(struct base64_state *state, UINT8 c)
return
res
;
}
struct
lsh_string
*
simple_decode_hex
(
const
unsigned
char
*
in
)
{
unsigned
length
=
strlen
(
in
);
unsigned
i
,
j
;
struct
lsh_string
*
out
;
assert
(
!
(
length
%
2
));
out
=
lsh_string_alloc
(
length
/
2
);
for
(
i
=
j
=
0
;
i
<
length
;
)
{
int
d1
=
hex_digits
[
in
[
i
++
]];
int
d2
=
hex_digits
[
in
[
i
++
]];
assert
(
d1
>=
0
);
assert
(
d2
>=
0
);
out
->
data
[
j
++
]
=
(
d1
<<
4
)
|
d2
;
}
return
out
;
}
src/digits.h
View file @
14047d99
...
...
@@ -56,4 +56,7 @@ base64_init(struct base64_state *state, UINT8 terminator);
int
base64_decode
(
struct
base64_state
*
state
,
UINT8
c
);
/* Only used by the testsuite */
struct
lsh_string
*
simple_decode_hex
(
const
unsigned
char
*
in
);
#endif
/* LSH_DIGITS_H_INCLUDED */
Write
Preview
Supports
Markdown
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