context BUGFIX add context.c into a build system and fix issues
diff --git a/src/context.c b/src/context.c
index c2eba9b..31f6e3e 100644
--- a/src/context.c
+++ b/src/context.c
@@ -15,9 +15,10 @@
#include <errno.h>
#include <unistd.h>
-#include "libyang.h"
-#include "common.h"
#include "context.h"
+#include "common.h"
+
+#include "libyang.h"
#define LY_INTERNAL_MODS_COUNT 0 /* TODO 6 when parser available */
@@ -36,7 +37,6 @@
#include IETF_YANG_TYPES_PATH
#include IETF_DATASTORES
#include IETF_YANG_LIB_PATH
-#endif
static struct internal_modules_s {
const char *name;
@@ -45,7 +45,6 @@
uint8_t implemented;
LYS_INFORMAT format;
} internal_modules[LY_INTERNAL_MODS_COUNT] = {
-#if LY_INTERNAL_MODS_COUNT
{"ietf-yang-metadata", "2016-08-05", (const char*)ietf_yang_metadata_2016_08_05_yin, 0, LYS_IN_YIN},
{"yang", "2017-02-20", (const char*)yang_2017_02_20_yin, 1, LYS_IN_YIN},
{"ietf-inet-types", "2013-07-15", (const char*)ietf_inet_types_2013_07_15_yin, 0, LYS_IN_YIN},
@@ -53,8 +52,8 @@
/* ietf-datastores and ietf-yang-library must be right here at the end of the list! */
{"ietf-datastores", "2017-08-17", (const char*)ietf_datastores_2017_08_17_yin, 0, LYS_IN_YIN},
{"ietf-yang-library", IETF_YANG_LIB_REV, (const char*)ietf_yang_library_2018_01_17_yin, 1, LYS_IN_YIN}
-#endif
};
+#endif
API LY_ERR
ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir)
@@ -72,7 +71,7 @@
LY_CHECK_ERR_GOTO(!new_dir,
LOGERR(ctx, LY_ESYS, "realpath() call failed for \"%s\" (%s).", search_dir, strerror(errno)),
cleanup);
- if (ly_set_add(ctx->search_paths, new_dir) == -1) {
+ if (ly_set_add(&ctx->search_paths, new_dir, 0) == -1) {
free(new_dir);
return LY_EMEM;
}
@@ -104,7 +103,7 @@
if (index >= 0) {
/* remove specific search directory */
- return ly_set_rm_index(ctx->search_paths, index);
+ return ly_set_rm_index(&ctx->search_paths, index);
} else {
/* remove them all */
for (; ctx->search_paths.number; ctx->search_paths.number--) {
@@ -125,19 +124,20 @@
char *search_dir_list;
char *sep, *dir;
LY_ERR rc = LY_SUCCESS;
- int i;
ctx = calloc(1, sizeof *ctx);
- LY_CHECK_ERR_RETURN(!ctx, LOGMEM(NULL), LY_EMEM);
+ LY_CHECK_ERR_RET(!ctx, LOGMEM(NULL), LY_EMEM);
/* dictionary */
lydict_init(&ctx->dict);
+#if 0 /* TODO when plugins implemented */
/* plugins */
ly_load_plugins();
+#endif
/* initialize thread-specific key */
- while ((i = pthread_key_create(&ctx->errlist_key, ly_err_free)) == EAGAIN);
+ while ((pthread_key_create(&ctx->errlist_key, ly_err_free)) == EAGAIN);
/* models list */
ctx->flags = options;
@@ -161,12 +161,14 @@
}
ctx->module_set_id = 1;
+#if 0 /* TODO when parser implemented */
/* load internal modules */
for (i = 0; i < (options & LY_CTX_NOYANGLIBRARY) ? LY_INTERNAL_MODS_COUNT - 2 : LY_INTERNAL_MODS_COUNT; i++) {
module = (struct lys_module *)lys_parse_mem(ctx, internal_modules[i].data, internal_modules[i].format);
LY_CHECK_GOTO(!module, error);
module->parsed->implemented = internal_modules[i].implemented;
}
+#endif
*new_ctx = ctx;
return rc;
@@ -259,7 +261,7 @@
}
API void
-ly_ctx_destroy(struct ly_ctx *ctx, void (*private_destructor)(const struct lys_node *node, void *priv))
+ly_ctx_destroy(struct ly_ctx *ctx, void (*private_destructor)(const struct lysc_node *node, void *priv))
{
LY_CHECK_ARG_RET(ctx, ctx,);