mirror of https://gitee.com/openkylin/libvirt.git
Introduce virTypedParamsCheck internal API
This API is useful for checking whether only a specific subset of supported typed parameters were passed.
This commit is contained in:
parent
40369ea674
commit
637a7c865a
|
@ -67,6 +67,7 @@ ignored_functions = {
|
|||
"virTypedParamsValidate": "internal function in virtypedparam.c",
|
||||
"virTypedParameterAssign": "internal function in virtypedparam.c",
|
||||
"virTypedParameterAssignFromStr": "internal function in virtypedparam.c",
|
||||
"virTypedParamsCheck": "internal function in virtypedparam.c",
|
||||
}
|
||||
|
||||
ignored_macros = {
|
||||
|
|
|
@ -1943,6 +1943,7 @@ virTPMCreateCancelPath;
|
|||
# util/virtypedparam.h
|
||||
virTypedParameterAssign;
|
||||
virTypedParameterAssignFromStr;
|
||||
virTypedParamsCheck;
|
||||
virTypedParamsValidate;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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.
|
||||
|
|
|
@ -29,6 +29,11 @@ int virTypedParamsValidate(virTypedParameterPtr params, int nparams,
|
|||
/* const char *name, int type ... */ ...)
|
||||
ATTRIBUTE_SENTINEL ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
bool virTypedParamsCheck(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
const char **names,
|
||||
int nnames);
|
||||
|
||||
int virTypedParameterAssign(virTypedParameterPtr param, const char *name,
|
||||
int type, /* TYPE arg */ ...)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
|
|
Loading…
Reference in New Issue