CYAML Internals
Macros | Functions | Variables
util.c File Reference

Utility functions. More...

#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "util.h"
Include dependency graph for util.c:

Macros

#define CYAML_RELEASE_FLAG   (1u << 31)
 
#define CYAML_STR_HELPER(_x)   #_x
 
#define CYAML_STR(_x)   CYAML_STR_HELPER(_x)
 
#define CYAML_VERSION_STR
 

Functions

void cyaml_log (cyaml_log_t level, void *ctx, const char *fmt, va_list args)
 
const char * cyaml_strerror (cyaml_err_t err)
 

Variables

const uint32_t cyaml_version
 
const char * cyaml_version_str = CYAML_VERSION_STR
 

Detailed Description

Utility functions.

Macro Definition Documentation

◆ CYAML_RELEASE_FLAG

#define CYAML_RELEASE_FLAG   (1u << 31)

Flag that indicates a release in cyaml_version.

◆ CYAML_STR

#define CYAML_STR (   _x)    CYAML_STR_HELPER(_x)

Stringification macro.

◆ CYAML_STR_HELPER

#define CYAML_STR_HELPER (   _x)    #_x

Stringification helper macro.

◆ CYAML_VERSION_STR

#define CYAML_VERSION_STR
Value:
CYAML_STR(VERSION_MAJOR) "." \
CYAML_STR(VERSION_MINOR) "." \
CYAML_STR(VERSION_PATCH)

Version string is composed from components in Makefile.

Function Documentation

◆ cyaml_log()

void cyaml_log ( cyaml_log_t  level,
void *  ctx,
const char *  fmt,
va_list  args 
)

Standard CYAML logging function.

This logs to stderr. It clients want to log elsewhere they must implement their own logging function, and pass it to CYAML in the cyaml_config_t structure.

Note
This default logging function composes single log messages from multiple separate fprintfs to stderr. If the client application writes to stderr from multiple threads, individual cyaml_log messages may get broken up by the client applications logging. To avoid this, clients should implement their own cyaml_log_fn_t and pass it in via cyaml_config_t.
Parameters
[in]levelLog level of message to log.
[in]ctxLogging context, unused.
[in]fmtFormat string for message to log.
[in]argsAdditional arguments used by fmt.

◆ cyaml_strerror()

const char* cyaml_strerror ( cyaml_err_t  err)

Convert a cyaml error code to a human-readable string.

Parameters
[in]errError code code to convert.
Returns
String representing err. The string is '\0' terminated, and owned by libcyaml.

Variable Documentation

◆ cyaml_version

const uint32_t cyaml_version
Initial value:
=
((VERSION_MAJOR << 16) |
(VERSION_MINOR << 8) |
(VERSION_PATCH << 0) |

CYAML library version number suitable for comparisons.

Version number binary composition is 0bRUUUUUUUJJJJJJJJNNNNNNNNPPPPPPPP.

Character Meaning
R Release flag. If set, it's a release.
U Unused / reserved.
J Major component of version.
N Minor component of version.
P Patch component of version.

◆ cyaml_version_str

const char* cyaml_version_str = CYAML_VERSION_STR

CYAML library version string.

CYAML_RELEASE_FLAG
#define CYAML_RELEASE_FLAG
Definition: util.c:20
CYAML_STR
#define CYAML_STR(_x)
Definition: util.c:26