From f88b7dea6effccf48b78be84e4a92bf197cf3c64 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sat, 28 Jul 2018 11:49:02 +0100 Subject: Added code to handle VALUE parametrs --- arg.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 9 deletions(-) (limited to 'arg.c') diff --git a/arg.c b/arg.c index 96e66a5..da34f92 100644 --- a/arg.c +++ b/arg.c @@ -740,23 +740,57 @@ int __add_arg( arg_t *arg, int type, void *val ) -/* -CmdArgVar::CmdArgVar() + +CmdArgVal::CmdArgVal() { - this->_type = 0; - this->val = NULL; + this->used = 0; + this->ptr = NULL; } -uint8_t* CmdArgVar::get() +int CmdArgVal::isUsed() { - return this->val; + return this->used; } -int CmdArgVar::type() +void CmdArgVal::setUsed() { - return this->_type; + this->used = 1; } -*/ + +void CmdArgVal::setValue(char *val) +{ + this->ptr = val; +} + +char* CmdArgVal::getValue() +{ + return this->ptr; +} + +CmdArgValConf::CmdArgValConf() +{ + this->used = 0; + this->def = 0; + this->ptr = NULL; + this->default_ptr = NULL; + this->result = NULL; +} + +int CmdArgValConf::isUsed() +{ + return this->used; +} + +void CmdArgValConf::setUsed() +{ + this->used = 1; +} + +void CmdArgValConf::link(CmdArgVal *valArg) +{ + this->result = valArg; +} + /* CmdArg::CmdArg() { @@ -867,6 +901,7 @@ void CmdArgFlagConf::link(CmdArgFlag *flagArg) this->result = flagArg; } + CmdArgDefault::CmdArgDefault() { this->param = NULL; @@ -900,6 +935,16 @@ CmdArgDefault::CmdArgDefault(char *param, CmdArgFlagConf *def, char *help, CmdAr this->result = (void *)result; } +CmdArgDefault::CmdArgDefault(char *param, CmdArgValConf *def, char *help, CmdArgVal *result) +{ + this->param = param; + this->type = ARGT_VAL; + this->def = (void *)def; + this->used = 0; + this->help = help; + this->result = (void *)result; +} + void CmdArgDefault::setParam(char *param) { @@ -997,6 +1042,14 @@ void CmdArg::load(int argc, char **argv) } case ARGT_VAL: { + CmdArgVal *val=(CmdArgVal *)param->getResult(); + CmdArgValConf *conf=(CmdArgValConf *)param->getDefault(); + + param->setUsed(); + val->setUsed(); + //flag->setFlag(); + val->setValue(param->getParam()); + conf->setUsed(); break; } -- cgit v1.2.3