mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* miscutil.c (hextobyte): Moved here from g10/misc.c so I can use it in
the keyserver helpers.
This commit is contained in:
parent
93b5a811ef
commit
fcc02ac22a
2 changed files with 30 additions and 0 deletions
|
@ -430,3 +430,28 @@ match_multistr(const char *multistr,const char *match)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
hextobyte( const char *s )
|
||||
{
|
||||
int c;
|
||||
|
||||
if( *s >= '0' && *s <= '9' )
|
||||
c = 16 * (*s - '0');
|
||||
else if( *s >= 'A' && *s <= 'F' )
|
||||
c = 16 * (10 + *s - 'A');
|
||||
else if( *s >= 'a' && *s <= 'f' )
|
||||
c = 16 * (10 + *s - 'a');
|
||||
else
|
||||
return -1;
|
||||
s++;
|
||||
if( *s >= '0' && *s <= '9' )
|
||||
c += *s - '0';
|
||||
else if( *s >= 'A' && *s <= 'F' )
|
||||
c += 10 + *s - 'A';
|
||||
else if( *s >= 'a' && *s <= 'f' )
|
||||
c += 10 + *s - 'a';
|
||||
else
|
||||
return -1;
|
||||
return c;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue