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