From d116653e2920854e127d544b602d1d4c7cbafe2f Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 26 Nov 2014 15:41:46 +0000 Subject: new program added, the setup for the config files on the server --- ZKTest/src/ZKTest.cpp | 87 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 45 deletions(-) (limited to 'ZKTest/src') diff --git a/ZKTest/src/ZKTest.cpp b/ZKTest/src/ZKTest.cpp index c4f4017..de2a3e2 100644 --- a/ZKTest/src/ZKTest.cpp +++ b/ZKTest/src/ZKTest.cpp @@ -25,7 +25,7 @@ using namespace std; static zhandle_t *zk; static const clientid_t *session_id; char* nodeType = "default"; -struct String_vector list_of_children = {0}; +struct String_vector list_of_children = { 0 }; int timeout = 3000; int responseCode = 0; std::mutex mutex_lock; @@ -47,26 +47,26 @@ int main(int argc, char **argv) char* hosts = "localhost:2181"; char* check = "localhost"; char* check2 = ":"; - if(argc >1) + if (argc > 1) { - for (int i = 1; i < argc; i++ ) + for (int i = 1; i < argc; i++) { - if(isdigit(argv[i][0])) + if (isdigit(argv[i][0])) { - if(strstr(argv[i],check2) != NULL) + if (strstr(argv[i], check2) != NULL) { hosts = argv[i]; } } - else if(strstr(argv[i],check) !=NULL) + else if (strstr(argv[i], check) != NULL) { - if(strstr(argv[i],check2) != NULL) + if (strstr(argv[i], check2) != NULL) { hosts = argv[1]; } } - else if(isalpha(argv[i][0])) + else if (isalpha(argv[i][0])) { nodeType = argv[i]; } @@ -109,14 +109,12 @@ int main(int argc, char **argv) * debug test to show that the loop does not continue until watcher * is called */ - std::cout<<"loop locked"<> temp; string addition_of_strings = "/configTest/" + temp; const char* config_to_watch = addition_of_strings.c_str(); - std::cout<<"setting watch for config type of "< elements; uint configBegin = 0; - for (uint it = 0; it != strlen(configString); it++ ) + for (uint it = 0; it != strlen(configString); it++) { - if(configString[it] == ';' || NULL) + if (configString[it] == ';') { string tempString; - while(configBegin != it) + while (configBegin != it) { tempString += configString[configBegin]; configBegin++; } - configBegin = it+1; - char* element = new char[tempString.length()+1]; - std::strcpy (element, tempString.c_str()); + configBegin = it + 1; + char* element = new char[tempString.length() + 1]; + std::strcpy(element, tempString.c_str()); elements.push_back(element); } } - std::cout<<"i am a client of type "<