diff options
author | wsanchez <wsanchez@13f79535-47bb-0310-9956-ffa450edef68> | 2002-07-24 20:29:38 +0000 |
---|---|---|
committer | wsanchez <wsanchez@13f79535-47bb-0310-9956-ffa450edef68> | 2002-07-24 20:29:38 +0000 |
commit | 745df9b8e9d4102c11cc6761627e53d1f67e9325 (patch) | |
tree | b87b0ba700abb6ff7142337497345ec9b98b29d5 /strings | |
parent | e6f458b9f73d2b1c6bd55cd6d7c040f2e46a3772 (diff) | |
download | libapr-745df9b8e9d4102c11cc6761627e53d1f67e9325.tar.gz |
Added apr_strtoll() and apr_atoll() to strings lib.
Submitted by: Shantonu Sen <ssen@apple.com>
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63730 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_strings.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/strings/apr_strings.c b/strings/apr_strings.c index 4dd000d6b..aa870fd03 100644 --- a/strings/apr_strings.c +++ b/strings/apr_strings.c @@ -65,6 +65,10 @@ #include <stddef.h> /* NULL */ #endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> /* strtol and strtoll */ +#endif + /** this is used to cache lengths in apr_pstrcat */ #define MAX_SAVED_LENGTHS 6 @@ -229,6 +233,21 @@ void *memchr(const void *s, int c, size_t n) } #endif +APR_DECLARE(long long) apr_strtoll(char *buf, char **end, int base) +{ +#if (APR_HAVE_STRTOLL) + return strtoll(buf, NULL, 0); +#else + /* best-effort function. If no strtoll, use strtol */ + return (long long)strtol(buf, NULL, 0); +#endif +} + +APR_DECLARE(long long) apr_atoll(char *buf) +{ + return apr_strtoll(buf, NULL, 0); +} + APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n) { const int BUFFER_SIZE = sizeof(int) * 3 + 2; |