strtoofft.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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, <daniel@haxx.se>, 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: strtoofft.h,v 1.9 2004/03/03 13:32:57 bagder Exp $
  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
  39. #if HAVE_STRTOLL
  40. #define 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 strtoofft _strtoi64
  45. #else /* MSVC7 or later */
  46. curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
  47. #define strtoofft curlx_strtoll
  48. #define NEED_CURL_STRTOLL
  49. #endif /* MSVC7 or later */
  50. #endif /* HAVE_STRTOLL */
  51. #else /* SIZEOF_CURL_OFF_T > 4 */
  52. /* simply use strtol() to get 32bit numbers */
  53. #define strtoofft strtol
  54. #endif
  55. #endif