mirror of
https://github.com/curl/curl.git
synced 2026-08-04 14:56:19 +03:00
lib: unify conversions to/from hex
Curl_hexbyte - output a byte as a two-digit ASCII hex number Curl_hexval - convert an ASCII hex digit to its binary value ... instead of duplicating similar code and hexdigit strings in numerous places. Closes #16888
This commit is contained in:
parent
1d84d683bb
commit
0c6e63a1be
8 changed files with 69 additions and 71 deletions
|
|
@ -102,6 +102,13 @@ int Curl_str_cspn(const char **linep, struct Curl_str *out, const char *cspn);
|
|||
void Curl_str_trimblanks(struct Curl_str *out);
|
||||
void Curl_str_passblanks(const char **linep);
|
||||
|
||||
/* given a hexadecimal letter, return the binary value. '0' returns 0, 'a'
|
||||
returns 10. THIS ONLY WORKS ON VALID HEXADECIMAL LETTER INPUT. Verify
|
||||
before calling this!
|
||||
*/
|
||||
extern const unsigned char Curl_hexasciitable[];
|
||||
#define Curl_hexval(x) (unsigned char)(Curl_hexasciitable[(x) - '0'] & 0x0f)
|
||||
|
||||
#define curlx_str_number(x,y,z) Curl_str_number(x,y,z)
|
||||
#define curlx_str_octal(x,y,z) Curl_str_octal(x,y,z)
|
||||
#define curlx_str_single(x,y) Curl_str_single(x,y)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue