add function virCommandNewVAList

Add function virCommandNewVAList which is equivalent to the
virCommandNewArgList but with va_list instead of a variable number
of arguments.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
Dmitry Guryanov 2012-07-31 22:56:06 +04:00 committed by Daniel Veillard
parent cafc26ff5f
commit 4033df7ed8
2 changed files with 25 additions and 0 deletions

View File

@ -815,6 +815,28 @@ virCommandNewArgList(const char *binary, ...)
return cmd;
}
/**
* virCommandNewVAList:
* @binary: program to run
* @va_list: additional arguments
*
* Create a new command with a NULL terminated
* variable argument list. @binary is handled as in virCommandNew.
*/
virCommandPtr
virCommandNewVAList(const char *binary, va_list list)
{
virCommandPtr cmd = virCommandNew(binary);
const char *arg;
if (!cmd || cmd->has_error)
return cmd;
while ((arg = va_arg(list, const char *)) != NULL)
virCommandAddArg(cmd, arg);
return cmd;
}
/*
* Preserve the specified file descriptor in the child, instead of

View File

@ -45,6 +45,9 @@ virCommandPtr virCommandNewArgs(const char *const*args) ATTRIBUTE_NONNULL(1);
virCommandPtr virCommandNewArgList(const char *binary, ...)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
virCommandPtr virCommandNewVAList(const char *binary, va_list list)
ATTRIBUTE_NONNULL(1);
/* All error report from these setup APIs is
* delayed until the Run/RunAsync methods
*/