libyang CHANGE allow using different versions of ietf-yang-library

By default, use the new ietf-yang-library revision (2017-08-17) as an
internal module, but allow caller to avoid its loading and instead the
caller can load its own version. In such a case, libyang will provide
context info (ly_ctx_info()) only in case the ietf-yang-library is
loaded in revision 2016-06-21 or 2017-08-17. Other revision can be loaded,
but libyang will not provide the context info in this form.
diff --git a/src/libyang.h.in b/src/libyang.h.in
index 13614fa..ca4cf50 100644
--- a/src/libyang.h.in
+++ b/src/libyang.h.in
@@ -1022,11 +1022,6 @@
  */
 
 /**
- * @brief Number of internal modules, which are always in every context and cannot be removed nor disabled.
- */
-#define LY_INTERNAL_MODULE_COUNT 5
-
-/**
  * @defgroup context Context
  * @{
  *
@@ -1051,7 +1046,12 @@
 #define LY_CTX_TRUSTED        0x02 /**< Handle the schema being parsed as trusted and skip its validation
                                         tests. Note that while this option improves performance, it can
                                         lead to an undefined behavior if the schema is not correct. */
-
+#define LY_CTX_NOYANGLIBRARY  0x04 /**< Do not internally implement ietf-yang-library module. The option
+                                        causes that function ly_ctx_info() does not work (returns NULL) until
+                                        the ietf-yang-library module is loaded manually. While any revision
+                                        of this schema can be loaded with this option, note that the only
+                                        revisions implemented by ly_ctx_info() are 2016-06-21 and 2017-08-17.
+                                        This option cannot be used with ly_ctx_new_yl*() functions. */
 
 /**@} contextoptions */
 
@@ -1127,6 +1127,13 @@
 struct ly_ctx *ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options);
 
 /**
+ * @brief Number of internal modules, which are in the context and cannot be removed nor disabled.
+ * @param[in] ctx Context to investigate.
+ * @return Number of internal modules, 0 in case of invalid parameter.
+ */
+unsigned int ly_ctx_internal_modules_count(struct ly_ctx *ctx);
+
+/**
  * @brief Add the search path into libyang context
  *
  * To reset search paths set in the context, use ly_ctx_unset_searchdirs() and then
@@ -1230,11 +1237,13 @@
  * @param[in] ctx Context to work in.
  * @param[in] name Name of the YANG module to get.
  * @param[in] revision Optional revision date of the YANG module to get. If not specified,
- * the schema in the newest revision is returned if any.
+ * the schema in the newest/implemented revision (see \p implemented parameter) is returned if any.
+ * @param[in] implemented In case the revision is not specified, require the implemented module
+ * instead of the newest revision of the module.
  * @return Pointer to the data model structure, NULL if no schema following the name and
  * revision requirements is present in the context.
  */
-const struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision);
+const struct lys_module *ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision, int implemented);
 
 /**
  * @brief Get pointer to the older schema tree to the specified one in the provided context.
@@ -1349,11 +1358,13 @@
  * @param[in] ctx Context to work in.
  * @param[in] ns Namespace of the YANG module to get.
  * @param[in] revision Optional revision date of the YANG module to get. If not specified,
- * the schema in the newest revision is returned if any.
+ * the schema in the newest/implemented revision (see \p implemented parameter) is returned if any.
+ * @param[in] implemented In case the revision is not specified, require the implemented module
+ * instead of the newest revision of the module.
  * @return Pointer to the data model structure, NULL if no schema following the namespace and
  * revision requirements is present in the context.
  */
-const struct lys_module *ly_ctx_get_module_by_ns(const struct ly_ctx *ctx, const char *ns, const char *revision);
+const struct lys_module *ly_ctx_get_module_by_ns(const struct ly_ctx *ctx, const char *ns, const char *revision, int implemented);
 
 /**
  * @brief Get submodule of a main module.