38 #define CO_BOOLEAN_INIT 0 39 #define CO_INTEGER8_INIT 0 40 #define CO_INTEGER16_INIT 0 41 #define CO_INTEGER32_INIT 0 42 #define CO_UNSIGNED8_INIT 0 43 #define CO_UNSIGNED16_INIT 0 44 #define CO_UNSIGNED32_INIT 0 45 #define CO_REAL32_INIT 0 46 #define CO_VISIBLE_STRING_INIT NULL 47 #define CO_OCTET_STRING_INIT NULL 48 #define CO_UNICODE_STRING_INIT NULL 49 #define CO_TIME_OF_DAY_INIT \ 53 #define CO_TIME_DIFF_INIT CO_TIME_OF_DAY_INIT 54 #define CO_DOMAIN_INIT NULL 55 #define CO_INTEGER24_INIT 0 56 #define CO_REAL64_INIT 0 57 #define CO_INTEGER40_INIT 0 58 #define CO_INTEGER48_INIT 0 59 #define CO_INTEGER56_INIT 0 60 #define CO_INTEGER64_INIT 0 61 #define CO_UNSIGNED24_INIT 0 62 #define CO_UNSIGNED40_INIT 0 63 #define CO_UNSIGNED48_INIT 0 64 #define CO_UNSIGNED56_INIT 0 65 #define CO_UNSIGNED64_INIT 0 67 #define CO_VISIBLE_STRING_MIN NULL 68 #define CO_VISIBLE_STRING_MAX NULL 70 #define CO_OCTET_STRING_MIN NULL 71 #define CO_OCTET_STRING_MAX NULL 73 #define CO_UNICODE_STRING_MIN NULL 74 #define CO_UNICODE_STRING_MAX NULL 76 #define CO_DOMAIN_MIN NULL 77 #define CO_DOMAIN_MAX NULL 79 #define CO_ARRAY_OFFSET ALIGN(sizeof(size_t), _Alignof(union co_val)) 81 static int co_array_alloc(
void *val,
size_t size);
82 static void co_array_free(
void *val);
83 static void co_array_init(
void *val,
size_t size);
84 static void co_array_fini(
void *val);
86 static size_t co_array_sizeof(
const void *val);
92 static size_t str16len(
const char16_t *s);
105 static char16_t *
str16ncpy(char16_t *dst,
const char16_t *src,
size_t n);
117 static int str16ncmp(
const char16_t *s1,
const char16_t *s2,
size_t n);
126 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \ 127 case CO_DEFTYPE_##a: \ 128 u->c = (co_##b##_t)CO_##a##_INIT; \ 130 #include <lely/co/def/type.def> 131 #undef LELY_CO_DEFINE_TYPE 143 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \ 144 case CO_DEFTYPE_##a: \ 145 u->c = (co_##b##_t)CO_##a##_MIN; \ 147 #include <lely/co/def/type.def> 148 #undef LELY_CO_DEFINE_TYPE 160 #define LELY_CO_DEFINE_TYPE(a, b, c, d) \ 161 case CO_DEFTYPE_##a: \ 162 u->c = (co_##b##_t)CO_##a##_MAX; \ 164 #include <lely/co/def/type.def> 165 #undef LELY_CO_DEFINE_TYPE 189 if (
__unlikely(co_array_alloc(val, n + 1) == -1))
192 co_array_init(val, n);
194 strncpy(*val, vs, n);
208 if (
__unlikely(co_array_alloc(val, n + 1) == -1))
211 co_array_init(val, n);
240 if (
__unlikely(co_array_alloc(val, 2 * (n + 1)) == -1))
243 co_array_init(val, 2 * n);
262 co_array_init(val, n);
264 memcpy(*val, dom, n);
300 ? co_array_sizeof(val)
306 co_val_make(co_unsigned16_t type,
void *val,
const void *ptr,
size_t n)
315 n = ptr ? strlen(ptr) : 0;
386 co_val_cmp(co_unsigned16_t type,
const void *v1,
const void *v2)
413 cmp = strncmp(p1, p2,
MIN(n1, n2));
416 cmp = memcmp(p1, p2,
MIN(n1, n2));
422 cmp = memcmp(p1, p2,
MIN(n1, n2));
429 cmp = (n1 > n2) - (n1 < n2);
432 const union co_val *u1 = v1;
433 const union co_val *u2 = v2;
444 cmp = uint32_cmp(&u1->t.ms, &u2->t.ms);
446 cmp = uint16_cmp(&u1->t.days, &u2->t.days);
449 cmp = uint32_cmp(&u1->td.ms, &u2->td.ms);
451 cmp = uint16_cmp(&u1->td.days, &u2->td.days);
470 co_val_read(co_unsigned16_t type,
void *val,
const uint8_t *begin,
473 assert(begin || begin == end);
474 assert(!end || end >= begin);
476 size_t n = end - begin;
484 (
const char *)begin, n) == -1))
502 char16_t *us = *(char16_t **)val;
504 for (
size_t i = 0; i + 1 < n; i += 2)
528 u->b = !!*(
const co_boolean_t *)begin;
534 u->i8 = *(
const co_integer8_t *)begin;
552 u->u8 = *(
const co_unsigned8_t *)begin;
570 u->r32 = ldle_flt32(begin);
578 & UINT32_C(0x0fffffff);
586 co_unsigned24_t u24 = 0;
587 for (
size_t i = 0; i < 3; i++)
588 u24 |= (co_unsigned24_t)*begin++
599 u->r64 = ldle_flt64(begin);
605 co_unsigned40_t u40 = 0;
606 for (
size_t i = 0; i < 5; i++)
607 u40 |= (co_unsigned40_t)*begin++
618 co_unsigned48_t u48 = 0;
619 for (
size_t i = 0; i < 6; i++)
620 u48 |= (co_unsigned48_t)*begin++
631 co_unsigned56_t u56 = 0;
632 for (
size_t i = 0; i < 7; i++)
633 u56 |= (co_unsigned56_t)*begin++
651 for (
size_t i = 0; i < 3; i++)
652 u->u24 |= (co_unsigned24_t)*begin++
661 for (
size_t i = 0; i < 5; i++)
662 u->u40 |= (co_unsigned40_t)*begin++
671 for (
size_t i = 0; i < 6; i++)
672 u->u48 |= (co_unsigned48_t)*begin++
681 for (
size_t i = 0; i < 7; i++)
682 u->u56 |= (co_unsigned56_t)*begin++
701 co_unsigned32_t ac = 0;
703 const uint8_t *begin = ptr;
704 const uint8_t *end = begin ? begin + n : NULL;
728 if (begin && (!end || end - begin >= (ptrdiff_t)n)) {
731 memcpy(begin, ptr, n);
734 memcpy(begin, ptr, n);
737 const char16_t *us = ptr;
738 for (
size_t i = 0; i + 1 < n; i += 2)
750 const union co_val *u = val;
753 if (begin && (!end || end - begin >= 1))
754 *(co_boolean_t *)begin = !!u->b;
757 if (begin && (!end || end - begin >= 1))
758 *(co_integer8_t *)begin = u->i8;
761 if (begin && (!end || end - begin >= 2))
765 if (begin && (!end || end - begin >= 4))
769 if (begin && (!end || end - begin >= 1))
770 *(co_unsigned8_t *)begin = u->u8;
773 if (begin && (!end || end - begin >= 2))
777 if (begin && (!end || end - begin >= 4))
781 if (begin && (!end || end - begin >= 4))
782 stle_flt32(begin, u->r32);
786 if (begin && (!end || end - begin >= 6)) {
787 stle_u32(begin, u->t.ms & UINT32_C(0x0fffffff));
792 if (begin && (!end || end - begin >= 3)) {
793 co_unsigned24_t u24 = u->i24 < 0
795 : (co_unsigned24_t)u->i24;
796 for (
size_t i = 0; i < 3; i++)
797 *begin++ = (u24 >> 8 * i) & 0xff;
801 if (begin && (!end || end - begin >= 8))
802 stle_flt64(begin, u->r64);
805 if (begin && (!end || end - begin >= 5)) {
806 co_unsigned40_t u40 = u->i40 < 0
808 : (co_unsigned40_t)u->i40;
809 for (
size_t i = 0; i < 5; i++)
810 *begin++ = (u40 >> 8 * i) & 0xff;
814 if (begin && (!end || end - begin >= 6)) {
815 co_unsigned48_t u48 = u->i48 < 0
817 : (co_unsigned48_t)u->i48;
818 for (
size_t i = 0; i < 6; i++)
819 *begin++ = (u48 >> 8 * i) & 0xff;
823 if (begin && (!end || end - begin >= 7)) {
824 co_unsigned56_t u56 = u->i56 < 0
826 : (co_unsigned56_t)u->i56;
827 for (
size_t i = 0; i < 7; i++)
828 *begin++ = (u56 >> 8 * i) & 0xff;
832 if (begin && (!end || end - begin >= 8))
836 if (begin && (!end || end - begin >= 3)) {
837 for (
size_t i = 0; i < 3; i++)
838 *begin++ = (u->u24 >> 8 * i) & 0xff;
842 if (begin && (!end || end - begin >= 5)) {
843 for (
size_t i = 0; i < 5; i++)
844 *begin++ = (u->u40 >> 8 * i) & 0xff;
848 if (begin && (!end || end - begin >= 6)) {
849 for (
size_t i = 0; i < 6; i++)
850 *begin++ = (u->u48 >> 8 * i) & 0xff;
854 if (begin && (!end || end - begin >= 7)) {
855 for (
size_t i = 0; i < 7; i++)
856 *begin++ = (u->u56 >> 8 * i) & 0xff;
860 if (begin && (!end || end - begin >= 8))
869 co_val_lex(co_unsigned16_t type,
void *val,
const char *begin,
const char *end,
873 assert(!end || end >= begin);
879 const char *cp = begin;
892 "boolean truth value overflow");
895 *(co_boolean_t *)val = u.u8;
904 && u.i8 == INT8_MIN))
907 "8-bit signed integer underflow");
910 && u.i8 == INT8_MAX))
913 "8-bit signed integer overflow");
915 *(co_integer8_t *)val = u.i8;
924 && u.i16 == INT16_MIN))
927 "16-bit signed integer underflow");
930 && u.i16 == INT16_MAX))
933 "16-bit signed integer overflow");
935 *(co_integer16_t *)val = u.i16;
944 && u.i32 == INT32_MIN))
947 "32-bit signed integer underflow");
950 && u.i32 == INT32_MAX))
953 "32-bit signed integer overflow");
955 *(co_integer32_t *)val = u.i32;
964 && u.u8 == UINT8_MAX))
967 "8-bit unsigned integer overflow");
969 *(co_unsigned8_t *)val = u.u8;
978 && u.u16 == UINT16_MAX))
981 "16-bit unsigned integer overflow");
983 *(co_unsigned16_t *)val = u.u16;
992 && u.u32 == UINT32_MAX))
995 "32-bit unsigned integer overflow");
997 *(co_unsigned32_t *)val = u.u32;
1006 && u.u32 == UINT32_MAX))
1009 "32-bit unsigned integer overflow");
1017 *(co_real32_t *)val = u.r32;
1026 "unable to create value of type VISIBLE_STRING");
1030 char *vs = *(
void **)val;
1039 while ((!end || cp + chars < end)
1040 && isxdigit((
unsigned char)cp[chars]))
1045 (chars + 1) / 2) == -1)) {
1048 "unable to create value of type OCTET_STRING");
1052 uint8_t *os = *(
void **)val;
1054 for (
size_t i = 0; i < chars; i++) {
1057 *os++ |=
ctox(cp[i]) & 0xf;
1059 *os =
ctox(cp[i]) & 0xf;
1075 "unable to create value of type UNICODE_STRING");
1079 char16_t *us = *(
void **)val;
1082 for (
size_t i = 0; i + 1 < n; i += 2)
1083 us[i / 2] =
letoh16(us[i / 2]);
1094 cp +=
lex_ctype(&isblank, cp, end, NULL);
1100 *(co_time_of_day_t *)val = u.t;
1108 "unable to create value of type DOMAIN");
1111 void *dom = *(
void **)val;
1126 "24-bit signed integer underflow");
1131 "24-bit signed integer overflow");
1134 *(co_integer24_t *)val = u.i32;
1143 && u.u64 == UINT64_MAX))
1146 "64-bit unsigned integer overflow");
1154 *(co_real64_t *)val = u.r64;
1165 "40-bit signed integer underflow");
1170 "40-bit signed integer overflow");
1173 *(co_integer40_t *)val = u.i64;
1184 "48-bit signed integer underflow");
1189 "48-bit signed integer overflow");
1192 *(co_integer48_t *)val = u.i64;
1203 "56-bit signed integer underflow");
1208 "56-bit signed integer overflow");
1211 *(co_integer56_t *)val = u.i64;
1220 && u.i64 == INT64_MIN))
1223 "64-bit signed integer underflow");
1226 && u.i64 == INT64_MAX))
1229 "64-bit signed integer overflow");
1231 *(co_integer64_t *)val = u.i64;
1242 "24-bit unsigned integer overflow");
1245 *(co_unsigned24_t *)val = u.u32;
1256 "40-bit unsigned integer overflow");
1259 *(co_unsigned40_t *)val = u.u64;
1270 "48-bit unsigned integer overflow");
1273 *(co_unsigned48_t *)val = u.u64;
1284 "56-bit unsigned integer overflow");
1287 *(co_unsigned56_t *)val = u.u64;
1296 && u.u64 == UINT64_MAX))
1299 "64-bit unsigned integer overflow");
1301 *(co_unsigned64_t *)val = u.u64;
1314 co_val_print(co_unsigned16_t type,
const void *val,
char **pbegin,
char *end)
1326 for (
const uint8_t *os = ptr; n; n--, os++) {
1328 pbegin, end,
xtoc(*os >> 4));
1334 char16_t *us = NULL;
1338 for (
size_t i = 0; i + 1 < n; i += 2)
1339 us[i / 2] =
htole16(us[i / 2]);
1351 const union co_val *u = val;
1363 return print_fmt(pbegin, end,
"0x%02" PRIx8, u->u8);
1365 return print_fmt(pbegin, end,
"0x%04" PRIx16, u->u16);
1367 return print_fmt(pbegin, end,
"0x%08" PRIx32, u->u32);
1381 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1391 return print_fmt(pbegin, end,
"0x%06" PRIx32, u->u24);
1393 return print_fmt(pbegin, end,
"0x%010" PRIx64, u->u40);
1395 return print_fmt(pbegin, end,
"0x%012" PRIx64, u->u48);
1397 return print_fmt(pbegin, end,
"0x%014" PRIx64, u->u56);
1399 return print_fmt(pbegin, end,
"0x%016" PRIx64, u->u64);
1406 co_array_alloc(
void *val,
size_t size)
1411 char *ptr = calloc(1, CO_ARRAY_OFFSET + size);
1416 *(
char **)val = ptr + CO_ARRAY_OFFSET;
1418 *(
char **)val = NULL;
1425 co_array_free(
void *val)
1429 char *ptr = *(
char **)val;
1431 free(ptr - CO_ARRAY_OFFSET);
1435 co_array_init(
void *val,
size_t size)
1439 char *ptr = *(
char **)val;
1440 assert(!size || ptr);
1442 *(
size_t *)(ptr - CO_ARRAY_OFFSET) = size;
1446 co_array_fini(
void *val)
1450 *(
char **)val = NULL;
1454 co_array_sizeof(
const void *val)
1458 const char *ptr = *(
const char **)val;
1459 return ptr ? *(
const size_t *)(ptr - CO_ARRAY_OFFSET) : 0;
1465 const char16_t *cp = s;
1475 for (; n && *src; n--)
1487 while (n-- && !(result = *s1 - *s2++) && *s1++)
uint_least16_t htole16(uint_least16_t x)
Converts a 16-bit unsigned integer from host to little-endian byte order.
void stle_u32(void *ptr, uint_least32_t x)
Stores a 32-bit unsigned integer in little-endian byte order.
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.
#define CO_INTEGER56_MAX
The maximum value of a 56-bit signed integer (encoded as an int64_t).
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_UNSIGNED56
The data type (and object index) of a 56-bit unsigned integer.
void stle_u64(void *ptr, uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
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.
#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 <string.h> and defines any missing functionality.
#define CO_INTEGER48_MAX
The maximum value of a 48-bit signed integer (encoded as an int64_t).
int co_val_init_us(char16_t **val, const char16_t *us)
Initializes an array of (16-bit) Unicode characters (CO_DEFTYPE_UNICODE_STRING).
#define CO_DEFTYPE_VISIBLE_STRING
The data type (and object index) of an array of visible characters.
uint_least64_t ldle_u64(const void *ptr)
Loads a 64-bit unsigned integer in little-endian byte order.
#define CO_DEFTYPE_DOMAIN
The data type (and object index) of an arbitrary large block of data.
A location in a text file.
This header file is part of the utilities library; it contains the comparison function definitions...
int co_val_init_vs(char **val, const char *vs)
Initializes an array of visible characters (CO_DEFTYPE_VISIBLE_STRING).
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.
#define CO_DEFTYPE_INTEGER24
The data type (and object index) of a 24-bit signed integer.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
int_least32_t ldle_i32(const void *ptr)
Loads a 32-bit signed integer in little-endian byte order.
size_t print_char(char **pbegin, char *end, int c)
Prints a single character to a memory buffer.
A union of the CANopen static data types.
#define CO_DEFTYPE_INTEGER48
The data type (and object index) of a 48-bit signed integer.
size_t print_c99_u8(char **pbegin, char *end, uint_least8_t u8)
Prints a C99 uint_least8_t to a memory buffer.
int co_val_cmp(co_unsigned16_t type, const void *v1, const void *v2)
Compares two values of the specified data type.
uint_least16_t ldle_u16(const void *ptr)
Loads a 16-bit unsigned integer in little-endian byte order.
#define CO_SDO_AC_ERROR
SDO abort code: General error.
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).
#define CO_DEFTYPE_UNSIGNED48
The data type (and object index) of a 48-bit unsigned integer.
#define MIN(a, b)
Returns the minimum of a and b.
size_t co_val_copy(co_unsigned16_t type, void *dst, const void *src)
Copies one value to another.
#define CO_UNSIGNED56_MAX
The maximum value of a 56-bit unsigned integer (encoded as a uint64_t).
int co_type_is_array(co_unsigned16_t type)
Returns 1 if the specified (static) data type is an array, and 0 if not.
static size_t str16len(const char16_t *s)
Returns the number of (16-bit) Unicode characters, excluding the terminating null bytes...
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
size_t co_val_write(co_unsigned16_t type, const void *val, uint8_t *begin, uint8_t *end)
Writes a value of the specified data type to 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.
This header file is part of the CANopen library; it contains the CANopen value declarations.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
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.
#define CO_INTEGER40_MAX
The maximum value of a 40-bit signed integer (encoded as an int64_t).
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 co_val_read(co_unsigned16_t type, void *val, const uint8_t *begin, const uint8_t *end)
Reads a value of the specified data type from a memory buffer.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED24
The data type (and object index) of a 24-bit unsigned integer.
size_t co_val_move(co_unsigned16_t type, void *dst, void *src)
Moves one value to another.
#define CO_DEFTYPE_INTEGER64
The data type (and object index) of a 64-bit signed integer.
#define CO_UNSIGNED24_MAX
The maximum value of a 24-bit unsigned integer (encoded as a uint32_t).
#define CO_DEFTYPE_REAL32
The data type (and object index) of a 32-bit IEEE-754 floating-point number.
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.
#define CO_DEFTYPE_INTEGER8
The data type (and object index) of an 8-bit signed integer.
size_t print_c99_u32(char **pbegin, char *end, uint_least32_t u32)
Prints a C99 uint_least32_t to a memory buffer.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
This is the internal header file of the CANopen library.
void stle_i32(void *ptr, int_least32_t x)
Stores a 32-bit signed integer in little-endian byte order.
#define CO_INTEGER40_MIN
The minimum value of a 40-bit signed integer (encoded as an int64_t).
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.
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.
#define CO_DEFTYPE_UNICODE_STRING
The data type (and object index) of an array of (16-bit) Unicode characters.
This header file is part of the utilities library; it contains the lexer function declarations...
#define CO_DEFTYPE_TIME_OF_DAY
The data type (and object index) of a 48-bit structure representing the absolute time.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
void stle_i16(void *ptr, int_least16_t x)
Stores a 16-bit signed integer in little-endian byte order.
int co_val_init_dom(void **val, const void *dom, size_t n)
Initializes an arbitrary large block of data (CO_DEFTYPE_DOMAIN).
size_t floc_lex(struct floc *at, const char *begin, const char *end)
Increments a file location by reading characters from a memory buffer.
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
#define CO_DEFTYPE_UNSIGNED40
The data type (and object index) of a 40-bit unsigned integer.
size_t print_c99_i64(char **pbegin, char *end, int_least64_t i64)
Prints a C99 int_least64_t to a memory buffer.
void stle_u16(void *ptr, uint_least16_t x)
Stores a 16-bit unsigned integer in little-endian byte order.
int co_val_init(co_unsigned16_t type, void *val)
Initializes a value of the specified data type to zero.
#define CO_UNSIGNED48_MAX
The maximum value of a 48-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).
int co_val_init_os(uint8_t **val, const uint8_t *os, size_t n)
Initializes an array of octets (CO_DEFTYPE_OCTET_STRING).
#define CO_INTEGER24_MIN
The minimum value of a 24-bit signed integer (encoded as an int32_t).
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.
static int str16ncmp(const char16_t *s1, const char16_t *s2, size_t n)
Compares two (16-bit) Unicode strings.
#define CO_DEFTYPE_INTEGER16
The data type (and object index) of a 16-bit signed integer.
int xtoc(int i)
Returns the character corresponding to the hexadecimal digit i.
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.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
This header file is part of the utilities library; it contains the diagnostic declarations.
#define __unlikely(x)
Indicates to the compiler that the expression is most-likely false.
#define CO_DEFTYPE_INTEGER56
The data type (and object index) of a 56-bit signed integer.
#define CO_INTEGER56_MIN
The minimum value of a 56-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).
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_u16(char **pbegin, char *end, uint_least16_t u16)
Prints a C99 uint_least16_t to a memory buffer.
int_least16_t ldle_i16(const void *ptr)
Loads a 16-bit signed integer in little-endian byte order.
#define CO_DEFTYPE_OCTET_STRING
The data type (and object index) of an array of octets.
void co_val_fini(co_unsigned16_t type, void *val)
Finalizes a value of the specified data type.
uint_least16_t letoh16(uint_least16_t x)
Converts a 16-bit unsigned integer from little-endian to host byte order.
#define CO_INTEGER24_MAX
The maximum value of a 24-bit signed integer (encoded as an int32_t).
#define CO_DEFTYPE_UNSIGNED64
The data type (and object index) of a 64-bit unsigned integer.
This header file is part of the utilities library; it contains the printing function declarations...
size_t print_fmt(char **pbegin, char *end, const char *format,...)
Prints a formatted string to a memory buffer.
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 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.
#define CO_SDO_AC_NO_MEM
SDO abort code: Out of memory.
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
#define CO_DEFTYPE_REAL64
The data type (and object index) of a 64-bit IEEE-754 floating-point number.
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 stle_i64(void *ptr, int_least64_t x)
Stores a 64-bit signed integer in little-endian byte order.
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.
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 print_c99_i16(char **pbegin, char *end, int_least16_t i16)
Prints a C99 int_least16_t to a memory buffer.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib.h> and defines any missing functionality.
size_t print_c99_i8(char **pbegin, char *end, int_least8_t i8)
Prints a C99 int_least8_t to a memory buffer.
#define CO_DEFTYPE_INTEGER32
The data type (and object index) of a 32-bit signed integer.
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.
int co_val_init_max(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its upper limit.
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.
#define CO_DEFTYPE_INTEGER40
The data type (and object index) of a 40-bit signed integer.
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.
int ctox(int c)
Returns the hexadecimal digit corresponding to the character c.
size_t lex_base64(const char *begin, const char *end, struct floc *at, void *ptr, size_t *pn)
Lexwes and decodes the Base64 representation of binary data from a memory buffer. ...
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_least64_t ldle_i64(const void *ptr)
Loads a 64-bit signed integer in little-endian byte order.
uint_least32_t ldle_u32(const void *ptr)
Loads a 32-bit unsigned integer in little-endian byte order.
int co_val_init_min(co_unsigned16_t type, void *val)
Initializes a value of the specified data type with its lower limit.
#define CO_BOOLEAN_MAX
The maximum value of a boolean truth value (true).
#define CO_DEFTYPE_BOOLEAN
The data type (and object index) of a boolean truth value.
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.