LSEARCH(3) BSD Programmer's Manual LSEARCH(3)
l
\bls
\bse
\bea
\bar
\brc
\bch
\bh, l
\blf
\bfi
\bin
\bnd
\bd,
\b, - linear searching routines
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
l
\bls
\bse
\bea
\bar
\brc
\bch
\bh(_
\bc_
\bo_
\bn_
\bs_
\bt _
\bv_
\bo_
\bi_
\bd _
\b*_
\bk_
\be_
\by, _
\bc_
\bo_
\bn_
\bs_
\bt _
\bv_
\bo_
\bi_
\bd _
\b*_
\bb_
\ba_
\bs_
\be, _
\bs_
\bi_
\bz_
\be_
\b__
\bt _
\b*_
\bn_
\be_
\bl_
\bp, _
\bs_
\bi_
\bz_
\be_
\b__
\bt _
\bw_
\bi_
\bd_
\bt_
\bh,
_
\bi_
\bn_
\bt _
\b(_
\b*_
\bc_
\bo_
\bm_
\bp_
\ba_
\br_
\b)_
\b(_
\bv_
\bo_
\bi_
\bd _
\b*_
\b, _
\bv_
\bo_
\bi_
\bd _
\b*_
\b));
l
\blf
\bfi
\bin
\bnd
\bd(_
\bc_
\bo_
\bn_
\bs_
\bt _
\bv_
\bo_
\bi_
\bd _
\b*_
\bk_
\be_
\by, _
\bc_
\bo_
\bn_
\bs_
\bt _
\bv_
\bo_
\bi_
\bd _
\b*_
\bb_
\ba_
\bs_
\be, _
\bs_
\bi_
\bz_
\be_
\b__
\bt _
\b*_
\bn_
\be_
\bl_
\bp, _
\bs_
\bi_
\bz_
\be_
\b__
\bt _
\bw_
\bi_
\bd_
\bt_
\bh,
_
\bi_
\bn_
\bt _
\b(_
\b*_
\bc_
\bo_
\bm_
\bp_
\ba_
\br_
\b)_
\b(_
\bv_
\bo_
\bi_
\bd _
\b*_
\b, _
\bv_
\bo_
\bi_
\bd _
\b*_
\b));
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
T
\bTh
\bhi
\bis
\bs i
\bin
\bnt
\bte
\ber
\brf
\bfa
\bac
\bce
\be w
\bwa
\bas
\bs o
\bob
\bbs
\bso
\bol
\ble
\bet
\bte
\be b
\bbe
\bef
\bfo
\bor
\bre
\be i
\bit
\bt w
\bwa
\bas
\bs w
\bwr
\bri
\bit
\btt
\bte
\ben
\bn.
\b. I
\bIt
\bt i
\bis
\bs a
\bav
\bva
\bai
\bil
\bla
\bab
\bbl
\ble
\be f
\bfr
\bro
\bom
\bm
t
\bth
\bhe
\be c
\bco
\bom
\bmp
\bpa
\bat
\bti
\bib
\bbi
\bil
\bli
\bit
\bty
\by l
\bli
\bib
\bbr
\bra
\bar
\bry
\by,
\b, l
\bli
\bib
\bbc
\bco
\bom
\bmp
\bpa
\bat
\bt.
\b.
The functions l
\bls
\bse
\bea
\bar
\brc
\bch
\bh(), and l
\blf
\bfi
\bin
\bnd
\bd() provide basic linear searching func-
_
\bB_
\ba_
\bs_
\be is the pointer to the beginning of an array. The argument _
\bn_
\be_
\bl_
\bp is
the current number of elements in the array, where each element is _
\bw_
\bi_
\bd_
\bt_
\bh
bytes long. The _
\bc_
\bo_
\bm_
\bp_
\ba_
\br function is a comparison routine which is used to
compare two elements. It takes two arguments which point to the _
\bk_
\be_
\by ob-
ject and to an array member, in that order, and must return an integer
less than, equivalent to, or greater than zero if the _
\bk_
\be_
\by object is con-
sidered, respectively, to be less than, equal to, or greater than the ar-
The l
\bls
\bse
\bea
\bar
\brc
\bch
\bh() and l
\blf
\bfi
\bin
\bnd
\bd() functions return a pointer into the array ref-
erenced by _
\bb_
\ba_
\bs_
\be where _
\bk_
\be_
\by is located. If _
\bk_
\be_
\by does not exist, l
\blf
\bfi
\bin
\bnd
\bd()
will return a null pointer and l
\bls
\bse
\bea
\bar
\brc
\bch
\bh() will add it to the array. When
an element is added to the array by l
\bls
\bse
\bea
\bar
\brc
\bch
\bh() the location referenced by
the argument _
\bn_
\be_
\bl_
\bp is incremented by one.
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO