esx: add esxVI_GetInt

Modeled after the already existing esxVI_GetLong.
This commit is contained in:
Dawid Zamirski 2015-03-09 11:54:04 -04:00 committed by Michal Privoznik
parent 17ab5bc0a6
commit 486a8e47c0
4 changed files with 39 additions and 0 deletions

View File

@ -2412,6 +2412,38 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName,
int
esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Int **value, esxVI_Occurrence occurence)
{
esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_Int_CastFromAnyType(dynamicProperty->val, value) < 0)
return -1;
break;
}
}
if (!(*value) && occurence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
}
return 0;
}
int
esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence)

View File

@ -338,6 +338,9 @@ int esxVI_GetBoolean(esxVI_ObjectContent *objectContent,
const char *propertyName,
esxVI_Boolean *value, esxVI_Occurrence occurrence);
int esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Int **value, esxVI_Occurrence occurrence);
int esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence);

View File

@ -1376,6 +1376,9 @@ ESX_VI__TEMPLATE__DEEP_COPY(Int,
(*dest)->value = src->value;
})
/* esxVI_Int_CastFromAnyType */
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Int)
/* esxVI_Int_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Int,
{

View File

@ -241,6 +241,7 @@ void esxVI_Int_Free(esxVI_Int **numberList);
int esxVI_Int_Validate(esxVI_Int *number);
int esxVI_Int_AppendToList(esxVI_Int **numberList, esxVI_Int *number);
int esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src);
int esxVI_Int_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Int **number);
int esxVI_Int_Serialize(esxVI_Int *number, const char *element,
virBufferPtr output);
int esxVI_Int_SerializeList(esxVI_Int *numberList, const char *element,