lwsearch.c revision ec5347e2c775f027573ce5648b910361aa926c01
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (C) 2000, 2001 Internet Software Consortium.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * purpose with or without fee is hereby granted, provided that the above
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * copyright notice and this permission notice appear in all copies.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * PERFORMANCE OF THIS SOFTWARE.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* $Id: lwsearch.c,v 1.12 2007/06/18 23:47:18 tbox Exp $ */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define LWSEARCHLIST_MAGIC ISC_MAGIC('L', 'W', 'S', 'L')
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define VALID_LWSEARCHLIST(l) ISC_MAGIC_VALID(l, LWSEARCHLIST_MAGIC)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchlist_create(isc_mem_t *mctx, ns_lwsearchlist_t **listp) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews list = isc_mem_get(mctx, sizeof(ns_lwsearchlist_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews isc_mem_put(mctx, list, sizeof(ns_lwsearchlist_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchlist_attach(ns_lwsearchlist_t *source, ns_lwsearchlist_t **target) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchlist_detach(ns_lwsearchlist_t **listp) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews isc_mem_put(list->mctx, name, sizeof(dns_name_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews isc_mem_put(mctx, list, sizeof(ns_lwsearchlist_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchlist_append(ns_lwsearchlist_t *list, dns_name_t *name) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews newname = isc_mem_get(list->mctx, sizeof(dns_name_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews result = dns_name_dup(name, list->mctx, newname);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews isc_mem_put(list->mctx, newname, sizeof(dns_name_t));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchctx_init(ns_lwsearchctx_t *sctx, ns_lwsearchlist_t *list,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (dns_name_isabsolute(name) || list == NULL) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sctx->searchname = ISC_LIST_HEAD(sctx->list->names);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sctx->searchname = ISC_LIST_NEXT(sctx->searchname,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (sctx->searchname == NULL && sctx->doneexact)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsns_lwsearchctx_current(ns_lwsearchctx_t *sctx, dns_name_t *absname) {