* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / libc / misc / lsearch.c
blobf3253e92501f314f10541af1a6d8a8be9675201d
1 /*
2 * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
4 *
5 * Dale Schumacher 399 Beacon Ave.
6 * (alias: Dalnefre') St. Paul, MN 55104
7 * dal@syntel.UUCP United States of America
8 * "It's not reality that's important, but how you perceive things."
9 */
11 #include <stdio.h>
13 char *
14 lfind(key, base, num, size, cmp)
15 register char *key, *base;
16 unsigned int *num;
17 register unsigned int size;
18 register int (*cmp) ();
20 register int n = *num;
22 while (n--)
24 if ((*cmp) (base, key) == 0)
25 return (base);
26 base += size;
28 return (NULL);
31 char *
32 lsearch(key, base, num, size, cmp)
33 char *key, *base;
34 register unsigned int *num;
35 register unsigned int size;
36 int (*cmp) ();
38 register char *p;
39 char *memcpy();
41 if ((p = lfind(key, base, num, size, cmp)) == NULL)
43 p = memcpy((base + (size * (*num))), key, size);
44 ++(*num);
46 return (p);