stumpless 2.2.0
Loading...
Searching...
No Matches
version.h File Reference

Runtime information about the library. More...

Go to the source code of this file.

Data Structures

struct  stumpless_version
 A description of a library version. More...
 

Functions

STUMPLESS_PUBLIC_FUNCTION struct stumpless_versionstumpless_get_version (void)
 Gets the version of code the library was built with.
 
STUMPLESS_PUBLIC_FUNCTION int stumpless_version_cmp (const struct stumpless_version *version_x, const struct stumpless_version *version_y)
 Compares the version of two given stumpless_version struct.
 
STUMPLESS_PUBLIC_FUNCTION char * stumpless_version_to_string (const struct stumpless_version *version)
 Creates a string representation of the given version.
 

Detailed Description

Runtime information about the library.

Function Documentation

◆ stumpless_get_version()

STUMPLESS_PUBLIC_FUNCTION struct stumpless_version * stumpless_get_version ( void )

Gets the version of code the library was built with.

This version must be freed by the caller when it is no longer needed to avoid a memory leak.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Unsafe heap This function is not safe to call from signal handlers due to the use of memory management functions to create the version structure.

Async Cancel Safety: AC-Unsafe heap This function is not safe to call from threads that may be asynchronously cancelled, due to the use of memory management functions.

Returns
The version of code used by the library build.

◆ stumpless_version_cmp()

STUMPLESS_PUBLIC_FUNCTION int stumpless_version_cmp ( const struct stumpless_version * version_x,
const struct stumpless_version * version_y )

Compares the version of two given stumpless_version struct.

This function makes use of a similar convention used by the standard library's strcmp function.

Thread Safety: MT-Safe race:version_x race:version_y This function is thread safe, as long as the versions to be compared are not modified by other threads during the call.

Async Signal Safety: AS-Safe This function is safe to call from signal handlers.

Async Cancel Safety: AC-Safe This function is safe to call from threads that may be asynchronously cancelled.

Parameters
version_x,version_yTwo given version(const) to be compared.
Returns
0 if version numbers are the same,
1 if version_x->patch - version_y->patch > 0, -1 if < 0
10 if version_x->minor - version_y->minor > 0, -10 if < 0
100 if version_x->major - version_y->major > 0, -100 if < 0
INT_MAX if one of the version pointers is null.

◆ stumpless_version_to_string()

STUMPLESS_PUBLIC_FUNCTION char * stumpless_version_to_string ( const struct stumpless_version * version)

Creates a string representation of the given version.

This string will be NULL-terminated, and will appear in the standard semantic versioning format of 'major.minor.patch'.

This string must be freed by the caller when it is no longer needed. Failing to do so will result in a memory leak of the returned string.

Thread Safety: MT-Safe race:version This function is thread safe, as long as the version is not modified by other threads during the call.

Async Signal Safety: AS-Safe This function is safe to call from signal handlers.

Async Cancel Safety: AC-Safe This function is safe to call from threads that may be asynchronously cancelled.

Parameters
versionThe version to convert to a string.
Returns
A string representation of the provided version. This should be destroyed via the memory deallocation function currently configured via stumpless_set_free(). If an error is encountered, then NULL is returned and an error code is set appropriately.