Common data types

Data types used throughout the library and related generic utilities and defintions.

Summary
Common data typesData types used throughout the library and related generic utilities and defintions.
Macros
NACORE_EUNKNOWNError code for unknown errors.
NACORE_LIBC_SIZE_FORMAT_LMLength modifier for size_t to be used with printf()-like functions of the platform’s standard C library.
NACORE_LIBC_SIZE_FORMAT_TYPEType from/to which size_t values can be safely casted.
Types
nacore_get_size_cbA function that returns the size of some value.
nacore_cmp_cbA function that compares two values.
nacore_to_string_cbA function that retuns a textual description of some value.
nacore_filter_cbA function that decides whether a certain value should be filtered out or not.
nacore_op_cbA function that performs some operation on a value.
Functions
nacore_ptr_cmp()Pointer comparison function.

Macros

NACORE_EUNKNOWN

Error code for unknown errors.

Its value should not overlap with errno.h error codes.

NACORE_LIBC_SIZE_FORMAT_LM

Length modifier for size_t to be used with printf()-like functions of the platform’s standard C library.

This is not needed for NASPRO core printf()-like functions, since those understand the z length modifier correctly.

See also NACORE_LIBC_SIZE_FORMAT_TYPE.

Available since NASPRO core 0.2.91, API 3.1.0.

NACORE_LIBC_SIZE_FORMAT_TYPE

Type from/to which size_t values can be safely casted.

This is mainly meant to be used in conjuction with NACORE_LIBC_SIZE_FORMAT_LM.

Example

size_t val = 0x12341234;

printf("The value of val is: %" NACORE_LIBC_FORMAT_LM "u\n",
       (NACORE_LIBC_SIZE_FORMAT_TYPE)val);

Available since NASPRO core 0.2.91, API 3.1.0.

Types

nacore_get_size_cb

typedef size_t (*nacore_get_size_cb)(const void *value, void *opaque)

A function that returns the size of some value.

Parameters

valueValue pointer.
opaqueExtra opaque data pointer or NULL.

Returns

Size of value as number of bytes.

nacore_cmp_cb

typedef int (*nacore_cmp_cb)(const void *v1, const void *v2, void *opaque)

A function that compares two values.

Parameters

v1First value.
v2Second value.
opaqueExtra opaque data pointer or NULL.

Returns

A strictly negative value if v1 < v2, 0 if v1 = v2, a strictly positive value if v1 > v2.

nacore_to_string_cb

typedef char * (*nacore_to_string_cb)(const void *value, void *opaque)

A function that retuns a textual description of some value.

Parameters

valueValue pointer.
opaqueExtra opaque data pointer or NULL.

Returns

A malloc()-allocated string containing a textual description of value.  The caller is in charge of free()ing such string.  If there was not enough memory, the function should return NULL.

nacore_filter_cb

typedef char (*nacore_filter_cb)(const void *value, void *opaque)

A function that decides whether a certain value should be filtered out or not.

Parameters

valuePointer to the value to be examined.
opaqueExtra opaque data pointer or NULL.

Returns

0 if the value has to be filtered out, non-0 otherwise.

nacore_op_cb

typedef void (*nacore_op_cb)(void *value, void *opaque)

A function that performs some operation on a value.

Usually, it is employed when performing context-dependent operations on values belonging to a certain set of data.

Paramters

valuePointer to the value to operate on.
opaqueExtra opaque data pointer or NULL.

Functions

nacore_ptr_cmp()

_NACORE_DEF int nacore_ptr_cmp(const void *v1,
const void *v2,
void *opaque)

Pointer comparison function.

opaque is used as a flag that, if NULL, makes the function usable as a nacore_cmp_cb callback for ascending ordering, otherwise for descending ordering.  The opaque pointer is never dereferenced.

Parameters

v1First pointer.
v2Second pointer.
opaqueOrdering direction flag.

Returns

If opaque is (not) NULL, a strictly negative (positive) value if v1 < v2, 0 if v1 == v2, a strictly positive (negative) value if v1 > v2.

typedef size_t (*nacore_get_size_cb)(const void *value, void *opaque)
A function that returns the size of some value.
typedef int (*nacore_cmp_cb)(const void *v1, const void *v2, void *opaque)
A function that compares two values.
typedef char * (*nacore_to_string_cb)(const void *value, void *opaque)
A function that retuns a textual description of some value.
typedef char (*nacore_filter_cb)(const void *value, void *opaque)
A function that decides whether a certain value should be filtered out or not.
typedef void (*nacore_op_cb)(void *value, void *opaque)
A function that performs some operation on a value.
_NACORE_DEF int nacore_ptr_cmp(const void *v1,
const void *v2,
void *opaque)
Pointer comparison function.
Type from/to which size_t values can be safely casted.
Length modifier for size_t to be used with printf()-like functions of the platform’s standard C library.
Close