ua_types.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef OPCUA_TYPES_H_
  2. #define OPCUA_TYPES_H_
  3. #include <stdint.h>
  4. #define DBG_VERBOSE(expression) // omit debug code
  5. #define DBG_ERR(expression) // omit debug code
  6. #define DBG(expression) // omit debug code
  7. #if defined(DEBUG) // --enable-debug=(yes|verbose)
  8. # undef DBG
  9. # define DBG(expression) expression
  10. # undef DBG_ERR
  11. # define DBG_ERR(expression) expression
  12. # if defined(VERBOSE) // --enable-debug=verbose
  13. # undef DBG_VERBOSE
  14. # define DBG_VERBOSE(expression) expression
  15. # endif
  16. #endif
  17. /* Basic types */
  18. typedef _Bool UA_Boolean;
  19. typedef uint8_t UA_Byte;
  20. typedef int8_t UA_SByte;
  21. typedef int16_t UA_Int16;
  22. typedef uint16_t UA_UInt16;
  23. typedef int32_t UA_Int32;
  24. typedef uint32_t UA_UInt32;
  25. typedef int64_t UA_Int64;
  26. typedef uint64_t UA_UInt64;
  27. typedef float UA_Float;
  28. typedef double UA_Double;
  29. /* ByteString - Part: 6, Chapter: 5.2.2.7, Page: 17 */
  30. typedef struct UA_ByteString {
  31. UA_Int32 length;
  32. UA_Byte* data;
  33. } UA_ByteString;
  34. /* Function return values */
  35. #define UA_SUCCESS 0
  36. #define UA_NO_ERROR UA_SUCCESS
  37. #define UA_ERROR (0x01 << 31)
  38. #define UA_ERR_INCONSISTENT (UA_ERROR | (0x01 << 1))
  39. #define UA_ERR_INVALID_VALUE (UA_ERROR | (0x01 << 2))
  40. #define UA_ERR_NO_MEMORY (UA_ERROR | (0x01 << 3))
  41. #define UA_ERR_NOT_IMPLEMENTED (UA_ERROR | (0x01 << 4))
  42. /* Boolean values and null */
  43. #define UA_TRUE (42==42)
  44. #define TRUE UA_TRUE
  45. #define UA_FALSE (!UA_TRUE)
  46. #define FALSE UA_FALSE
  47. /* Compare values */
  48. #define UA_EQUAL 0
  49. #define UA_NOT_EQUAL (!UA_EQUAL)
  50. /* heap memory functions */
  51. #define UA_NULL ((void*)0)
  52. extern void const * UA_alloc_lastptr;
  53. #define UA_free(ptr) _UA_free(ptr,#ptr,__FILE__,__LINE__)
  54. UA_Int32 _UA_free(void * ptr,char*,char*,int);
  55. UA_Int32 UA_memcpy(void *dst, void const *src, int size);
  56. #define UA_alloc(ptr,size) _UA_alloc(ptr,size,#ptr,#size,__FILE__,__LINE__)
  57. UA_Int32 _UA_alloc(void ** dst, int size,char*,char*,char*,int);
  58. #endif