Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / lib / libcompat / 4.3 / lsearch.3
1 .\" Copyright (c) 1989, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)lsearch.3   8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libcompat/4.3/lsearch.3,v 1.4.2.4 2001/12/17 10:08:29 ru Exp $
34 .\" $DragonFly: src/lib/libcompat/4.3/Attic/lsearch.3,v 1.2 2003/06/17 04:26:48 dillon Exp $
35 .\"
36 .Dd June 4, 1993
37 .Dt LSEARCH 3
38 .Os
39 .Sh NAME
40 .Nm lsearch ,
41 .Nm lfind
42 .Nd linear searching routines
43 .Sh LIBRARY
44 .Lb libcompat
45 .Sh SYNOPSIS
46 .In sys/types.h
47 .Ft char *
48 .Fn lsearch "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
49 .Ft char *
50 .Fn lfind "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
51 .Sh DESCRIPTION
52 .Bf -symbolic
53 This interface was obsolete before it was written.
54 .Ef
55 .Pp
56 The functions
57 .Fn lsearch ,
58 and
59 .Fn lfind
60 provide basic linear searching functionality.
61 .Pp
62 .Fa Base
63 is the pointer to the beginning of an array.
64 The argument
65 .Fa nelp
66 is the current number of elements in the array, where each element
67 is
68 .Fa width
69 bytes long.
70 The
71 .Fa compar
72 function
73 is a comparison routine which is used to compare two elements.
74 It takes two arguments which point to the
75 .Fa key
76 object and to an array member, in that order, and must return an integer
77 less than, equivalent to, or greater than zero if the
78 .Fa key
79 object is considered, respectively, to be less than, equal to, or greater
80 than the array member.
81 .Pp
82 The
83 .Fn lsearch
84 and
85 .Fn lfind
86 functions
87 return a pointer into the array referenced by
88 .Fa base
89 where
90 .Fa key
91 is located.
92 If
93 .Fa key
94 does not exist,
95 .Fn lfind
96 will return a null pointer and
97 .Fn lsearch
98 will add it to the array.
99 When an element is added to the array by
100 .Fn lsearch
101 the location referenced by the argument
102 .Fa nelp
103 is incremented by one.
104 .Sh SEE ALSO
105 .Xr bsearch 3 ,
106 .Xr db 3