mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-09 23:34:38 +01:00
Debug
This commit is contained in:
parent
d5775d03fe
commit
500215fd59
2 changed files with 28 additions and 4 deletions
|
|
@ -215,6 +215,7 @@ typedef struct dmnode {
|
|||
DMOBJ *obj;
|
||||
struct dmnode *parent;
|
||||
struct uci_section *idb_s;
|
||||
json_object *idb_json;
|
||||
char *current_object;
|
||||
void *prev_data;
|
||||
char *prev_instance;
|
||||
|
|
|
|||
|
|
@ -1999,7 +1999,17 @@ static struct uci_section *get_uci_instance_db_section(const char *object, const
|
|||
|
||||
static int mobj_get_instances_db(DMOBJECT_ARGS)
|
||||
{
|
||||
//BBF_ERR("#### OBJ: node->current_object=%s && node->is_instanceobj=%d && node->obj->obj=%s ####", node->current_object, node->is_instanceobj, node->obj->obj);
|
||||
BBF_ERR("#### OBJ: node->current_object=%s && node->is_instanceobj=%d && node->obj->obj=%s &&& node->parent=%p && node->parent->current_object=%s &&& node->parent->idb_json=%p &&& node->idb_json=%p && instance=%s ####",
|
||||
node->current_object, node->is_instanceobj,
|
||||
node->obj->obj, node->parent, node->parent->current_object, node->parent->idb_json, node->idb_json, instance);
|
||||
|
||||
|
||||
if (node->parent->idb_json == NULL) node->parent->idb_json = json_object_new_object();
|
||||
|
||||
|
||||
if (node->idb_json == NULL) node->idb_json = json_object_new_object();
|
||||
|
||||
json_object_object_add(node->parent->idb_json, (node->is_instanceobj == 1) ? instance : node->obj->obj, node->idb_json);
|
||||
|
||||
if (node->is_instanceobj == 0 && node->obj->browseinstobj != NULL) {
|
||||
node->idb_s = get_uci_instance_db_section(node->current_object, "idb_parent");
|
||||
|
|
@ -2025,28 +2035,32 @@ static int mparam_get_instances_db(DMPARAM_ARGS)
|
|||
if (node->is_instanceobj == 0)
|
||||
return 0;
|
||||
|
||||
BBF_ERR("LEAF: node->current_object=%s && leaf->parameter=%s && node->is_instanceobj=%d && node->obj->obj=%s && node->idb_json=%p",
|
||||
node->current_object, leaf->parameter, node->is_instanceobj, node->obj->obj, node->idb_json);
|
||||
|
||||
char full_param[MAX_DM_PATH] = {0};
|
||||
char *value = dmstrdup("");
|
||||
|
||||
snprintf(full_param, sizeof(full_param), "%s%s", node->current_object, leaf->parameter);
|
||||
|
||||
//BBF_ERR("LEAF: node->current_object=%s && leaf->parameter=%s && node->is_instanceobj=%d && node->obj->obj=%s", node->current_object, leaf->parameter, node->is_instanceobj, node->obj->obj);
|
||||
|
||||
(leaf->getvalue)(full_param, dmctx, data, instance, &value);
|
||||
|
||||
if (leaf->dm_flags & DM_FLAG_UNIQUE) {
|
||||
if (node->idb_json) json_object_object_add(node->idb_json, leaf->parameter, json_object_new_string(value));
|
||||
dmuci_set_value_by_section_bbfdm(node->idb_s, leaf->parameter, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define JSON_FILE "/etc/bbfdm/data.json"
|
||||
int dm_entry_instances_db(struct dmctx *ctx)
|
||||
{
|
||||
DMOBJ *root = ctx->dm_entryobj;
|
||||
DMNODE node = {.current_object = ""};
|
||||
int err = 0;
|
||||
|
||||
BBF_ERR("root->obj=%s && node->current_object=%s", root->obj, node.current_object);
|
||||
|
||||
ctx->inparam_isparam = 0;
|
||||
ctx->findparam = 1;
|
||||
ctx->stop = 0;
|
||||
|
|
@ -2057,5 +2071,14 @@ int dm_entry_instances_db(struct dmctx *ctx)
|
|||
|
||||
err = dm_browse(ctx, &node, root, NULL, NULL);
|
||||
|
||||
BBF_ERR("++++++++++++++++++++++++ END ++++++++++++++++++++++++++++");
|
||||
BBF_ERR("&&& node.idb_json=%p &&&", node.idb_json);
|
||||
|
||||
FILE *fp = fopen(JSON_FILE, "w");
|
||||
if (fp) {
|
||||
fprintf(fp, "%s", json_object_to_json_string_ext(node.idb_json, JSON_C_TO_STRING_PRETTY));
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return (ctx->findparam == 0) ? err : 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue