XROAD
xroad_common_types.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <stdint.h>
9 #include <stdlib.h>
10 #include <math.h>
11 
12 typedef int32_t xroad_errno_t;
14 typedef int32_t xroad_result_t;
15 
16 // UTC timestamp in microseconds (In some special cases it could be in nsec)
17 typedef int64_t xroad_timestamp_t;
18 
19 // Timestamp in TSC (see RDTSC CPU instruction)
20 typedef struct
21 {
22  uint64_t value;
23 } xroad_tsc_t;
24 
25 
26 #define XROAD_OK 0
27 #define XROAD_FAILED -1
28 
29 #define XROAD_IS_SUCCEEDED(x) ((x) >= XROAD_OK)
30 #define XROAD_IS_FAILED(x) ((x) < XROAD_OK)
31 
32 #define XROAD_ERROR_NOT_FOUND -2
33 #define XROAD_ERROR_INVALID_ARG -3
34 #define XROAD_ERROR_TOO_LONG -4
35 #define XROAD_ERROR_DUPLICATE_VAL -5
36 #define XROAD_ERROR_NOT_CONNECTED -6
37 #define XROAD_ERROR_INVALID_OBJECT -7
38 #define XROAD_ERROR_CHECK_FAILED -8
39 #define XROAD_ERROR_WRONG_FORMAT -9
40 #define XROAD_ERROR_ALREADY_EXISTS -10
41 #define XROAD_ERROR_ALREADY_CONNECTED -11
42 #define XROAD_ERROR_NO_MORE_RESOURCES -12
43 #define XROAD_ERROR_NOT_IMPL -13
44 #define XROAD_ERROR_ALREADY_DONE -14
45 #define XROAD_ERROR_WRONG_STATE -15
46 #define XROAD_ERROR_BUSY -16
47 #define XROAD_ERROR_UNABLE_TO_ROUTE -17
48 #define XROAD_ERROR_IGNORED -18
49 #define XROAD_ERROR_WRONG_SYSTEM_ROLE -19
50 #define XROAD_ERROR_DENIED -20
51 #define XROAD_ERROR_WRONG_TYPE -21
52 #define XROAD_ERROR_RATE_LIMIT -22
53 
54 #define XROAD_EPSILON 0.000000001
55 #define XROAD_SECONDS_IN_DAY 86400L
56 #define XROAD_SECONDS_IN_HOUR 3600L
57 #define XROAD_SECONDS_IN_MINUTE 60L
58 #define XROAD_MICROSECONDS 1000000L
59 #define XROAD_MILLISECONDS 1000L
60 
61 #define XROAD_CACHELINE_SZ 64U
62 #define XROAD_NONDESTRUCTIVE_OFFSET 128U
63 
65 #define xroad_bad_pointer ((void*)~0ull)
66 
68 typedef uint64_t xroad_object_id_t;
69 
72 
74 typedef enum
75 {
91 
92  // Keep this one the last!
95 
97 typedef union
98 {
99  void* ptr;
100  const void* cptr;
101  int64_t i64;
102  uint64_t u64;
103  int32_t i32;
104  uint32_t u32;
105  struct
106  {
107  uint32_t u32_1;
108  uint32_t u32_2;
109  };
111 
113 #define xroad_ctx_null ((xroad_context_t){0})
114 
116 typedef struct
117 {
118  char* ptr;
119  size_t size;
121 
123 typedef struct
124 {
125  const char* ptr;
126  size_t size;
Basic data buffer (either with data or for data)
Definition: xroad_common_types.h:117
size_t size
Size of the buffer.
Definition: xroad_common_types.h:119
char * ptr
Pointer to the buffer start.
Definition: xroad_common_types.h:118
Basic constant data buffer (either with data or for data)
Definition: xroad_common_types.h:124
const char * ptr
Pointer to the buffer start.
Definition: xroad_common_types.h:125
size_t size
Size of the buffer.
Definition: xroad_common_types.h:126
Definition: xroad_objects_types.h:160
Definition: xroad_common_types.h:21
Union of values for transparently passing to callbacks instead of void*
Definition: xroad_common_types.h:98
uint64_t xroad_object_id_t
Type for xroad object ID.
Definition: xroad_common_types.h:68
int32_t xroad_result_t
Non-negative integer result or negative error code (like xroad_errno_t)
Definition: xroad_common_types.h:14
xroad_bin_types_t
Binary type class identifiers for tracing and logging.
Definition: xroad_common_types.h:75
@ xroad_bin_type_uint
Unsigned integer.
Definition: xroad_common_types.h:79
@ xroad_bin_type_cstr
C-string (zero-terminated)
Definition: xroad_common_types.h:83
@ xroad_bin_type_max
Internal constant.
Definition: xroad_common_types.h:93
@ xroad_bin_type_datetime
xroad_datetime_t
Definition: xroad_common_types.h:87
@ xroad_bin_type_objref
XROAD object reference {type, ID}.
Definition: xroad_common_types.h:89
@ xroad_bin_type_none
No type.
Definition: xroad_common_types.h:76
@ xroad_bin_type_char
Char type.
Definition: xroad_common_types.h:77
@ xroad_bin_type_tsc
Timestamp in TSC.
Definition: xroad_common_types.h:80
@ xroad_bin_type_str
String (size, bytes)
Definition: xroad_common_types.h:82
@ xroad_bin_type_date
xroad_date_t
Definition: xroad_common_types.h:85
@ xroad_bin_type_float
Floating point types.
Definition: xroad_common_types.h:81
@ xroad_bin_type_time
xroad_time_t
Definition: xroad_common_types.h:86
@ xroad_bin_type_ts
Timestamp in usec since Epoch.
Definition: xroad_common_types.h:90
@ xroad_bin_type_obj
XROAD object (size, bytes)
Definition: xroad_common_types.h:88
@ xroad_bin_type_bin
Binary data (size, bytes)
Definition: xroad_common_types.h:84
@ xroad_bin_type_int
Signed integet.
Definition: xroad_common_types.h:78