Elektra 0.11.0
reference.c File Reference

Reference methods. More...

#include "kdbease.h"
#include "kdbhelper.h"
#include <string.h>

Functions

int elektraIsReferenceRedundant (const char *reference)
 Check whether a reference is redundant (i.e.
 
char * elektraResolveReference (const char *reference, const Key *baseKey, const Key *parentKey)
 Resolve reference into a full keyname.
 

Detailed Description

Reference methods.

Function Documentation

◆ elektraIsReferenceRedundant()

int elektraIsReferenceRedundant ( const char * reference)

Check whether a reference is redundant (i.e.

it can be expressed in less characters) or not.

This can be used to give a warning to users, because redundant references are often mistakes. Using "../some/key/../path" instead of "../some/path" may indicate, that either a mistake was made while editing, or the concept of references was misunderstood.

Parameters
referencethe reference to check
Return values
1if the reference is redundant
0otherwise

◆ elektraResolveReference()

char * elektraResolveReference ( const char * reference,
const Key * baseKey,
const Key * parentKey )

Resolve reference into a full keyname.

References operate like UNIX paths, with some additions:

  • '.' refers to the current key
  • '..' refers to the parent of the current key
  • '@' refers to the parentKey of KDB
  • references starting with anything but './', '../' and '@/' as absolute, only embedded '/./' and '/../' as well as '/.' and '/..' at the end will be resolved (like in any keySetName call)
Parameters
referenceThe reference to resolve
baseKeyThe key identified by the reference "./"
parentKeyThe key identified by the reference "@/"
Returns
a newly allocated string, containing the full keyname; has to be disposed with elektraFree()