diff options
| author | David Lamparter <equinox@diac24.net> | 2019-02-04 22:56:50 +0100 | 
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-02-19 21:41:39 +0100 | 
| commit | 591f57cff3e035439dff7c39a9bd688892fa5363 (patch) | |
| tree | e52873cf2ad95b7cf029809244991dac48ad8e82 /lib/yang_translator.c | |
| parent | 3ec9556728c7fe17bb1c47e62abf75bbff29502f (diff) | |
lib: yang: use common yang_ctx_new_setup()
After creating a libyang context, we need to hook up our callback to use
embedded built-in modules.  I hadn't added this to the yang translator
code.
Also, ly_ctx_new fails if the search directory doesn't exist.  Since
that's not a hard error for us, work around that and ignore inaccessible
YANG_MODELS_DIR.  (This is needed for snap packages.)
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/yang_translator.c')
| -rw-r--r-- | lib/yang_translator.c | 6 | 
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/yang_translator.c b/lib/yang_translator.c index c3092e56e5..6d6f92836f 100644 --- a/lib/yang_translator.c +++ b/lib/yang_translator.c @@ -162,8 +162,7 @@ struct yang_translator *yang_translator_load(const char *path)  	RB_INSERT(yang_translators, &yang_translators, translator);  	/* Initialize the translator libyang context. */ -	translator->ly_ctx = -		ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD); +	translator->ly_ctx = yang_ctx_new_setup();  	if (!translator->ly_ctx) {  		flog_warn(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);  		goto error; @@ -525,8 +524,7 @@ static void str_replace(char *o_string, const char *s_string,  void yang_translator_init(void)  { -	ly_translator_ctx = -		ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD); +	ly_translator_ctx = yang_ctx_new_setup();  	if (!ly_translator_ctx) {  		flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);  		exit(1);  | 
