/* * Print out information for all nodes matching PATH using aug_match and * then aug_get etc. on each of the matches. */ static void dump_match(struct augeas *aug, const char *path) { char **matches; int nmatches; int i; nmatches = aug_match(aug, path, &matches); if (nmatches < 0) { fprintf(stderr, "aug_match for '%s' failed\n", path); fprintf(stderr, "error: %s\n", aug_error_message(aug)); exit(1); } fprintf(stderr, "iterating matches\n"); fprintf(stderr, "%d matches for %s\n", nmatches, path); for (i=0; i < nmatches; i++) { const char *value, *label; char *file; aug_get(aug, matches[i], &value); aug_label(aug, matches[i], &label); aug_source(aug, matches[i], &file); printf("%s: %s %s %s\n", matches[i], label, value, file); free(file); free(matches[i]); } free(matches); }
/* * call-seq: * label(PATH) -> String * * Lookup the label associated with PATH */ VALUE augeas_label(VALUE s, VALUE path) { augeas *aug = aug_handle(s); const char *cpath = StringValueCStr(path); const char *label; aug_label(aug, cpath, &label); if (label != NULL) { return rb_str_new(label, strlen(label)) ; } else { return Qnil; } }