# Especially tools/ccanlint/ccanlint and tools/namespacize.
# distclean: destroy everything back to pristine state
-# Anything with an _info.c file is a module.
-ALL=$(patsubst ccan/%/_info.c, %, $(wildcard ccan/*/_info.c))
+# Anything with an _info file is a module.
+ALL=$(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info))
ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
# Not all modules have tests.
ALL_TESTS=$(patsubst ccan/%/test/, %, $(wildcard ccan/*/test/))
distclean: clean
rm -f $(ALL_DEPENDS)
-$(ALL_DEPENDS): %/.depends: %/_info.c tools/ccan_depends
+$(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
@tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
# Actual dependencies are created in inter-depends
-check-%: tools/run_tests ccan/%/_info
+check-%: tools/run_tests ccan/%/info
@echo Testing $*...
- @if tools/run_tests $(V) $$(for f in `ccan/$*/_info libs`; do echo --lib=$$f; done) `[ ! -f ccan/$*.o ] || echo --apiobj=ccan/$*.o` ccan/$* $(filter-out ccan/$*.o, $(filter %.o, $^)) | grep ^'not ok'; then exit 1; else exit 0; fi
+ @if tools/run_tests $(V) $$(for f in `ccan/$*/info libs`; do echo --lib=$$f; done) `[ ! -f ccan/$*.o ] || echo --apiobj=ccan/$*.o` ccan/$* $(filter-out ccan/$*.o, $(filter %.o, $^)) | grep ^'not ok'; then exit 1; else exit 0; fi
-ccan/%/_info: ccan/%/_info.c
- $(CC) $(CFLAGS) -o $@ $<
+ccan/%/info: ccan/%/_info
+ $(CC) $(CFLAGS) -o $@ -x c $<
libccan.a(%.o): ccan/%.o
$(AR) r $@ $<
clean: tools-clean
- $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info` `find . -name '*.d'`
+ $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name info` `find . -name '*.d'`
$(RM) inter-depends lib-depends test-depends
# Creates a dependency from the tests to the object files which it needs.
inter-depends: $(ALL_DEPENDS) Makefile
- @for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/[a-z]*.c)" = "$$dir/[a-z]*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@
+ @for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/*.c)" = "$$dir/*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@
# Creates dependencies between tests, so if foo depends on bar, bar is tested
# first
# Example makefile which makes a "libccan.a" of everything under ccan/.
# For simple projects you could just do:
-# SRCFILES += $(wildcard ccan/*/[a-z]*.c)
+# SRCFILES += $(wildcard ccan/*/*.c)
CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. $(DEPGEN)
DEPGEN=-MD
-include ccan/*/*.d
-# Every directory with .c files (other than _info.c) is included.
-DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/[a-z]*.c))))
+# Every directory with .c files is included.
+DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c))))
# We compile all the ccan/foo/*.o files together into ccan/foo.o
OBJFILES=$(DIRS:=.o)
# Dependencies are autogenerated in the .d files.
# We create all the .o files and link them together.
$(OBJFILES): %.o:
- cd $* && $(CC) -I../.. $(CFLAGS) -c [a-z]*.c && cd ../.. && $(LD) -r -o $@ `echo $*/[a-z]*.c ' ' | sed 's/\.c /.o /g'`
+ cd $* && $(CC) -I../.. $(CFLAGS) -c *.c && cd ../.. && $(LD) -r -o $@ `echo $*/*.c ' ' | sed 's/\.c /.o /g'`
$(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
@URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@
-$(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info.c
+$(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info
tar -c -j -f $@ `bzr ls --versioned --kind=file ccan/$*`
-$(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info.c tools/ccan_depends
+$(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info tools/ccan_depends
tar cfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file)
distclean: distclean-web
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * alignof - ALIGNOF() macro to determine alignment of a type.
+ *
+ * Many platforms have requirements that certain types must be aligned
+ * to certain address boundaries, such as ints needing to be on 4-byte
+ * boundaries. Attempting to access variables with incorrect
+ * alignment may cause performance loss or even program failure (eg. a
+ * bus signal).
+ *
+ * There are times which it's useful to be able to programatically
+ * access these requirements, such as for dynamic allocators.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <stdlib.h>
+ * #include <ccan/alignof/alignof.h>
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * char arr[sizeof(int)];
+ *
+ * if ((unsigned long)arr % ALIGNOF(int)) {
+ * printf("arr %p CANNOT hold an int\n", arr);
+ * exit(1);
+ * } else {
+ * printf("arr %p CAN hold an int\n", arr);
+ * exit(0);
+ * }
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/build_assert\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * alignof - ALIGNOF() macro to determine alignment of a type.
- *
- * Many platforms have requirements that certain types must be aligned
- * to certain address boundaries, such as ints needing to be on 4-byte
- * boundaries. Attempting to access variables with incorrect
- * alignment may cause performance loss or even program failure (eg. a
- * bus signal).
- *
- * There are times which it's useful to be able to programatically
- * access these requirements, such as for dynamic allocators.
- *
- * Example:
- * #include <stdio.h>
- * #include <stdlib.h>
- * #include <ccan/alignof/alignof.h>
- *
- * int main(int argc, char *argv[])
- * {
- * char arr[sizeof(int)];
- *
- * if ((unsigned long)arr % ALIGNOF(int)) {
- * printf("arr %p CANNOT hold an int\n", arr);
- * exit(1);
- * } else {
- * printf("arr %p CAN hold an int\n", arr);
- * exit(0);
- * }
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/build_assert\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * alloc - memory allocator routines
+ *
+ * The alloc module implements a simple allocator which you can use to
+ * dynamically allocate space within a region of memory. This can be useful
+ * for suballocations within a given region, or a memory-mapped file.
+ *
+ * All metadata is kept within the memory handed to the allocator: you only
+ * need hand the pointer and the size of the memory to each call.
+ *
+ * The region contents is always in offsets, so it can be mapped in different
+ * places, but is not endian-safe.
+ *
+ * Example:
+ * #include <sys/mman.h>
+ * #include <unistd.h>
+ * #include <sys/types.h>
+ * #include <err.h>
+ * #include <sys/stat.h>
+ * #include <fcntl.h>
+ * #include <string.h>
+ * #include <ccan/alloc/alloc.h>
+ *
+ * static void usage(const char *name)
+ * {
+ * errx(1, "Usage: %s --create <mapfile>\n"
+ * " %s --check <mapfile>\n"
+ * " %s --alloc <mapfile>\n"
+ * " %s --free=<offset> <mapfile>\n", name, name, name, name);
+ * }
+ *
+ * // Create a memory mapped file, and allocate from within it
+ * int main(int argc, char *argv[])
+ * {
+ * void *a, *p;
+ * int fd;
+ * enum { CREATE, CHECK, ALLOC, FREE } cmd;
+ *
+ * if (argc != 3)
+ * usage(argv[0]);
+ *
+ * if (strcmp(argv[1], "--create") == 0)
+ * cmd = CREATE;
+ * else if (strcmp(argv[1], "--check") == 0)
+ * cmd = CHECK;
+ * else if (strcmp(argv[1], "--alloc") == 0)
+ * cmd = ALLOC;
+ * else if (strncmp(argv[1], "--free=", strlen("--free=")) == 0)
+ * cmd = FREE;
+ * else
+ * usage(argv[0]);
+ *
+ * if (cmd == CREATE) {
+ * fd = open(argv[2], O_RDWR|O_CREAT|O_EXCL, 0600);
+ * if (fd < 0)
+ * err(1, "Could not create %s", argv[2]);
+ * if (ftruncate(fd, 1048576) != 0)
+ * err(1, "Could not set length on %s", argv[2]);
+ * } else {
+ * fd = open(argv[2], O_RDWR);
+ * if (fd < 0)
+ * err(1, "Could not open %s", argv[2]);
+ * }
+ *
+ * a = mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_SHARED, fd,0);
+ * if (a == MAP_FAILED)
+ * err(1, "Could not map %s", argv[2]);
+ *
+ * switch (cmd) {
+ * case CREATE:
+ * alloc_init(a, 1048576);
+ * break;
+ * case CHECK:
+ * if (!alloc_check(a, 1048576))
+ * err(1, "Region is corrupt");
+ * break;
+ * case ALLOC:
+ * p = alloc_get(a, 1048576, 1024, 16);
+ * if (!p)
+ * errx(1, "Could not allocate");
+ * printf("%zu\n", (char *)p - (char *)a);
+ * break;
+ * case FREE:
+ * p = (char *)a + atol(argv[1] + strlen("--free="));
+ * alloc_free(a, 1048576, p);
+ * break;
+ * }
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/build_assert\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * alloc - memory allocator routines
- *
- * The alloc module implements a simple allocator which you can use to
- * dynamically allocate space within a region of memory. This can be useful
- * for suballocations within a given region, or a memory-mapped file.
- *
- * All metadata is kept within the memory handed to the allocator: you only
- * need hand the pointer and the size of the memory to each call.
- *
- * The region contents is always in offsets, so it can be mapped in different
- * places, but is not endian-safe.
- *
- * Example:
- * #include <sys/mman.h>
- * #include <unistd.h>
- * #include <sys/types.h>
- * #include <err.h>
- * #include <sys/stat.h>
- * #include <fcntl.h>
- * #include <string.h>
- * #include <ccan/alloc/alloc.h>
- *
- * static void usage(const char *name)
- * {
- * errx(1, "Usage: %s --create <mapfile>\n"
- * " %s --check <mapfile>\n"
- * " %s --alloc <mapfile>\n"
- * " %s --free=<offset> <mapfile>\n", name, name, name, name);
- * }
- *
- * // Create a memory mapped file, and allocate from within it
- * int main(int argc, char *argv[])
- * {
- * void *a, *p;
- * int fd;
- * enum { CREATE, CHECK, ALLOC, FREE } cmd;
- *
- * if (argc != 3)
- * usage(argv[0]);
- *
- * if (strcmp(argv[1], "--create") == 0)
- * cmd = CREATE;
- * else if (strcmp(argv[1], "--check") == 0)
- * cmd = CHECK;
- * else if (strcmp(argv[1], "--alloc") == 0)
- * cmd = ALLOC;
- * else if (strncmp(argv[1], "--free=", strlen("--free=")) == 0)
- * cmd = FREE;
- * else
- * usage(argv[0]);
- *
- * if (cmd == CREATE) {
- * fd = open(argv[2], O_RDWR|O_CREAT|O_EXCL, 0600);
- * if (fd < 0)
- * err(1, "Could not create %s", argv[2]);
- * if (ftruncate(fd, 1048576) != 0)
- * err(1, "Could not set length on %s", argv[2]);
- * } else {
- * fd = open(argv[2], O_RDWR);
- * if (fd < 0)
- * err(1, "Could not open %s", argv[2]);
- * }
- *
- * a = mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_SHARED, fd,0);
- * if (a == MAP_FAILED)
- * err(1, "Could not map %s", argv[2]);
- *
- * switch (cmd) {
- * case CREATE:
- * alloc_init(a, 1048576);
- * break;
- * case CHECK:
- * if (!alloc_check(a, 1048576))
- * err(1, "Region is corrupt");
- * break;
- * case ALLOC:
- * p = alloc_get(a, 1048576, 1024, 16);
- * if (!p)
- * errx(1, "Could not allocate");
- * printf("%zu\n", (char *)p - (char *)a);
- * break;
- * case FREE:
- * p = (char *)a + atol(argv[1] + strlen("--free="));
- * alloc_free(a, 1048576, p);
- * break;
- * }
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/build_assert\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * antithread - Accelerated Native Technology Implementation of "threads"
+ *
+ * Threads suck. Antithreads try not to. FIXME.
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/talloc\n");
+ printf("ccan/alloc\n");
+ printf("ccan/noerr\n");
+ printf("ccan/read_write_all\n"); /* For tests */
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * antithread - Accelerated Native Technology Implementation of "threads"
- *
- * Threads suck. Antithreads try not to. FIXME.
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/talloc\n");
- printf("ccan/alloc\n");
- printf("ccan/noerr\n");
- printf("ccan/read_write_all\n"); /* For tests */
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <string.h>
+#include "config.h"
+
+#include "ccan/array/array.h"
+
+/**
+ * array - A collection of macros for generic dynamic array management.
+ *
+ * The array module provides generic dynamic array functions via macros. It
+ * removes the tedium of managing realloc'd arrays with pointer, size, and
+ * allocated size. It also fits into structures quite well. It uses the
+ * talloc library to allocate the memory.
+ *
+ * NOTE: The API should be fairly stable now, but do expect small changes
+ * over time.
+ *
+ * Example:
+ * #include <ccan/array/array.h>
+ * #include <stdio.h>
+ *
+ * int main(void) {
+ * array(int) numbers = array_new(NULL);
+ * char buffer[32];
+ * int add;
+ *
+ * for (;;) {
+ * array_for(i, numbers, printf("%d ", *i))
+ * if (numbers.size) puts("");
+ *
+ * printf("array> ");
+ * fgets(buffer, sizeof(buffer), stdin);
+ * if (*buffer==0 || *buffer=='\n')
+ * break;
+ * add = atoi(buffer);
+ *
+ * array_append(numbers, add);
+ * }
+ *
+ * array_free(numbers);
+ *
+ * return 0;
+ * }
+ *
+ * Author: Joey Adams
+ * Version: 0.1
+ * Licence: BSD
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0)
+ #ifndef ARRAY_USE_TALLOC
+ /* Nothing. */
+ #else
+ printf("ccan/talloc\n");
+ #endif
+ return 0;
+
+ return 1;
+}
+++ /dev/null
-#include <string.h>
-#include "config.h"
-
-#include "ccan/array/array.h"
-
-/**
- * array - A collection of macros for generic dynamic array management.
- *
- * The array module provides generic dynamic array functions via macros. It
- * removes the tedium of managing realloc'd arrays with pointer, size, and
- * allocated size. It also fits into structures quite well. It uses the
- * talloc library to allocate the memory.
- *
- * NOTE: The API should be fairly stable now, but do expect small changes
- * over time.
- *
- * Example:
- * #include <ccan/array/array.h>
- * #include <stdio.h>
- *
- * int main(void) {
- * array(int) numbers = array_new(NULL);
- * char buffer[32];
- * int add;
- *
- * for (;;) {
- * array_for(i, numbers, printf("%d ", *i))
- * if (numbers.size) puts("");
- *
- * printf("array> ");
- * fgets(buffer, sizeof(buffer), stdin);
- * if (*buffer==0 || *buffer=='\n')
- * break;
- * add = atoi(buffer);
- *
- * array_append(numbers, add);
- * }
- *
- * array_free(numbers);
- *
- * return 0;
- * }
- *
- * Author: Joey Adams
- * Version: 0.1
- * Licence: BSD
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0)
- #ifndef ARRAY_USE_TALLOC
- /* Nothing. */
- #else
- printf("ccan/talloc\n");
- #endif
- return 0;
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * array_size - routine for safely deriving the size of a visible array.
+ *
+ * This provides a simple ARRAY_SIZE() macro, which (given a good compiler)
+ * will also break compile if you try to use it on a pointer.
+ *
+ * This can ensure your code is robust to changes, without needing a gratuitous
+ * macro or constant.
+ *
+ * Example:
+ * #include <ccan/array_size/array_size.h>
+ * #include <stdlib.h>
+ *
+ * // We currently use 32 random values.
+ * static unsigned int vals[32];
+ *
+ * void init_values(void)
+ * {
+ * unsigned int i;
+ * for (i = 0; i < ARRAY_SIZE(vals); i++)
+ * vals[i] = random();
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/build_assert\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * array_size - routine for safely deriving the size of a visible array.
- *
- * This provides a simple ARRAY_SIZE() macro, which (given a good compiler)
- * will also break compile if you try to use it on a pointer.
- *
- * This can ensure your code is robust to changes, without needing a gratuitous
- * macro or constant.
- *
- * Example:
- * #include <ccan/array_size/array_size.h>
- * #include <stdlib.h>
- *
- * // We currently use 32 random values.
- * static unsigned int vals[32];
- *
- * void init_values(void)
- * {
- * unsigned int i;
- * for (i = 0; i < ARRAY_SIZE(vals); i++)
- * vals[i] = random();
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/build_assert\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * build_assert - routines for build-time assertions
+ *
+ * This code provides routines which will cause compilation to fail should some
+ * assertion be untrue: such failures are preferable to run-time assertions,
+ * but much more limited since they can only depends on compile-time constants.
+ *
+ * These assertions are most useful when two parts of the code must be kept in
+ * sync: it is better to avoid such cases if possible, but seconds best is to
+ * detect invalid changes at build time.
+ *
+ * For example, a tricky piece of code might rely on a certain element being at
+ * the start of the structure. To ensure that future changes don't break it,
+ * you would catch such changes in your code like so:
+ *
+ * Example:
+ * #include <stddef.h>
+ * #include <ccan/build_assert/build_assert.h>
+ *
+ * struct foo {
+ * char string[5];
+ * int x;
+ * };
+ *
+ * char *foo_string(struct foo *foo)
+ * {
+ * // This trick requires that the string be first in the structure
+ * BUILD_ASSERT(offsetof(struct foo, string) == 0);
+ * return (char *)foo;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0)
+ /* Nothing. */
+ return 0;
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * build_assert - routines for build-time assertions
- *
- * This code provides routines which will cause compilation to fail should some
- * assertion be untrue: such failures are preferable to run-time assertions,
- * but much more limited since they can only depends on compile-time constants.
- *
- * These assertions are most useful when two parts of the code must be kept in
- * sync: it is better to avoid such cases if possible, but seconds best is to
- * detect invalid changes at build time.
- *
- * For example, a tricky piece of code might rely on a certain element being at
- * the start of the structure. To ensure that future changes don't break it,
- * you would catch such changes in your code like so:
- *
- * Example:
- * #include <stddef.h>
- * #include <ccan/build_assert/build_assert.h>
- *
- * struct foo {
- * char string[5];
- * int x;
- * };
- *
- * char *foo_string(struct foo *foo)
- * {
- * // This trick requires that the string be first in the structure
- * BUILD_ASSERT(offsetof(struct foo, string) == 0);
- * return (char *)foo;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0)
- /* Nothing. */
- return 0;
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * check_type - routines for compile time type checking
+ *
+ * C has fairly weak typing: ints get automatically converted to longs, signed
+ * to unsigned, etc. There are some cases where this is best avoided, and
+ * these macros provide methods for evoking warnings (or build errors) when
+ * a precise type isn't used.
+ *
+ * On compilers which don't support typeof() these routines are less effective,
+ * since they have to use sizeof() which can only distiguish between types of
+ * different size.
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+#if !HAVE_TYPEOF
+ printf("ccan/build_assert\n");
+#endif
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * check_type - routines for compile time type checking
- *
- * C has fairly weak typing: ints get automatically converted to longs, signed
- * to unsigned, etc. There are some cases where this is best avoided, and
- * these macros provide methods for evoking warnings (or build errors) when
- * a precise type isn't used.
- *
- * On compilers which don't support typeof() these routines are less effective,
- * since they have to use sizeof() which can only distiguish between types of
- * different size.
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
-#if !HAVE_TYPEOF
- printf("ccan/build_assert\n");
-#endif
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * ciniparser - easily parse and manipulate ini style configuration files
+ * A dictionary object is allocated which contains string keys and values.
+ * Functions to read string values return statically allocated objects,
+ * there is no need to free them (also, do not modify them directly).
+ *
+ * Additional functions to manipulate or unset objects in the dictionary
+ * can be found in the test suite.
+ *
+ * Example:
+ *
+ * #include <stdio.h>
+ * #include <stdbool.h>
+ * #include <ccan/ciniparser/ciniparser.h>
+ *
+ * #define CONFIG_FILE "/etc/config.ini"
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * dictionary *d;
+ * char *val1;
+ * bool val2;
+ * double val3;
+ * int val4;
+ *
+ * d = ciniparser_load(CONFIG_FILE);
+ * if (d == NULL)
+ * return 1;
+ *
+ * val1 = ciniparser_getstring(d, "daemon:pidfile", NULL);
+ * val2 = ciniparser_getboolean(d, "daemon:debug", false);
+ * val3 = ciniparser_getdouble(d, "daemon:maxload", 3.5);
+ * val4 = ciniparser_getint(d, "daemon:maxchild", 5);
+ *
+ * ciniparser_freedict(d);
+ *
+ * return 0;
+ *}
+ * License: MIT
+ */
+
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * ciniparser - easily parse and manipulate ini style configuration files
- * A dictionary object is allocated which contains string keys and values.
- * Functions to read string values return statically allocated objects,
- * there is no need to free them (also, do not modify them directly).
- *
- * Additional functions to manipulate or unset objects in the dictionary
- * can be found in the test suite.
- *
- * Example:
- *
- * #include <stdio.h>
- * #include <stdbool.h>
- * #include <ccan/ciniparser/ciniparser.h>
- *
- * #define CONFIG_FILE "/etc/config.ini"
- *
- * int main(int argc, char *argv[])
- * {
- * dictionary *d;
- * char *val1;
- * bool val2;
- * double val3;
- * int val4;
- *
- * d = ciniparser_load(CONFIG_FILE);
- * if (d == NULL)
- * return 1;
- *
- * val1 = ciniparser_getstring(d, "daemon:pidfile", NULL);
- * val2 = ciniparser_getboolean(d, "daemon:debug", false);
- * val3 = ciniparser_getdouble(d, "daemon:maxload", 3.5);
- * val4 = ciniparser_getint(d, "daemon:maxchild", 5);
- *
- * ciniparser_freedict(d);
- *
- * return 0;
- *}
- * License: MIT
- */
-
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * container_of - routine for upcasting
+ *
+ * It is often convenient to create code where the caller registers a pointer
+ * to a generic structure and a callback. The callback might know that the
+ * pointer points to within a larger structure, and container_of gives a
+ * convenient and fairly type-safe way of returning to the enclosing structure.
+ *
+ * This idiom is an alternative to providing a void * pointer for every
+ * callback.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <ccan/container_of/container_of.h>
+ *
+ * struct timer {
+ * void *members;
+ * };
+ *
+ * struct info {
+ * int my_stuff;
+ * struct timer timer;
+ * };
+ *
+ * static void my_timer_callback(struct timer *timer)
+ * {
+ * struct info *info = container_of(timer, struct info, timer);
+ * printf("my_stuff is %u\n", info->my_stuff);
+ * }
+ *
+ * int main()
+ * {
+ * struct info info = { .my_stuff = 1 };
+ *
+ * register_timer(&info.timer);
+ * // ...
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/check_type\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * container_of - routine for upcasting
- *
- * It is often convenient to create code where the caller registers a pointer
- * to a generic structure and a callback. The callback might know that the
- * pointer points to within a larger structure, and container_of gives a
- * convenient and fairly type-safe way of returning to the enclosing structure.
- *
- * This idiom is an alternative to providing a void * pointer for every
- * callback.
- *
- * Example:
- * #include <stdio.h>
- * #include <ccan/container_of/container_of.h>
- *
- * struct timer {
- * void *members;
- * };
- *
- * struct info {
- * int my_stuff;
- * struct timer timer;
- * };
- *
- * static void my_timer_callback(struct timer *timer)
- * {
- * struct info *info = container_of(timer, struct info, timer);
- * printf("my_stuff is %u\n", info->my_stuff);
- * }
- *
- * int main()
- * {
- * struct info info = { .my_stuff = 1 };
- *
- * register_timer(&info.timer);
- * // ...
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/check_type\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <string.h>
+
+/**
+ * crc - routines for crc of bytes
+ *
+ * Cyclic Redundancy Check routines. These are reasonably fast
+ * checksum routines, but not suitable for cryptographic use.
+ *
+ * They are useful for simple error detection, eg. a 32-bit CRC will
+ * detect a single error burst of up to 32 bits.
+ *
+ * Example:
+ * #include <ccan/crc.h>
+ * #include <stdio.h>
+ * #include <stdlib.h>
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * if (argc != 2) {
+ * fprintf(stderr, "Usage: %s <string>\n"
+ * "Prints 32 bit CRC of the string\n", argv[0]);
+ * exit(1);
+ * }
+ * printf("0x%08x\n", crc32c(argv[1], strlen(argv[1])));
+ * exit(0);
+ * }
+ *
+ * Licence: GPL (v2 or any later version)
+ * Author: Gary S. Brown, Clay Haapala
+ * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <string.h>
-
-/**
- * crc - routines for crc of bytes
- *
- * Cyclic Redundancy Check routines. These are reasonably fast
- * checksum routines, but not suitable for cryptographic use.
- *
- * They are useful for simple error detection, eg. a 32-bit CRC will
- * detect a single error burst of up to 32 bits.
- *
- * Example:
- * #include <ccan/crc.h>
- * #include <stdio.h>
- * #include <stdlib.h>
- *
- * int main(int argc, char *argv[])
- * {
- * if (argc != 2) {
- * fprintf(stderr, "Usage: %s <string>\n"
- * "Prints 32 bit CRC of the string\n", argv[0]);
- * exit(1);
- * }
- * printf("0x%08x\n", crc32c(argv[1], strlen(argv[1])));
- * exit(0);
- * }
- *
- * Licence: GPL (v2 or any later version)
- * Author: Gary S. Brown, Clay Haapala
- * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * crcsync - routines to use crc for an rsync-like protocol.
+ *
+ * This is a complete library for synchronization using a variant of the
+ * rsync protocol.
+ *
+ * Example:
+ * // Calculate checksums of file (3-arg mode)
+ * // Or print differences between file and checksums (4+ arg mode)
+ * #include <ccan/crcsync/crcsync.h>
+ * #include <ccan/grab_file/grab_file.h>
+ * #include <stdio.h>
+ * #include <stdlib.h>
+ * #include <err.h>
+ *
+ * static void print_result(long result)
+ * {
+ * if (result < 0)
+ * printf("MATCHED CRC %lu\n", -result - 1);
+ * else if (result > 0)
+ * printf("%lu literal bytes\n", result);
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * size_t len, used, blocksize;
+ * char *file;
+ * struct crc_context *ctx;
+ * uint32_t *crcs;
+ * long res, i;
+ *
+ * if (argc < 3 || (blocksize = atoi(argv[1])) == 0)
+ * errx(1, "Usage: %s <blocksize> <file> <crc>...\n"
+ * "OR: %s <blocksize> <file>", argv[0], argv[0]);
+ *
+ * file = grab_file(NULL, argv[2], &len);
+ * if (!file)
+ * err(1, "Opening file %s", argv[2]);
+ *
+ * if (argc == 3) {
+ * // Short form prints CRCs of file for use in long form.
+ * used = (len + blocksize - 1) / blocksize;
+ * crcs = malloc(used * sizeof(uint32_t));
+ * crc_of_blocks(file, len, blocksize, 32, crcs);
+ * for (i = 0; i < used; i++)
+ * printf("%i ", crcs[i]);
+ * printf("\n");
+ * return 0;
+ * }
+ *
+ * crcs = malloc((argc - 3) * sizeof(uint32_t));
+ * for (i = 0; i < argc-3; i++)
+ * crcs[i] = atoi(argv[3+i]);
+ *
+ * ctx = crc_context_new(blocksize, 32, crcs, argc-3);
+ * for (used = 0; used < len; ) {
+ * used += crc_read_block(ctx, &res, file+used, len-used);
+ * print_result(res);
+ * }
+ * while ((res = crc_read_flush(ctx)) != 0)
+ * print_result(res);
+ *
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (v2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/crc\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * crcsync - routines to use crc for an rsync-like protocol.
- *
- * This is a complete library for synchronization using a variant of the
- * rsync protocol.
- *
- * Example:
- * // Calculate checksums of file (3-arg mode)
- * // Or print differences between file and checksums (4+ arg mode)
- * #include <ccan/crcsync/crcsync.h>
- * #include <ccan/grab_file/grab_file.h>
- * #include <stdio.h>
- * #include <stdlib.h>
- * #include <err.h>
- *
- * static void print_result(long result)
- * {
- * if (result < 0)
- * printf("MATCHED CRC %lu\n", -result - 1);
- * else if (result > 0)
- * printf("%lu literal bytes\n", result);
- * }
- *
- * int main(int argc, char *argv[])
- * {
- * size_t len, used, blocksize;
- * char *file;
- * struct crc_context *ctx;
- * uint32_t *crcs;
- * long res, i;
- *
- * if (argc < 3 || (blocksize = atoi(argv[1])) == 0)
- * errx(1, "Usage: %s <blocksize> <file> <crc>...\n"
- * "OR: %s <blocksize> <file>", argv[0], argv[0]);
- *
- * file = grab_file(NULL, argv[2], &len);
- * if (!file)
- * err(1, "Opening file %s", argv[2]);
- *
- * if (argc == 3) {
- * // Short form prints CRCs of file for use in long form.
- * used = (len + blocksize - 1) / blocksize;
- * crcs = malloc(used * sizeof(uint32_t));
- * crc_of_blocks(file, len, blocksize, 32, crcs);
- * for (i = 0; i < used; i++)
- * printf("%i ", crcs[i]);
- * printf("\n");
- * return 0;
- * }
- *
- * crcs = malloc((argc - 3) * sizeof(uint32_t));
- * for (i = 0; i < argc-3; i++)
- * crcs[i] = atoi(argv[3+i]);
- *
- * ctx = crc_context_new(blocksize, 32, crcs, argc-3);
- * for (used = 0; used < len; ) {
- * used += crc_read_block(ctx, &res, file+used, len-used);
- * print_result(res);
- * }
- * while ((res = crc_read_flush(ctx)) != 0)
- * print_result(res);
- *
- * return 0;
- * }
- *
- * Licence: LGPL (v2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/crc\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * daemonize - routine to turn a process into a well-behaved daemon.
+ *
+ * Daemons should detach themselves thoroughly from the process which launched
+ * them, and not prevent any filesystems from being unmounted. daemonize()
+ * helps with the process.
+ *
+ * Example:
+ * #include <ccan/daemonize/daemonize.h>
+ * #include <ccan/str/str.h>
+ * #include <err.h>
+ * #include <unistd.h>
+ * #include <stdlib.h>
+ *
+ * static void usage(const char *name)
+ * {
+ * errx(1, "Usage: %s [--daemonize]\n", name);
+ * }
+ *
+ * // Wait for a minute, possibly as a daemon.
+ * int main(int argc, char *argv[])
+ * {
+ * if (argc != 1) {
+ * if (argc == 2 && streq(argv[1], "--daemonize")) {
+ * if (!daemonize())
+ * err(1, "Failed to become daemon");
+ * } else
+ * usage(argv[1]);
+ * }
+ * sleep(60);
+ * exit(0);
+ * }
+ *
+ * Licence: BSD (2 clause, ie. MIT)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ if (strcmp(argv[1], "libs") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * daemonize - routine to turn a process into a well-behaved daemon.
- *
- * Daemons should detach themselves thoroughly from the process which launched
- * them, and not prevent any filesystems from being unmounted. daemonize()
- * helps with the process.
- *
- * Example:
- * #include <ccan/daemonize/daemonize.h>
- * #include <ccan/str/str.h>
- * #include <err.h>
- * #include <unistd.h>
- * #include <stdlib.h>
- *
- * static void usage(const char *name)
- * {
- * errx(1, "Usage: %s [--daemonize]\n", name);
- * }
- *
- * // Wait for a minute, possibly as a daemon.
- * int main(int argc, char *argv[])
- * {
- * if (argc != 1) {
- * if (argc == 2 && streq(argv[1], "--daemonize")) {
- * if (!daemonize())
- * err(1, "Failed to become daemon");
- * } else
- * usage(argv[1]);
- * }
- * sleep(60);
- * exit(0);
- * }
- *
- * Licence: BSD (2 clause, ie. MIT)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- if (strcmp(argv[1], "libs") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * endian - endian conversion macros for simple types
+ *
+ * Portable protocols (such as on-disk formats, or network protocols)
+ * are often defined to be a particular endian: little-endian (least
+ * significant bytes first) or big-endian (most significant bytes
+ * first).
+ *
+ * Similarly, some CPUs lay out values in memory in little-endian
+ * order (most commonly, Intel's 8086 and derivatives), or big-endian
+ * order (almost everyone else).
+ *
+ * This module provides conversion routines, inspired by the linux kernel.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <err.h>
+ * #include <ccan/endian/endian.h>
+ *
+ * //
+ * int main(int argc, char *argv[])
+ * {
+ * uint32_t value;
+ *
+ * if (argc != 2)
+ * errx(1, "Usage: %s <value>", argv[0]);
+ *
+ * printf("native: %08x\n", value);
+ * printf("little-endian: %08x\n", cpu_to_le32(value));
+ * printf("big-endian: %08x\n", cpu_to_be32(value));
+ * printf("byte-reversed: %08x\n", swab_u32(value));
+ * exit(0);
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0)
+ /* Nothing */
+ return 0;
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * endian - endian conversion macros for simple types
- *
- * Portable protocols (such as on-disk formats, or network protocols)
- * are often defined to be a particular endian: little-endian (least
- * significant bytes first) or big-endian (most significant bytes
- * first).
- *
- * Similarly, some CPUs lay out values in memory in little-endian
- * order (most commonly, Intel's 8086 and derivatives), or big-endian
- * order (almost everyone else).
- *
- * This module provides conversion routines, inspired by the linux kernel.
- *
- * Example:
- * #include <stdio.h>
- * #include <err.h>
- * #include <ccan/endian/endian.h>
- *
- * //
- * int main(int argc, char *argv[])
- * {
- * uint32_t value;
- *
- * if (argc != 2)
- * errx(1, "Usage: %s <value>", argv[0]);
- *
- * printf("native: %08x\n", value);
- * printf("little-endian: %08x\n", cpu_to_le32(value));
- * printf("big-endian: %08x\n", cpu_to_be32(value));
- * printf("byte-reversed: %08x\n", swab_u32(value));
- * exit(0);
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0)
- /* Nothing */
- return 0;
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * grab_file - file helper routines
+ *
+ * This contains simple functions for getting the contents of a file.
+ *
+ * Example:
+ * #include <err.h>
+ * #include <stdio.h>
+ * #include <string.h>
+ * #include <ccan/grab_file/grab_file.h>
+ * #include <ccan/talloc/talloc.h> // For talloc_free()
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * size_t len;
+ * char *file;
+ *
+ * file = grab_file(NULL, argv[1], &len);
+ * if (!file)
+ * err(1, "Could not read file %s", argv[1]);
+ * if (strlen(file) != len)
+ * printf("File contains NUL characters\n");
+ * else if (len == 0)
+ * printf("File contains nothing\n");
+ * else if (strchr(file, '\n'))
+ * printf("File contains multiple lines\n");
+ * else
+ * printf("File contains one line\n");
+ * talloc_free(file);
+ *
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/str_talloc\n"); /* Needed for tests. */
+ printf("ccan/talloc\n");
+ printf("ccan/noerr\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * grab_file - file helper routines
- *
- * This contains simple functions for getting the contents of a file.
- *
- * Example:
- * #include <err.h>
- * #include <stdio.h>
- * #include <string.h>
- * #include <ccan/grab_file/grab_file.h>
- * #include <ccan/talloc/talloc.h> // For talloc_free()
- *
- * int main(int argc, char *argv[])
- * {
- * size_t len;
- * char *file;
- *
- * file = grab_file(NULL, argv[1], &len);
- * if (!file)
- * err(1, "Could not read file %s", argv[1]);
- * if (strlen(file) != len)
- * printf("File contains NUL characters\n");
- * else if (len == 0)
- * printf("File contains nothing\n");
- * else if (strchr(file, '\n'))
- * printf("File contains multiple lines\n");
- * else
- * printf("File contains one line\n");
- * talloc_free(file);
- *
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/str_talloc\n"); /* Needed for tests. */
- printf("ccan/talloc\n");
- printf("ccan/noerr\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <string.h>
+
+/**
+ * hash - routines for hashing bytes
+ *
+ * When creating a hash table it's important to have a hash function
+ * which mixes well and is fast. This package supplies such functions.
+ *
+ * The hash functions come in two flavors: the normal ones and the
+ * stable ones. The normal ones can vary from machine-to-machine and
+ * may change if we find better or faster hash algorithms in future.
+ * The stable ones will always give the same results on any computer,
+ * and on any version of this package.
+ *
+ * Licence: Public Domain
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <string.h>
-
-/**
- * hash - routines for hashing bytes
- *
- * When creating a hash table it's important to have a hash function
- * which mixes well and is fast. This package supplies such functions.
- *
- * The hash functions come in two flavors: the normal ones and the
- * stable ones. The normal ones can vary from machine-to-machine and
- * may change if we find better or faster hash algorithms in future.
- * The stable ones will always give the same results on any computer,
- * and on any version of this package.
- *
- * Licence: Public Domain
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+/**
+ * ilog - Integer logarithm.
+ *
+ * ILOG_32() and ILOG_64() compute the minimum number of bits required to store
+ * an unsigned 32-bit or 64-bit value without any leading zero bits.
+ * This can also be thought of as the location of the highest set bit, with
+ * counting starting from one (so that 0 returns 0, 1 returns 1, and 2**31
+ * returns 32).
+ * When the value is known to be non-zero ILOGNZ_32() and ILOGNZ_64() can
+ * compile into as few as two instructions, one of which may get optimized out
+ * later.
+ * STATIC_ILOG_32 and STATIC_ILOG_64 allow computation on compile-time
+ * constants, so other compile-time constants can be derived from them.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <limits.h>
+ * #include <ccan/ilog/ilog.h>
+ *
+ * int main(void){
+ * int i;
+ * printf("ILOG_32(0x%08X)=%i\n",0,ILOG_32(0));
+ * for(i=1;i<=STATIC_ILOG_32(USHRT_MAX);i++){
+ * uint32_t v;
+ * v=(uint32_t)1U<<i-1;
+ * //Here we know v is non-zero, so we can use ILOGNZ_32().
+ * printf("ILOG_32(0x%08X)=%i\n",v,ILOGNZ_32(v));
+ * }
+ * return 0;
+ * }
+ *
+ * License: LGPL (v2 or later)
+ */
+#include <string.h>
+#include "config.h"
+
+int main(int _argc,const char *_argv[]){
+ /*Expect exactly one argument.*/
+ if(_argc!=2)return 1;
+ if(strcmp(_argv[1],"depends")==0){
+ /*PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY*/
+ return 0;
+ }
+ return 1;
+}
+++ /dev/null
-/**
- * ilog - Integer logarithm.
- *
- * ILOG_32() and ILOG_64() compute the minimum number of bits required to store
- * an unsigned 32-bit or 64-bit value without any leading zero bits.
- * This can also be thought of as the location of the highest set bit, with
- * counting starting from one (so that 0 returns 0, 1 returns 1, and 2**31
- * returns 32).
- * When the value is known to be non-zero ILOGNZ_32() and ILOGNZ_64() can
- * compile into as few as two instructions, one of which may get optimized out
- * later.
- * STATIC_ILOG_32 and STATIC_ILOG_64 allow computation on compile-time
- * constants, so other compile-time constants can be derived from them.
- *
- * Example:
- * #include <stdio.h>
- * #include <limits.h>
- * #include <ccan/ilog/ilog.h>
- *
- * int main(void){
- * int i;
- * printf("ILOG_32(0x%08X)=%i\n",0,ILOG_32(0));
- * for(i=1;i<=STATIC_ILOG_32(USHRT_MAX);i++){
- * uint32_t v;
- * v=(uint32_t)1U<<i-1;
- * //Here we know v is non-zero, so we can use ILOGNZ_32().
- * printf("ILOG_32(0x%08X)=%i\n",v,ILOGNZ_32(v));
- * }
- * return 0;
- * }
- *
- * License: LGPL (v2 or later)
- */
-#include <string.h>
-#include "config.h"
-
-int main(int _argc,const char *_argv[]){
- /*Expect exactly one argument.*/
- if(_argc!=2)return 1;
- if(strcmp(_argv[1],"depends")==0){
- /*PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY*/
- return 0;
- }
- return 1;
-}
--- /dev/null
+/**
+ * isaac - A fast, high-quality pseudo-random number generator.
+ *
+ * ISAAC (Indirect, Shift, Accumulate, Add, and Count) is the most advanced of
+ * a series of pseudo-random number generators designed by Robert J. Jenkins
+ * Jr. in 1996: http://www.burtleburtle.net/bob/rand/isaac.html
+ * To quote:
+ * No efficient method is known for deducing their internal states.
+ * ISAAC requires an amortized 18.75 instructions to produce a 32-bit value.
+ * There are no cycles in ISAAC shorter than 2**40 values.
+ * The expected cycle length is 2**8295 values.
+ * ...
+ * ISAAC-64 generates a different sequence than ISAAC, but it uses the same
+ * principles.
+ * It uses 64-bit arithmetic.
+ * It generates a 64-bit result every 19 instructions.
+ * All cycles are at least 2**72 values, and the average cycle length is
+ * 2**16583.
+ * An additional, important comment from Bob Jenkins in 2006:
+ * Seeding a random number generator is essentially the same problem as
+ * encrypting the seed with a block cipher.
+ * ISAAC should be initialized with the encryption of the seed by some
+ * secure cipher.
+ * I've provided a seeding routine in my implementations, which nobody has
+ * broken so far, but I have less faith in that initialization routine than
+ * I have in ISAAC.
+ *
+ * A number of attacks on ISAAC have been published.
+ * [Pudo01] can recover the entire internal state and has expected running time
+ * less than the square root of the number of states, or 2**4121 (4.67E+1240).
+ * [Auma06] reveals a large set of weak states, consisting of those for which
+ * the first value is repeated one or more times elsewhere in the state
+ * vector.
+ * These induce a bias in the output relative to the repeated value.
+ * The seed values used as input below are scrambled before being used, so any
+ * duplicates in them do not imply duplicates in the resulting internal state,
+ * however the chances of some duplicate existing elsewhere in a random state
+ * are just over 255/2**32, or merely 1 in 16 million.
+ * Such states are, of course, much rarer in ISAAC-64.
+ * It is not clear if an attacker can tell from just the output if ISAAC is in
+ * a weak state, or deduce the full internal state in any case except that
+ * where all or almost all of the entries in the state vector are identical.
+ * @MISC{Pudo01,
+ * author="Marina Pudovkina",
+ * title="A Known Plaintext Attack on the {ISAAC} Keystream Generator",
+ * howpublished="Cryptology ePrint Archive, Report 2001/049",
+ * year=2001,
+ * note="\url{http://eprint.iacr.org/2001/049}",
+ * }
+ * @MISC{Auma06,
+ * author="Jean-Philippe Aumasson",
+ * title="On the Pseudo-Random Generator {ISAAC}",
+ * howpublished="Cryptology ePrint Archive, Report 2006/438",
+ * year=2006,
+ * note="\url{http://eprint.iacr.org/2006/438}",
+ * }
+ *
+ * Even if one does not trust the security of this PRNG (and, without a good
+ * source of entropy to seed it, one should not), ISAAC is an excellent source
+ * of high-quality random numbers for Monte Carlo simulations, etc.
+ * It is the fastest 32-bit generator among all of those that pass the
+ * statistical tests in the recent survey
+ * http://www.iro.umontreal.ca/~simardr/testu01/tu01.html, with the exception
+ * of Marsa-LFIB4, and it is quite competitive on 64-bit archtectures.
+ * Unlike Marsa-LFIB4 (and all other LFib generators), there are no linear
+ * dependencies between successive values, and unlike many generators found in
+ * libc implementations, there are no small periods in the least significant
+ * bits, or seeds which lead to very small periods in general.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <time.h>
+ * #include <ccan/isaac/isaac.h>
+ *
+ * int main(void){
+ * static const char *CHEESE[3]={"Cheddar","Provolone","Camembert"};
+ * isaac_ctx isaac;
+ * unsigned char seed[8];
+ * time_t now;
+ * int i;
+ * //N.B.: time() is not a good source of entropy.
+ * //Do not use it for cryptogrpahic purposes.
+ * time(&now);
+ * //Print it out so we can reproduce problems if needed.
+ * printf("Seed: 0x%016llX\n",(long long)now);
+ * //And convert the time to a byte array so that we can reproduce the same
+ * // seed on platforms with different endianesses.
+ * for(i=0;i<8;i++){
+ * seed[i]=(unsigned char)(now&0xFF);
+ * now>>=8;
+ * }
+ * isaac_init(&isaac,seed,8);
+ * printf("0x%08lX\n",(long)isaac_next_uint32(&isaac));
+ * printf("%s\n",CHEESE[isaac_next_uint(&isaac,3)]);
+ * printf("%0.8G\n",isaac_next_float(&isaac));
+ * printf("%0.8G\n",isaac_next_signed_float(&isaac));
+ * printf("%0.18G\n",isaac_next_double(&isaac));
+ * printf("%0.18G\n",isaac_next_signed_double(&isaac));
+ * return 0;
+ * }
+ *
+ * License: Public Domain
+ */
+#include <string.h>
+#include <stdio.h>
+#include "config.h"
+
+int main(int _argc,const char *_argv[]){
+ /*Expect exactly one argument.*/
+ if(_argc!=2)return 1;
+ if(strcmp(_argv[1],"depends")==0){
+ printf("ccan/ilog\n");
+ return 0;
+ }
+ return 1;
+}
+++ /dev/null
-/**
- * isaac - A fast, high-quality pseudo-random number generator.
- *
- * ISAAC (Indirect, Shift, Accumulate, Add, and Count) is the most advanced of
- * a series of pseudo-random number generators designed by Robert J. Jenkins
- * Jr. in 1996: http://www.burtleburtle.net/bob/rand/isaac.html
- * To quote:
- * No efficient method is known for deducing their internal states.
- * ISAAC requires an amortized 18.75 instructions to produce a 32-bit value.
- * There are no cycles in ISAAC shorter than 2**40 values.
- * The expected cycle length is 2**8295 values.
- * ...
- * ISAAC-64 generates a different sequence than ISAAC, but it uses the same
- * principles.
- * It uses 64-bit arithmetic.
- * It generates a 64-bit result every 19 instructions.
- * All cycles are at least 2**72 values, and the average cycle length is
- * 2**16583.
- * An additional, important comment from Bob Jenkins in 2006:
- * Seeding a random number generator is essentially the same problem as
- * encrypting the seed with a block cipher.
- * ISAAC should be initialized with the encryption of the seed by some
- * secure cipher.
- * I've provided a seeding routine in my implementations, which nobody has
- * broken so far, but I have less faith in that initialization routine than
- * I have in ISAAC.
- *
- * A number of attacks on ISAAC have been published.
- * [Pudo01] can recover the entire internal state and has expected running time
- * less than the square root of the number of states, or 2**4121 (4.67E+1240).
- * [Auma06] reveals a large set of weak states, consisting of those for which
- * the first value is repeated one or more times elsewhere in the state
- * vector.
- * These induce a bias in the output relative to the repeated value.
- * The seed values used as input below are scrambled before being used, so any
- * duplicates in them do not imply duplicates in the resulting internal state,
- * however the chances of some duplicate existing elsewhere in a random state
- * are just over 255/2**32, or merely 1 in 16 million.
- * Such states are, of course, much rarer in ISAAC-64.
- * It is not clear if an attacker can tell from just the output if ISAAC is in
- * a weak state, or deduce the full internal state in any case except that
- * where all or almost all of the entries in the state vector are identical.
- * @MISC{Pudo01,
- * author="Marina Pudovkina",
- * title="A Known Plaintext Attack on the {ISAAC} Keystream Generator",
- * howpublished="Cryptology ePrint Archive, Report 2001/049",
- * year=2001,
- * note="\url{http://eprint.iacr.org/2001/049}",
- * }
- * @MISC{Auma06,
- * author="Jean-Philippe Aumasson",
- * title="On the Pseudo-Random Generator {ISAAC}",
- * howpublished="Cryptology ePrint Archive, Report 2006/438",
- * year=2006,
- * note="\url{http://eprint.iacr.org/2006/438}",
- * }
- *
- * Even if one does not trust the security of this PRNG (and, without a good
- * source of entropy to seed it, one should not), ISAAC is an excellent source
- * of high-quality random numbers for Monte Carlo simulations, etc.
- * It is the fastest 32-bit generator among all of those that pass the
- * statistical tests in the recent survey
- * http://www.iro.umontreal.ca/~simardr/testu01/tu01.html, with the exception
- * of Marsa-LFIB4, and it is quite competitive on 64-bit archtectures.
- * Unlike Marsa-LFIB4 (and all other LFib generators), there are no linear
- * dependencies between successive values, and unlike many generators found in
- * libc implementations, there are no small periods in the least significant
- * bits, or seeds which lead to very small periods in general.
- *
- * Example:
- * #include <stdio.h>
- * #include <time.h>
- * #include <ccan/isaac/isaac.h>
- *
- * int main(void){
- * static const char *CHEESE[3]={"Cheddar","Provolone","Camembert"};
- * isaac_ctx isaac;
- * unsigned char seed[8];
- * time_t now;
- * int i;
- * //N.B.: time() is not a good source of entropy.
- * //Do not use it for cryptogrpahic purposes.
- * time(&now);
- * //Print it out so we can reproduce problems if needed.
- * printf("Seed: 0x%016llX\n",(long long)now);
- * //And convert the time to a byte array so that we can reproduce the same
- * // seed on platforms with different endianesses.
- * for(i=0;i<8;i++){
- * seed[i]=(unsigned char)(now&0xFF);
- * now>>=8;
- * }
- * isaac_init(&isaac,seed,8);
- * printf("0x%08lX\n",(long)isaac_next_uint32(&isaac));
- * printf("%s\n",CHEESE[isaac_next_uint(&isaac,3)]);
- * printf("%0.8G\n",isaac_next_float(&isaac));
- * printf("%0.8G\n",isaac_next_signed_float(&isaac));
- * printf("%0.18G\n",isaac_next_double(&isaac));
- * printf("%0.18G\n",isaac_next_signed_double(&isaac));
- * return 0;
- * }
- *
- * License: Public Domain
- */
-#include <string.h>
-#include <stdio.h>
-#include "config.h"
-
-int main(int _argc,const char *_argv[]){
- /*Expect exactly one argument.*/
- if(_argc!=2)return 1;
- if(strcmp(_argv[1],"depends")==0){
- printf("ccan/ilog\n");
- return 0;
- }
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * list - double linked list routines
+ *
+ * The list header contains routines for manipulating double linked lists.
+ * It defines two types: struct list_head used for anchoring lists, and
+ * struct list_node which is usually embedded in the structure which is placed
+ * in the list.
+ *
+ * Example:
+ * #include <err.h>
+ * #include <stdio.h>
+ * #include <stdlib.h>
+ * #include <ccan/list/list.h>
+ *
+ * struct parent {
+ * const char *name;
+ * struct list_head children;
+ * unsigned int num_children;
+ * };
+ *
+ * struct child {
+ * const char *name;
+ * struct list_node list;
+ * };
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * struct parent p;
+ * struct child *c;
+ * unsigned int i;
+ *
+ * if (argc < 2)
+ * errx(1, "Usage: %s parent children...", argv[0]);
+ *
+ * p.name = argv[1];
+ * list_head_init(&p.children);
+ * for (i = 2; i < argc; i++) {
+ * c = malloc(sizeof(*c));
+ * c->name = argv[i];
+ * list_add(&p.children, &c->list);
+ * p.num_children++;
+ * }
+ *
+ * printf("%s has %u children:", p.name, p.num_children);
+ * list_for_each(&p.children, c, list)
+ * printf("%s ", c->name);
+ * printf("\n");
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/container_of\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * list - double linked list routines
- *
- * The list header contains routines for manipulating double linked lists.
- * It defines two types: struct list_head used for anchoring lists, and
- * struct list_node which is usually embedded in the structure which is placed
- * in the list.
- *
- * Example:
- * #include <err.h>
- * #include <stdio.h>
- * #include <stdlib.h>
- * #include <ccan/list/list.h>
- *
- * struct parent {
- * const char *name;
- * struct list_head children;
- * unsigned int num_children;
- * };
- *
- * struct child {
- * const char *name;
- * struct list_node list;
- * };
- *
- * int main(int argc, char *argv[])
- * {
- * struct parent p;
- * struct child *c;
- * unsigned int i;
- *
- * if (argc < 2)
- * errx(1, "Usage: %s parent children...", argv[0]);
- *
- * p.name = argv[1];
- * list_head_init(&p.children);
- * for (i = 2; i < argc; i++) {
- * c = malloc(sizeof(*c));
- * c->name = argv[i];
- * list_add(&p.children, &c->list);
- * p.num_children++;
- * }
- *
- * printf("%s has %u children:", p.name, p.num_children);
- * list_for_each(&p.children, c, list)
- * printf("%s ", c->name);
- * printf("\n");
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/container_of\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * md4 - MD4 Message Digest Algorithm (RFC1320).
+ *
+ * Message Digest #4 is a 128-bit hashing algorithm; it is quick but
+ * not sufficiently strong for cryptographic use (duplicates can be
+ * found very efficiently). It provides sufficient mixing to have an
+ * avalanche effect: any change in input changes the output completely.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <ccan/md4/md4.h>
+ *
+ * // Provide MD4 sums of the input strings.
+ * int main(int argc, char *argv[])
+ * {
+ * unsigned int i, j;
+ * struct md4_ctx ctx;
+ *
+ * for (i = 1; i < argc; i++) {
+ * md4_init(&ctx);
+ * md4_hash(&ctx, argv[i], strlen(argv[i]));
+ * md4_finish(&ctx);
+ * for (j = 0; j < 16; j++)
+ * printf("%02x", ctx.hash.bytes[j]);
+ * printf("\n");
+ * }
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/endian\n");
+ printf("ccan/array_size\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * md4 - MD4 Message Digest Algorithm (RFC1320).
- *
- * Message Digest #4 is a 128-bit hashing algorithm; it is quick but
- * not sufficiently strong for cryptographic use (duplicates can be
- * found very efficiently). It provides sufficient mixing to have an
- * avalanche effect: any change in input changes the output completely.
- *
- * Example:
- * #include <stdio.h>
- * #include <ccan/md4/md4.h>
- *
- * // Provide MD4 sums of the input strings.
- * int main(int argc, char *argv[])
- * {
- * unsigned int i, j;
- * struct md4_ctx ctx;
- *
- * for (i = 1; i < argc; i++) {
- * md4_init(&ctx);
- * md4_hash(&ctx, argv[i], strlen(argv[i]));
- * md4_finish(&ctx);
- * for (j = 0; j < 16; j++)
- * printf("%02x", ctx.hash.bytes[j]);
- * printf("\n");
- * }
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/endian\n");
- printf("ccan/array_size\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * noerr - routines for cleaning up without blatting errno
+ *
+ * It is a good idea to follow the standard C convention of setting errno in
+ * your own helper functions. Unfortunately, care must be taken in the error
+ * paths as most standard functions can (and do) overwrite errno, even if they
+ * succeed.
+ *
+ * Example:
+ * #include <sys/types.h>
+ * #include <sys/stat.h>
+ * #include <fcntl.h>
+ * #include <stdbool.h>
+ * #include <string.h>
+ * #include <errno.h>
+ * #include <ccan/noerr/noerr.h>
+ *
+ * bool write_string_to_file(const char *file, const char *string)
+ * {
+ * int ret, fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0600);
+ * if (fd < 0)
+ * return false;
+ * ret = write(fd, string, strlen(string));
+ * if (ret < 0) {
+ * // Preserve errno from write above.
+ * close_noerr(fd);
+ * unlink_noerr(file);
+ * return false;
+ * }
+ * if (close(fd) != 0) {
+ * // Again, preserve errno.
+ * unlink_noerr(file);
+ * return false;
+ * }
+ * // A short write means out of space.
+ * if (ret < strlen(string)) {
+ * unlink(file);
+ * errno = ENOSPC;
+ * return false;
+ * }
+ * return true;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0)
+ /* Nothing. */
+ return 0;
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * noerr - routines for cleaning up without blatting errno
- *
- * It is a good idea to follow the standard C convention of setting errno in
- * your own helper functions. Unfortunately, care must be taken in the error
- * paths as most standard functions can (and do) overwrite errno, even if they
- * succeed.
- *
- * Example:
- * #include <sys/types.h>
- * #include <sys/stat.h>
- * #include <fcntl.h>
- * #include <stdbool.h>
- * #include <string.h>
- * #include <errno.h>
- * #include <ccan/noerr/noerr.h>
- *
- * bool write_string_to_file(const char *file, const char *string)
- * {
- * int ret, fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0600);
- * if (fd < 0)
- * return false;
- * ret = write(fd, string, strlen(string));
- * if (ret < 0) {
- * // Preserve errno from write above.
- * close_noerr(fd);
- * unlink_noerr(file);
- * return false;
- * }
- * if (close(fd) != 0) {
- * // Again, preserve errno.
- * unlink_noerr(file);
- * return false;
- * }
- * // A short write means out of space.
- * if (ret < strlen(string)) {
- * unlink(file);
- * errno = ENOSPC;
- * return false;
- * }
- * return true;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0)
- /* Nothing. */
- return 0;
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * ogg_to_pcm - decode ogg vorbis audio files to PCM data using libvorbis
+ *
+ * ogg_to_pcm implements a single function using libvorbis to decode
+ * signed 16 bit ogg audio data to signed 16 bit PCM data.
+ *
+ * Example:
+ * #include <stdint.h>
+ * #include <ogg_to_pcm.h>
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * int16_t *pcmbuffer;
+ * int rc, sample_size, sample_rate, channels, nsamples;
+ *
+ * rc = ogg_to_pcm("mysound.ogg", &pcmbuffer,
+ * &sample_size, &sample_rate, &channels, &nsamples);
+ * if (rc != 0)
+ * return -1;
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ *
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("libvorbis\n");
+ return 0;
+ }
+
+ if (strcmp(argv[1], "libs") == 0) {
+ printf("vorbisfile\n");
+ return 0;
+ }
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * ogg_to_pcm - decode ogg vorbis audio files to PCM data using libvorbis
- *
- * ogg_to_pcm implements a single function using libvorbis to decode
- * signed 16 bit ogg audio data to signed 16 bit PCM data.
- *
- * Example:
- * #include <stdint.h>
- * #include <ogg_to_pcm.h>
- *
- * int main(int argc, char *argv[])
- * {
- * int16_t *pcmbuffer;
- * int rc, sample_size, sample_rate, channels, nsamples;
- *
- * rc = ogg_to_pcm("mysound.ogg", &pcmbuffer,
- * &sample_size, &sample_rate, &channels, &nsamples);
- * if (rc != 0)
- * return -1;
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- *
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("libvorbis\n");
- return 0;
- }
-
- if (strcmp(argv[1], "libs") == 0) {
- printf("vorbisfile\n");
- return 0;
- }
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * read_write_all - read_all and write_all routines.
+ *
+ * Successful read and write calls may only partly complete if a
+ * signal is received or they are not operating on a normal file.
+ *
+ * read_all() and write_all() do the looping for you.
+ *
+ * Example:
+ * #include <err.h>
+ * #include <stdio.h>
+ * #include <unistd.h>
+ * #include <ccan/read_write_all/read_write_all.h>
+ *
+ * #define BUFFER_SIZE 10
+ * int main(int argc, char *argv[])
+ * {
+ * char buffer[BUFFER_SIZE+1];
+ *
+ * if (!read_all(STDIN_FILENO, buffer, BUFFER_SIZE))
+ * err(1, "Could not read %u characters", BUFFER_SIZE);
+ * buffer[BUFFER_SIZE] = '\0';
+ * printf("I read '%.*s'\n", BUFFER_SIZE, buffer);
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * read_write_all - read_all and write_all routines.
- *
- * Successful read and write calls may only partly complete if a
- * signal is received or they are not operating on a normal file.
- *
- * read_all() and write_all() do the looping for you.
- *
- * Example:
- * #include <err.h>
- * #include <stdio.h>
- * #include <unistd.h>
- * #include <ccan/read_write_all/read_write_all.h>
- *
- * #define BUFFER_SIZE 10
- * int main(int argc, char *argv[])
- * {
- * char buffer[BUFFER_SIZE+1];
- *
- * if (!read_all(STDIN_FILENO, buffer, BUFFER_SIZE))
- * err(1, "Could not read %u characters", BUFFER_SIZE);
- * buffer[BUFFER_SIZE] = '\0';
- * printf("I read '%.*s'\n", BUFFER_SIZE, buffer);
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * str - string helper routines
+ *
+ * This is a grab bag of functions for string operations, designed to enhance
+ * the standard string.h.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <ccan/str/str.h>
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * if (argv[1] && streq(argv[1], "--verbose"))
+ * printf("verbose set\n");
+ * if (argv[1] && strstarts(argv[1], "--"))
+ * printf("Some option set\n");
+ * if (argv[1] && strends(argv[1], "cow-powers"))
+ * printf("Magic option set\n");
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * str - string helper routines
- *
- * This is a grab bag of functions for string operations, designed to enhance
- * the standard string.h.
- *
- * Example:
- * #include <stdio.h>
- * #include <ccan/str/str.h>
- *
- * int main(int argc, char *argv[])
- * {
- * if (argv[1] && streq(argv[1], "--verbose"))
- * printf("verbose set\n");
- * if (argv[1] && strstarts(argv[1], "--"))
- * printf("Some option set\n");
- * if (argv[1] && strends(argv[1], "cow-powers"))
- * printf("Magic option set\n");
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * str_talloc - string helper routines which use talloc
+ *
+ * This is a grab bag of fnctions for string operations, designed to enhance
+ * the standard string.h; these are separated from the non-talloc-needing
+ * string utilities in "str.h".
+ *
+ * Example:
+ * #include <ccan/str_talloc/str_talloc.h>
+ * #include <ccan/talloc/talloc.h>
+ * #include <ccan/grab_file/grab_file.h>
+ * #include <err.h>
+ *
+ * // Dumb demo program to double-linespace a file.
+ * int main(int argc, char *argv[])
+ * {
+ * char *textfile;
+ * char **lines;
+ *
+ * // Grab lines in file.
+ * textfile = grab_file(NULL, argv[1], NULL);
+ * if (!textfile)
+ * err(1, "Failed reading %s", argv[1]);
+ * lines = strsplit(textfile, textfile, "\n", NULL);
+ *
+ * // Join them back together with two linefeeds.
+ * printf("%s", strjoin(textfile, lines, "\n\n"));
+ *
+ * // Free everything, just because we can.
+ * talloc_free(textfile);
+ * return 0;
+ * }
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/talloc\n");
+ printf("ccan/noerr\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * str_talloc - string helper routines which use talloc
- *
- * This is a grab bag of fnctions for string operations, designed to enhance
- * the standard string.h; these are separated from the non-talloc-needing
- * string utilities in "str.h".
- *
- * Example:
- * #include <ccan/str_talloc/str_talloc.h>
- * #include <ccan/talloc/talloc.h>
- * #include <ccan/grab_file/grab_file.h>
- * #include <err.h>
- *
- * // Dumb demo program to double-linespace a file.
- * int main(int argc, char *argv[])
- * {
- * char *textfile;
- * char **lines;
- *
- * // Grab lines in file.
- * textfile = grab_file(NULL, argv[1], NULL);
- * if (!textfile)
- * err(1, "Failed reading %s", argv[1]);
- * lines = strsplit(textfile, textfile, "\n", NULL);
- *
- * // Join them back together with two linefeeds.
- * printf("%s", strjoin(textfile, lines, "\n\n"));
- *
- * // Free everything, just because we can.
- * talloc_free(textfile);
- * return 0;
- * }
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/talloc\n");
- printf("ccan/noerr\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * talloc - tree allocator routines
+ *
+ * Talloc is a hierarchical memory pool system with destructors: you keep your
+ * objects in heirarchies reflecting their lifetime. Every pointer returned
+ * from talloc() is itself a valid talloc context, from which other talloc()s
+ * can be attached. This means you can do this:
+ *
+ * struct foo *X = talloc(mem_ctx, struct foo);
+ * X->name = talloc_strdup(X, "foo");
+ *
+ * and the pointer X->name would be a "child" of the talloc context "X" which
+ * is itself a child of mem_ctx. So if you do talloc_free(mem_ctx) then it is
+ * all destroyed, whereas if you do talloc_free(X) then just X and X->name are
+ * destroyed, and if you do talloc_free(X->name) then just the name element of
+ * X is destroyed.
+ *
+ * If you think about this, then what this effectively gives you is an n-ary
+ * tree, where you can free any part of the tree with talloc_free().
+ *
+ * Talloc has been measured with a time overhead of around 4% over glibc
+ * malloc, and 48/80 bytes per allocation (32/64 bit).
+ *
+ * This version is based on svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/talloc revision 23158.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <stdarg.h>
+ * #include <err.h>
+ * #include <ccan/talloc/talloc.h>
+ *
+ * // A structure containing a popened command.
+ * struct command
+ * {
+ * FILE *f;
+ * const char *command;
+ * };
+ *
+ * // When struct command is freed, we also want to pclose pipe.
+ * static int close_cmd(struct command *cmd)
+ * {
+ * pclose(cmd->f);
+ * // 0 means "we succeeded, continue freeing"
+ * return 0;
+ * }
+ *
+ * // This function opens a writable pipe to the given command.
+ * struct command *open_output_cmd(const void *ctx, char *fmt, ...)
+ * {
+ * va_list ap;
+ * struct command *cmd = talloc(ctx, struct command);
+ *
+ * if (!cmd)
+ * return NULL;
+ *
+ * va_start(ap, fmt);
+ * cmd->command = talloc_vasprintf(cmd, fmt, ap);
+ * va_end(ap);
+ * if (!cmd->command) {
+ * talloc_free(cmd);
+ * return NULL;
+ * }
+ *
+ * cmd->f = popen(cmd->command, "w");
+ * if (!cmd->f) {
+ * talloc_free(cmd);
+ * return NULL;
+ * }
+ * talloc_set_destructor(cmd, close_cmd);
+ * return cmd;
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * struct command *cmd;
+ *
+ * if (argc != 2)
+ * errx(1, "Usage: %s <command>\n", argv[0]);
+ *
+ * cmd = open_output_cmd(NULL, "%s hello", argv[1]);
+ * if (!cmd)
+ * err(1, "Running '%s hello'", argv[1]);
+ * fprintf(cmd->f, "This is a test\n");
+ * talloc_free(cmd);
+ * return 0;
+ * }
+ *
+ * Licence: GPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/typesafe_cb\n");
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * talloc - tree allocator routines
- *
- * Talloc is a hierarchical memory pool system with destructors: you keep your
- * objects in heirarchies reflecting their lifetime. Every pointer returned
- * from talloc() is itself a valid talloc context, from which other talloc()s
- * can be attached. This means you can do this:
- *
- * struct foo *X = talloc(mem_ctx, struct foo);
- * X->name = talloc_strdup(X, "foo");
- *
- * and the pointer X->name would be a "child" of the talloc context "X" which
- * is itself a child of mem_ctx. So if you do talloc_free(mem_ctx) then it is
- * all destroyed, whereas if you do talloc_free(X) then just X and X->name are
- * destroyed, and if you do talloc_free(X->name) then just the name element of
- * X is destroyed.
- *
- * If you think about this, then what this effectively gives you is an n-ary
- * tree, where you can free any part of the tree with talloc_free().
- *
- * Talloc has been measured with a time overhead of around 4% over glibc
- * malloc, and 48/80 bytes per allocation (32/64 bit).
- *
- * This version is based on svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/talloc revision 23158.
- *
- * Example:
- * #include <stdio.h>
- * #include <stdarg.h>
- * #include <err.h>
- * #include <ccan/talloc/talloc.h>
- *
- * // A structure containing a popened command.
- * struct command
- * {
- * FILE *f;
- * const char *command;
- * };
- *
- * // When struct command is freed, we also want to pclose pipe.
- * static int close_cmd(struct command *cmd)
- * {
- * pclose(cmd->f);
- * // 0 means "we succeeded, continue freeing"
- * return 0;
- * }
- *
- * // This function opens a writable pipe to the given command.
- * struct command *open_output_cmd(const void *ctx, char *fmt, ...)
- * {
- * va_list ap;
- * struct command *cmd = talloc(ctx, struct command);
- *
- * if (!cmd)
- * return NULL;
- *
- * va_start(ap, fmt);
- * cmd->command = talloc_vasprintf(cmd, fmt, ap);
- * va_end(ap);
- * if (!cmd->command) {
- * talloc_free(cmd);
- * return NULL;
- * }
- *
- * cmd->f = popen(cmd->command, "w");
- * if (!cmd->f) {
- * talloc_free(cmd);
- * return NULL;
- * }
- * talloc_set_destructor(cmd, close_cmd);
- * return cmd;
- * }
- *
- * int main(int argc, char *argv[])
- * {
- * struct command *cmd;
- *
- * if (argc != 2)
- * errx(1, "Usage: %s <command>\n", argv[0]);
- *
- * cmd = open_output_cmd(NULL, "%s hello", argv[1]);
- * if (!cmd)
- * err(1, "Running '%s hello'", argv[1]);
- * fprintf(cmd->f, "This is a test\n");
- * talloc_free(cmd);
- * return 0;
- * }
- *
- * Licence: GPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/typesafe_cb\n");
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * tap - Test Anything Protocol
+ *
+ * The tap package produces simple-to-parse mainly-human-readable test
+ * output to assist in the writing of test cases. It is based on the
+ * (now-defunct) libtap, which is based on Perl's CPAN TAP module. Its
+ * output can be parsed by a harness such as CPAN's Prove.
+ *
+ * CCAN testcases are expected to output the TAP format, usually using
+ * this package.
+ *
+ * For more information about TAP, see:
+ * http://en.wikipedia.org/wiki/Test_Anything_Protocol
+ *
+ * Based on the original libtap, Copyright (c) 2004 Nik Clayton.
+ *
+ * Example:
+ * #include <string.h>
+ * #include <ccan/tap/tap.h>
+ *
+ * // Run some simple (but overly chatty) tests on strcmp().
+ * int main(int argc, char *argv[])
+ * {
+ * const char a[] = "a", another_a[] = "a";
+ * const char b[] = "b";
+ * const char ab[] = "ab";
+ *
+ * plan_tests(4);
+ * diag("Testing different pointers (%p/%p) with same contents",
+ * a, another_a);
+ * ok1(strcmp(a, another_a) == 0);
+ *
+ * diag("'a' comes before 'b'");
+ * ok1(strcmp(a, b) < 0);
+ * ok1(strcmp(b, a) > 0);
+ *
+ * diag("'ab' comes after 'a'");
+ * ok1(strcmp(ab, a) > 0);
+ * return exit_status();
+ * }
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0)
+ return 0;
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * tap - Test Anything Protocol
- *
- * The tap package produces simple-to-parse mainly-human-readable test
- * output to assist in the writing of test cases. It is based on the
- * (now-defunct) libtap, which is based on Perl's CPAN TAP module. Its
- * output can be parsed by a harness such as CPAN's Prove.
- *
- * CCAN testcases are expected to output the TAP format, usually using
- * this package.
- *
- * For more information about TAP, see:
- * http://en.wikipedia.org/wiki/Test_Anything_Protocol
- *
- * Based on the original libtap, Copyright (c) 2004 Nik Clayton.
- *
- * Example:
- * #include <string.h>
- * #include <ccan/tap/tap.h>
- *
- * // Run some simple (but overly chatty) tests on strcmp().
- * int main(int argc, char *argv[])
- * {
- * const char a[] = "a", another_a[] = "a";
- * const char b[] = "b";
- * const char ab[] = "ab";
- *
- * plan_tests(4);
- * diag("Testing different pointers (%p/%p) with same contents",
- * a, another_a);
- * ok1(strcmp(a, another_a) == 0);
- *
- * diag("'a' comes before 'b'");
- * ok1(strcmp(a, b) < 0);
- * ok1(strcmp(b, a) > 0);
- *
- * diag("'ab' comes after 'a'");
- * ok1(strcmp(ab, a) > 0);
- * return exit_status();
- * }
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0)
- return 0;
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * typesafe_cb - macros for safe callbacks.
+ *
+ * The basis of the typesafe_cb header is cast_if_type(): a
+ * conditional cast macro. If an expression exactly matches a given
+ * type, it is cast to the target type, otherwise it is left alone.
+ *
+ * This allows us to create functions which take a small number of
+ * specific types, rather than being forced to use a void *. In
+ * particular, it is useful for creating typesafe callbacks as the
+ * helpers typesafe_cb(), typesafe_cb_preargs() and
+ * typesafe_cb_postargs() demonstrate.
+ *
+ * The standard way of passing arguments to callback functions in C is
+ * to use a void pointer, which the callback then casts back to the
+ * expected type. This unfortunately subverts the type checking the
+ * compiler would perform if it were a direct call. Here's an example:
+ *
+ * static void my_callback(void *_obj)
+ * {
+ * struct obj *obj = _obj;
+ * ...
+ * }
+ * ...
+ * register_callback(my_callback, &my_obj);
+ *
+ * If we wanted to use the natural type for my_callback (ie. "void
+ * my_callback(struct obj *obj)"), we could make register_callback()
+ * take a void * as its first argument, but this would subvert all
+ * type checking. We really want register_callback() to accept only
+ * the exactly correct function type to match the argument, or a
+ * function which takes a void *.
+ *
+ * This is where typesafe_cb() comes in: it uses cast_if_type() to
+ * cast the callback function if it matches the argument type:
+ *
+ * void _register_callback(void (*cb)(void *arg), void *arg);
+ * #define register_callback(cb, arg) \
+ * _register_callback(typesafe_cb(void, (cb), (arg)), (arg))
+ *
+ * On compilers which don't support the extensions required
+ * cast_if_type() and friend become an unconditional cast, so your
+ * code will compile but you won't get type checking.
+ *
+ * Licence: LGPL (2 or any later version)
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ return 0;
+ }
+
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * typesafe_cb - macros for safe callbacks.
- *
- * The basis of the typesafe_cb header is cast_if_type(): a
- * conditional cast macro. If an expression exactly matches a given
- * type, it is cast to the target type, otherwise it is left alone.
- *
- * This allows us to create functions which take a small number of
- * specific types, rather than being forced to use a void *. In
- * particular, it is useful for creating typesafe callbacks as the
- * helpers typesafe_cb(), typesafe_cb_preargs() and
- * typesafe_cb_postargs() demonstrate.
- *
- * The standard way of passing arguments to callback functions in C is
- * to use a void pointer, which the callback then casts back to the
- * expected type. This unfortunately subverts the type checking the
- * compiler would perform if it were a direct call. Here's an example:
- *
- * static void my_callback(void *_obj)
- * {
- * struct obj *obj = _obj;
- * ...
- * }
- * ...
- * register_callback(my_callback, &my_obj);
- *
- * If we wanted to use the natural type for my_callback (ie. "void
- * my_callback(struct obj *obj)"), we could make register_callback()
- * take a void * as its first argument, but this would subvert all
- * type checking. We really want register_callback() to accept only
- * the exactly correct function type to match the argument, or a
- * function which takes a void *.
- *
- * This is where typesafe_cb() comes in: it uses cast_if_type() to
- * cast the callback function if it matches the argument type:
- *
- * void _register_callback(void (*cb)(void *arg), void *arg);
- * #define register_callback(cb, arg) \
- * _register_callback(typesafe_cb(void, (cb), (arg)), (arg))
- *
- * On compilers which don't support the extensions required
- * cast_if_type() and friend become an unconditional cast, so your
- * code will compile but you won't get type checking.
- *
- * Licence: LGPL (2 or any later version)
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- return 0;
- }
-
- return 1;
-}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * wwviaudio - realtime playback and mixing of 16 bit signed PCM audio data.
+ *
+ * wwviaudio provides a set of functions for realtime playback and mixing
+ * of audio samples, e.g. music, sound effects, etc. as in a video game.
+ *
+ * Example:
+ *
+ * something along these lines:
+ *
+ * if (wwviaudio_initialize_portaudio() != 0)
+ * bail_out_and_die();
+ *
+ * You would probably use #defines or enums rather than bare ints...
+ * wwviaudio_read_ogg_clip(1, "mysound1.ogg");
+ * wwviaudio_read_ogg_clip(2, "mysound2.ogg");
+ * wwviaudio_read_ogg_clip(3, "mysound3.ogg");
+ * wwviaudio_read_ogg_clip(4, "mymusic.ogg");
+ *
+ * ...
+ *
+ * wwviaudio_play_music(4); <-- begins playing music in background, returns immediately
+ *
+ * while (program isn't done) {
+ * do_stuff();
+ * if (something happened)
+ * wwviaudio_add_sound(1);
+ * if (something else happened)
+ * wwviaudio_add_sound(2);
+ * time_passes();
+ * }
+ *
+ * wwviaudio_cancel_all_sounds();
+ * wwviaduio_stop_portaudio();
+ *
+ * Licence: LGPL (2 or any later version)
+ *
+ */
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/ogg_to_pcm\n"
+ "libvorbis\n"
+ "portaudio >=19\n");
+ return 0;
+ }
+
+ if (strcmp(argv[1], "libs") == 0) {
+ printf("vorbisfile\n"
+ "portaudio\n");
+ return 0;
+ }
+ return 1;
+}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * wwviaudio - realtime playback and mixing of 16 bit signed PCM audio data.
- *
- * wwviaudio provides a set of functions for realtime playback and mixing
- * of audio samples, e.g. music, sound effects, etc. as in a video game.
- *
- * Example:
- *
- * something along these lines:
- *
- * if (wwviaudio_initialize_portaudio() != 0)
- * bail_out_and_die();
- *
- * You would probably use #defines or enums rather than bare ints...
- * wwviaudio_read_ogg_clip(1, "mysound1.ogg");
- * wwviaudio_read_ogg_clip(2, "mysound2.ogg");
- * wwviaudio_read_ogg_clip(3, "mysound3.ogg");
- * wwviaudio_read_ogg_clip(4, "mymusic.ogg");
- *
- * ...
- *
- * wwviaudio_play_music(4); <-- begins playing music in background, returns immediately
- *
- * while (program isn't done) {
- * do_stuff();
- * if (something happened)
- * wwviaudio_add_sound(1);
- * if (something else happened)
- * wwviaudio_add_sound(2);
- * time_passes();
- * }
- *
- * wwviaudio_cancel_all_sounds();
- * wwviaduio_stop_portaudio();
- *
- * Licence: LGPL (2 or any later version)
- *
- */
-int main(int argc, char *argv[])
-{
- if (argc != 2)
- return 1;
-
- if (strcmp(argv[1], "depends") == 0) {
- printf("ccan/ogg_to_pcm\n"
- "libvorbis\n"
- "portaudio >=19\n");
- return 0;
- }
-
- if (strcmp(argv[1], "libs") == 0) {
- printf("vorbisfile\n"
- "portaudio\n");
- return 0;
- }
- return 1;
-}
static const char *describe_has_info(struct manifest *m, void *check_result)
{
- return "You have no _info.c file.\n\n"
- "The file _info.c contains the metadata for a ccan package: things\n"
+ return "You have no _info file.\n\n"
+ "The file _info contains the metadata for a ccan package: things\n"
"like the dependencies, the documentation for the package as a whole\n"
"and license information.\n";
}
{
FILE *info;
- if (!ask("Should I create a template _info.c file for you?"))
+ if (!ask("Should I create a template _info file for you?"))
return;
- info = fopen("_info.c", "w");
+ info = fopen("_info", "w");
if (!info)
- err(1, "Trying to create a template _info.c");
+ err(1, "Trying to create a template _info");
if (fprintf(info, template, m->basename) < 0) {
- unlink_noerr("_info.c");
- err(1, "Writing template into _info.c");
+ unlink_noerr("_info");
+ err(1, "Writing template into _info");
}
fclose(info);
}
struct ccanlint has_info = {
- .name = "Has _info.c file",
+ .name = "Has _info file",
.check = check_has_info,
.describe = describe_has_info,
.handle = create_info_template,
continue;
}
- if (streq(f->name, "_info.c")) {
+ if (streq(f->name, "_info")) {
m->info_file = f;
f->contents = grab_file(f, f->name, &f->contents_size);
if (!f->contents)
static void create_info_template_doc(struct manifest *m, void *check_result)
{
- int fd = open("_info.c.new", O_WRONLY|O_CREAT|O_EXCL, 0666);
+ int fd = open("_info.new", O_WRONLY|O_CREAT|O_EXCL, 0666);
FILE *new;
char *oldcontents;
if (fd < 0 || !(new = fdopen(fd, "w")))
- err(1, "Creating _info.c.new to insert documentation");
+ err(1, "Creating _info.new to insert documentation");
if (fprintf(new,
"/**\n"
" * Followed by an Example: section with a standalone\n"
" * (trivial and usually useless) program\n"
" */\n", m->basename, m->basename) < 0) {
- unlink_noerr("_info.c.new");
- err(1, "Writing to _info.c.new to insert documentation");
+ unlink_noerr("_info.new");
+ err(1, "Writing to _info.new to insert documentation");
}
- oldcontents = grab_file(m, "_info.c", NULL);
+ oldcontents = grab_file(m, "_info", NULL);
if (!oldcontents) {
- unlink_noerr("_info.c.new");
- err(1, "Reading _info.c");
+ unlink_noerr("_info.new");
+ err(1, "Reading _info");
}
if (fprintf(new, "%s", oldcontents) < 0) {
- unlink_noerr("_info.c.new");
- err(1, "Appending _info.c to _info.c.new");
+ unlink_noerr("_info.new");
+ err(1, "Appending _info to _info.new");
}
if (fclose(new) != 0) {
- unlink_noerr("_info.c.new");
- err(1, "Closing _info.c.new");
+ unlink_noerr("_info.new");
+ err(1, "Closing _info.new");
}
- if (rename("_info.c.new", "_info.c") != 0) {
- unlink_noerr("_info.c.new");
- err(1, "Renaming _info.c.new to _info.c");
+ if (rename("_info.new", "_info") != 0) {
+ unlink_noerr("_info.new");
+ err(1, "Renaming _info.new to _info");
}
}
if (!id->summary) {
has_info_documentation.handle = create_info_template_doc;
reason = talloc_asprintf_append(reason,
- "Your _info.c has no module documentation.\n\n"
+ "Your _info file has no module documentation.\n\n"
"CCAN modules use /**-style comments for documentation: the\n"
- "overall documentation belongs in the _info.c metafile.\n");
+ "overall documentation belongs in the _info metafile.\n");
}
if (!id->description)
reason = talloc_asprintf_append(reason,
- "Your _info.c has no module description.\n\n"
- "The lines after the first summary line in the _info.c file\n"
+ "Your _info file has no module description.\n\n"
+ "The lines after the first summary line in the _info file\n"
"documentation should describe the purpose and use of the\n"
"overall package\n");
if (!id->example)
reason = talloc_asprintf_append(reason,
- "Your _info.c has no module example.\n\n"
- "There should be an Example: section of the _info.c documentation\n"
+ "Your _info file has no module example.\n\n"
+ "There should be an Example: section of the _info documentation\n"
"which provides a concise toy program which uses your module\n");
return reason;
}
}
struct ccanlint has_info_documentation = {
- .name = "Documentation in _info.c",
+ .name = "Documentation in _info file",
.total_score = 3,
.score = has_info_documentation_score,
.check = check_has_info_documentation,
/* Be careful about trying to compile over running programs (parallel make) */
static char *compile_info(const void *ctx, const char *dir)
{
- char *infofile = talloc_asprintf(ctx, "%s/_info.%u", dir, getpid());
- char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s %s/_info.c",
+ char *infofile = talloc_asprintf(ctx, "%s/info.%u", dir, getpid());
+ char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s -x c %s/_info",
infofile, dir);
talloc_set_destructor(infofile, unlink_info);
if (system(cmd) != 0)
char **deps, **lines, *raw, *fname;
unsigned int i, n = 0;
- fname = talloc_asprintf(ctx, "%s/_info.c", dir);
+ fname = talloc_asprintf(ctx, "%s/_info", dir);
raw = grab_file(fname, fname, NULL);
if (!raw)
errx(1, "Could not open %s", fname);
verbose("Looking for dependents in %s\n", parent);
verbose_indent();
for (file = get_dir(parent); *file; file++) {
- char *infoc, **deps;
+ char *info, **deps;
bool isdep = false;
if (basename(*file, *file)[0] == '.')
continue;
- infoc = talloc_asprintf(*file, "%s/_info.c", *file);
- if (access(infoc, R_OK) != 0)
+ info = talloc_asprintf(*file, "%s/_info", *file);
+ if (access(info, R_OK) != 0)
continue;
for (deps = get_deps(*file, *file, false); *deps; deps++) {
#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I."
-/* This actually compiles and runs the _info.c file to get dependencies. */
+/* This actually compiles and runs the info file to get dependencies. */
char **get_deps(const void *ctx, const char *dir, bool recurse);
-/* This is safer: just looks for ccan/ strings in _info.c */
+/* This is safer: just looks for ccan/ strings in info */
char **get_safe_ccan_deps(const void *ctx, const char *dir, bool recurse);
#endif /* CCAN_TOOLS_H */
$tempfolder = "temp/";
//infofile
-$infofile = '/_info.c';
+$infofile = '/_info';
//temp repo
$temprepo = "temprepo/";
$uploadscript = "http://ccan.ozlabs.org/uploader.php";
//infofile
-$infofile = '/_info.c';
+$infofile = '/_info';
//ccan admin
$ccanadmin = "rusty@rustcorp.com.au";
function extract_field($field,$module)
{
- return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info.c'));
+ return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info'));
}
// Convert double line breaks into paragraphs, and blank spaces into preformat.
$d = dir($argv[1]);
$modules = array();
while (false !== ($entry = $d->read())) {
- if ($entry[0] != '.' && is_file($argv[1].$entry."/_info.c")) {
+ if ($entry[0] != '.' && is_file($argv[1].$entry."/_info")) {
array_push($modules, $entry);
}
}
by uploading here; .tar.gz, .zip or even single C files.
</p>
-<p>If it has a valid _info.c file and a testsuite (see <a href="http://ccan.ozlabs.org/Wiki/ModuleGuide">the module creation guide</a>), it'll go into the
+<p>If it has a valid _info file and a testsuite (see <a href="http://ccan.ozlabs.org/Wiki/ModuleGuide">the module creation guide</a>), it'll go into the
main repository. Otherwise, it'll go into our "junkcode" area where
people can browse and download it.
</p>
by uploading here; .tar.gz, .zip or even single C files.
</p>
-<p>If it has a valid _info.c file and a testsuite, it'll go into the
+<p>If it has a valid _info file and a testsuite, it'll go into the
main repository. Otherwise, it'll go into our "junkcode" area where
people can browse and download it.
</p>