| Elektra 0.11.0

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

Copyright
  BSD License (see LICENSE.md or https://www.libelektra.org)

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

  reference | the reference to check

Return values

  1 | if the reference is redundant
  0 | otherwise

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

  reference | The reference to resolve
  baseKey | The key identified by the reference "./"
  parentKey | The key identified by the reference "@/"

Returns
  a newly allocated string, containing the full keyname; has to be disposed with elektraFree()