mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
renamed omapi_value_asint to omapi_value_getint, added omapi_value_getregion
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: value.c,v 1.2 2000/01/24 05:35:18 tale Exp $ */
|
/* $Id: value.c,v 1.3 2000/01/31 14:59:23 tale Exp $ */
|
||||||
|
|
||||||
/* Principal Author: Ted Lemon */
|
/* Principal Author: Ted Lemon */
|
||||||
|
|
||||||
@@ -181,23 +181,31 @@ omapi_value_storestr(omapi_value_t **vp, omapi_string_t *name, char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
omapi_value_asint(omapi_data_t *t) {
|
omapi_value_getint(omapi_value_t *value) {
|
||||||
isc_uint32_t stored_value; /* Stored in network byte order. */
|
REQUIRE(value != NULL && value->value != NULL);
|
||||||
|
REQUIRE(value->value->type == omapi_datatype_int ||
|
||||||
|
((value->value->type == omapi_datatype_data ||
|
||||||
|
(value->value->type == omapi_datatype_string)) &&
|
||||||
|
value->value->u.buffer.len == sizeof(isc_uint32_t)));
|
||||||
|
|
||||||
REQUIRE(t != NULL);
|
return (omapi_data_getint(value->value));
|
||||||
REQUIRE(t->type == omapi_datatype_int ||
|
|
||||||
((t->type == omapi_datatype_data ||
|
|
||||||
(t->type == omapi_datatype_string)) &&
|
|
||||||
t->u.buffer.len == sizeof(stored_value)));
|
|
||||||
|
|
||||||
if (t->type == omapi_datatype_int)
|
|
||||||
return (t->u.integer);
|
|
||||||
|
|
||||||
else if (t->type == omapi_datatype_string ||
|
|
||||||
t->type == omapi_datatype_data) {
|
|
||||||
memcpy(&stored_value, t->u.buffer.value, sizeof(stored_value));
|
|
||||||
return (ntohl(stored_value));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WARNING: The region is valid only as long as the value pointer
|
||||||
|
* is valid. See omapi.h.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
omapi_value_getregion(omapi_value_t *value, isc_region_t *region) {
|
||||||
|
REQUIRE(value != NULL && value->value != NULL);
|
||||||
|
REQUIRE(value->value->type == omapi_datatype_data ||
|
||||||
|
value->value->type == omapi_datatype_string);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boy, the word "value" appears a lot. Almost like a Smurf song.
|
||||||
|
* La la la la la la, la la la la la.
|
||||||
|
*/
|
||||||
|
region->base = value->value->u.buffer.value;
|
||||||
|
region->length = value->value->u.buffer.len;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user