printAugTree
This commit is contained in:
parent
e2140ef531
commit
99763104a2
19
main.cpp
19
main.cpp
|
@ -22,7 +22,7 @@ static void testGet() {
|
||||||
aug = aug_init(root, loadpath, AUG_NO_STDINC | AUG_NO_LOAD);
|
aug = aug_init(root, loadpath, AUG_NO_STDINC | AUG_NO_LOAD);
|
||||||
|
|
||||||
r = aug_load_file(aug, "/etc/hosts");
|
r = aug_load_file(aug, "/etc/hosts");
|
||||||
r = aug_source(aug, "/files/etc/hosts/1", &s);
|
r = aug_source(aug, "/files/etc/hosts/1/ipaddr", NULL);
|
||||||
|
|
||||||
std::cout << "The value read from node: " << s << std::endl;
|
std::cout << "The value read from node: " << s << std::endl;
|
||||||
|
|
||||||
|
@ -53,17 +53,15 @@ static void readHostsFile() {
|
||||||
/// Get the tree of the /etc/hosts file printed in the console
|
/// Get the tree of the /etc/hosts file printed in the console
|
||||||
/// Implementation based on https://github.com/Nexenta/node-augeas/blob/756276c432cc9e506836800ac9d217bedbbef55c/libaugeas.cc#L784
|
/// Implementation based on https://github.com/Nexenta/node-augeas/blob/756276c432cc9e506836800ac9d217bedbbef55c/libaugeas.cc#L784
|
||||||
|
|
||||||
static void readHostsTree() {
|
static void printAugTree(const std::string& matchPath, const std::string& filePath) {
|
||||||
struct augeas *aug;
|
struct augeas *aug;
|
||||||
int r;
|
int r;
|
||||||
FILE *out = tmpfile();
|
FILE *out = tmpfile();
|
||||||
|
|
||||||
aug = aug_init(root, loadpath, AUG_NO_STDINC | AUG_NO_LOAD);
|
aug = aug_init(root, loadpath, AUG_NO_STDINC | AUG_NO_LOAD);
|
||||||
|
|
||||||
const std::string matchPath = "/files/etc/hosts/*";
|
r = aug_load_file(aug, filePath.c_str());
|
||||||
|
r = aug_print(aug, out,matchPath.c_str());
|
||||||
r = aug_load_file(aug, "/etc/hosts");
|
|
||||||
r = aug_print(aug, out,"/files/etc/hosts/*");
|
|
||||||
|
|
||||||
std::map <std::string, std::string> stdBindList;
|
std::map <std::string, std::string> stdBindList;
|
||||||
std::map <std::string , std::string>::iterator pos;
|
std::map <std::string , std::string>::iterator pos;
|
||||||
|
@ -101,15 +99,14 @@ static void readHostsTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
aug_close(aug);
|
aug_close(aug);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
testGet();
|
//testGet();
|
||||||
readHostsTree();
|
printAugTree("/files/etc/hosts/*", "/etc/hosts");
|
||||||
|
printAugTree("/files/etc/ssh/sshd_config/*", "/etc/ssh/sshd_config");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue