LSEARCH(3) BSD Programmer's Manual LSEARCH(3) NNAAMMEE llsseeaarrcchh, llffiinndd,, - linear searching routines SSYYNNOOPPSSIISS _c_h_a_r _* llsseeaarrcchh(_c_o_n_s_t _v_o_i_d _*_k_e_y, _c_o_n_s_t _v_o_i_d _*_b_a_s_e, _s_i_z_e___t _*_n_e_l_p, _s_i_z_e___t _w_i_d_t_h, _i_n_t _(_*_c_o_m_p_a_r_)_(_v_o_i_d _*_, _v_o_i_d _*_)); _c_h_a_r _* llffiinndd(_c_o_n_s_t _v_o_i_d _*_k_e_y, _c_o_n_s_t _v_o_i_d _*_b_a_s_e, _s_i_z_e___t _*_n_e_l_p, _s_i_z_e___t _w_i_d_t_h, _i_n_t _(_*_c_o_m_p_a_r_)_(_v_o_i_d _*_, _v_o_i_d _*_)); DDEESSCCRRIIPPTTIIOONN TThhiiss iinntteerrffaaccee wwaass oobbssoolleettee bbeeffoorree iitt wwaass wwrriitttteenn.. IItt iiss aavvaaiillaabbllee ffrroomm tthhee ccoommppaattiibbiilliittyy lliibbrraarryy,, lliibbccoommppaatt.. The functions llsseeaarrcchh(), and llffiinndd() provide basic linear searching func- tionality. _B_a_s_e is the pointer to the beginning of an array. The argument _n_e_l_p is the current number of elements in the array, where each element is _w_i_d_t_h bytes long. The _c_o_m_p_a_r function is a comparison routine which is used to compare two elements. It takes two arguments which point to the _k_e_y 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 _k_e_y object is con- sidered, respectively, to be less than, equal to, or greater than the ar- ray member. The llsseeaarrcchh() and llffiinndd() functions return a pointer into the array ref- erenced by _b_a_s_e where _k_e_y is located. If _k_e_y does not exist, llffiinndd() will return a null pointer and llsseeaarrcchh() will add it to the array. When an element is added to the array by llsseeaarrcchh() the location referenced by the argument _n_e_l_p is incremented by one. SSEEEE AALLSSOO bsearch(3), db(3) 4.4BSD June 4, 1993 1