CNDP  22.08.0
jcfg_decode.h File Reference
#include <sys/queue.h>
#include <pthread.h>
#include <json-c/json_object.h>
#include <json-c/json_tokener.h>
#include <json-c/json_util.h>
#include <json-c/json_visit.h>
#include <json-c/linkhash.h>
#include <stddef.h>
#include <stdint.h>
#include "jcfg.h"

Go to the source code of this file.

Functions

int jcfg_list_add (jcfg_list_t *lst, void *obj)
 
int _decode_defaults (struct json_object *obj, int flags, struct json_object *parent, const char *key, size_t *index, void *arg)
 
int jcfg_decode_lport_groups_end (jcfg_info_t *jinfo, void *arg)
 
int __decoder_val_get (obj_value_t *val, uint64_t *v)
 
int __decoder_array_val_get (obj_value_t *val, obj_value_t **arr)
 
int __decode_object (obj_value_t *val, struct json_object *obj, enum json_type type)
 

Detailed Description

The internal decode APIs and defines for JCFG.

Definition in file jcfg_decode.h.

Function Documentation

◆ jcfg_list_add()

int jcfg_list_add ( jcfg_list_t lst,
void *  obj 
)

Add an object pointer to a jcfg_list_t structure

The jcfg_list_t.list array uses realloc() to grow the list as needed.

Parameters
lstThe pointer to a jcfg_list_ structure
objThe object pointer to add to the list array.
Returns
-1 on error or 0 - N for the location of the object in the array.

◆ _decode_defaults()

int _decode_defaults ( struct json_object *  obj,
int  flags,
struct json_object *  parent,
const char *  key,
size_t *  index,
void *  arg 
)

Decode the default,umem,lport, ... sections in the JSON file (private or internal)

These are private functions and each supports the different sections in the JSON file format.

Parameters
objThe json object to decode from JSON object
flagsThe flags used by the JSON-C parser
parentThe JSON-C parent of this object.
keyThe pointer to the key value of the JSON object
indexThe new index value returned from JSON parsing to be placed in this index pointer location
argThe user supplied argument to be passed to the callback routines
Returns
The JSON parsing flags are returned, including OK and error

◆ jcfg_decode_lport_groups_end()

int jcfg_decode_lport_groups_end ( jcfg_info_t jinfo,
void *  arg 
)

Finish lport_group decoding after all sections have been decoded

This function creates logical ports and assigns them to threads, which can only be done after all other sections have been decoded.

Parameters
jinfoThe jcfg information structure pointer
argThe user supplied argument (currently unused)
Returns
0 on success or -1 on error

◆ __decoder_val_get()

int __decoder_val_get ( obj_value_t val,
uint64_t *  v 
)

Decoder value get routine for scalar object.

Parameters
valThe obj_value_t pointer to extract the value into 'v' return pointer.
vThe location to put the returned object value.
Returns
0 on success or -1 on error

◆ __decoder_array_val_get()

int __decoder_array_val_get ( obj_value_t val,
obj_value_t **  arr 
)

Decoder value get routine for array object.

Parameters
valThe obj_value_t pointer to extract the values into 'arr' return pointer.
arrThe location to put the array of returned object values.
Returns
0 on success or -1 on error

◆ __decode_object()

int __decode_object ( obj_value_t val,
struct json_object *  obj,
enum json_type  type 
)

Decode a common object given its type and value.

Parameters
valThe object value pointer to decode the object from JSON to JCFG
objThe JSON object to decode
typeThe type of JSON object to decode
Returns
0 on success or -1 on error