[augeas-devel] aug_info and multipart keys

David Lutterkort lutter at redhat.com
Tue Oct 26 23:03:53 UTC 2010


On Tue, 2010-10-26 at 17:10 -0400, Francis Giraldeau wrote:
> The aug_info returns the location of node label/value inside a file. But
> with multipart key, then a key may be not in one chunk, so we would have
> to return a list of position... I really don't have a clue on the best
> way to deal with this. Any idea? 

There's an easy way to do that, if you are happy with the information
being imprecise: just report the union of the positions of all key
parts. Of course, that way, you also catch stuff that's not part of the
label.

The real solution requires two things:

      * keeping track of positions in either a list or in an array; e.g.

                struct pos_info {
                  uint nkeys;
                  uint *key_begin;
                  uint *key_end;
                  .. similar for value ..
                  uint  child_begin;
                  uint  child_end;
                }
                
        Of course, you now have to allocate the key_begin/end arrays
        also when you allocate pos_info, realloc them when a new key is
        added etc.
      * In the new API, return those arrays, with the understanding that
        (a) they must not be modified by the caller and (b) the pointers
        are only valid until the next call into the Augeas API, e.g.
        
                int aug_nodepos(struct augeas *aug, const char *path,
                                const int *nkeys, const int **key_begin, const int **key_end,
                                const int *nvalues, const int **val_begin, const int **val_end,
                                const int *children_begin, const int *children_end);
                
        The API should allow any of the int * and int ** to be passed in to be NULL
        
David

                




More information about the augeas-devel mailing list