提交 637a7c86 编写于 作者: J Jiri Denemark

Introduce virTypedParamsCheck internal API

This API is useful for checking whether only a specific subset of
supported typed parameters were passed.
上级 40369ea6
...@@ -67,6 +67,7 @@ ignored_functions = { ...@@ -67,6 +67,7 @@ ignored_functions = {
"virTypedParamsValidate": "internal function in virtypedparam.c", "virTypedParamsValidate": "internal function in virtypedparam.c",
"virTypedParameterAssign": "internal function in virtypedparam.c", "virTypedParameterAssign": "internal function in virtypedparam.c",
"virTypedParameterAssignFromStr": "internal function in virtypedparam.c", "virTypedParameterAssignFromStr": "internal function in virtypedparam.c",
"virTypedParamsCheck": "internal function in virtypedparam.c",
} }
ignored_macros = { ignored_macros = {
......
...@@ -1943,6 +1943,7 @@ virTPMCreateCancelPath; ...@@ -1943,6 +1943,7 @@ virTPMCreateCancelPath;
# util/virtypedparam.h # util/virtypedparam.h
virTypedParameterAssign; virTypedParameterAssign;
virTypedParameterAssignFromStr; virTypedParameterAssignFromStr;
virTypedParamsCheck;
virTypedParamsValidate; virTypedParamsValidate;
......
...@@ -109,6 +109,32 @@ cleanup: ...@@ -109,6 +109,32 @@ cleanup:
} }
/* Check if params contains only specified parameter names. Return true if
* only specified names are present in params, false if params contains any
* unspecified parameter name. */
bool
virTypedParamsCheck(virTypedParameterPtr params,
int nparams,
const char **names,
int nnames)
{
int i, j;
for (i = 0; i < nparams; i++) {
bool found = false;
for (j = 0; j < nnames; j++) {
if (STREQ(params[i].field, names[j])) {
found = true;
break;
}
}
if (!found)
return false;
}
return true;
}
/* Assign name, type, and the appropriately typed arg to param; in the /* Assign name, type, and the appropriately typed arg to param; in the
* case of a string, the caller is assumed to have malloc'd a string, * case of a string, the caller is assumed to have malloc'd a string,
* or can pass NULL to have this function malloc an empty string. * or can pass NULL to have this function malloc an empty string.
......
...@@ -29,6 +29,11 @@ int virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...@@ -29,6 +29,11 @@ int virTypedParamsValidate(virTypedParameterPtr params, int nparams,
/* const char *name, int type ... */ ...) /* const char *name, int type ... */ ...)
ATTRIBUTE_SENTINEL ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_SENTINEL ATTRIBUTE_RETURN_CHECK;
bool virTypedParamsCheck(virTypedParameterPtr params,
int nparams,
const char **names,
int nnames);
int virTypedParameterAssign(virTypedParameterPtr param, const char *name, int virTypedParameterAssign(virTypedParameterPtr param, const char *name,
int type, /* TYPE arg */ ...) int type, /* TYPE arg */ ...)
ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_RETURN_CHECK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册