Configuration tree traversal

Overview

// typedefs

typedef struct cfg_obj_descr cfg_obj_descr;

typedef int (*cfg_inst_handler)(
    cfg_handle handle,
    void *user_data
    );

// structs

struct cfg_obj_descr;

// global variables

te_errno typedef te_errno(* cfg_handle_cb_func)(cfg_handle handle, void *opaque);
const te_enum_map cfg_cva_mapping[];

// global functions

te_errno cfg_register_object_str(const char* oid, cfg_obj_descr* descr, cfg_handle* handle);
te_errno cfg_register_object(const cfg_oid* oid, cfg_obj_descr* descr, cfg_handle* handle);
te_errno cfg_register_object_fmt(cfg_obj_descr* descr, cfg_handle* handle, const char* oid_fmt, ...);
te_errno te_errno cfg_unregister_object_str(const char* id_fmt, ...);
te_errno cfg_get_object_descr(cfg_handle handle, cfg_obj_descr* descr);
te_errno cfg_get_oid_str(cfg_handle handle, char** oid);
te_errno cfg_get_oid(cfg_handle handle, cfg_oid** oid);
te_errno cfg_get_subid(cfg_handle handle, char** subid);
te_errno cfg_get_inst_name(cfg_handle handle, char** name);
te_errno cfg_get_inst_name_type(cfg_handle handle, cfg_val_type type, cfg_inst_val* val);
te_errno cfg_get_ith_inst_name(const char* str_oid, unsigned int i, char** name);
te_errno cfg_find_str(const char* oid, cfg_handle* p_handle);
static te_errno cfg_find_vfmt(cfg_handle* p_handle, const char* oid_fmt, va_list ap);
te_errno cfg_find_fmt(cfg_handle* p_handle, const char* oid_fmt, ...);
te_errno te_errno cfg_find(const cfg_oid* oid, cfg_handle* handle);
te_errno cfg_find_object_by_instance(cfg_handle instance, cfg_handle* object);
te_errno cfg_find_pattern(const char* pattern, unsigned int* p_num, cfg_handle** p_set);
te_errno cfg_find_pattern_fmt(unsigned int* p_num, cfg_handle** p_set, const char* ptrn_fmt, ...);
te_errno cfg_find_pattern_iter_fmt(cfg_handle_cb_func cb_func, void* opaque, const char* ptrn_fmt, ...);
te_errno te_errno cfg_get_son(cfg_handle handle, cfg_handle* son);
te_errno cfg_get_brother(cfg_handle handle, cfg_handle* brother);
te_errno cfg_get_father(cfg_handle handle, cfg_handle* father);
te_errno cfg_enumerate(cfg_handle handle, cfg_inst_handler callback, void* user_data);

// macros

#define CFG_IS_INST(_handle)

Detailed Documentation

Typedefs

typedef struct cfg_obj_descr cfg_obj_descr

Object properties description

typedef int (*cfg_inst_handler)(
    cfg_handle handle,
    void *user_data
    )

Function handler called during instances enumeration

Global Variables

te_errno typedef te_errno(* cfg_handle_cb_func)(cfg_handle handle, void *opaque)

Type of callback function which can passed to cfg_find_pattern_iter_fmt().

Parameters:

handle

Configurator object or instance handle

opaque

Opaque data

Returns:

Status code

const te_enum_map cfg_cva_mapping[]

Array to convert cfg value access rights to string and vice versa

Global Functions

te_errno cfg_register_object_str(const char* oid, cfg_obj_descr* descr, cfg_handle* handle)

Register new object using string object identifiers.

Parameters:

oid

object identifier in string representation

descr

object properties description

handle

location for handle of the new object

Returns:

Status code (see te_errno.h)

te_errno cfg_register_object(const cfg_oid* oid, cfg_obj_descr* descr, cfg_handle* handle)

Register new object using array object identifiers.

Parameters:

oid

object identifier

descr

object properties description

handle

location for handle of the new object

Returns:

Status code (see te_errno.h)

te_errno cfg_register_object_fmt(cfg_obj_descr* descr, cfg_handle* handle, const char* oid_fmt, ...)

The same function as cfg_register_object_str, but OID may be format string.

te_errno te_errno cfg_unregister_object_str(const char* id_fmt, ...)

Request Configurator to remove an object with a given id from the data base of objects.

Parameters:

id_fmt

a format string for the object id.

Returns:

Status code.

te_errno cfg_get_object_descr(cfg_handle handle, cfg_obj_descr* descr)

Obtain parameters configured for the object.

Parameters:

handle

object handle

descr

OUT: location for the object properties description

Returns:

Status code (see te_errno.h)

te_errno cfg_get_oid_str(cfg_handle handle, char** oid)

Obtain identifier of object or object instance by its handle.

Parameters:

handle

handle of object or object instance

oid

OUT: location for the oid pointer (memory for the string is allocated by the routine using malloc()

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_get_oid(cfg_handle handle, cfg_oid** oid)

Obtain identifier of object or object instance by its handle.

Parameters:

handle

handle of object or object instance

oid

OUT: location for the oid pointer (memory for the array is allocated by the routine using malloc()

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_get_subid(cfg_handle handle, char** subid)

Obtain sub-identifier of object by its handle.

Parameters:

handle

handle of object

subid

OUT: location for the sub-identifier (should be at least CFG_SUBID_MAX length)

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_get_inst_name(cfg_handle handle, char** name)

Obtain name of object instance by its handle.

Parameters:

handle

handle of object instance

name

OUT: location for the name

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_get_inst_name_type(cfg_handle handle, cfg_val_type type, cfg_inst_val* val)

Obtain integer name of object instance by its handle.

Parameters:

handle

Handle of object instance

type

Type instance name

val

Value of the corresponding type

type == CVT_BOOL -> (bool *)
type == CVT_INT8 -> (int8_t *)
type == CVT_UINT8 -> (uint8_t *)
type == CVT_INT16 -> (int16_t *)
type == CVT_UINT16 -> (uint16_t *)
type == CVT_INT32 -> (int32_t *)
type == CVT_UINT32 -> (uint32_t *)
type == CVT_INT64 -> (int64_t *)
type == CVT_UINT64 -> (uint64_t *)
type == CVT_ADDRESS -> (struct sockaddr **)

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_get_ith_inst_name(const char* str_oid, unsigned int i, char** name)

Obtain name of object instance by its handle.

Parameters:

str_oid

object instance identifier in string

i

index of the instance subid

name

OUT: location for the name

Returns:

0 or TE_EINVAL if invalid handle is provided

te_errno cfg_find_str(const char* oid, cfg_handle* p_handle)

Find the object or object instance by its object identifier. Root object identifier is “/”; root object instance identifier is “/:”.

Parameters:

oid

object identifier in string representation

p_handle

location for object or instance handle

Returns:

Status code

static te_errno cfg_find_vfmt(cfg_handle* p_handle, const char* oid_fmt, va_list ap)

The same function as cfg_find_str, but OID may be format string

te_errno cfg_find_fmt(cfg_handle* p_handle, const char* oid_fmt, ...)

The same function as cfg_find_str, but OID may be format string

te_errno te_errno cfg_find(const cfg_oid* oid, cfg_handle* handle)

Find the object or object instance by its object identifier.

Parameters:

oid

object identifier

handle

location for object or instance handle

Returns:

Status code

te_errno cfg_find_object_by_instance(cfg_handle instance, cfg_handle* object)

Find object of the given instance.

Parameters:

instance

instance handle

object

location for object handle

Returns:

Status code

te_errno cfg_find_pattern(const char* pattern, unsigned int* p_num, cfg_handle** p_set)

Find all objects or object instances matching a pattern.

Parameters:

pattern

string object identifier possibly containing ‘*’ (see Configurator documentation for details)

p_num

number of found objects or object instances

p_set

array of object/(object instance) handles; memory for the array is allocated using malloc()

Returns:

0 or TE_EINVAL if a pattern format is incorrect or some argument is NULL.

te_errno cfg_find_pattern_fmt(unsigned int* p_num, cfg_handle** p_set, const char* ptrn_fmt, ...)

The same function as cfg_find_pattern, but OID may be format string

te_errno cfg_find_pattern_iter_fmt(cfg_handle_cb_func cb_func, void* opaque, const char* ptrn_fmt, ...)

Find all objects or object instances matching a pattern and call cb_func for each object.

Parameters:

cb_func

Pointer to a callback function.

opaque

Opaque argument to pass cb_func.

ptrn_fmt

Foramt string with the pattern.

Returns:

Status code

te_errno te_errno cfg_get_son(cfg_handle handle, cfg_handle* son)

Get handle of the oldest son of the object or object instance.

Parameters:

handle

handle of the object or object instance

son

pointer to oldest son of the object or object instance.

Returns:

Status code

te_errno cfg_get_brother(cfg_handle handle, cfg_handle* brother)

Get handle of the brother of the object or object instance.

Parameters:

handle

handle of the object or object instance

brother

pointer to the brother’s handle

Returns:

Status code

te_errno cfg_get_father(cfg_handle handle, cfg_handle* father)

Get handle of the father of the object or object instance.

Parameters:

handle

handle of the object or object instance

father

pointer to the father’s handle

Returns:

Status code

te_errno cfg_enumerate(cfg_handle handle, cfg_inst_handler callback, void* user_data)

Enumerate all instances of the object (enumeration is stopped if callback returns non-zero).

Parameters:

handle

object handle

callback

the function to be called for each object instance

user_data

opaque user data

Returns:

Status code (see te_errno.h)

Macros

#define CFG_IS_INST(_handle)

Is it Configurator object instance handle?

Parameters:

_handle

Configurator handle