libyang CHANGE rename ambiguous lyp_ prefixed functions and structures

The 'p' in the lyp_ prefix is not unique since it may refer to printer
as well as parser. Some of the objects are connected with libyang output
object, so they are now prefixed by 'ly_out_' prefix. The rest
(lyp_print() or lyp_write()) is so generic that only the `ly_` prefix
can be used for them.
diff --git a/src/printer.c b/src/printer.c
index 6a70cdf..0c10bfc 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -120,7 +120,7 @@
             }
         }
     } else if ((node->flags & LYD_DEFAULT) && !(options & LYDP_WD_MASK) && !(node->schema->flags & LYS_CONFIG_R)) {
-        /* LYP_WD_EXPLICIT
+        /* LYDP_WD_EXPLICIT
          * - print only if it contains status data in its subtree */
         LYD_TREE_DFS_BEGIN(node, next, elem) {
             if (elem->schema->flags & LYS_CONFIG_R) {
@@ -144,33 +144,33 @@
     return 1;
 }
 
-API LYP_OUT_TYPE
-lyp_out_type(const struct lyp_out *out)
+API LY_OUT_TYPE
+ly_out_type(const struct ly_out *out)
 {
-    LY_CHECK_ARG_RET(NULL, out, LYP_OUT_ERROR);
+    LY_CHECK_ARG_RET(NULL, out, LY_OUT_ERROR);
     return out->type;
 }
 
-API struct lyp_out *
-lyp_new_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg)
+API struct ly_out *
+ly_out_new_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg)
 {
-    struct lyp_out *out;
+    struct ly_out *out;
 
     out = calloc(1, sizeof *out);
     LY_CHECK_ERR_RET(!out, LOGMEM(NULL), NULL);
 
-    out->type = LYP_OUT_CALLBACK;
+    out->type = LY_OUT_CALLBACK;
     out->method.clb.func = writeclb;
     out->method.clb.arg = arg;
 
     return out;
 }
 
-API ssize_t (*lyp_clb(struct lyp_out *out, ssize_t (*writeclb)(void *arg, const void *buf, size_t count)))(void *arg, const void *buf, size_t count)
+API ssize_t (*ly_out_clb(struct ly_out *out, ssize_t (*writeclb)(void *arg, const void *buf, size_t count)))(void *arg, const void *buf, size_t count)
 {
     void *prev_clb;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type == LYP_OUT_CALLBACK, NULL);
+    LY_CHECK_ARG_RET(NULL, out, out->type == LY_OUT_CALLBACK, NULL);
 
     prev_clb = out->method.clb.func;
 
@@ -182,11 +182,11 @@
 }
 
 API void *
-lyp_clb_arg(struct lyp_out *out, void *arg)
+ly_out_clb_arg(struct ly_out *out, void *arg)
 {
     void *prev_arg;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type == LYP_OUT_CALLBACK, NULL);
+    LY_CHECK_ARG_RET(NULL, out, out->type == LY_OUT_CALLBACK, NULL);
 
     prev_arg = out->method.clb.arg;
 
@@ -197,21 +197,21 @@
     return prev_arg;
 }
 
-API struct lyp_out *
-lyp_new_fd(int fd)
+API struct ly_out *
+ly_out_new_fd(int fd)
 {
-    struct lyp_out *out;
+    struct ly_out *out;
 
     out = calloc(1, sizeof *out);
     LY_CHECK_ERR_RET(!out, LOGMEM(NULL), NULL);
 
 #ifdef HAVE_VDPRINTF
-    out->type = LYP_OUT_FD;
+    out->type = LY_OUT_FD;
     out->method.fd = fd;
 #else
     /* Without vdfprintf(), change the printing method to printing to a FILE stream.
      * To preserve the original file descriptor, duplicate it and use it to open file stream. */
-    out->type = LYP_OUT_FDSTREAM;
+    out->type = LY_OUT_FDSTREAM;
     out->method.fdstream.fd = fd;
 
     fd = dup(out->method.fdstream.fd);
@@ -235,21 +235,21 @@
 }
 
 API int
-lyp_fd(struct lyp_out *out, int fd)
+ly_out_fd(struct ly_out *out, int fd)
 {
     int prev_fd;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type <= LYP_OUT_FDSTREAM, -1);
+    LY_CHECK_ARG_RET(NULL, out, out->type <= LY_OUT_FDSTREAM, -1);
 
-    if (out->type == LYP_OUT_FDSTREAM) {
+    if (out->type == LY_OUT_FDSTREAM) {
         prev_fd = out->method.fdstream.fd;
-    } else { /* LYP_OUT_FD */
+    } else { /* LY_OUT_FD */
         prev_fd = out->method.fd;
     }
 
     if (fd != -1) {
         /* replace output stream */
-        if (out->type == LYP_OUT_FDSTREAM) {
+        if (out->type == LY_OUT_FDSTREAM) {
             int streamfd;
             FILE *stream;
 
@@ -268,7 +268,7 @@
             fclose(out->method.fdstream.f);
             out->method.fdstream.f = stream;
             out->method.fdstream.fd = streamfd;
-        } else { /* LYP_OUT_FD */
+        } else { /* LY_OUT_FD */
             out->method.fd = fd;
         }
     }
@@ -276,26 +276,26 @@
     return prev_fd;
 }
 
-API struct lyp_out *
-lyp_new_file(FILE *f)
+API struct ly_out *
+ly_out_new_file(FILE *f)
 {
-    struct lyp_out *out;
+    struct ly_out *out;
 
     out = calloc(1, sizeof *out);
     LY_CHECK_ERR_RET(!out, LOGMEM(NULL), NULL);
 
-    out->type = LYP_OUT_FILE;
+    out->type = LY_OUT_FILE;
     out->method.f = f;
 
     return out;
 }
 
 API FILE *
-lyp_file(struct lyp_out *out, FILE *f)
+ly_out_file(struct ly_out *out, FILE *f)
 {
     FILE *prev_f;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type == LYP_OUT_FILE, NULL);
+    LY_CHECK_ARG_RET(NULL, out, out->type == LY_OUT_FILE, NULL);
 
     prev_f = out->method.f;
 
@@ -306,15 +306,15 @@
     return prev_f;
 }
 
-API struct lyp_out *
-lyp_new_memory(char **strp, size_t size)
+API struct ly_out *
+ly_out_new_memory(char **strp, size_t size)
 {
-    struct lyp_out *out;
+    struct ly_out *out;
 
     out = calloc(1, sizeof *out);
     LY_CHECK_ERR_RET(!out, LOGMEM(NULL), NULL);
 
-    out->type = LYP_OUT_MEMORY;
+    out->type = LY_OUT_MEMORY;
     out->method.mem.buf = strp;
     if (!size) {
         /* buffer is supposed to be allocated */
@@ -328,11 +328,11 @@
 }
 
 char *
-lyp_memory(struct lyp_out *out, char **strp, size_t size)
+ly_out_memory(struct ly_out *out, char **strp, size_t size)
 {
     char *data;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type == LYP_OUT_MEMORY, NULL);
+    LY_CHECK_ARG_RET(NULL, out, out->type == LY_OUT_MEMORY, NULL);
 
     data = *out->method.mem.buf;
 
@@ -353,33 +353,33 @@
 }
 
 API LY_ERR
-lyp_out_reset(struct lyp_out *out)
+ly_out_reset(struct ly_out *out)
 {
     LY_CHECK_ARG_RET(NULL, out, LY_EINVAL);
 
     switch(out->type) {
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
         return LY_EINT;
-    case LYP_OUT_FD:
+    case LY_OUT_FD:
         if ((lseek(out->method.fd, 0, SEEK_SET) == -1) && errno != ESPIPE) {
             LOGERR(NULL, LY_ESYS, "Seeking output file descriptor failed (%s).", strerror(errno));
             return LY_ESYS;
         }
         break;
-    case LYP_OUT_FDSTREAM:
-    case LYP_OUT_FILE:
-    case LYP_OUT_FILEPATH:
+    case LY_OUT_FDSTREAM:
+    case LY_OUT_FILE:
+    case LY_OUT_FILEPATH:
         if ((fseek(out->method.f, 0, SEEK_SET) == -1) && errno != ESPIPE) {
             LOGERR(NULL, LY_ESYS, "Seeking output file stream failed (%s).", strerror(errno));
             return LY_ESYS;
         }
         break;
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         out->printed = 0;
         out->method.mem.len = 0;
         break;
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_CALLBACK:
         /* nothing to do (not seekable) */
         break;
     }
@@ -387,15 +387,15 @@
     return LY_SUCCESS;
 }
 
-API struct lyp_out *
-lyp_new_filepath(const char *filepath)
+API struct ly_out *
+ly_out_new_filepath(const char *filepath)
 {
-    struct lyp_out *out;
+    struct ly_out *out;
 
     out = calloc(1, sizeof *out);
     LY_CHECK_ERR_RET(!out, LOGMEM(NULL), NULL);
 
-    out->type = LYP_OUT_FILEPATH;
+    out->type = LY_OUT_FILEPATH;
     out->method.fpath.f = fopen(filepath, "w");
     if (!out->method.fpath.f) {
         LOGERR(NULL, LY_ESYS, "Failed to open file \"%s\" (%s).", filepath, strerror(errno));
@@ -406,11 +406,11 @@
 }
 
 API const char *
-lyp_filepath(struct lyp_out *out, const char *filepath)
+ly_out_filepath(struct ly_out *out, const char *filepath)
 {
     FILE *f;
 
-    LY_CHECK_ARG_RET(NULL, out, out->type == LYP_OUT_FILEPATH, filepath ? NULL : ((void *)-1));
+    LY_CHECK_ARG_RET(NULL, out, out->type == LY_OUT_FILEPATH, filepath ? NULL : ((void *)-1));
 
     if (!filepath) {
         return out->method.fpath.filepath;
@@ -432,53 +432,53 @@
 }
 
 API void
-lyp_free(struct lyp_out *out, void (*clb_arg_destructor)(void *arg), int destroy)
+ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), int destroy)
 {
     if (!out) {
         return;
     }
 
     switch (out->type) {
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_CALLBACK:
         if (clb_arg_destructor) {
             clb_arg_destructor(out->method.clb.arg);
         }
         break;
-    case LYP_OUT_FDSTREAM:
+    case LY_OUT_FDSTREAM:
         fclose(out->method.fdstream.f);
         if (destroy) {
             close(out->method.fdstream.fd);
         }
         break;
-    case LYP_OUT_FD:
+    case LY_OUT_FD:
         if (destroy) {
             close(out->method.fd);
         }
         break;
-    case LYP_OUT_FILE:
+    case LY_OUT_FILE:
         if (destroy) {
             fclose(out->method.f);
         }
         break;
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         if (destroy) {
             free(*out->method.mem.buf);
         }
         break;
-    case LYP_OUT_FILEPATH:
+    case LY_OUT_FILEPATH:
         free(out->method.fpath.filepath);
         if (destroy) {
             fclose(out->method.fpath.f);
         }
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
     free(out);
 }
 
 API LY_ERR
-lyp_print(struct lyp_out *out, const char *format, ...)
+ly_print(struct ly_out *out, const char *format, ...)
 {
     int count = 0;
     char *msg = NULL, *aux;
@@ -489,21 +489,21 @@
     va_start(ap, format);
 
     switch (out->type) {
-    case LYP_OUT_FD:
+    case LY_OUT_FD:
 #ifdef HAVE_VDPRINTF
         count = vdprintf(out->method.fd, format, ap);
         break;
 #else
-        /* never should be here since lyp_fd() is supposed to set type to LYP_OUT_FDSTREAM in case vdprintf() is missing */
+        /* never should be here since ly_out_fd() is supposed to set type to LY_OUT_FDSTREAM in case vdprintf() is missing */
         LOGINT(NULL);
         return LY_EINT;
 #endif
-    case LYP_OUT_FDSTREAM:
-    case LYP_OUT_FILEPATH:
-    case LYP_OUT_FILE:
+    case LY_OUT_FDSTREAM:
+    case LY_OUT_FILEPATH:
+    case LY_OUT_FILE:
         count = vfprintf(out->method.f, format, ap);
         break;
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         if ((count = vasprintf(&msg, format, ap)) < 0) {
             break;
         }
@@ -525,14 +525,14 @@
         (*out->method.mem.buf)[out->method.mem.len] = '\0';
         free(msg);
         break;
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_CALLBACK:
         if ((count = vasprintf(&msg, format, ap)) < 0) {
             break;
         }
         count = out->method.clb.func(out->method.clb.arg, msg, count);
         free(msg);
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
 
@@ -543,7 +543,7 @@
         out->status = LY_ESYS;
         return LY_ESYS;
     } else {
-        if (out->type == LYP_OUT_FDSTREAM) {
+        if (out->type == LY_OUT_FDSTREAM) {
             /* move the original file descriptor to the end of the output file */
             lseek(out->method.fdstream.fd, 0, SEEK_END);
         }
@@ -553,26 +553,26 @@
 }
 
 void
-ly_print_flush(struct lyp_out *out)
+ly_print_flush(struct ly_out *out)
 {
     switch (out->type) {
-    case LYP_OUT_FDSTREAM:
+    case LY_OUT_FDSTREAM:
         /* move the original file descriptor to the end of the output file */
         lseek(out->method.fdstream.fd, 0, SEEK_END);
         fflush(out->method.fdstream.f);
         break;
-    case LYP_OUT_FILEPATH:
-    case LYP_OUT_FILE:
+    case LY_OUT_FILEPATH:
+    case LY_OUT_FILE:
         fflush(out->method.f);
         break;
-    case LYP_OUT_FD:
+    case LY_OUT_FD:
         fsync(out->method.fd);
         break;
-    case LYP_OUT_MEMORY:
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_MEMORY:
+    case LY_OUT_CALLBACK:
         /* nothing to do */
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
 
@@ -581,7 +581,7 @@
 }
 
 API LY_ERR
-lyp_write(struct lyp_out *out, const char *buf, size_t len)
+ly_write(struct ly_out *out, const char *buf, size_t len)
 {
     int written = 0;
 
@@ -606,7 +606,7 @@
 
 repeat:
     switch (out->type) {
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         if (out->method.mem.len + len + 1 > out->method.mem.size) {
             *out->method.mem.buf = ly_realloc(*out->method.mem.buf, out->method.mem.len + len + 1);
             if (!*out->method.mem.buf) {
@@ -622,18 +622,18 @@
 
         out->printed += len;
         return LY_SUCCESS;
-    case LYP_OUT_FD:
+    case LY_OUT_FD:
         written = write(out->method.fd, buf, len);
         break;
-    case LYP_OUT_FDSTREAM:
-    case LYP_OUT_FILEPATH:
-    case LYP_OUT_FILE:
+    case LY_OUT_FDSTREAM:
+    case LY_OUT_FILEPATH:
+    case LY_OUT_FILE:
         written =  fwrite(buf, sizeof *buf, len, out->method.f);
         break;
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_CALLBACK:
         written = out->method.clb.func(out->method.clb.arg, buf, len);
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
 
@@ -649,7 +649,7 @@
         out->status = LY_ESYS;
         return LY_ESYS;
     } else {
-        if (out->type == LYP_OUT_FDSTREAM) {
+        if (out->type == LY_OUT_FDSTREAM) {
             /* move the original file descriptor to the end of the output file */
             lseek(out->method.fdstream.fd, 0, SEEK_END);
         }
@@ -659,12 +659,12 @@
 }
 
 LY_ERR
-ly_write_skip(struct lyp_out *out, size_t count, size_t *position)
+ly_write_skip(struct ly_out *out, size_t count, size_t *position)
 {
     LYOUT_CHECK(out, out->status);
 
     switch (out->type) {
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         if (out->method.mem.len + count > out->method.mem.size) {
             *out->method.mem.buf = ly_realloc(*out->method.mem.buf, out->method.mem.len + count);
             if (!(*out->method.mem.buf)) {
@@ -685,11 +685,11 @@
         /* update printed bytes counter despite we actually printed just a hole */
         out->printed += count;
         break;
-    case LYP_OUT_FD:
-    case LYP_OUT_FDSTREAM:
-    case LYP_OUT_FILEPATH:
-    case LYP_OUT_FILE:
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_FD:
+    case LY_OUT_FDSTREAM:
+    case LY_OUT_FILEPATH:
+    case LY_OUT_FILE:
+    case LY_OUT_CALLBACK:
         /* buffer the hole */
         if (out->buf_len + count > out->buf_size) {
             out->buffered = ly_realloc(out->buffered, out->buf_len + count);
@@ -712,7 +712,7 @@
         ++out->hole_count;
 
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
 
@@ -720,22 +720,22 @@
 }
 
 LY_ERR
-ly_write_skipped(struct lyp_out *out, size_t position, const char *buf, size_t count)
+ly_write_skipped(struct ly_out *out, size_t position, const char *buf, size_t count)
 {
     LY_ERR ret = LY_SUCCESS;
 
     LYOUT_CHECK(out, out->status);
 
     switch (out->type) {
-    case LYP_OUT_MEMORY:
+    case LY_OUT_MEMORY:
         /* write */
         memcpy(&(*out->method.mem.buf)[position], buf, count);
         break;
-    case LYP_OUT_FD:
-    case LYP_OUT_FDSTREAM:
-    case LYP_OUT_FILEPATH:
-    case LYP_OUT_FILE:
-    case LYP_OUT_CALLBACK:
+    case LY_OUT_FD:
+    case LY_OUT_FDSTREAM:
+    case LY_OUT_FILEPATH:
+    case LY_OUT_FILE:
+    case LY_OUT_CALLBACK:
         if (out->buf_len < position + count) {
             out->status = LY_ESYS;
             LOGMEM_RET(NULL);
@@ -750,15 +750,15 @@
         if (!out->hole_count) {
             /* all holes filled, we can write the buffer,
              * printed bytes counter is updated by ly_write() */
-            ret = lyp_write(out, out->buffered, out->buf_len);
+            ret = ly_write(out, out->buffered, out->buf_len);
             out->buf_len = 0;
         }
         break;
-    case LYP_OUT_ERROR:
+    case LY_OUT_ERROR:
         LOGINT(NULL);
     }
 
-    if (out->type == LYP_OUT_FILEPATH) {
+    if (out->type == LY_OUT_FILEPATH) {
         /* move the original file descriptor to the end of the output file */
         lseek(out->method.fdstream.fd, 0, SEEK_END);
     }