summaryrefslogtreecommitdiff
path: root/libc/misc/search/_lsearch.c
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2006-02-13 07:19:48 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2006-02-13 07:19:48 +0000
commit875a2e681496b4017e26ade47f72921e62898143 (patch)
tree3a7263afe2303e8bf7f62a11f17c7f1d1f203564 /libc/misc/search/_lsearch.c
parent7402c2f51bf55dc9d29dfb3397135719d0300b65 (diff)
Rename some files, that will conflict w/ IMA
Diffstat (limited to 'libc/misc/search/_lsearch.c')
-rw-r--r--libc/misc/search/_lsearch.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libc/misc/search/_lsearch.c b/libc/misc/search/_lsearch.c
new file mode 100644
index 000000000..eefef2121
--- /dev/null
+++ b/libc/misc/search/_lsearch.c
@@ -0,0 +1,51 @@
+/*
+ * 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 <string.h>
+#include <stdio.h>
+#include <search.h>
+
+libc_hidden_proto(lfind)
+
+#ifdef L_lfind
+
+void *lfind(const void *key, const void *base, size_t *nmemb,
+ size_t size, int (*compar)(const void *, const void *))
+{
+ register int n = *nmemb;
+
+ while (n--) {
+ if ((*compar) (base, key) == 0)
+ return ((void*)base);
+ base += size;
+ }
+ return (NULL);
+}
+libc_hidden_def(lfind)
+
+#endif
+
+#ifdef L_lsearch
+
+libc_hidden_proto(memcpy)
+
+void *lsearch(const void *key, void *base, size_t *nmemb,
+ size_t size, int (*compar)(const void *, const void *))
+{
+ register char *p;
+
+ if ((p = lfind(key, base, nmemb, size, compar)) == NULL) {
+ p = memcpy((base + (size * (*nmemb))), key, size);
+ ++(*nmemb);
+ }
+ return (p);
+}
+
+#endif