strtoofft.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _CURL_STRTOOFFT_H
  2. #define _CURL_STRTOOFFT_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2004, Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * $Id$
  24. ***************************************************************************/
  25. /*
  26. * CAUTION: this header is designed to work when included by the app-side
  27. * as well as the library. Do not mix with library internals!
  28. */
  29. #include "setup.h"
  30. #include <stddef.h>
  31. #include <curl/curl.h> /* for the curl_off_t type */
  32. /* Determine what type of file offset conversion handling we wish to use. For
  33. * systems with a 32-bit curl_off_t type, we should use strtol. For systems
  34. * with a 64-bit curl_off_t type, we should use strtoll if it exists, and if
  35. * not, should try to emulate its functionality. At any rate, we define
  36. * 'strtoofft' such that it can be used to work with curl_off_t's regardless.
  37. */
  38. #if (SIZEOF_CURL_OFF_T > 4) && (SIZEOF_LONG < 8)
  39. #if HAVE_STRTOLL
  40. #define curlx_strtoofft strtoll
  41. #else /* HAVE_STRTOLL */
  42. /* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
  43. #if defined(_MSC_VER) && (_MSC_VER >= 1300)
  44. #define curlx_strtoofft _strtoi64
  45. #else /* MSVC7 or later */
  46. curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
  47. #define curlx_strtoofft curlx_strtoll
  48. #define NEED_CURL_STRTOLL
  49. #endif /* MSVC7 or later */
  50. #endif /* HAVE_STRTOLL */
  51. #else /* (SIZEOF_CURL_OFF_T > 4) && (SIZEOF_LONG < 8) */
  52. /* simply use strtol() to get numbers, either 32 or 64 bit */
  53. #define curlx_strtoofft strtol
  54. #endif
  55. #if defined(_MSC_VER) || defined(__WATCOMC__)
  56. #define CURL_LLONG_MIN 0x8000000000000000i64
  57. #define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFi64
  58. #elif defined(HAVE_LL)
  59. #define CURL_LLONG_MIN 0x8000000000000000LL
  60. #define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
  61. #else
  62. #define CURL_LLONG_MIN 0x8000000000000000L
  63. #define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFL
  64. #endif
  65. #endif