added Sttp::sendCmdLV()

This commit is contained in:
hyung-hwan 2020-08-11 07:09:08 +00:00
parent 04ede03b37
commit 751663cf4f
2 changed files with 54 additions and 61 deletions

View File

@ -62,7 +62,8 @@ public:
int sendCmdV (const qse_mchar_t* name, qse_size_t nargs, va_list ap); int sendCmdV (const qse_mchar_t* name, qse_size_t nargs, va_list ap);
int sendCmdV (const qse_wchar_t* name, qse_size_t nargs, va_list ap); int sendCmdV (const qse_wchar_t* name, qse_size_t nargs, va_list ap);
// TODO: sendCmdLV int sendCmdLV (const qse_mchar_t* name, qse_size_t nargs, va_list ap);
int sendCmdLV (const qse_wchar_t* name, qse_size_t nargs, va_list ap);
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -683,79 +683,41 @@ int Sttp::write_char (qse_wchar_t c)
int Sttp::sendCmd (const qse_mchar_t* name, qse_size_t nargs, ...) int Sttp::sendCmd (const qse_mchar_t* name, qse_size_t nargs, ...)
{ {
int n; int n;
va_list ap; va_list ap;
va_start (ap, nargs); va_start (ap, nargs);
n = this->sendCmd(name, nargs, ap); n = this->sendCmd(name, nargs, ap);
va_end (ap); va_end (ap);
return n; return n;
} }
int Sttp::sendCmd (const qse_wchar_t* name, qse_size_t nargs, ...) int Sttp::sendCmd (const qse_wchar_t* name, qse_size_t nargs, ...)
{ {
int n; int n;
va_list ap; va_list ap;
va_start (ap, nargs); va_start (ap, nargs);
n = this->sendCmd(name, nargs, ap); n = this->sendCmd(name, nargs, ap);
va_end (ap); va_end (ap);
return n; return n;
} }
int Sttp::sendCmdL (const qse_mchar_t* name, qse_size_t nargs, ...) int Sttp::sendCmdL (const qse_mchar_t* name, qse_size_t nargs, ...)
{ {
if (name[0] == '\0') return 0; // don't send a null command int n;
if (this->beginWrite(name) <= -1) return -1; va_list ap;
va_start (ap, nargs);
if (nargs > 0) n = this->sendCmdL(name, nargs, ap);
{ va_end (ap);
va_list ap; return n;
va_start (ap, nargs);
for (qse_size_t i = 1; i <= nargs; i++)
{
qse_mchar_t* p = va_arg(ap, qse_mchar_t*);
qse_size_t l = va_arg(ap, qse_size_t);
if (this->writeStringArg(p, l) <= -1)
{
va_end (ap);
return -1;
}
}
va_end (ap);
}
if (this->endWrite() <= -1) return -1;
return 0;
} }
int Sttp::sendCmdL (const qse_wchar_t* name, qse_size_t nargs, ...) int Sttp::sendCmdL (const qse_wchar_t* name, qse_size_t nargs, ...)
{ {
if (name[0] == '\0') return 0; // don't send a null command int n;
if (this->beginWrite(name) <= -1) return -1; va_list ap;
va_start (ap, nargs);
if (nargs > 0) n = this->sendCmdL(name, nargs, ap);
{ va_end (ap);
va_list ap; return n;
va_start (ap, nargs);
for (qse_size_t i = 1; i <= nargs; i++)
{
qse_wchar_t* p = va_arg(ap, qse_wchar_t*);
qse_size_t l = va_arg(ap, qse_size_t);
if (this->writeStringArg(p, l) <= -1)
{
va_end (ap);
return -1;
}
}
va_end (ap);
}
if (this->endWrite() <= -1) return -1;
return 0;
} }
int Sttp::sendCmdV (const qse_mchar_t* name, qse_size_t nargs, va_list ap) int Sttp::sendCmdV (const qse_mchar_t* name, qse_size_t nargs, va_list ap)
@ -768,11 +730,7 @@ int Sttp::sendCmdV (const qse_mchar_t* name, qse_size_t nargs, va_list ap)
for (qse_size_t i = 1; i <= nargs; i++) for (qse_size_t i = 1; i <= nargs; i++)
{ {
qse_mchar_t* p = va_arg(ap, qse_mchar_t*); qse_mchar_t* p = va_arg(ap, qse_mchar_t*);
if (this->writeStringArg(p) <= -1) if (this->writeStringArg(p) <= -1) return -1;
{
va_end (ap);
return -1;
}
} }
} }
@ -790,11 +748,45 @@ int Sttp::sendCmdV (const qse_wchar_t* name, qse_size_t nargs, va_list ap)
for (qse_size_t i = 1; i <= nargs; i++) for (qse_size_t i = 1; i <= nargs; i++)
{ {
qse_wchar_t* p = va_arg(ap, qse_wchar_t*); qse_wchar_t* p = va_arg(ap, qse_wchar_t*);
if (this->writeStringArg(p) <= -1) if (this->writeStringArg(p) <= -1) return -1;
{ }
va_end (ap); }
return -1;
} if (this->endWrite() <= -1) return -1;
return 0;
}
int Sttp::sendCmdLV (const qse_mchar_t* name, qse_size_t nargs, va_list ap)
{
if (name[0] == '\0') return 0; // don't send a null command
if (this->beginWrite(name) <= -1) return -1;
if (nargs > 0)
{
for (qse_size_t i = 1; i <= nargs; i++)
{
qse_mchar_t* p = va_arg(ap, qse_mchar_t*);
qse_size_t l = va_arg(ap, qse_size_t);
if (this->writeStringArg(p, l) <= -1) return -1;
}
}
if (this->endWrite() <= -1) return -1;
return 0;
}
int Sttp::sendCmdLV (const qse_wchar_t* name, qse_size_t nargs, va_list ap)
{
if (name[0] == '\0') return 0; // don't send a null command
if (this->beginWrite(name) <= -1) return -1;
if (nargs > 0)
{
for (qse_size_t i = 1; i <= nargs; i++)
{
qse_wchar_t* p = va_arg(ap, qse_wchar_t*);
qse_size_t l = va_arg(ap, qse_size_t);
if (this->writeStringArg(p, l) <= -1) return -1;
} }
} }