diff options
author | FreeArtMan <dos21h@gmail.com> | 2018-07-28 11:49:02 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2018-07-28 11:49:02 +0100 |
commit | f88b7dea6effccf48b78be84e4a92bf197cf3c64 (patch) | |
tree | 71babc06d6a4997159c5acc309ad55e537ed1922 /arg.c | |
parent | 081b818ecc209944cfeae11e76d04323974b1d6b (diff) | |
download | libarg++-f88b7dea6effccf48b78be84e4a92bf197cf3c64.tar.gz libarg++-f88b7dea6effccf48b78be84e4a92bf197cf3c64.zip |
Added code to handle VALUE parametrs
Diffstat (limited to 'arg.c')
-rw-r--r-- | arg.c | 71 |
1 files changed, 62 insertions, 9 deletions
@@ -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; } |