Created
May 2, 2025 12:48
-
-
Save rwestphal/70d6d343895c648590498908221c0774 to your computer and use it in GitHub Desktop.
libyang issue #2390
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <err.h> | |
#include <libyang/libyang.h> | |
#define YANG_SEARCH_PATH "/usr/local/share/yang/" | |
const LY_ERR module_callback(const char *mod_name, const char *mod_rev, | |
const char *submod_name, const char *submod_rev, | |
void *user_data, LYS_INFORMAT *format, | |
const char **module_data, | |
ly_module_imp_data_free_clb *free_module_data) | |
{ | |
printf("Callback invoked for module: %s\n", mod_name); | |
return LY_ENOTFOUND; | |
} | |
int main(int argc, char **argv) | |
{ | |
struct ly_ctx *ly_ctx; | |
/* initialization */ | |
if (ly_ctx_new(YANG_SEARCH_PATH, | |
LY_CTX_NO_YANGLIBRARY | LY_CTX_PREFER_SEARCHDIRS, | |
&ly_ctx) | |
!= LY_SUCCESS) | |
errx(1, "ly_ctx_new(): %s", ly_errmsg(ly_ctx)); | |
// set the import callback | |
ly_ctx_set_module_imp_clb(ly_ctx, module_callback, NULL); | |
// load module | |
const char *module = "holo-isis"; | |
printf("Loading %s...\n", module); | |
if (ly_ctx_load_module(ly_ctx, module, NULL, NULL) == NULL) | |
errx(1, "ly_ctx_load_module(%s): %s", module, | |
ly_errmsg(ly_ctx)); | |
/* cleanup */ | |
ly_ctx_destroy(ly_ctx); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment