+int datastore_schema_get_running_xpaths(char ***root_xpath, char ***modules) {
+ assert_session();
+ assert(root_xpath);
+ assert(modules);
+
+ const struct lys_module *module;
+ const struct lys_node *root;
+ uint32_t idx = 0;
+ char **xpath_list = 0;
+ char **mod_list = 0;
+ int total = 0;
+
+ while((module = ly_ctx_get_module_iter(session_context, &idx)) != 0) {
+ if(!generate_is_excluded_module(module->name) && (module->implemented)) {
+ LY_TREE_FOR(module->data, root) {
+ if(((root->nodetype == LYS_CONTAINER) || (root->nodetype == LYS_LIST)) && ((root->flags & LYS_STATUS_DEPRC) == 0) && ((root->flags & LYS_CONFIG_W) == 1)) {
+ xpath_list = (char **)realloc(xpath_list, sizeof(char *) * (total + 1));
+ if(!xpath_list) {
+ log_error("bad realloc\n");
+ return NTS_ERR_FAILED;
+ }
+ asprintf(&xpath_list[total], "/%s:%s", module->name, root->name);
+ if(!xpath_list[total]) {
+ log_error("bad asprintf\n");
+ return NTS_ERR_FAILED;
+ }
+
+ mod_list = (char **)realloc(mod_list, sizeof(char *) * (total + 1));
+ if(!mod_list) {
+ log_error("bad realloc\n");
+ return NTS_ERR_FAILED;
+ }
+ asprintf(&mod_list[total], "%s", module->name);
+ if(!mod_list[total]) {
+ log_error("bad asprintf\n");
+ return NTS_ERR_FAILED;
+ }
+ total++;
+ }
+ else if(root->nodetype == LYS_USES) {
+ struct lys_node *chd;
+ LY_TREE_FOR(root->child, chd) {
+ if(((chd->nodetype == LYS_CONTAINER) || (chd->nodetype == LYS_LIST)) && ((chd->flags & LYS_STATUS_DEPRC) == 0) && ((root->flags & LYS_CONFIG_W) == 1)) {
+ xpath_list = (char **)realloc(xpath_list, sizeof(char *) * (total + 1));
+ if(!xpath_list) {
+ log_error("bad realloc\n");
+ return NTS_ERR_FAILED;
+ }
+ asprintf(&xpath_list[total], "/%s:%s", module->name, chd->name);
+ if(!xpath_list[total]) {
+ log_error("bad asprintf\n");
+ return NTS_ERR_FAILED;
+ }
+
+ mod_list = (char **)realloc(mod_list, sizeof(char *) * (total + 1));
+ if(!mod_list) {
+ log_error("bad realloc\n");
+ return NTS_ERR_FAILED;
+ }
+ asprintf(&mod_list[total], "%s", module->name);
+ if(!mod_list[total]) {
+ log_error("bad asprintf\n");
+ return NTS_ERR_FAILED;
+ }
+ total++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ *root_xpath = xpath_list;
+ *modules = mod_list;
+ return total;
+}
+
+int datastore_schema_print_root_paths(void) {