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 | |
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')
-rw-r--r-- | common/ChangeLog | 17 | ||||
-rw-r--r-- | common/util.h | 15 |
2 files changed, 32 insertions, 0 deletions
diff --git a/common/ChangeLog b/common/ChangeLog new file mode 100644 index 000000000..70bc1cc8a --- /dev/null +++ b/common/ChangeLog @@ -0,0 +1,17 @@ +2001-12-14 Werner Koch <wk@gnupg.org> + + * util.h (digitp, hexdigitp): New ctype like macros. + (atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New. + + + Copyright 2001 Free Software Foundation, Inc. + + This file is free software; as a special exception the author gives + unlimited permission to copy and/or distribute it, with or without + modifications, as long as this notice is preserved. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + 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*/ |