MSVC: handle symbol visibility

On MSVC, the exported symbols have to be marked both in the header and
in the implementation as dllexport, whereas on GCC the visibility=normal
attribute is only supposed to be used in the implementation. As a
result, we need two types of macros here, one for the public headers,
and the other for TUs with implementation. Also, the symbol name cannot
be generic ("API") because we only want to mark as dllexport those
symbols which are in a library that we're building *now*. Otherwise this
will break havoc in any libraries which also use the `ABI` macro *and*
also use libyang.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index b4d8eaa..076fa37 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -127,7 +127,7 @@
     [LY_STMT_YIN_ELEMENT] = {"yin-element", "value", STMT_FLAG_ID},
 };
 
-API const char *
+LIBYANG_API_DEF const char *
 ly_stmt2str(enum ly_stmt stmt)
 {
     if (stmt == LY_STMT_EXTENSION_INSTANCE) {
@@ -144,7 +144,7 @@
     [LYS_DEV_REPLACE] = "replace",
 };
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lysc_tree_dfs_full(const struct lysc_node *root, lysc_dfs_clb dfs_clb, void *data)
 {
     struct lysc_node *elem, *elem2;
@@ -181,7 +181,7 @@
     return LY_SUCCESS;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lysc_module_dfs_full(const struct lys_module *mod, lysc_dfs_clb dfs_clb, void *data)
 {
     const struct lysc_node *root;
@@ -396,13 +396,13 @@
     return next;
 }
 
-API const struct lysc_node *
+LIBYANG_API_DEF const struct lysc_node *
 lys_getnext(const struct lysc_node *last, const struct lysc_node *parent, const struct lysc_module *module, uint32_t options)
 {
     return lys_getnext_(last, parent, module, NULL, options);
 }
 
-API const struct lysc_node *
+LIBYANG_API_DEF const struct lysc_node *
 lys_getnext_ext(const struct lysc_node *last, const struct lysc_node *parent, const struct lysc_ext_instance *ext, uint32_t options)
 {
     return lys_getnext_(last, parent, NULL, ext, options);
@@ -441,7 +441,7 @@
     return NULL;
 }
 
-API const struct lysc_node *
+LIBYANG_API_DEF const struct lysc_node *
 lys_find_child(const struct lysc_node *parent, const struct lys_module *module, const char *name, size_t name_len,
         uint16_t nodetype, uint32_t options)
 {
@@ -474,7 +474,7 @@
     return NULL;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_find_xpath_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, uint32_t options,
         struct ly_set **set)
 {
@@ -524,7 +524,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_find_expr_atoms(const struct lysc_node *ctx_node, const struct lys_module *cur_mod, const struct lyxp_expr *expr,
         const struct lysc_prefix *prefixes, uint32_t options, struct ly_set **set)
 {
@@ -570,7 +570,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_find_xpath(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, uint32_t options,
         struct ly_set **set)
 {
@@ -622,7 +622,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_find_lypath_atoms(const struct ly_path *path, struct ly_set **set)
 {
     LY_ERR ret = LY_SUCCESS;
@@ -652,7 +652,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output,
         struct ly_set **set)
 {
@@ -686,7 +686,7 @@
     return ret;
 }
 
-API const struct lysc_node *
+LIBYANG_API_DEF const struct lysc_node *
 lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output)
 {
     const struct lysc_node *snode = NULL;
@@ -803,7 +803,7 @@
     }
 }
 
-API char *
+LIBYANG_API_DEF char *
 lysc_path(const struct lysc_node *node, LYSC_PATH_TYPE pathtype, char *buffer, size_t buflen)
 {
     return lysc_path_until(node, NULL, pathtype, buffer, buflen);
@@ -1177,7 +1177,7 @@
     assert(!unres->ds_unres.disabled.count);
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_set_implemented(struct lys_module *mod, const char **features)
 {
     LY_ERR ret = LY_SUCCESS;
@@ -1753,7 +1753,7 @@
     return format;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_parse(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, const char **features, struct lys_module **module)
 {
     LY_ERR ret = LY_SUCCESS;
@@ -1799,7 +1799,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format, struct lys_module **module)
 {
     LY_ERR ret;
@@ -1815,7 +1815,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format, struct lys_module **module)
 {
     LY_ERR ret;
@@ -1831,7 +1831,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format, struct lys_module **module)
 {
     LY_ERR ret;
@@ -1848,7 +1848,7 @@
     return ret;
 }
 
-API LY_ERR
+LIBYANG_API_DEF LY_ERR
 lys_search_localfile(const char * const *searchpaths, ly_bool cwd, const char *name, const char *revision,
         char **localfile, LYS_INFORMAT *format)
 {