# Common data types

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

Summary

Common data types | Data types used throughout the library and related generic utilities and defintions.
Macros |
NACORE_ELOOP | Error code indicating too many levels of symbolic links.
NACORE_EUNKNOWN | Error code for unknown errors.
NACORE_LIBC_SIZE_FORMAT_LM | Length modifier for size_t to be used with printf()-like functions of the platform’s standard C library.
NACORE_LIBC_SIZE_FORMAT_TYPE | Type from/to which size_t values can be safely casted.
Types |
nacore_get_size_cb | A function that returns the size of some value.
nacore_cmp_cb | A function that compares two values.
nacore_to_string_cb | A function that retuns a textual description of some value.
nacore_filter_cb | A function that decides whether a certain value should be filtered out or not.
nacore_op_cb | A function that performs some operation on a value.
Functions |
nacore_ptr_cmp() | Pointer comparison function.

### Macros

### NACORE_ELOOP

Error code indicating too many levels of symbolic links.

It is equivalent to ELOOP on POSIX-compliant platforms.

### 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.

### 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);

### Types

### nacore_get_size_cb

A function that returns the size of some value.

#### Parameters

value | Value pointer.
opaque | Extra opaque data pointer or NULL.

#### Returns

Size of value as number of bytes.

### nacore_cmp_cb

A function that compares two values.

#### Parameters

v1 | First value.
v2 | Second value.
opaque | Extra 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

A function that retuns a textual description of some value.

#### Parameters

value | Value pointer.
opaque | Extra 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

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

#### Parameters

value | Pointer to the value to be examined.
opaque | Extra opaque data pointer or NULL.

#### Returns

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

### nacore_op_cb

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

value | Pointer to the value to operate on.
opaque | Extra 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

v1 | First pointer.
v2 | Second pointer.
opaque | Ordering 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.

> _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.
A function that compares two values.
Close