summaryrefslogtreecommitdiff
path: root/arg.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2018-07-28 11:49:02 +0100
committerFreeArtMan <dos21h@gmail.com>2018-07-28 11:49:02 +0100
commitf88b7dea6effccf48b78be84e4a92bf197cf3c64 (patch)
tree71babc06d6a4997159c5acc309ad55e537ed1922 /arg.c
parent081b818ecc209944cfeae11e76d04323974b1d6b (diff)
downloadlibarg++-f88b7dea6effccf48b78be84e4a92bf197cf3c64.tar.gz
libarg++-f88b7dea6effccf48b78be84e4a92bf197cf3c64.zip
Added code to handle VALUE parametrs
Diffstat (limited to 'arg.c')
-rw-r--r--arg.c71
1 files changed, 62 insertions, 9 deletions
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;
}