40 #define CO_BOOLEAN_INIT 0
41 #define CO_INTEGER8_INIT 0
42 #define CO_INTEGER16_INIT 0
43 #define CO_INTEGER32_INIT 0
44 #define CO_UNSIGNED8_INIT 0
45 #define CO_UNSIGNED16_INIT 0
46 #define CO_UNSIGNED32_INIT 0
47 #define CO_REAL32_INIT 0
48 #define CO_VISIBLE_STRING_INIT NULL
49 #define CO_OCTET_STRING_INIT NULL
50 #define CO_UNICODE_STRING_INIT NULL
51 #define CO_TIME_OF_DAY_INIT \
55 #define CO_TIME_DIFF_INIT CO_TIME_OF_DAY_INIT
56 #define CO_DOMAIN_INIT NULL
57 #define CO_INTEGER24_INIT 0
58 #define CO_REAL64_INIT 0
59 #define CO_INTEGER40_INIT 0
60 #define CO_INTEGER48_INIT 0
61 #define CO_INTEGER56_INIT 0
62 #define CO_INTEGER64_INIT 0
63 #define CO_UNSIGNED24_INIT 0
64 #define CO_UNSIGNED40_INIT 0
65 #define CO_UNSIGNED48_INIT 0
66 #define CO_UNSIGNED56_INIT 0
67 #define CO_UNSIGNED64_INIT 0
69 #define CO_VISIBLE_STRING_MIN NULL
70 #define CO_VISIBLE_STRING_MAX NULL
72 #define CO_OCTET_STRING_MIN NULL
73 #define CO_OCTET_STRING_MAX NULL
75 #define CO_UNICODE_STRING_MIN NULL
76 #define CO_UNICODE_STRING_MAX NULL
78 #define CO_DOMAIN_MIN NULL
79 #define CO_DOMAIN_MAX NULL
81 #define CO_ARRAY_OFFSET ALIGN(sizeof(size_t), _Alignof(union co_val))
83 static int co_array_alloc(
void *val,
size_t size);
84 static void co_array_free(
void *val);
85 static void co_array_init(
void *val,
size_t size);
86 static void co_array_fini(
void *val);
88 static size_t co_array_sizeof(
const void *val);
94 static size_t str16len(
const char16_t *s);
107 static char16_t *
str16ncpy(char16_t *dst,
const char16_t *src,
size_t n);
119 static int str16ncmp(
const char16_t *s1,
const char16_t *s2,
size_t n);
128 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
129 case CO_DEFTYPE_##a: \
130 u->c = (co_##b##_t)CO_##a##_INIT; \
132 #include <lely/co/def/type.def>
133 #undef LELY_CO_DEFINE_TYPE
145 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
146 case CO_DEFTYPE_##a: \
147 u->c = (co_##b##_t)CO_##a##_MIN; \
149 #include <lely/co/def/type.def>
150 #undef LELY_CO_DEFINE_TYPE
162 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \
163 case CO_DEFTYPE_##a: \
164 u->c = (co_##b##_t)CO_##a##_MAX; \
166 #include <lely/co/def/type.def>
167 #undef LELY_CO_DEFINE_TYPE
191 if (co_array_alloc(val, n + 1) == -1)
194 co_array_init(val, n);
196 strncpy(*val, vs, n);
210 if (co_array_alloc(val, n + 1) == -1)
213 co_array_init(val, n);
242 if (co_array_alloc(val, 2 * (n + 1)) == -1)
245 co_array_init(val, 2 * n);
261 if (co_array_alloc(val, n) == -1)
264 co_array_init(val, n);
266 memcpy(*val, dom, n);
302 ? co_array_sizeof(val)
308 co_val_make(co_unsigned16_t type,
void *val,
const void *ptr,
size_t n)
314 n = ptr ? strlen(ptr) : 0;
397 co_val_cmp(co_unsigned16_t type,
const void *v1,
const void *v2)
424 cmp = strncmp(p1, p2,
MIN(n1, n2));
427 cmp = memcmp(p1, p2,
MIN(n1, n2));
433 cmp = memcmp(p1, p2,
MIN(n1, n2));
440 cmp = (n1 > n2) - (n1 < n2);
443 const union co_val *u1 = v1;
444 const union co_val *u2 = v2;
455 cmp = uint16_cmp(&u1->t.days, &u2->t.days);
457 cmp = uint32_cmp(&u1->t.ms, &u2->t.ms);
460 cmp = uint16_cmp(&u1->td.days, &u2->td.days);
462 cmp = uint32_cmp(&u1->td.ms, &u2->td.ms);
481 co_val_read(co_unsigned16_t type,
void *val,
const uint_least8_t *begin,
482 const uint_least8_t *end)
484 assert(begin || begin == end);
485 assert(!end || end >= begin);
487 size_t n = end - begin;
507 char16_t *us = *(char16_t **)val;
509 for (
size_t i = 0; i + 1 < n; i += 2)
530 u->b = !!*(
const co_boolean_t *)begin;
536 u->i8 = *(
const co_integer8_t *)begin;
554 u->u8 = *(
const co_unsigned8_t *)begin;
572 u->r32 = ldle_flt32(begin);
580 & UINT32_C(0x0fffffff);
588 co_unsigned24_t u24 = 0;
589 for (
size_t i = 0; i < 3; i++)
590 u24 |= (co_unsigned24_t)*begin++
601 u->r64 = ldle_flt64(begin);
607 co_unsigned40_t u40 = 0;
608 for (
size_t i = 0; i < 5; i++)
609 u40 |= (co_unsigned40_t)*begin++
620 co_unsigned48_t u48 = 0;
621 for (
size_t i = 0; i < 6; i++)
622 u48 |= (co_unsigned48_t)*begin++
633 co_unsigned56_t u56 = 0;
634 for (
size_t i = 0; i < 7; i++)
635 u56 |= (co_unsigned56_t)*begin++
653 for (
size_t i = 0; i < 3; i++)
654 u->u24 |= (co_unsigned24_t)*begin++
663 for (
size_t i = 0; i < 5; i++)
664 u->u40 |= (co_unsigned40_t)*begin++
673 for (
size_t i = 0; i < 6; i++)
674 u->u48 |= (co_unsigned48_t)*begin++
683 for (
size_t i = 0; i < 7; i++)
684 u->u56 |= (co_unsigned56_t)*begin++
703 co_unsigned32_t ac = 0;
705 const uint_least8_t *begin = ptr;
706 const uint_least8_t *end = begin ? begin + n : NULL;
720 co_val_write(co_unsigned16_t type,
const void *val, uint_least8_t *begin,
730 if (begin && (!end || end - begin >= (ptrdiff_t)n)) {
733 memcpy(begin, ptr, n);
736 memcpy(begin, ptr, n);
739 const char16_t *us = ptr;
740 for (
size_t i = 0; i + 1 < n; i += 2)
752 const union co_val *u = val;
755 if (begin && (!end || end - begin >= 1))
756 *(co_boolean_t *)begin = !!u->b;
759 if (begin && (!end || end - begin >= 1))
760 *(co_integer8_t *)begin = u->i8;
763 if (begin && (!end || end - begin >= 2))
767 if (begin && (!end || end - begin >= 4))
771 if (begin && (!end || end - begin >= 1))
772 *(co_unsigned8_t *)begin = u->u8;
775 if (begin && (!end || end - begin >= 2))
779 if (begin && (!end || end - begin >= 4))
783 if (begin && (!end || end - begin >= 4))
784 stle_flt32(begin, u->r32);
788 if (begin && (!end || end - begin >= 6)) {
789 stle_u32(begin, u->t.ms & UINT32_C(0x0fffffff));
794 if (begin && (!end || end - begin >= 3)) {
795 co_unsigned24_t u24 = u->i24 < 0
797 : (co_unsigned24_t)u->i24;
798 for (
size_t i = 0; i < 3; i++)
799 *begin++ = (u24 >> 8 * i) & 0xff;
803 if (begin && (!end || end - begin >= 8))
804 stle_flt64(begin, u->r64);
807 if (begin && (!end || end - begin >= 5)) {
808 co_unsigned40_t u40 = u->i40 < 0
810 : (co_unsigned40_t)u->i40;
811 for (
size_t i = 0; i < 5; i++)
812 *begin++ = (u40 >> 8 * i) & 0xff;
816 if (begin && (!end || end - begin >= 6)) {
817 co_unsigned48_t u48 = u->i48 < 0
819 : (co_unsigned48_t)u->i48;
820 for (
size_t i = 0; i < 6; i++)
821 *begin++ = (u48 >> 8 * i) & 0xff;
825 if (begin && (!end || end - begin >= 7)) {
826 co_unsigned56_t u56 = u->i56 < 0
828 : (co_unsigned56_t)u->i56;
829 for (
size_t i = 0; i < 7; i++)
830 *begin++ = (u56 >> 8 * i) & 0xff;
834 if (begin && (!end || end - begin >= 8))
838 if (begin && (!end || end - begin >= 3)) {
839 for (
size_t i = 0; i < 3; i++)
840 *begin++ = (u->u24 >> 8 * i) & 0xff;
844 if (begin && (!end || end - begin >= 5)) {
845 for (
size_t i = 0; i < 5; i++)
846 *begin++ = (u->u40 >> 8 * i) & 0xff;
850 if (begin && (!end || end - begin >= 6)) {
851 for (
size_t i = 0; i < 6; i++)
852 *begin++ = (u->u48 >> 8 * i) & 0xff;
856 if (begin && (!end || end - begin >= 7)) {
857 for (
size_t i = 0; i < 7; i++)
858 *begin++ = (u->u56 >> 8 * i) & 0xff;
862 if (begin && (!end || end - begin >= 8))
871 co_val_lex(co_unsigned16_t type,
void *val,
const char *begin,
const char *end,
875 assert(!end || end >= begin);
881 const char *cp = begin;
894 "boolean truth value overflow");
897 *(co_boolean_t *)val = u.u8;
906 "8-bit signed integer underflow");
910 "8-bit signed integer overflow");
912 *(co_integer8_t *)val = u.i8;
921 "16-bit signed integer underflow");
923 && u.i16 == INT16_MAX)
925 "16-bit signed integer overflow");
927 *(co_integer16_t *)val = u.i16;
936 "32-bit signed integer underflow");
938 && u.i32 == INT32_MAX)
940 "32-bit signed integer overflow");
942 *(co_integer32_t *)val = u.i32;
951 "8-bit unsigned integer overflow");
953 *(co_unsigned8_t *)val = u.u8;
962 "16-bit unsigned integer overflow");
964 *(co_unsigned16_t *)val = u.u16;
973 "32-bit unsigned integer overflow");
975 *(co_unsigned32_t *)val = u.u32;
984 "32-bit unsigned integer overflow");
992 *(co_real32_t *)val = u.r32;
1001 "unable to create value of type VISIBLE_STRING");
1005 char *vs = *(
void **)val;
1018 "unable to create value of type OCTET_STRING");
1022 uint_least8_t *os = *(
void **)val;
1035 "unable to create value of type UNICODE_STRING");
1039 char16_t *us = *(
void **)val;
1042 for (
size_t i = 0; i + 1 < n; i += 2)
1043 us[i / 2] =
letoh16(us[i / 2]);
1054 cp +=
lex_ctype(&isblank, cp, end, NULL);
1060 *(co_time_of_day_t *)val = u.t;
1068 "unable to create value of type DOMAIN");
1071 void *dom = *(
void **)val;
1086 "24-bit signed integer underflow");
1091 "24-bit signed integer overflow");
1094 *(co_integer24_t *)val = u.i32;
1103 "64-bit unsigned integer overflow");
1111 *(co_real64_t *)val = u.r64;
1122 "40-bit signed integer underflow");
1127 "40-bit signed integer overflow");
1130 *(co_integer40_t *)val = u.i64;
1141 "48-bit signed integer underflow");
1146 "48-bit signed integer overflow");
1149 *(co_integer48_t *)val = u.i64;
1160 "56-bit signed integer underflow");
1165 "56-bit signed integer overflow");
1168 *(co_integer56_t *)val = u.i64;
1177 "64-bit signed integer underflow");
1179 && u.i64 == INT64_MAX)
1181 "64-bit signed integer overflow");
1183 *(co_integer64_t *)val = u.i64;
1194 "24-bit unsigned integer overflow");
1197 *(co_unsigned24_t *)val = u.u32;
1208 "40-bit unsigned integer overflow");
1211 *(co_unsigned40_t *)val = u.u64;
1222 "48-bit unsigned integer overflow");
1225 *(co_unsigned48_t *)val = u.u64;
1236 "56-bit unsigned integer overflow");
1239 *(co_unsigned56_t *)val = u.u64;
1248 "64-bit unsigned integer overflow");
1250 *(co_unsigned64_t *)val = u.u64;
1263 co_val_print(co_unsigned16_t type,
const void *val,
char **pbegin,
char *end)
1277 char16_t *us = NULL;
1281 for (
size_t i = 0; i + 1 < n; i += 2)
1282 us[i / 2] =
htole16(us[i / 2]);
1294 const union co_val *u = val;
1306 return print_fmt(pbegin, end,
"0x%02" PRIx8, u->u8);
1308 return print_fmt(pbegin, end,
"0x%04" PRIx16, u->u16);
1310 return print_fmt(pbegin, end,
"0x%08" PRIx32, u->u32);
1324 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1334 return print_fmt(pbegin, end,
"0x%06" PRIx32, u->u24);
1336 return print_fmt(pbegin, end,
"0x%010" PRIx64, u->u40);
1338 return print_fmt(pbegin, end,
"0x%012" PRIx64, u->u48);
1340 return print_fmt(pbegin, end,
"0x%014" PRIx64, u->u56);
1342 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1349 co_array_alloc(
void *val,
size_t size)
1355 char *ptr = calloc(1, CO_ARRAY_OFFSET + size);
1360 *(
char **)val = ptr + CO_ARRAY_OFFSET;
1362 *(
char **)val = NULL;
1369 co_array_free(
void *val)
1373 char *ptr = *(
char **)val;
1375 free(ptr - CO_ARRAY_OFFSET);
1379 co_array_init(
void *val,
size_t size)
1383 char *ptr = *(
char **)val;
1384 assert(!size || ptr);
1386 *(
size_t *)(ptr - CO_ARRAY_OFFSET) = size;
1390 co_array_fini(
void *val)
1394 *(
char **)val = NULL;
1398 co_array_sizeof(
const void *val)
1402 const char *ptr = *(
const char **)val;
1403 return ptr ? *(
const size_t *)(ptr - CO_ARRAY_OFFSET) : 0;
1409 const char16_t *cp = s;
1419 for (; n && *src; n--)
1431 while (n-- && !(result = *s1 - *s2++) && *s1++)
This header file is part of the utilities library; it contains the comparison function definitions.
This header file is part of the utilities library; it contains the diagnostic declarations.
size_t floc_lex(struct floc *at, const char *begin, const char *end)
Increments a file location by reading characters from a memory buffer.
void diag_if(enum diag_severity severity, int errc, const struct floc *at, const char *format,...)
Emits a diagnostic message occurring at a location in a text file.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
void stle_u64(uint_least8_t dst[8], uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
uint_least16_t htole16(uint_least16_t x)
Converts a 16-bit unsigned integer from host to little-endian byte order.
uint_least32_t ldle_u32(const uint_least8_t src[4])
Loads a 32-bit unsigned integer in little-endian byte order.
void stle_i64(uint_least8_t dst[8], int_least64_t x)
Stores a 64-bit signed integer in little-endian byte order.
int_least32_t ldle_i32(const uint_least8_t src[4])
Loads a 32-bit signed integer in little-endian byte order.
int_least16_t ldle_i16(const uint_least8_t src[2])
Loads a 16-bit signed integer in little-endian byte order.
int_least64_t ldle_i64(const uint_least8_t src[8])
Loads a 64-bit signed integer in little-endian byte order.
uint_least16_t ldle_u16(const uint_least8_t src[2])
Loads a 16-bit unsigned integer in little-endian byte order.
void stle_i16(uint_least8_t dst[2], int_least16_t x)
Stores a 16-bit signed integer in little-endian byte order.
uint_least64_t ldle_u64(const uint_least8_t src[8])
Loads a 64-bit unsigned integer in little-endian byte order.
void stle_i32(uint_least8_t dst[4], int_least32_t x)
Stores a 32-bit signed integer in little-endian byte order.
uint_least16_t letoh16(uint_least16_t x)
Converts a 16-bit unsigned integer from little-endian to host byte order.
void stle_u16(uint_least8_t dst[2], uint_least16_t x)
Stores a 16-bit unsigned integer in little-endian byte order.
void stle_u32(uint_least8_t dst[4], uint_least32_t x)
Stores a 32-bit unsigned integer in little-endian byte order.
@ ERRNUM_RANGE
Result too large.
@ ERRNUM_NOMEM
Not enough space.
@ ERRNUM_INVAL
Invalid argument.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
#define CO_SDO_AC_ERROR
SDO abort code: General error.
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
#define MIN(a, b)
Returns the minimum of a and b.
This header file is part of the utilities library; it contains the lexer function declarations.
size_t lex_c99_i16(const char *begin, const char *end, struct floc *at, int_least16_t *pi16)
Lexes a C99 int_least16_t from a memory buffer.
size_t lex_ctype(int(*ctype)(int), const char *begin, const char *end, struct floc *at)
Greedily lexes a sequence of characters of the specified class from a memory buffer.
size_t lex_c99_u8(const char *begin, const char *end, struct floc *at, uint_least8_t *pu8)
Lexes a C99 uint_least8_t from a memory buffer.
size_t lex_base64(const char *begin, const char *end, struct floc *at, void *ptr, size_t *pn)
Lexes and decodes the Base64 representation of binary data from a memory buffer.
size_t lex_c99_str(const char *begin, const char *end, struct floc *at, char *s, size_t *pn)
Lexes a UTF-8 encoded Unicode string from a memory buffer.
size_t lex_c99_i8(const char *begin, const char *end, struct floc *at, int_least8_t *pi8)
Lexes a C99 int_least8_t from a memory buffer.
size_t lex_c99_u32(const char *begin, const char *end, struct floc *at, uint_least32_t *pu32)
Lexes a C99 uint_least32_t from a memory buffer.
size_t lex_c99_u64(const char *begin, const char *end, struct floc *at, uint_least64_t *pu64)
Lexes a C99 uint_least64_t from a memory buffer.
size_t lex_c99_i32(const char *begin, const char *end, struct floc *at, int_least32_t *pi32)
Lexes a C99 int_least32_t from a memory buffer.
size_t lex_c99_u16(const char *begin, const char *end, struct floc *at, uint_least16_t *pu16)
Lexes a C99 uint_least16_t from a memory buffer.
size_t lex_c99_i64(const char *begin, const char *end, struct floc *at, int_least64_t *pi64)
Lexes a C99 int_least64_t from a memory buffer.
This header file is part of the utilities library; it contains the printing function declarations.
size_t print_c99_i8(char **pbegin, char *end, int_least8_t i8)
Prints a C99 int_least8_t to a memory buffer.
size_t print_c99_str(char **pbegin, char *end, const char *s, size_t n)
Prints a UTF-8 encoded Unicode string to a memory buffer.
size_t print_char(char **pbegin, char *end, int c)
Prints a single character to a memory buffer.
size_t print_c99_u8(char **pbegin, char *end, uint_least8_t u8)
Prints a C99 uint_least8_t to a memory buffer.
size_t print_c99_i32(char **pbegin, char *end, int_least32_t i32)
Prints a C99 int_least32_t to a memory buffer.
size_t print_c99_u32(char **pbegin, char *end, uint_least32_t u32)
Prints a C99 uint_least32_t to a memory buffer.
size_t print_base64(char **pbegin, char *end, const void *ptr, size_t n)
Prints the Base64 representation of binary data to a memory buffer.
size_t print_c99_i16(char **pbegin, char *end, int_least16_t i16)
Prints a C99 int_least16_t to a memory buffer.
size_t print_c99_i64(char **pbegin, char *end, int_least64_t i64)
Prints a C99 int_least64_t to a memory buffer.
size_t print_c99_u16(char **pbegin, char *end, uint_least16_t u16)
Prints a C99 uint_least16_t to a memory buffer.
size_t print_fmt(char **pbegin, char *end, const char *format,...)
Prints a formatted string to a memory buffer.
This is the internal header file of the CANopen library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
This header file is part of the C11 and POSIX compatibility library; it includes <string....
A location in a text file.
#define CO_DEFTYPE_UNICODE_STRING
The data type (and object index) of an array of (16-bit) Unicode characters.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
#define CO_DEFTYPE_INTEGER24
The data type (and object index) of a 24-bit signed integer.
#define CO_DEFTYPE_UNSIGNED48
The data type (and object index) of a 48-bit unsigned integer.
#define CO_DEFTYPE_INTEGER48
The data type (and object index) of a 48-bit signed integer.
#define CO_DEFTYPE_VISIBLE_STRING
The data type (and object index) of an array of visible characters.
#define CO_DEFTYPE_UNSIGNED40
The data type (and object index) of a 40-bit unsigned integer.
int co_type_is_array(co_unsigned16_t type)
Returns 1 if the specified (static) data type is an array, and 0 if not.
#define CO_DEFTYPE_INTEGER56
The data type (and object index) of a 56-bit signed integer.
#define CO_DEFTYPE_UNSIGNED64
The data type (and object index) of a 64-bit unsigned integer.
#define CO_DEFTYPE_INTEGER8
The data type (and object index) of an 8-bit signed integer.
#define CO_DEFTYPE_DOMAIN
The data type (and object index) of an arbitrary large block of data.
#define CO_DEFTYPE_UNSIGNED24
The data type (and object index) of a 24-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_REAL64
The data type (and object index) of a 64-bit IEEE-754 floating-point number.
#define CO_DEFTYPE_BOOLEAN
The data type (and object index) of a boolean truth value.
#define CO_DEFTYPE_INTEGER40
The data type (and object index) of a 40-bit signed integer.
#define CO_DEFTYPE_TIME_OF_DAY
The data type (and object index) of a 48-bit structure representing the absolute time.
size_t co_type_sizeof(co_unsigned16_t type)
Returns the native size (in bytes) of a value of the specified data type, or 0 if it is not a static ...
#define CO_DEFTYPE_INTEGER32
The data type (and object index) of a 32-bit signed integer.
#define CO_DEFTYPE_INTEGER64
The data type (and object index) of a 64-bit signed integer.
#define CO_DEFTYPE_UNSIGNED56
The data type (and object index) of a 56-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
#define CO_DEFTYPE_INTEGER16
The data type (and object index) of a 16-bit signed integer.
#define CO_DEFTYPE_OCTET_STRING
The data type (and object index) of an array of octets.
#define CO_DEFTYPE_REAL32
The data type (and object index) of a 32-bit IEEE-754 floating-point number.
#define CO_DEFTYPE_TIME_DIFF
The data type (and object index) of a 48-bit structure representing a time difference.
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types....
A union of the CANopen static data types.
size_t co_val_read(co_unsigned16_t type, void *val, const uint_least8_t *begin, const uint_least8_t *end)
Reads a value of the specified data type from a memory buffer.
int co_val_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
size_t co_val_move(co_unsigned16_t type, void *dst, void *src)
Moves one value to another.
static size_t str16len(const char16_t *s)
Returns the number of (16-bit) Unicode characters, excluding the terminating null bytes,...
static char16_t * str16ncpy(char16_t *dst, const char16_t *src, size_t n)
Copies at most n (16-bit) Unicode characters from the string at src to dst.
int co_val_init_os(uint_least8_t **val, const uint_least8_t *os, size_t n)
Initializes an array of octets (CO_DEFTYPE_OCTET_STRING).
size_t co_val_write(co_unsigned16_t type, const void *val, uint_least8_t *begin, uint_least8_t *end)
Writes a value of the specified data type to a memory buffer.
int co_val_init_dom(void **val, const void *dom, size_t n)
Initializes an arbitrary large block of data (CO_DEFTYPE_DOMAIN).
const void * co_val_addressof(co_unsigned16_t type, const void *val)
Returns the address of the first byte in a value of the specified data type.
static int str16ncmp(const char16_t *s1, const char16_t *s2, size_t n)
Compares two (16-bit) Unicode strings.
size_t co_val_copy(co_unsigned16_t type, void *dst, const void *src)
Copies one value to another.
size_t co_val_sizeof(co_unsigned16_t type, const void *val)
Returns the size (in bytes) of a value of the specified data type.
int co_val_init_us_n(char16_t **val, const char16_t *us, size_t n)
Initializes an array of (16-bit) Unicode characters (CO_DEFTYPE_UNICODE_STRING).
int co_val_init_vs_n(char **val, const char *vs, size_t n)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
int co_val_init_us(char16_t **val, const char16_t *us)
Initializes an array of (16-bit) Unicode characters (CO_DEFTYPE_UNICODE_STRING).
int co_val_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.
co_unsigned32_t co_val_read_sdo(co_unsigned16_t type, void *val, const void *ptr, size_t n)
Reads a value of the specified data type from an SDO buffer.
int co_val_init_min(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its lower limit.
size_t co_val_print(co_unsigned16_t type, const void *val, char **pbegin, char *end)
Prints a value of the specified data type to a memory buffer.
size_t co_val_make(co_unsigned16_t type, void *val, const void *ptr, size_t n)
Constructs a value of the specified data type.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
int co_val_init_vs(char **val, const char *vs)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
size_t co_val_lex(co_unsigned16_t type, void *val, const char *begin, const char *end, struct floc *at)
Lexes a value of the specified data type from a memory buffer.
int co_val_init_max(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its upper limit.
This header file is part of the CANopen library; it contains the CANopen value declarations.
#define CO_INTEGER24_MAX
The maximum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_INTEGER48_MAX
The maximum value of a 48-bit signed integer (encoded as an int64_t).
#define CO_INTEGER24_MIN
The minimum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_BOOLEAN_MAX
The maximum value of a boolean truth value (true).
#define CO_INTEGER40_MAX
The maximum value of a 40-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED40_MAX
The maximum value of a 40-bit unsigned integer (encoded as a uint64_t).
#define CO_UNSIGNED56_MAX
The maximum value of a 56-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER48_MIN
The minimum value of a 48-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED48_MAX
The maximum value of a 48-bit unsigned integer (encoded as a uint64_t).
#define CO_INTEGER56_MAX
The maximum value of a 56-bit signed integer (encoded as an int64_t).
#define CO_INTEGER40_MIN
The minimum value of a 40-bit signed integer (encoded as an int64_t).
#define CO_UNSIGNED24_MAX
The maximum value of a 24-bit unsigned integer (encoded as a uint32_t).
#define CO_INTEGER56_MIN
The minimum value of a 56-bit signed integer (encoded as an int64_t).