mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: New function string_to_u64.
* common/stringhelp.c (string_to_u64): New. * dirmngr/http.c (longcounter_t): Remove. (struct cookie_s): Change content_length to uint64_t. (parse_response): Use string_to_u64. -- Meanwhile we allow some C99 features including stdint.h. Thus we can simplify things now. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
72fa314b71
commit
0698324cde
4 changed files with 25 additions and 14 deletions
|
@ -58,6 +58,7 @@
|
|||
|
||||
#define tohex_lower(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'a'))
|
||||
|
||||
|
||||
/* Sometimes we want to avoid mixing slashes and backslashes on W32
|
||||
and prefer backslashes. There is usual no problem with mixing
|
||||
them, however a very few W32 API calls can't grok plain slashes.
|
||||
|
@ -660,6 +661,25 @@ compare_filenames (const char *a, const char *b)
|
|||
}
|
||||
|
||||
|
||||
/* Convert a base-10 number in STRING into a 64 bit unsigned int
|
||||
* value. Leading white spaces are skipped but no error checking is
|
||||
* done. Thus it is similar to atoi(). */
|
||||
uint64_t
|
||||
string_to_u64 (const char *string)
|
||||
{
|
||||
uint64_t val = 0;
|
||||
|
||||
while (spacep (string))
|
||||
string++;
|
||||
for (; digitp (string); string++)
|
||||
{
|
||||
val *= 10;
|
||||
val += *string - '0';
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
/* Convert 2 hex characters at S to a byte value. Return this value
|
||||
or -1 if there is an error. */
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue