[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - New function transform_file_error



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=745490e6af85935e4cdd6d0f1c8246f7e780a0ed
Commit:        745490e6af85935e4cdd6d0f1c8246f7e780a0ed
Parent:        174e416282518386aac8d29b995a4225f06d5fd3
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Thu Jan 7 10:58:54 2010 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Thu Jan 7 11:45:04 2010 -0800

New function transform_file_error

  * src/transfrom.h (transform_file_error): add prototype
  * src/transform.c (transform_file_error): new function
---
 src/transform.c |   28 ++++++++++++++++++++++++++++
 src/transform.h |    5 +++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/transform.c b/src/transform.c
index bd762c1..4f48826 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -525,6 +525,34 @@ int transform_validate(struct augeas *aug, struct tree *xfm) {
     return 0;
 }
 
+void transform_file_error(struct augeas *aug, const char *status,
+                          const char *filename, const char *format, ...) {
+    char *ep = err_path(filename);
+    struct tree *err;
+    char *msg;
+    va_list ap;
+    int r;
+
+    err = tree_find_cr(aug, ep);
+    if (err == NULL)
+        return;
+
+    tree_unlink_children(aug, err);
+    tree_set_value(err, status);
+
+    err = tree_child_cr(err, s_message);
+    if (err == NULL)
+        return;
+
+    va_start(ap, format);
+    r = vasprintf(&msg, format, ap);
+    va_end(ap);
+    if (r < 0)
+        return;
+    tree_set_value(err, msg);
+    free(msg);
+}
+
 int transform_load(struct augeas *aug, struct tree *xfm) {
     int nmatches;
     char **matches;
diff --git a/src/transform.h b/src/transform.h
index 567d5b3..3792233 100644
--- a/src/transform.h
+++ b/src/transform.h
@@ -90,6 +90,11 @@ int remove_file(struct augeas *aug, struct tree *tree);
 
 /* Return a printable name for the transform XFM. Never returns NULL. */
 const char *xfm_lens_name(struct tree *xfm);
+
+/* Store a file-specific transformation error in /augeas/files/PATH/error */
+ATTRIBUTE_FORMAT(printf, 4, 5)
+void transform_file_error(struct augeas *aug, const char *status,
+                          const char *filename, const char *format, ...);
 #endif
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]