xref: /csrg-svn/lib/libcompat/4.3/lsearch.3 (revision 61241)
1*61241Sbostic.\" Copyright (c) 1989, 1991, 1993
2*61241Sbostic.\"	The Regents of the University of California.  All rights reserved.
339299Sbostic.\"
443565Strent.\" %sccs.include.redist.man%
539299Sbostic.\"
6*61241Sbostic.\"     @(#)lsearch.3	8.1 (Berkeley) 06/04/93
739299Sbostic.\"
848349Scael.Dd
948349Scael.Dt LSEARCH 3
1048349Scael.Os
1148349Scael.Sh NAME
1248349Scael.Nm lsearch ,
1348349Scael.Nm lfind,
1448349Scael.Nd linear searching routines
1548349Scael.Sh SYNOPSIS
1648349Scael.Ft char *
1748349Scael.Fn lsearch "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
1848349Scael.Ft char *
1948349Scael.Fn lfind "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
2048349Scael.Sh DESCRIPTION
2148349Scael.Bf -symbolic
2240196SbosticThis interface was obsolete before it was written.
2340196SbosticIt is available from the compatibility library, libcompat.
2448349Scael.Ef
2548349Scael.Pp
2639299SbosticThe functions
2748349Scael.Fn lsearch ,
2839299Sbosticand
2948349Scael.Fn lfind
3039299Sbosticprovide basic linear searching functionality.
3148349Scael.Pp
3248349Scael.Fa Base
3339299Sbosticis the pointer to the beginning of an array.
3448349ScaelThe argument
3548349Scael.Fa nelp
3639299Sbosticis the current number of elements in the array, where each element
3739299Sbosticis
3848349Scael.Fa width
3939299Sbosticbytes long.
4048349ScaelThe
4148349Scael.Fa compar
4248349Scaelfunction
4339299Sbosticis a comparison routine which is used to compare two elements.
4448349ScaelIt takes two arguments which point to the
4548349Scael.Fa key
4640196Sbosticobject and to an array member, in that order, and must return an integer
4748349Scaelless than, equivalent to, or greater than zero if the
4848349Scael.Fa key
4940196Sbosticobject is considered, respectively, to be less than, equal to, or greater
5040196Sbosticthan the array member.
5148349Scael.Pp
5248349ScaelThe
5348349Scael.Fn lsearch
5439299Sbosticand
5548349Scael.Fn lfind
5648349Scaelfunctions
5739299Sbosticreturn a pointer into the array referenced by
5848349Scael.Fa base
5939299Sbosticwhere
6048349Scael.Fa key
6139299Sbosticis located.
6239299SbosticIf
6348349Scael.Fa key
6439299Sbosticdoes not exist,
6548349Scael.Fn lfind
6648349Scaelwill return a null pointer and
6748349Scael.Fn lsearch
6839299Sbosticwill add it to the array.
6939299SbosticWhen an element is added to the array by
7048349Scael.Fn lsearch
7139299Sbosticthe location referenced by the argument
7248349Scael.Fa nelp
7339299Sbosticis incremented by one.
7448349Scael.Sh SEE ALSO
7548349Scael.Xr bsearch 3 ,
7648376Scael.Xr db 3
77