lqueue \
lstack \
md4 \
- memmem \
+ mem \
net \
nfs \
noerr \
--- /dev/null
+../../licenses/CC0
\ No newline at end of file
--- /dev/null
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+
+/**
+ * mem - Provide mem*() functions if missing from C library
+ *
+ * This code implements some string.h mem*() functions if they're not
+ * already available in the C library. Functions included are:
+ * memmem()
+ *
+ * License: CC0
+ */
+int main(int argc, char *argv[])
+{
+ /* Expect exactly one argument */
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ if (strcmp(argv[1], "testdepends") == 0) {
+ printf("ccan/array_size");
+ return 0;
+ }
+
+ return 1;
+}
--- /dev/null
+/* CC0 (Public domain) - see LICENSE file for details */
+
+#include "config.h"
+
+#include <string.h>
+#include <ccan/mem/mem.h>
+
+#if !HAVE_MEMMEM
+void *memmem(const void *haystack, size_t haystacklen,
+ const void *needle, size_t needlelen)
+{
+ const char *p;
+
+ if (needlelen > haystacklen)
+ return NULL;
+
+ p = haystack;
+
+ for (p = haystack;
+ (p + needlelen) <= ((const char *)haystack + haystacklen);
+ p++)
+ if (memcmp(p, needle, needlelen) == 0)
+ return (void *)p;
+
+ return NULL;
+}
+#endif
--- /dev/null
+/* CC0 (Public domain) - see LICENSE file for details */
+#ifndef CCAN_MEM_H
+#define CCAN_MEM_H
+
+#include "config.h"
+
+#include <string.h>
+
+#if !HAVE_MEMMEM
+void *memmem(const void *haystack, size_t haystacklen,
+ const void *needle, size_t needlelen);
+#endif
+
+#endif /* CCAN_MEM_H */
--- /dev/null
+#include <ccan/array_size/array_size.h>
+#include <ccan/mem/mem.h>
+#include <ccan/tap/tap.h>
+
+int main(void)
+{
+ char haystack1[] = "abcd\0efgh";
+ char needle1[] = "ab";
+ char needle2[] = "d\0e";
+
+ /* This is how many tests you plan to run */
+ plan_tests(3);
+
+ ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
+ ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
+ ok1(memmem(haystack1, sizeof(haystack1), needle2, 3) == (haystack1 + 3));
+
+ /* This exits depending on whether all tests passed */
+ return exit_status();
+}
+++ /dev/null
-../../licenses/CC0
\ No newline at end of file
+++ /dev/null
-#include "config.h"
-#include <stdio.h>
-#include <string.h>
-
-/**
- * memmem - Trivial module providing a memmem() implementation
- *
- * This code implements memmem() if it's not alreayd available in the
- * C library.
- *
- * License: CC0
- */
-int main(int argc, char *argv[])
-{
- /* Expect exactly one argument */
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- if (strcmp(argv[1], "testdepends") == 0) {
- printf("ccan/array_size");
- return 0;
- }
-
- return 1;
-}
+++ /dev/null
-/* CC0 (Public domain) - see LICENSE file for details */
-
-#include "config.h"
-
-#include <string.h>
-#include <ccan/memmem/memmem.h>
-
-#if !HAVE_MEMMEM
-void *memmem(const void *haystack, size_t haystacklen,
- const void *needle, size_t needlelen)
-{
- const char *p;
-
- if (needlelen > haystacklen)
- return NULL;
-
- p = haystack;
-
- for (p = haystack;
- (p + needlelen) <= ((const char *)haystack + haystacklen);
- p++)
- if (memcmp(p, needle, needlelen) == 0)
- return (void *)p;
-
- return NULL;
-}
-#endif
+++ /dev/null
-/* CC0 (Public domain) - see LICENSE file for details */
-#ifndef CCAN_MEMMEM_H
-#define CCAN_MEMMEM_H
-
-#include "config.h"
-
-#include <string.h>
-
-#if !HAVE_MEMMEM
-void *memmem(const void *haystack, size_t haystacklen,
- const void *needle, size_t needlelen);
-#endif
-
-#endif /* CCAN_MEMMEM_H */
+++ /dev/null
-#include <ccan/array_size/array_size.h>
-#include <ccan/memmem/memmem.h>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
- char haystack1[] = "abcd\0efgh";
- char needle1[] = "ab";
- char needle2[] = "d\0e";
-
- /* This is how many tests you plan to run */
- plan_tests(3);
-
- ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
- ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
- ok1(memmem(haystack1, sizeof(haystack1), needle2, 3) == (haystack1 + 3));
-
- /* This exits depending on whether all tests passed */
- return exit_status();
-}
printf("ccan/list\n");
printf("ccan/str\n");
printf("ccan/bytestring\n");
- printf("ccan/memmem\n");
+ printf("ccan/mem\n");
return 0;
}
#include <ccan/list/list.h>
#include <stdio.h>
-#include <ccan/memmem/memmem.h>
+#include <ccan/mem/mem.h>
#include <ccan/rfc822/rfc822.h>
#ifdef TAL_USE_TALLOC