confview.c revision bfcdcde570be11e3d210cfdd262fae8b8e6c62ce
7d98a1783f222964bcde7d56dab77b822706204dBob Halley * Copyright (C) 1999, 2000 Internet Software Consortium.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * Permission to use, copy, modify, and distribute this software for any
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * purpose with or without fee is hereby granted, provided that the above
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * copyright notice and this permission notice appear in all copies.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley/* $Id: confview.c,v 1.55 2000/11/08 03:53:14 marka Exp $ */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#include <isc/string.h> /* Required for HP/UX (and others?) */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley** Due to the repetive nature of the fields in a view
5fe5a0c02634eaadfcbc3528bf2c184557110a3bAndreas Gustafsson** we have here a collection of macros to used in defining
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley** accessor/modifier functions for most of the fields in a view.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley** Three functions are created: set, get and unset.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley** In all the macros FUNC is a character sequence that is used in
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley** constructing the final function name. FIELD is the field in the view.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#define SETBOOL(FUNC, FIELD) SETBYTYPE(isc_boolean_t, FUNC, FIELD)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#define GETBOOL(FUNC, FIELD) GETBYTYPE(isc_boolean_t, FUNC, FIELD)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#define UNSETBOOL(FUNC, FIELD) UNSETBYTYPE(isc_boolean_t, FUNC, FIELD)
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson#define SETNOTIFYTYPE(FUNC, FIELD) SETBYTYPE(dns_notifytype_t, FUNC, FIELD)
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson#define GETNOTIFYTYPE(FUNC, FIELD) GETBYTYPE(dns_notifytype_t, FUNC, FIELD)
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson#define UNSETNOTIFYTYPE(FUNC, FIELD) UNSETBYTYPE(dns_notifytype_t, FUNC, FIELD)
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson#define SETDIALUPTYPE(FUNC, FIELD) SETBYTYPE(dns_dialuptype_t, FUNC, FIELD)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#define GETDIALUPTYPE(FUNC, FIELD) GETBYTYPE(dns_dialuptype_t, FUNC, FIELD)
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence#define UNSETDIALUPTYPE(FUNC, FIELD) UNSETBYTYPE(dns_dialuptype_t, FUNC, FIELD)
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley#define SETUINT32(FUNC, FIELD) SETBYTYPE(isc_uint32_t, FUNC, FIELD)
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley#define GETUINT32(FUNC, FIELD) GETBYTYPE(isc_uint32_t, FUNC, FIELD)
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence#define UNSETUINT32(FUNC, FIELD) UNSETBYTYPE(isc_uint32_t, FUNC, FIELD)
c90f5e8d1edbd5c277f2ee320167a12a30ba7c7bMichael Graff#define SETSOCKADDR(FUNC, FIELD) SETBYTYPE(isc_sockaddr_t, FUNC, FIELD)
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence#define GETSOCKADDR(FUNC, FIELD) GETBYTYPE(isc_sockaddr_t, FUNC, FIELD)
c90f5e8d1edbd5c277f2ee320167a12a30ba7c7bMichael Graff#define UNSETSOCKADDR(FUNC, FIELD) UNSETBYTYPE(isc_sockaddr_t, FUNC, FIELD)
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson#define PVT_CONCAT(x,y) x ## y
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson** The SET, GET and UNSETBYTYPE macros are all used whene the field in the
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson** view is a pointer to a fundamental type that requires no special copying,
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson** such as integers or booleans.
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson#define SETBYTYPE(TYPE, FUNCNAME, FIELDNAME) \
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas GustafssonPVT_CONCAT(dns_c_view_set, FUNCNAME)(dns_c_view_t *view, TYPE newval) { \
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley view->FIELDNAME = isc_mem_get(view->mem, sizeof (TYPE)); \
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson return (existed ? ISC_R_EXISTS : ISC_R_SUCCESS); \
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson#define GETBYTYPE(TYPE, FUNCNAME, FIELDNAME) \
11d435aa4cf77e035445978f7e3776a3589715fdAndreas GustafssonPVT_CONCAT(dns_c_view_get, FUNCNAME)(dns_c_view_t *view, TYPE *retval) {\
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson#define UNSETBYTYPE(TYPE, FUNCNAME, FIELDNAME) \
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas GustafssonPVT_CONCAT(dns_c_view_unset, FUNCNAME)(dns_c_view_t *view) { \
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson isc_mem_put(view->mem, view->FIELDNAME, \
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson** Now SET, GET and UNSET for dns_c_ipmatchlist_t fields
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas GustafssonPVT_CONCAT(dns_c_view_set, FUNCNAME)(dns_c_view_t *view, \
5542df09597c479be604da0ece8271cbc6fd9c4aDavid Lawrence dns_c_ipmatchlist_attach(newval, &view->FIELDNAME); \
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob HalleyPVT_CONCAT(dns_c_view_unset, FUNCNAME)(dns_c_view_t *view) { \
return (ISC_R_NOTFOUND); \
return (ISC_R_SUCCESS); \
return (ISC_R_NOTFOUND); \
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
isc_result_t r;
if (r != ISC_R_SUCCESS) {
return (ISC_R_SUCCESS);
const char *viewname,
const char *name)
return (res);
!= ISC_R_NOTFOUND)
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC
return (ISC_R_SUCCESS);
if (port == 0) { \
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC
ISC_TRUE));
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC
return (ISC_R_SUCCESS);
return rval;
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (res);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
if (deepcopy) {
return (res);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
if (copy) {
return (res);
return (res);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
switch(transtype) {
case dns_trans_primary:
case dns_trans_secondary:
case dns_trans_response:
return (ISC_R_FAILURE);
if (!existed) {
switch (transtype) {
case dns_trans_primary:
case dns_trans_secondary:
case dns_trans_response:
return (ISC_R_FAILURE);
return (result);
switch(transtype) {
case dns_trans_primary:
case dns_trans_secondary:
case dns_trans_response:
return (ISC_R_FAILURE);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_FAILURE);
if (copy) {
return (res);
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC
#ifndef NOMINUM_PUBLIC