lwsearch.h revision 135446
1/*
2 * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001  Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/* $Id: lwsearch.h,v 1.4.208.1 2004/03/06 10:21:25 marka Exp $ */
19
20#ifndef NAMED_LWSEARCH_H
21#define NAMED_LWSEARCH_H 1
22
23#include <isc/mutex.h>
24#include <isc/result.h>
25#include <isc/types.h>
26
27#include <dns/types.h>
28
29#include <named/types.h>
30
31/*
32 * Lightweight resolver search list types and routines.
33 *
34 * An ns_lwsearchlist_t holds a list of search path elements.
35 *
36 * An ns_lwsearchctx stores the state of search list during a lookup
37 * operation.
38 */
39
40struct ns_lwsearchlist {
41	unsigned int magic;
42
43	isc_mutex_t lock;
44	isc_mem_t *mctx;
45	unsigned int refs;
46	dns_namelist_t names;
47};
48
49struct ns_lwsearchctx {
50	dns_name_t *relname;
51	dns_name_t *searchname;
52	unsigned int ndots;
53	ns_lwsearchlist_t *list;
54	isc_boolean_t doneexact;
55	isc_boolean_t exactfirst;
56};
57
58isc_result_t
59ns_lwsearchlist_create(isc_mem_t *mctx, ns_lwsearchlist_t **listp);
60/*
61 * Create an empty search list object.
62 */
63
64void
65ns_lwsearchlist_attach(ns_lwsearchlist_t *source, ns_lwsearchlist_t **target);
66/*
67 * Attach to a search list object.
68 */
69
70void
71ns_lwsearchlist_detach(ns_lwsearchlist_t **listp);
72/*
73 * Detach from a search list object.
74 */
75
76isc_result_t
77ns_lwsearchlist_append(ns_lwsearchlist_t *list, dns_name_t *name);
78/*
79 * Append an element to a search list.  This creates a copy of the name.
80 */
81
82void
83ns_lwsearchctx_init(ns_lwsearchctx_t *sctx, ns_lwsearchlist_t *list,
84		    dns_name_t *name, unsigned int ndots);
85/*
86 * Creates a search list context structure.
87 */
88
89void
90ns_lwsearchctx_first(ns_lwsearchctx_t *sctx);
91/*
92 * Moves the search list context iterator to the first element, which
93 * is usually the exact name.
94 */
95
96isc_result_t
97ns_lwsearchctx_next(ns_lwsearchctx_t *sctx);
98/*
99 * Moves the search list context iterator to the next element.
100 */
101
102isc_result_t
103ns_lwsearchctx_current(ns_lwsearchctx_t *sctx, dns_name_t *absname);
104/*
105 * Obtains the current name to be looked up.  This involves either
106 * concatenating the name with a search path element, making an
107 * exact name absolute, or doing nothing.
108 */
109
110#endif /* NAMED_LWSEARCH_H */
111