3 /* lsearch(3) and lfind(3)
5 * Author: Terrence W. Holm Sep. 1988
10 _PROTOTYPE( char *lsearch
, (char *key
, char *base
,
11 unsigned *count
, unsigned width
,
12 int (*keycmp
)(const void *, const void *)));
13 _PROTOTYPE( char *lfind
, (char *key
, char *base
,
14 unsigned *count
, unsigned width
,
15 int (*keycmp
)(const void *, const void *)));
17 char *lsearch(key
, base
, count
, width
, keycmp
)
22 _PROTOTYPE( int (*keycmp
), (const void *, const void *));
25 char *last
= base
+ *count
* width
;
27 for (entry
= base
; entry
< last
; entry
+= width
)
28 if (keycmp(key
, entry
) == 0) return(entry
);
30 bcopy(key
, last
, width
);
36 char *lfind(key
, base
, count
, width
, keycmp
)
41 _PROTOTYPE( int (*keycmp
), (const void *, const void *));
44 char *last
= base
+ *count
* width
;
46 for (entry
= base
; entry
< last
; entry
+= width
)
47 if (keycmp(key
, entry
) == 0) return(entry
);