date and time created 90/05/03 17:47:31 by bostic
[unix-history] / usr / src / lib / libcompat / 4.3 / lsearch.3
CommitLineData
a7c86a7b
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
8190f343 16.\" @(#)lsearch.3 5.2 (Berkeley) %G%
a7c86a7b
KB
17.\"
18.TH LSEARCH 3 ""
19.UC 7
20.SH NAME
8190f343 21lsearch, lfind, \- linear searching routines
a7c86a7b
KB
22.SH SYNOPSIS
23.ft B
24.nf
8190f343
KB
25char *
26lsearch(const void *key, const void *base,
27size_t *nelp, size_t width,
28int (*compar) (void *, void *));
a7c86a7b 29.sp
8190f343
KB
30char *
31lfind(const void *key, const void *base,
32size_t *nelp, size_t width,
33int (*compar) (void *, void *));
a7c86a7b
KB
34.ft R
35.SH DESCRIPTION
8190f343
KB
36.ft B
37This interface was obsolete before it was written.
38It is available from the compatibility library, libcompat.
39.ft R
40.PP
a7c86a7b
KB
41The functions
42.IR lsearch ,
a7c86a7b 43and
8190f343 44.IR lfind
a7c86a7b
KB
45provide basic linear searching functionality.
46.PP
47.I Base
48is the pointer to the beginning of an array.
49.I Nelp
50is the current number of elements in the array, where each element
51is
52.I width
53bytes long.
54.I Compar
55is a comparison routine which is used to compare two elements.
8190f343
KB
56It is called with two arguments that point to the
57.I key
58object and to an array member, in that order, and must return an integer
59less than, equal to, or greater than zero if the
60.I key
61object is considered, respectively, to be less than, equal to, or greater
62than the array member.
a7c86a7b
KB
63.PP
64.I Lsearch
65and
66.I lfind
67return a pointer into the array referenced by
68.I base
69where
70.I key
71is located.
72If
73.I key
74does not exist,
75.I lfind
76will return a NULL pointer and
77.I lsearch
78will add it to the array.
79When an element is added to the array by
80.I lsearch
81the location referenced by the argument
82.I nelp
83is incremented by one.
a7c86a7b
KB
84.SH "SEE ALSO"
85bsearch(3), hsearch(3), tsearch(3)