[augeas-devel] [PATCH 08/10] Add new API function aug_text_retrieve

lutter at redhat.com lutter at redhat.com
Tue May 22 00:44:35 UTC 2012


From: David Lutterkort <lutter at redhat.com>

---
 src/augeas.c |   29 +++++++++++++++++++++++++++++
 src/augeas.h |   12 ++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/augeas.c b/src/augeas.c
index 76cf272..314b445 100644
--- a/src/augeas.c
+++ b/src/augeas.c
@@ -1654,6 +1654,35 @@ int aug_text_store(augeas *aug, const char *lens, const char *path,
     return -1;
 }
 
+int aug_text_retrieve(struct augeas *aug, const char *lens, const char *path,
+                      const char *text_in,
+                      ATTRIBUTE_UNUSED unsigned int text_in_len,
+                      char **text_out, unsigned int *text_out_len) {
+    struct tree *tree = NULL;
+    int r;
+
+    *text_out = NULL;
+    *text_out_len = 0;
+
+    api_entry(aug);
+
+    tree = tree_find(aug, path);
+    ERR_BAIL(aug);
+
+    r = text_retrieve(aug, lens, path, tree, text_in, text_out);
+    if (r < 0)
+        goto error;
+
+    if (*text_out != NULL)
+        *text_out_len = strlen(*text_out);
+
+    api_exit(aug);
+    return 0;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
 int aug_to_xml(const struct augeas *aug, const char *pathin,
                xmlNode **xmldoc, unsigned int flags) {
     struct pathx *p;
diff --git a/src/augeas.h b/src/augeas.h
index c181cfc..cdb12e8 100644
--- a/src/augeas.h
+++ b/src/augeas.h
@@ -316,6 +316,18 @@ int aug_load(augeas *aug);
 int aug_text_store(augeas *aug, const char *lens, const char *path,
                    const char *text, unsigned int text_len);
 
+/* Function: aug_text_retrieve
+ *
+ * Transform the tree at PATH into TEXT_OUT using lens LENS, assuming the
+ * tree was initially generated using TEXT_IN.
+ *
+ * Returns:
+ * 0 on success, or a negative value on failure
+ */
+int aug_text_retrieve(struct augeas *aug, const char *lens, const char *path,
+                      const char *text_in, unsigned int text_in_len,
+                      char **text_out, unsigned int *text_out_len);
+
 /* Function: aug_print
  *
  * Print each node matching PATH and its descendants to OUT.
-- 
1.7.7.6




More information about the augeas-devel mailing list