From: Rusty Russell Date: Thu, 28 May 2009 04:54:10 +0000 (+0930) Subject: Rename _info.c to _info: this means we can simple compile *.c. X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=570c9c555f076e74f46141bb42b5d1d7ac89f632;hp=-c;p=ccan Rename _info.c to _info: this means we can simple compile *.c. --- 570c9c555f076e74f46141bb42b5d1d7ac89f632 diff --git a/Makefile b/Makefile index 409c4b4a..8d53cbc6 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ # 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/)) @@ -25,27 +25,27 @@ check: $(ALL_TESTS:%=check-%) 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 diff --git a/Makefile-ccan b/Makefile-ccan index 5d04109e..2e802dd5 100644 --- a/Makefile-ccan +++ b/Makefile-ccan @@ -1,6 +1,6 @@ # 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) @@ -8,8 +8,8 @@ CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototy 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) @@ -20,5 +20,5 @@ libccan.a: $(OBJFILES) # 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'` diff --git a/Makefile-web b/Makefile-web index 4a180eca..a0f16efa 100644 --- a/Makefile-web +++ b/Makefile-web @@ -56,10 +56,10 @@ $(WEBDIR)/ccan.jpg: web/ccan.jpg $(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 diff --git a/ccan/alignof/_info b/ccan/alignof/_info new file mode 100644 index 00000000..e647afbf --- /dev/null +++ b/ccan/alignof/_info @@ -0,0 +1,48 @@ +#include +#include +#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 + * #include + * #include + * + * 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; +} diff --git a/ccan/alignof/_info.c b/ccan/alignof/_info.c deleted file mode 100644 index e647afbf..00000000 --- a/ccan/alignof/_info.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#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 - * #include - * #include - * - * 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; -} diff --git a/ccan/alloc/_info b/ccan/alloc/_info new file mode 100644 index 00000000..9b00284f --- /dev/null +++ b/ccan/alloc/_info @@ -0,0 +1,108 @@ +#include +#include +#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 + * #include + * #include + * #include + * #include + * #include + * #include + * #include + * + * static void usage(const char *name) + * { + * errx(1, "Usage: %s --create \n" + * " %s --check \n" + * " %s --alloc \n" + * " %s --free= \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; +} diff --git a/ccan/alloc/_info.c b/ccan/alloc/_info.c deleted file mode 100644 index 9b00284f..00000000 --- a/ccan/alloc/_info.c +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * #include - * #include - * #include - * #include - * - * static void usage(const char *name) - * { - * errx(1, "Usage: %s --create \n" - * " %s --check \n" - * " %s --alloc \n" - * " %s --free= \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; -} diff --git a/ccan/antithread/_info b/ccan/antithread/_info new file mode 100644 index 00000000..24b4e997 --- /dev/null +++ b/ccan/antithread/_info @@ -0,0 +1,26 @@ +#include +#include +#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; +} diff --git a/ccan/antithread/_info.c b/ccan/antithread/_info.c deleted file mode 100644 index 24b4e997..00000000 --- a/ccan/antithread/_info.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#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; -} diff --git a/ccan/array/_info b/ccan/array/_info new file mode 100644 index 00000000..af3bd39f --- /dev/null +++ b/ccan/array/_info @@ -0,0 +1,62 @@ +#include +#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 + * #include + * + * 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; +} diff --git a/ccan/array/_info.c b/ccan/array/_info.c deleted file mode 100644 index af3bd39f..00000000 --- a/ccan/array/_info.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#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 - * #include - * - * 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; -} diff --git a/ccan/array_size/_info b/ccan/array_size/_info new file mode 100644 index 00000000..794ba785 --- /dev/null +++ b/ccan/array_size/_info @@ -0,0 +1,41 @@ +#include +#include +#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 + * #include + * + * // 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; +} diff --git a/ccan/array_size/_info.c b/ccan/array_size/_info.c deleted file mode 100644 index 794ba785..00000000 --- a/ccan/array_size/_info.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#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 - * #include - * - * // 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; -} diff --git a/ccan/build_assert/_info b/ccan/build_assert/_info new file mode 100644 index 00000000..d2fe3d9c --- /dev/null +++ b/ccan/build_assert/_info @@ -0,0 +1,48 @@ +#include +#include +#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 + * #include + * + * 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; +} diff --git a/ccan/build_assert/_info.c b/ccan/build_assert/_info.c deleted file mode 100644 index d2fe3d9c..00000000 --- a/ccan/build_assert/_info.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#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 - * #include - * - * 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; -} diff --git a/ccan/check_type/_info b/ccan/check_type/_info new file mode 100644 index 00000000..42d3328a --- /dev/null +++ b/ccan/check_type/_info @@ -0,0 +1,32 @@ +#include +#include +#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; +} diff --git a/ccan/check_type/_info.c b/ccan/check_type/_info.c deleted file mode 100644 index 42d3328a..00000000 --- a/ccan/check_type/_info.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#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; -} diff --git a/ccan/ciniparser/_info b/ccan/ciniparser/_info new file mode 100644 index 00000000..e3af8baf --- /dev/null +++ b/ccan/ciniparser/_info @@ -0,0 +1,56 @@ +#include +#include +#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 + * #include + * #include + * + * #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; +} diff --git a/ccan/ciniparser/_info.c b/ccan/ciniparser/_info.c deleted file mode 100644 index e3af8baf..00000000 --- a/ccan/ciniparser/_info.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#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 - * #include - * #include - * - * #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; -} diff --git a/ccan/container_of/_info b/ccan/container_of/_info new file mode 100644 index 00000000..4c25c296 --- /dev/null +++ b/ccan/container_of/_info @@ -0,0 +1,57 @@ +#include +#include +#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 + * #include + * + * 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; +} diff --git a/ccan/container_of/_info.c b/ccan/container_of/_info.c deleted file mode 100644 index 4c25c296..00000000 --- a/ccan/container_of/_info.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#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 - * #include - * - * 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; -} diff --git a/ccan/crc/_info b/ccan/crc/_info new file mode 100644 index 00000000..c3f0b763 --- /dev/null +++ b/ccan/crc/_info @@ -0,0 +1,42 @@ +#include + +/** + * 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 + * #include + * #include + * + * int main(int argc, char *argv[]) + * { + * if (argc != 2) { + * fprintf(stderr, "Usage: %s \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 + */ +int main(int argc, char *argv[]) +{ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + return 0; + } + + return 1; +} diff --git a/ccan/crc/_info.c b/ccan/crc/_info.c deleted file mode 100644 index c3f0b763..00000000 --- a/ccan/crc/_info.c +++ /dev/null @@ -1,42 +0,0 @@ -#include - -/** - * 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 - * #include - * #include - * - * int main(int argc, char *argv[]) - * { - * if (argc != 2) { - * fprintf(stderr, "Usage: %s \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 - */ -int main(int argc, char *argv[]) -{ - if (argc != 2) - return 1; - - if (strcmp(argv[1], "depends") == 0) { - return 0; - } - - return 1; -} diff --git a/ccan/crcsync/_info b/ccan/crcsync/_info new file mode 100644 index 00000000..52e2ebe2 --- /dev/null +++ b/ccan/crcsync/_info @@ -0,0 +1,83 @@ +#include +#include +#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 + * #include + * #include + * #include + * #include + * + * 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 ...\n" + * "OR: %s ", 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; +} diff --git a/ccan/crcsync/_info.c b/ccan/crcsync/_info.c deleted file mode 100644 index 52e2ebe2..00000000 --- a/ccan/crcsync/_info.c +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * #include - * - * 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 ...\n" - * "OR: %s ", 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; -} diff --git a/ccan/daemonize/_info b/ccan/daemonize/_info new file mode 100644 index 00000000..2bdcaa97 --- /dev/null +++ b/ccan/daemonize/_info @@ -0,0 +1,54 @@ +#include +#include +#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 + * #include + * #include + * #include + * #include + * + * 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; +} diff --git a/ccan/daemonize/_info.c b/ccan/daemonize/_info.c deleted file mode 100644 index 2bdcaa97..00000000 --- a/ccan/daemonize/_info.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * #include - * - * 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; -} diff --git a/ccan/endian/_info b/ccan/endian/_info new file mode 100644 index 00000000..ae63e14e --- /dev/null +++ b/ccan/endian/_info @@ -0,0 +1,51 @@ +#include +#include +#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 + * #include + * #include + * + * // + * int main(int argc, char *argv[]) + * { + * uint32_t value; + * + * if (argc != 2) + * errx(1, "Usage: %s ", 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; +} diff --git a/ccan/endian/_info.c b/ccan/endian/_info.c deleted file mode 100644 index ae63e14e..00000000 --- a/ccan/endian/_info.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#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 - * #include - * #include - * - * // - * int main(int argc, char *argv[]) - * { - * uint32_t value; - * - * if (argc != 2) - * errx(1, "Usage: %s ", 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; -} diff --git a/ccan/grab_file/_info b/ccan/grab_file/_info new file mode 100644 index 00000000..f5d22bbc --- /dev/null +++ b/ccan/grab_file/_info @@ -0,0 +1,53 @@ +#include +#include +#include "config.h" + +/** + * grab_file - file helper routines + * + * This contains simple functions for getting the contents of a file. + * + * Example: + * #include + * #include + * #include + * #include + * #include // 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; +} diff --git a/ccan/grab_file/_info.c b/ccan/grab_file/_info.c deleted file mode 100644 index f5d22bbc..00000000 --- a/ccan/grab_file/_info.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include "config.h" - -/** - * grab_file - file helper routines - * - * This contains simple functions for getting the contents of a file. - * - * Example: - * #include - * #include - * #include - * #include - * #include // 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; -} diff --git a/ccan/hash/_info b/ccan/hash/_info new file mode 100644 index 00000000..2ec72725 --- /dev/null +++ b/ccan/hash/_info @@ -0,0 +1,27 @@ +#include + +/** + * 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; +} diff --git a/ccan/hash/_info.c b/ccan/hash/_info.c deleted file mode 100644 index 2ec72725..00000000 --- a/ccan/hash/_info.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -/** - * 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; -} diff --git a/ccan/ilog/_info b/ccan/ilog/_info new file mode 100644 index 00000000..2b4aeb2e --- /dev/null +++ b/ccan/ilog/_info @@ -0,0 +1,45 @@ +/** + * 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 + * #include + * #include + * + * 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< +#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; +} diff --git a/ccan/ilog/_info.c b/ccan/ilog/_info.c deleted file mode 100644 index 2b4aeb2e..00000000 --- a/ccan/ilog/_info.c +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 - * #include - * #include - * - * 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< -#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; -} diff --git a/ccan/isaac/_info b/ccan/isaac/_info new file mode 100644 index 00000000..32eba0a5 --- /dev/null +++ b/ccan/isaac/_info @@ -0,0 +1,116 @@ +/** + * 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 + * #include + * #include + * + * 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 +#include +#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; +} diff --git a/ccan/isaac/_info.c b/ccan/isaac/_info.c deleted file mode 100644 index 32eba0a5..00000000 --- a/ccan/isaac/_info.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - * 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 - * #include - * #include - * - * 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 -#include -#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; -} diff --git a/ccan/list/_info b/ccan/list/_info new file mode 100644 index 00000000..003887c9 --- /dev/null +++ b/ccan/list/_info @@ -0,0 +1,68 @@ +#include +#include +#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 + * #include + * #include + * #include + * + * 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; +} diff --git a/ccan/list/_info.c b/ccan/list/_info.c deleted file mode 100644 index 003887c9..00000000 --- a/ccan/list/_info.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * - * 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; -} diff --git a/ccan/md4/_info b/ccan/md4/_info new file mode 100644 index 00000000..d3c2c420 --- /dev/null +++ b/ccan/md4/_info @@ -0,0 +1,48 @@ +#include +#include +#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 + * #include + * + * // 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; +} diff --git a/ccan/md4/_info.c b/ccan/md4/_info.c deleted file mode 100644 index d3c2c420..00000000 --- a/ccan/md4/_info.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#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 - * #include - * - * // 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; -} diff --git a/ccan/noerr/_info b/ccan/noerr/_info new file mode 100644 index 00000000..fee413d3 --- /dev/null +++ b/ccan/noerr/_info @@ -0,0 +1,60 @@ +#include +#include +#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 + * #include + * #include + * #include + * #include + * #include + * #include + * + * 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; +} diff --git a/ccan/noerr/_info.c b/ccan/noerr/_info.c deleted file mode 100644 index fee413d3..00000000 --- a/ccan/noerr/_info.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * #include - * #include - * #include - * - * 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; -} diff --git a/ccan/ogg_to_pcm/_info b/ccan/ogg_to_pcm/_info new file mode 100644 index 00000000..48d4da88 --- /dev/null +++ b/ccan/ogg_to_pcm/_info @@ -0,0 +1,45 @@ +#include +#include +#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 + * #include + * + * 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; +} diff --git a/ccan/ogg_to_pcm/_info.c b/ccan/ogg_to_pcm/_info.c deleted file mode 100644 index 48d4da88..00000000 --- a/ccan/ogg_to_pcm/_info.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#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 - * #include - * - * 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; -} diff --git a/ccan/read_write_all/_info b/ccan/read_write_all/_info new file mode 100644 index 00000000..32fccc88 --- /dev/null +++ b/ccan/read_write_all/_info @@ -0,0 +1,43 @@ +#include +#include +#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 + * #include + * #include + * #include + * + * #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; +} diff --git a/ccan/read_write_all/_info.c b/ccan/read_write_all/_info.c deleted file mode 100644 index 32fccc88..00000000 --- a/ccan/read_write_all/_info.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * - * #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; -} diff --git a/ccan/str/_info b/ccan/str/_info new file mode 100644 index 00000000..081e862d --- /dev/null +++ b/ccan/str/_info @@ -0,0 +1,38 @@ +#include +#include +#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 + * #include + * + * 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; +} diff --git a/ccan/str/_info.c b/ccan/str/_info.c deleted file mode 100644 index 081e862d..00000000 --- a/ccan/str/_info.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#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 - * #include - * - * 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; -} diff --git a/ccan/str_talloc/_info b/ccan/str_talloc/_info new file mode 100644 index 00000000..aaf9d996 --- /dev/null +++ b/ccan/str_talloc/_info @@ -0,0 +1,52 @@ +#include +#include +#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 + * #include + * #include + * #include + * + * // 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; +} diff --git a/ccan/str_talloc/_info.c b/ccan/str_talloc/_info.c deleted file mode 100644 index aaf9d996..00000000 --- a/ccan/str_talloc/_info.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * - * // 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; -} diff --git a/ccan/talloc/_info b/ccan/talloc/_info new file mode 100644 index 00000000..95c91536 --- /dev/null +++ b/ccan/talloc/_info @@ -0,0 +1,105 @@ +#include +#include +#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 + * #include + * #include + * #include + * + * // 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 \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; +} diff --git a/ccan/talloc/_info.c b/ccan/talloc/_info.c deleted file mode 100644 index 95c91536..00000000 --- a/ccan/talloc/_info.c +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#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 - * #include - * #include - * #include - * - * // 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 \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; -} diff --git a/ccan/tap/_info b/ccan/tap/_info new file mode 100644 index 00000000..010f9896 --- /dev/null +++ b/ccan/tap/_info @@ -0,0 +1,55 @@ +#include +#include +#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 + * #include + * + * // 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; +} diff --git a/ccan/tap/_info.c b/ccan/tap/_info.c deleted file mode 100644 index 010f9896..00000000 --- a/ccan/tap/_info.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#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 - * #include - * - * // 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; -} diff --git a/ccan/typesafe_cb/_info b/ccan/typesafe_cb/_info new file mode 100644 index 00000000..5e35eb76 --- /dev/null +++ b/ccan/typesafe_cb/_info @@ -0,0 +1,61 @@ +#include +#include +#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; +} diff --git a/ccan/typesafe_cb/_info.c b/ccan/typesafe_cb/_info.c deleted file mode 100644 index 5e35eb76..00000000 --- a/ccan/typesafe_cb/_info.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#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; -} diff --git a/ccan/wwviaudio/_info b/ccan/wwviaudio/_info new file mode 100644 index 00000000..84a33276 --- /dev/null +++ b/ccan/wwviaudio/_info @@ -0,0 +1,61 @@ +#include +#include +#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; +} diff --git a/ccan/wwviaudio/_info.c b/ccan/wwviaudio/_info.c deleted file mode 100644 index 84a33276..00000000 --- a/ccan/wwviaudio/_info.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#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; -} diff --git a/tools/ccanlint/compulsory_tests/has_info.c b/tools/ccanlint/compulsory_tests/has_info.c index e7f2622d..ed2d4c81 100644 --- a/tools/ccanlint/compulsory_tests/has_info.c +++ b/tools/ccanlint/compulsory_tests/has_info.c @@ -20,8 +20,8 @@ static void *check_has_info(struct manifest *m) 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"; } @@ -56,22 +56,22 @@ static void create_info_template(struct manifest *m, void *check_result) { 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, diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index 62e4a13a..2a66a545 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -71,7 +71,7 @@ static void add_files(struct manifest *m, const char *dir) 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) diff --git a/tools/ccanlint/tests/has_info_documentation.c b/tools/ccanlint/tests/has_info_documentation.c index 4202880e..8a506aba 100644 --- a/tools/ccanlint/tests/has_info_documentation.c +++ b/tools/ccanlint/tests/has_info_documentation.c @@ -48,12 +48,12 @@ extern struct ccanlint has_info_documentation; 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" @@ -64,26 +64,26 @@ static void create_info_template_doc(struct manifest *m, void *check_result) " * 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"); } } @@ -96,20 +96,20 @@ static const char *describe_has_info_documentation(struct manifest *m, 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; } @@ -122,7 +122,7 @@ static unsigned int has_info_documentation_score(struct manifest *m, } 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, diff --git a/tools/depends.c b/tools/depends.c index 2bf11415..c9cf8816 100644 --- a/tools/depends.c +++ b/tools/depends.c @@ -39,8 +39,8 @@ static int unlink_info(char *infofile) /* 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) @@ -98,7 +98,7 @@ static char **get_one_safe_deps(const void *ctx, 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); diff --git a/tools/namespacize.c b/tools/namespacize.c index f5dced5d..0ed36aa6 100644 --- a/tools/namespacize.c +++ b/tools/namespacize.c @@ -507,14 +507,14 @@ static void adjust_dependents(const char *dir) 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++) { diff --git a/tools/tools.h b/tools/tools.h index 84b1fb8a..4bdb8077 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -10,10 +10,10 @@ #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 */ diff --git a/web/configuration b/web/configuration index fcb38358..aeeca274 100644 --- a/web/configuration +++ b/web/configuration @@ -21,7 +21,7 @@ $junkcode = "junkcode/"; $tempfolder = "temp/"; //infofile -$infofile = '/_info.c'; +$infofile = '/_info'; //temp repo $temprepo = "temprepo/"; diff --git a/web/static-configuration b/web/static-configuration index f0fcb89e..0e9d0169 100644 --- a/web/static-configuration +++ b/web/static-configuration @@ -6,7 +6,7 @@ $tempfolder = "/home/ccan/upload-temp/"; $uploadscript = "http://ccan.ozlabs.org/uploader.php"; //infofile -$infofile = '/_info.c'; +$infofile = '/_info'; //ccan admin $ccanadmin = "rusty@rustcorp.com.au"; @@ -22,7 +22,7 @@ $repo_base = 'http://ccan.ozlabs.org/repo/?cmd=inventory;path='; 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. diff --git a/web/staticall.php b/web/staticall.php index ac39eddc..1998e147 100644 --- a/web/staticall.php +++ b/web/staticall.php @@ -28,7 +28,7 @@ Or you can just download the tarball of everything includ $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); } } diff --git a/web/staticupload.php b/web/staticupload.php index 998ca21c..7cbb64f1 100644 --- a/web/staticupload.php +++ b/web/staticupload.php @@ -16,7 +16,7 @@ Got C code sitting around which might help someone? Put it to work by uploading here; .tar.gz, .zip or even single C files.

-

If it has a valid _info.c file and a testsuite (see the module creation guide), it'll go into the +

If it has a valid _info file and a testsuite (see the module creation guide), it'll go into the main repository. Otherwise, it'll go into our "junkcode" area where people can browse and download it.

diff --git a/web/upload.php b/web/upload.php index 2c208b47..2972180d 100644 --- a/web/upload.php +++ b/web/upload.php @@ -12,7 +12,7 @@ include('configuration'); by uploading here; .tar.gz, .zip or even single C files.

-

If it has a valid _info.c file and a testsuite, it'll go into the +

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.