diff --git a/main.cpp b/main.cpp index 7084ad2..8efb66a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,11 @@ #include #include #include -#include #include #include -// This file is currently for testing and training using augeas with C++ + + +// Testing and training using augeas with C++ // https://github.com/hercules-team/augeas/blob/master/tests/test-api.c static const char *abs_top_srcdir; @@ -29,7 +30,8 @@ static void testGet() { aug_close(aug); } -static void readHostsFile() { +// This prints the actual file +static void printPreview(const std::string& matchPath, const std::string& filePath) { struct augeas *aug; int r; char *s; @@ -39,8 +41,8 @@ static void readHostsFile() { aug = aug_init(root, loadpath, AUG_NO_STDINC | AUG_NO_LOAD); - r = aug_load_file(aug, "/etc/hosts"); - r = aug_preview(aug, "/files/etc/hosts/1", &s); + r = aug_load_file(aug, filePath.c_str()); + r = aug_preview(aug, matchPath.c_str(), &s); std::cout << s << std::endl; @@ -105,6 +107,10 @@ static void printAugTree(const std::string& matchPath, const std::string& filePa int main(int argc, char *argv[]) { //testGet(); + + printPreview("/files/etc/hosts/1", "/etc/hosts"); + //printPreview("/files/etc/ssh/sshd_config/*", "/etc/ssh/sshd_config"); + printAugTree("/files/etc/hosts/*", "/etc/hosts"); printAugTree("/files/etc/ssh/sshd_config/*", "/etc/ssh/sshd_config");