Volksdata 1.0b7
RDF library
Loading...
Searching...
No Matches
Private Volksdata API
Collaboration diagram for Private Volksdata API:

Topics

 Private RDF codec API
 Store interface module

Macros

#define VOLK_MIN_ERROR   -88899
 Minimum error value.
#define VOLK_MAX_ERROR   -88000
#define VOLK_MIN_WARNING   88800
 First warning value.
#define VOLK_MAX_WARNING   88899
#define LOG_DEBUG(...)
#define LOG_TRACE(...)
#define LOG_RC(rc)
 Log an error or warning for return codes that are not VOLK_OK.
#define CHECK(exp, marker)
 Jump to marker if exp does not return VOLK_OK.
#define PCHECK(exp, marker)
 Jump to marker if exp returns a negative value (skip warnings).
#define NLCHECK(exp, marker)
 Log error and jump to marker if exp is NULL.
#define RCCK(exp)
 Return exp return value if it is of VOLK_rc type and nonzero.
#define PRCCK(exp)
 Return exp return value if it is of VOLK_rc type and negative (=error).
#define RCNL(exp)
 Return NULL if exp returns a nonzero value.
#define PRCNL(exp)
 Return NULL if exp returns a negative value (=error).
#define NLNL(exp)
 Log error and return NULL if exp is NULL.
#define MALLOC_GUARD(var, rc)
 Allocate one pointer with malloc and return rc if it fails.
#define CALLOC_GUARD(var, rc)
 Allocate one pointer with calloc and return rc if it fails.

Functions

char * strndup (const char *src, size_t max)
 Replacement for GNU strndup.
char * strdup (const char *src)
 Replacement for GNU strdup.
VOLK_rc mkdir_p (const char *path, mode_t mode)
 Make recursive directories.
VOLK_rc rm_r (const char *path)
 Remove a directory recursively, as in Unix "rm -r".
int utf8_encode (const uint32_t utf, unsigned char *out)
 Encode a code point using UTF-8.

Detailed Description

Macro Definition Documentation

◆ VOLK_MIN_ERROR

#define VOLK_MIN_ERROR   -88899

Minimum error value.

Definition at line 249 of file core.h.

◆ VOLK_MAX_ERROR

#define VOLK_MAX_ERROR   -88000

brief Maximum error value.

Note
When adding new error codes, use a value smaller than this.

Definition at line 254 of file core.h.

◆ VOLK_MIN_WARNING

#define VOLK_MIN_WARNING   88800

First warning value.

Definition at line 257 of file core.h.

◆ VOLK_MAX_WARNING

#define VOLK_MAX_WARNING   88899

brief Maximum warning value.

Note
When adding new warning codes, use a value smaller than this.

Definition at line 263 of file core.h.

◆ LOG_DEBUG

#define LOG_DEBUG ( ...)

Definition at line 275 of file core.h.

◆ LOG_TRACE

#define LOG_TRACE ( ...)

Definition at line 276 of file core.h.

◆ LOG_RC

#define LOG_RC ( rc)
Value:
do { \
if ((rc) < 0) log_error (VOLK_strerror (rc)); \
else if ((rc) > 0) log_warn (VOLK_strerror (rc)); \
} while (0)
const char * VOLK_strerror(VOLK_rc rc)
Return an error message for a return code.
Definition core.c:195

Log an error or warning for return codes that are not VOLK_OK.

Note that, if used outside of the other macros below, care must be taken to pass it an actual return code rather than an expression, otherwise the expression will be evaluated multiple times.

Definition at line 285 of file core.h.

◆ CHECK

#define CHECK ( exp,
marker )
Value:
do { \
VOLK_rc _rc = (exp); \
LOG_RC(_rc); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
goto marker; \
} \
} while (0)
#define UNLIKELY(x)
Definition core.h:39
#define VOLK_OK
Generic success return code.
Definition core.h:83
int VOLK_rc
Definition core.h:79

Jump to marker if exp does not return VOLK_OK.

Definition at line 291 of file core.h.

◆ PCHECK

#define PCHECK ( exp,
marker )
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
LOG_RC(_rc); \
goto marker; \
} \
} while (0)

Jump to marker if exp returns a negative value (skip warnings).

Definition at line 303 of file core.h.

◆ NLCHECK

#define NLCHECK ( exp,
marker )
Value:
do { \
if (UNLIKELY ((exp) == NULL)) { \
log_error ("*** PREMATURE EXIT due to NULL result."); \
goto marker; \
} \
} while (0);

Log error and jump to marker if exp is NULL.

Definition at line 315 of file core.h.

◆ RCCK

#define RCCK ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
return _rc; \
} \
} while (0)

Return exp return value if it is of VOLK_rc type and nonzero.

Definition at line 323 of file core.h.

◆ PRCCK

#define PRCCK ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
return _rc; \
} \
} while (0)

Return exp return value if it is of VOLK_rc type and negative (=error).

Definition at line 334 of file core.h.

◆ RCNL

#define RCNL ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
return NULL; \
} \
} while (0);

Return NULL if exp returns a nonzero value.

Definition at line 345 of file core.h.

◆ PRCNL

#define PRCNL ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
return NULL; \
} \
} while (0)

Return NULL if exp returns a negative value (=error).

Definition at line 356 of file core.h.

◆ NLNL

#define NLNL ( exp)
Value:
do { \
if (UNLIKELY ((exp) == NULL)) { \
log_error ("*** PREMATURE EXIT due to NULL result."); \
return NULL; \
} \
} while (0)

Log error and return NULL if exp is NULL.

Definition at line 367 of file core.h.

◆ MALLOC_GUARD

#define MALLOC_GUARD ( var,
rc )
Value:
do { \
(var) = malloc (sizeof *(var)); \
if (UNLIKELY (var == NULL)) return (rc); \
} while (0)

Allocate one pointer with malloc and return rc if it fails.

Definition at line 375 of file core.h.

◆ CALLOC_GUARD

#define CALLOC_GUARD ( var,
rc )
Value:
do { \
(var) = calloc (1, sizeof *(var)); \
if (UNLIKELY (var == NULL)) return (rc); \
} while (0)

Allocate one pointer with calloc and return rc if it fails.

Definition at line 381 of file core.h.

Function Documentation

◆ strndup()

char * strndup ( const char * src,
size_t max )

Replacement for GNU strndup.

param[in] src String to duplicate. param[in] max Max number of characters to duplicate. The length is capped to the smaller value between this and the source string length (characters up to the trailing \0).

return Duplicated string. The caller is in charge of freeing it after use.

Definition at line 92 of file core.c.

◆ strdup()

char * strdup ( const char * src)

Replacement for GNU strdup.

param[in] str String to duplicate.

return Duplicated string. The caller is in charge of freeing it after use.

Definition at line 109 of file core.c.

◆ mkdir_p()

VOLK_rc mkdir_p ( const char * path,
mode_t mode )

Make recursive directories.

Modified from https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950

Definition at line 50 of file core.c.

◆ rm_r()

VOLK_rc rm_r ( const char * path)

Remove a directory recursively, as in Unix "rm -r".

Parameters
[in]pathPath of directory to remove.

Remove a directory recursively, as in Unix "rm -r".

Adapted from https://stackoverflow.com/questions/5467725/how-to-delete-a-directory-and-its-contents-in-posix-c/42596507#42596507

Definition at line 124 of file core.c.

◆ utf8_encode()

int utf8_encode ( const uint32_t utf,
unsigned char * out )
inline

Encode a code point using UTF-8.

https://gist.github.com/MightyPork/52eda3e5677b4b03524e40c9f0ab1da5

Author
Ondřej Hruška ondra.nosp@m.@ond.nosp@m.rovo..nosp@m.com
Parameters
out- output buffer (min 5 characters), will be 0-terminated
utf- code point 0-0x10FFFF
Returns
number of bytes on success, 0 on failure (also produces U+FFFD, which uses 3 bytes)

Definition at line 445 of file core.h.