diff options
author | Werner Koch <[email protected]> | 2003-09-28 13:42:18 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2003-09-28 13:42:18 +0000 |
commit | edb5762c5fcd8f5a6cf39bf01e0a8471e4117c2f (patch) | |
tree | 8f36683f5fb7c44494e6ed8168672c7396a4bb2c /include/util.h | |
parent | * g10.c (main): New commands --card-edit, --card-status and (diff) | |
download | gnupg-edb5762c5fcd8f5a6cf39bf01e0a8471e4117c2f.tar.gz gnupg-edb5762c5fcd8f5a6cf39bf01e0a8471e4117c2f.zip |
* util.h: Add the atoi_* and xtoi_* suite of macros from 1.9.
* dynload.h: New. Taken from 1.9.
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h index 179f05f16..b0d8613ce 100644 --- a/include/util.h +++ b/include/util.h @@ -270,6 +270,14 @@ int vasprintf ( char **result, const char *format, va_list args); #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)) + /* Note this isn't identical to a C locale isspace() without \f and \v, but works for the purposes used here. */ #define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t') |