Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

string_to_uint.h 1016B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2001-2018 The strace developers.
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #ifndef STRACE_STRING_TO_UINT_H
  8. # define STRACE_STRING_TO_UINT_H
  9. # include <limits.h>
  10. # include "kernel_types.h"
  11. extern long long
  12. string_to_uint_ex(const char *str, char **endptr,
  13. unsigned long long max_val, const char *accepted_ending);
  14. static inline long long
  15. string_to_uint_upto(const char *const str, const unsigned long long max_val)
  16. {
  17. return string_to_uint_ex(str, NULL, max_val, NULL);
  18. }
  19. static inline int
  20. string_to_uint(const char *str)
  21. {
  22. return string_to_uint_upto(str, INT_MAX);
  23. }
  24. static inline long
  25. string_to_ulong(const char *str)
  26. {
  27. return string_to_uint_upto(str, LONG_MAX);
  28. }
  29. static inline kernel_long_t
  30. string_to_kulong(const char *str)
  31. {
  32. return string_to_uint_upto(str, ((kernel_ulong_t) -1ULL) >> 1);
  33. }
  34. static inline long long
  35. string_to_ulonglong(const char *str)
  36. {
  37. return string_to_uint_upto(str, LLONG_MAX);
  38. }
  39. #endif /* !STRACE_STRING_TO_UINT_H */