diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-11 22:08:28 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-11 22:08:28 +0000 |
commit | 1eb3e9989a8241c1654788fc7589e1f679e73dff (patch) | |
tree | 00f181e6187be0a35f9b1bf438e1fb81c2255ef2 /libc/misc/lsearch/lsearch.c | |
parent | 22ed2fc2317bd267d32949bd4c3409f4cbdd0fe6 (diff) |
New misc tree that actually has misc stuff in it.
Diffstat (limited to 'libc/misc/lsearch/lsearch.c')
-rw-r--r-- | libc/misc/lsearch/lsearch.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libc/misc/lsearch/lsearch.c b/libc/misc/lsearch/lsearch.c new file mode 100644 index 000000000..aed4b1e7d --- /dev/null +++ b/libc/misc/lsearch/lsearch.c @@ -0,0 +1,43 @@ +/* + * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath) + * + * + * Dale Schumacher 399 Beacon Ave. + * (alias: Dalnefre') St. Paul, MN 55104 + * dal@syntel.UUCP United States of America + * "It's not reality that's important, but how you perceive things." + */ + +#include <stdio.h> + +char *lfind(key, base, num, size, cmp) +register char *key, *base; +unsigned int *num; +register unsigned int size; +register int (*cmp) (); +{ + register int n = *num; + + while (n--) { + if ((*cmp) (base, key) == 0) + return (base); + base += size; + } + return (NULL); +} + +char *lsearch(key, base, num, size, cmp) +char *key, *base; +register unsigned int *num; +register unsigned int size; +int (*cmp) (); +{ + register char *p; + char *memcpy(); + + if ((p = lfind(key, base, num, size, cmp)) == NULL) { + p = memcpy((base + (size * (*num))), key, size); + ++(*num); + } + return (p); +} |