Break out init of orig-ptr to yang_start() to be made after options

This commit is contained in:
Olof hagsand 2024-09-28 18:04:04 +02:00
parent ba40f5a929
commit 43bfc82942
8 changed files with 24 additions and 3 deletions

View file

@ -829,6 +829,7 @@ main(int argc,
if (nacm_load_external(h) < 0) if (nacm_load_external(h) < 0)
goto done; goto done;
} }
yang_start(h);
/* Create top-level data yangs */ /* Create top-level data yangs */
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL) if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
goto done; goto done;

View file

@ -842,8 +842,10 @@ main(int argc,
/* In case ietf-yang-metadata is loaded by application, handle annotation extension */ /* In case ietf-yang-metadata is loaded by application, handle annotation extension */
if (yang_metadata_init(h) < 0) if (yang_metadata_init(h) < 0)
goto done; goto done;
yang_start(h);
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
xml_nsctx_namespace_netconf_default(h); xml_nsctx_namespace_netconf_default(h);
/* Create top-level and store as option */ /* Create top-level and store as option */
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL) if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
goto done; goto done;

View file

@ -866,6 +866,7 @@ main(int argc,
/* Initialize plugin module by creating a handle holding plugin and callback lists */ /* Initialize plugin module by creating a handle holding plugin and callback lists */
if (clixon_plugin_module_init(h) < 0) if (clixon_plugin_module_init(h) < 0)
goto done; goto done;
yang_start(h);
/* In case ietf-yang-metadata is loaded by application, handle annotation extension */ /* In case ietf-yang-metadata is loaded by application, handle annotation extension */
if (yang_metadata_init(h) < 0) if (yang_metadata_init(h) < 0)
goto done; goto done;

View file

@ -1353,6 +1353,7 @@ main(int argc,
/* Initialize plugin module by creating a handle holding plugin and callback lists */ /* Initialize plugin module by creating a handle holding plugin and callback lists */
if (clixon_plugin_module_init(h) < 0) if (clixon_plugin_module_init(h) < 0)
goto done; goto done;
yang_start(h);
/* Call start function in all plugins before we go interactive */ /* Call start function in all plugins before we go interactive */
if (clixon_plugin_start_all(h) < 0) if (clixon_plugin_start_all(h) < 0)
goto done; goto done;

View file

@ -511,7 +511,7 @@ main(int argc,
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
xml_nsctx_namespace_netconf_default(h); xml_nsctx_namespace_netconf_default(h);
yang_start(h);
/* Add (hardcoded) netconf features in case ietf-netconf loaded here /* Add (hardcoded) netconf features in case ietf-netconf loaded here
* Otherwise it is loaded in netconf_module_load below * Otherwise it is loaded in netconf_module_load below
*/ */

View file

@ -347,6 +347,7 @@ void *yang_action_cb_get(yang_stmt *ys);
int yang_action_cb_add(yang_stmt *ys, void *rc); int yang_action_cb_add(yang_stmt *ys, void *rc);
int ys_populate_feature(clixon_handle h, yang_stmt *ys); int ys_populate_feature(clixon_handle h, yang_stmt *ys);
int yang_init(clixon_handle h); int yang_init(clixon_handle h);
int yang_start(clixon_handle h);
int yang_exit(clixon_handle h); int yang_exit(clixon_handle h);
#endif /* _CLIXON_YANG_H_ */ #endif /* _CLIXON_YANG_H_ */

View file

@ -132,6 +132,7 @@ clixon_client_init(const char *config_file)
/* Find, read and parse configfile */ /* Find, read and parse configfile */
if (clicon_options_main(h) < 0) if (clicon_options_main(h) < 0)
return NULL; return NULL;
yang_start(h);
return h; return h;
} }

View file

@ -4456,7 +4456,7 @@ yang_action_cb_add(yang_stmt *ys,
return 0; return 0;
} }
/*! Init yang code /*! Init yang code. Called before any yang code, before options
* *
* Add two external tables for YANGs * Add two external tables for YANGs
* @param[in] h Clixon handle * @param[in] h Clixon handle
@ -4470,7 +4470,6 @@ yang_init(clixon_handle h)
map_ptr2ptr *mp; map_ptr2ptr *mp;
yang_stmt *ymounts; yang_stmt *ymounts;
_yang_use_orig = clicon_option_bool(h, "CLICON_YANG_USE_ORIGINAL");
if ((mp = calloc(1, sizeof(*mp))) == NULL){ if ((mp = calloc(1, sizeof(*mp))) == NULL){
clixon_err(OE_UNIX, errno, "calloc"); clixon_err(OE_UNIX, errno, "calloc");
goto done; goto done;
@ -4492,6 +4491,21 @@ yang_init(clixon_handle h)
return retval; return retval;
} }
/*! Start yang code. Called after yang options loaded
*
* Called after YANG config and -o options and plugins init
* But before YANG data loaded
* Set local CLICON_YANG_USE_ORIGINAL variable
* @param[in] h Clixon handle
* @retval 0 OK
*/
int
yang_start(clixon_handle h)
{
_yang_use_orig = clicon_option_bool(h, "CLICON_YANG_USE_ORIGINAL");
return 0;
}
/*! Exit yang code /*! Exit yang code
* *
* @param[in] h Clixon handle * @param[in] h Clixon handle