ua_util_internal.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2014, 2017 (c) Florian Palm
  7. * Copyright 2015 (c) LEvertz
  8. * Copyright 2015-2016 (c) Sten Grüner
  9. * Copyright 2015 (c) Chris Iatrou
  10. * Copyright 2015-2016 (c) Oleksiy Vasylyev
  11. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  12. */
  13. #ifndef UA_UTIL_H_
  14. #define UA_UTIL_H_
  15. #define UA_INTERNAL
  16. #include "ua_types.h"
  17. _UA_BEGIN_DECLS
  18. /* Macro-Expand for MSVC workarounds */
  19. #define UA_MACRO_EXPAND(x) x
  20. /* Integer Shortnames
  21. * ------------------
  22. * These are not exposed on the public API, since many user-applications make
  23. * the same definitions in their headers. */
  24. typedef UA_Byte u8;
  25. typedef UA_SByte i8;
  26. typedef UA_UInt16 u16;
  27. typedef UA_Int16 i16;
  28. typedef UA_UInt32 u32;
  29. typedef UA_Int32 i32;
  30. typedef UA_UInt64 u64;
  31. typedef UA_Int64 i64;
  32. typedef UA_StatusCode status;
  33. /* Utility Functions
  34. * ----------------- */
  35. /* Convert given byte string to a positive number. Returns the number of valid
  36. * digits. Stops if a non-digit char is found and returns the number of digits
  37. * up to that point. */
  38. size_t UA_readNumber(u8 *buf, size_t buflen, u32 *number);
  39. /* Same as UA_ReadNumber but with a base parameter */
  40. size_t UA_readNumberWithBase(u8 *buf, size_t buflen, u32 *number, u8 base);
  41. #ifndef UA_MIN
  42. #define UA_MIN(A,B) (A > B ? B : A)
  43. #endif
  44. #ifndef UA_MAX
  45. #define UA_MAX(A,B) (A > B ? A : B)
  46. #endif
  47. #ifdef UA_DEBUG_DUMP_PKGS
  48. void UA_EXPORT UA_dump_hex_pkg(UA_Byte* buffer, size_t bufferLen);
  49. #endif
  50. _UA_END_DECLS
  51. #endif /* UA_UTIL_H_ */