diff options
author | Werner Koch <wk@gnupg.org> | 2001-12-14 14:37:08 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2001-12-14 14:37:08 +0100 |
commit | 317bccd134e8301a3354803dd148ef0e7931408a (patch) | |
tree | 4b69f4c1e8765cf0fb805eca84fa049440335e1a /common/util.h | |
parent | * sign.c (get_default_signer): Use keydb_classify_name here. (diff) | |
download | gnupg2-317bccd134e8301a3354803dd148ef0e7931408a.tar.xz gnupg2-317bccd134e8301a3354803dd148ef0e7931408a.zip |
* util.h (digitp, hexdigitp): New ctype like macros.
(atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New.
Diffstat (limited to 'common/util.h')
-rw-r--r-- | common/util.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h index 485cc1c05..e30923330 100644 --- a/common/util.h +++ b/common/util.h @@ -55,6 +55,21 @@ int map_kbx_err (int err); int map_assuan_err (int err); +/* some macros to replace ctype ones and avoid locale problems */ +#define digitp(p) (*(p) >= '0' && *(p) <= '9') +#define hexdigitp(a) (digitp (a) \ + || ((a) >= 'A' && (a) <= 'F') \ + || ((a) >= 'a' && (a) <= 'f')) +/* the atoi macros assume that the buffer has only valid digits */ +#define atoi_1(p) (*(p) - '0' ) +#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) +#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2)) +#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ + *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) +#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) + + + #endif /*GNUPG_COMMON_UTIL_H*/ |