+#include "config.h"
#include <stdio.h>
#include <string.h>
-#include "config.h"
/**
* crcsync - routines to use crc for an rsync-like protocol.
* // Calculate checksums of file (3-arg mode)
* // Or print differences between file and checksums (4+ arg mode)
* #include <ccan/crcsync/crcsync.h>
- * #include <ccan/grab_file/grab_file.h>
+ * #include <ccan/tal/grab_file/grab_file.h>
+ * #include <ccan/tal/tal.h>
* #include <stdio.h>
* #include <stdlib.h>
* #include <err.h>
* size_t len, used, blocksize;
* char *file;
* struct crc_context *ctx;
- * uint32_t *crcs;
+ * uint64_t *crcs;
* long res, i;
*
* if (argc < 3 || (blocksize = atoi(argv[1])) == 0)
* errx(1, "Usage: %s <blocksize> <file> <crc>...\n"
* "OR: %s <blocksize> <file>", argv[0], argv[0]);
*
- * file = grab_file(NULL, argv[2], &len);
+ * file = grab_file(NULL, argv[2]);
* if (!file)
* err(1, "Opening file %s", argv[2]);
- *
+ * len = tal_count(file) - 1;
+ *
* 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));
+ * crcs = malloc(used * sizeof(crcs[0]));
* crc_of_blocks(file, len, blocksize, 32, crcs);
* for (i = 0; i < used; i++)
- * printf("%i ", crcs[i]);
+ * printf("%llu ", (long long)crcs[i]);
* printf("\n");
* return 0;
* }
* for (i = 0; i < argc-3; i++)
* crcs[i] = atoi(argv[3+i]);
*
- * ctx = crc_context_new(blocksize, 32, crcs, argc-3);
+ * ctx = crc_context_new(blocksize, 32, crcs, argc-3, 0);
* for (used = 0; used < len; ) {
* used += crc_read_block(ctx, &res, file+used, len-used);
* print_result(res);
* return 0;
* }
*
- * Licence: LGPL (v2 or any later version)
+ * License: LGPL (v2.1 or any later version)
+ * Author: Rusty Russell <rusty@rustcorp.com.au>
*/
int main(int argc, char *argv[])
{
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/crc\n");
+ return 0;
+ }
+ if (strcmp(argv[1], "testdepends") == 0) {
printf("ccan/array_size\n");
return 0;
}
+ if (strcmp(argv[1], "ccanlint") == 0) {
+ /* We actually depend on the GPL crc routines, so not really LGPL :( */
+ printf("license_depends_compat FAIL\n");
+ return 0;
+ }
return 1;
}