value.c revision 15a44745412679c30a6d022733925af70a38b715
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * Copyright (C) 1996-2000 Internet Software Consortium.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * Permission to use, copy, modify, and distribute this software for any
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * purpose with or without fee is hereby granted, provided that the above
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * copyright notice and this permission notice appear in all copies.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley/* $Id: value.c,v 1.8 2000/07/27 09:54:26 tale Exp $ */
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley/* Principal Author: Ted Lemon */
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_reference(omapi_value_t **r, omapi_value_t *h) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if (--((*h)->refcnt) <= 0) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley isc_mem_put(omapi_mctx, *h, sizeof(omapi_value_t));
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_storedata(omapi_value_t **vp, omapi_string_t *name,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_storemem(omapi_value_t **vp, omapi_string_t *name,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley memcpy((*vp)->value->u.buffer.value, value, len);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_storeint(omapi_value_t **vp, omapi_string_t *name, int value)
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley result = omapi_data_create(&(*vp)->value, omapi_datatype_int);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_storeobject(omapi_value_t **vp, omapi_string_t *name,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley result = omapi_data_create(&(*vp)->value, omapi_datatype_int);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_storestr(omapi_value_t **vp, omapi_string_t *name, char *value)
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley REQUIRE(value->value->type == omapi_datatype_int ||
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley (value->value->type == omapi_datatype_string)) &&
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley value->value->u.buffer.len == sizeof(isc_uint32_t)));
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * WARNING: The region is valid only as long as the value pointer
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * is valid. See omapi.h.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyomapi_value_getregion(omapi_value_t *value, isc_region_t *region) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley REQUIRE(value->value->type == omapi_datatype_data ||
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * Boy, the word "value" appears a lot. Almost like a Smurf song.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley * La la la la la la, la la la la la.