diff --git a/src/proj/main.cfg b/src/proj/main.cfg new file mode 100644 index 0000000..20077e7 --- /dev/null +++ b/src/proj/main.cfg @@ -0,0 +1,3 @@ +{ + param: "hello" +} \ No newline at end of file diff --git a/src/proj/main.cpp b/src/proj/main.cpp index ba18a08..e7e7f37 100644 --- a/src/proj/main.cpp +++ b/src/proj/main.cpp @@ -1,6 +1,10 @@ #include "cwCommon.h" #include "cwLog.h" #include "cwCommonImpl.h" +#include "cwText.h" +#include "cwObject.h" + +using namespace cw; void print( void* arg, const char* text ) { @@ -9,10 +13,37 @@ void print( void* arg, const char* text ) int main( int argc, char* argv[] ) { + rc_t rc = kOkRC; + object_t* cfg = nullptr; cw::log::createGlobal(); - cwLogInfo("Project template"); + cwLogInfo("Project template: args:%i", argc); + if( argc < 2 || textLength(argv[1])==0 ) + { + cwLogError(kInvalidArgRC,"No cfg. file was given."); + goto errLabel; + } + else + { + const char* val = nullptr; + + if((rc = objectFromFile(argv[1],cfg)) != kOkRC ) + { + cwLogError(rc,"The file '%s'.",argv[1]); + goto errLabel; + } + + if((rc = cfg->getv("param",val)) != kOkRC ) + { + cwLogError(kSyntaxErrorRC,"The 'param' cfg. field was not found."); + goto errLabel; + } + + cwLogInfo("param=%s",cwStringNullGuard(val)); + } + +errLabel: cw::log::destroyGlobal(); return 0;