[augeas-devel] Transform strings and store/retrieve resulting trees

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


A while ago, Rich Jones asked on IRC if would be possible to add API calls
so that strings can directly be transformed and stored in the tree through
the API. This patch series implements calls to do that.

The two new API functions aug_text_store and aug_text_retrieve can be used
to produce a tree from a string, respectively a string from a tree.

The prototypes for these functions are

  int aug_text_store(augeas *aug, const char *lens, const char *path,
                     const char *text, unsigned int text_len);
  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);

While playing with these, I noticed that it would be much nicer for
retrieve if we stored the raw input string somewhere in the tree. I am
contemplating to change the above so that the input/output strings are
taken from the values of nodes in the tree. That would mean that in augtool
you'd do

  set /raw/in/t1 "192.168.0.1 host.example.com machine\n"
  store Hosts.lns /raw/in/t1 /text/t1
  .. change /text/t1 ...
  retrieve Hosts.lns /raw/in/t1 /text/t1 /raw/out/t1
  get /raw/out/t1

I think this latter form is nicer, but I'd like to hear from others what
they think.

There are currently no restrictions on which tree nodes
aug_text_store/aug_text_retrieve operate - I think that's actually an
advantage, and I think it should stay that way. Parse errors for storeing
into PATH are stored under /augeas/text/PATH (with the consequence that
parse errors for storing at /text/t1 go into /augeas/text/text/t1)

Comments, complaints, and reviews very welcome.

David




More information about the augeas-devel mailing list