31# define ANJ_INTERNAL_INCLUDE_UTILS
32# include <anj_internal/utils.h>
33# undef ANJ_INTERNAL_INCLUDE_UTILS
45# define ANJ_ID_INVALID UINT16_MAX
54# define ANJ_CONTAINER_OF(ptr, type, member) \
55 ((type *) (void *) ((char *) (intptr_t) (ptr) -offsetof(type, member)))
58# define ANJ_MIN(a, b) ((a) < (b) ? (a) : (b))
61# define ANJ_MAX(a, b) ((a) < (b) ? (b) : (a))
64# define ANJ_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
67# define ANJ_QUOTE(Value) # Value
70# define ANJ_QUOTE_MACRO(Value) ANJ_QUOTE(Value)
73# define ANJ_ASSERT(cond, msg) assert((cond) && (bool) "" msg)
79# define ANJ_UNREACHABLE(msg) ANJ_ASSERT(0, msg)
85# define ANJ_CONCAT(...) \
86 _ANJ_CONCAT_INTERNAL__( \
87 _ANJ_CONCAT_INTERNAL__(_ANJ_CONCAT_INTERNAL_, \
88 _ANJ_VARARG_LENGTH(__VA_ARGS__)), \
100# define ANJ_STATIC_ASSERT(condition, message) \
101 struct ANJ_CONCAT(static_assert_, message) { \
102 char message[(condition) ? 1 : -1]; \
109# define ANJ_MAKE_RESOURCE_INSTANCE_PATH(Oid, Iid, Rid, Riid) \
110 _ANJ_MAKE_URI_PATH(Oid, Iid, Rid, Riid, 4)
116# define ANJ_MAKE_RESOURCE_PATH(Oid, Iid, Rid) \
117 _ANJ_MAKE_URI_PATH(Oid, Iid, Rid, ANJ_ID_INVALID, 3)
123# define ANJ_MAKE_INSTANCE_PATH(Oid, Iid) \
124 _ANJ_MAKE_URI_PATH(Oid, Iid, ANJ_ID_INVALID, ANJ_ID_INVALID, 2)
130# define ANJ_MAKE_OBJECT_PATH(Oid) \
131 _ANJ_MAKE_URI_PATH( \
132 Oid, ANJ_ID_INVALID, ANJ_ID_INVALID, ANJ_ID_INVALID, 1)
138# define ANJ_MAKE_ROOT_PATH() \
139 _ANJ_MAKE_URI_PATH(ANJ_ID_INVALID, \
153 for (
size_t i = 0; i < left->
uri_len; ++i) {
154 if (left->
ids[i] != right->
ids[i]) {
172 return path->
uri_len > id_type;
181 return path->
uri_len == (size_t) id_type + 1u;
193 for (
size_t i = 0; i < base->
uri_len; ++i) {
194 if (path->
ids[i] != base->
ids[i]) {
Core type and constant definitions for Anjay Lite.
anj_id_type_t
Definition defs.h:238
Global configuration validation header for Anjay Lite.
uint16_t ids[ANJ_URI_PATH_MAX_LENGTH]
Definition defs.h:261
size_t uri_len
Definition defs.h:262
static bool anj_uri_path_equal(const anj_uri_path_t *left, const anj_uri_path_t *right)
Definition utils.h:148
size_t anj_uint32_to_string_value(char *out_buff, uint32_t value)
static bool anj_uri_path_is(const anj_uri_path_t *path, anj_id_type_t id_type)
Definition utils.h:179
int anj_string_to_objlnk_value(anj_objlnk_value_t *out, const char *objlnk)
static bool anj_uri_path_outside_base(const anj_uri_path_t *path, const anj_uri_path_t *base)
Definition utils.h:188
int anj_string_to_uint32_value(uint32_t *out_val, const char *buff, size_t buff_len)
size_t anj_int64_to_string_value(char *out_buff, int64_t value)
size_t anj_uint16_to_string_value(char *out_buff, uint16_t value)
size_t anj_uint64_to_string_value(char *out_buff, uint64_t value)
bool anj_uri_path_increasing(const anj_uri_path_t *previous_path, const anj_uri_path_t *current_path)
static bool anj_uri_path_has(const anj_uri_path_t *path, anj_id_type_t id_type)
Definition utils.h:170
size_t anj_double_to_string_value(char *out_buff, double value)
uint16_t anj_determine_block_buffer_size(size_t buff_size)
int anj_string_to_double_value(double *out_val, const char *buff, size_t buff_len)
int anj_string_to_uint64_value(uint64_t *out_val, const char *buff, size_t buff_len)
int anj_string_to_int64_value(int64_t *out_val, const char *buff, size_t buff_len)
static size_t anj_uri_path_length(const anj_uri_path_t *path)
Definition utils.h:162