1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)lsearch.3 8.1 (Berkeley) 06/04/93 7.\" 8.Dd 9.Dt LSEARCH 3 10.Os 11.Sh NAME 12.Nm lsearch , 13.Nm lfind, 14.Nd linear searching routines 15.Sh SYNOPSIS 16.Ft char * 17.Fn lsearch "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)" 18.Ft char * 19.Fn lfind "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)" 20.Sh DESCRIPTION 21.Bf -symbolic 22This interface was obsolete before it was written. 23It is available from the compatibility library, libcompat. 24.Ef 25.Pp 26The functions 27.Fn lsearch , 28and 29.Fn lfind 30provide basic linear searching functionality. 31.Pp 32.Fa Base 33is the pointer to the beginning of an array. 34The argument 35.Fa nelp 36is the current number of elements in the array, where each element 37is 38.Fa width 39bytes long. 40The 41.Fa compar 42function 43is a comparison routine which is used to compare two elements. 44It takes two arguments which point to the 45.Fa key 46object and to an array member, in that order, and must return an integer 47less than, equivalent to, or greater than zero if the 48.Fa key 49object is considered, respectively, to be less than, equal to, or greater 50than the array member. 51.Pp 52The 53.Fn lsearch 54and 55.Fn lfind 56functions 57return a pointer into the array referenced by 58.Fa base 59where 60.Fa key 61is located. 62If 63.Fa key 64does not exist, 65.Fn lfind 66will return a null pointer and 67.Fn lsearch 68will add it to the array. 69When an element is added to the array by 70.Fn lsearch 71the location referenced by the argument 72.Fa nelp 73is incremented by one. 74.Sh SEE ALSO 75.Xr bsearch 3 , 76.Xr db 3 77