summaryrefslogtreecommitdiff
path: root/c_src/permdb.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2016-04-29 12:45:58 +0200
committerLinus Nordberg <linus@nordu.net>2016-04-29 12:45:58 +0200
commitce461321ef514cc0b21e44e415eb05ad2122036b (patch)
treedd1121fea3b9e5a995b757e06feda2e67bc617e9 /c_src/permdb.c
parent41dfffcc1572073c3d1d201a0a19dd2c4ca1bb4a (diff)
Turn a bunch of outcommented fprintf's into dprintf's.
Also, rename dprintf 'level' to 'category' and add DEBUG_REBUILD.
Diffstat (limited to 'c_src/permdb.c')
-rw-r--r--c_src/permdb.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/c_src/permdb.c b/c_src/permdb.c
index 66b9813..2b14d0b 100644
--- a/c_src/permdb.c
+++ b/c_src/permdb.c
@@ -176,7 +176,7 @@ indexfile_add_header(buffered_file *file)
void
datafile_add_header(buffered_file *file)
{
- //fprintf(stderr, "adding header to %s\n", bf_name(file));
+ dprintf(WRITE, (stderr, "adding header to %s\n", bf_name(file)));
bf_add(file, &data_file_cookie, sizeof(data_file_cookie));
bf_add_be32(file, 4096);
bf_add_be32(file, 2);
@@ -206,9 +206,10 @@ struct commit_info {
int
validate_checksum(struct commit_info *commit, buffered_file *file)
{
- /*fprintf(stderr,
- "validate_checksum: read from file: length %llu start %llu\n",
- commit->length, commit->start);*/
+ dprintf(READ,
+ (stderr,
+ "validate_checksum: read from file: length %llu start %llu\n",
+ commit->length, commit->start));
unsigned char *checksumdata = bf_read(file, commit->start,
commit->length, NULL);
@@ -236,7 +237,7 @@ validate_checksum(struct commit_info *commit, buffered_file *file)
int
verify_index_commit(buffered_file *file, node_offset offset)
{
- //fprintf(stderr, "verifying index file: commit verification\n");
+ dprintf(READ, (stderr, "verifying index file: commit verification\n"));
offset -= INDEX_COMMIT_TRAILER_SIZE;
unsigned char *data =
bf_read(file, offset, INDEX_COMMIT_TRAILER_SIZE, NULL);
@@ -260,7 +261,7 @@ verify_index_commit(buffered_file *file, node_offset offset)
int
indexfile_verify_file(buffered_file *file)
{
- //fprintf(stderr, "verifying index file\n");
+ dprintf(READ, (stderr, "verifying index file\n"));
unsigned char *header = bf_read(file, 0, sizeof(index_file_cookie), NULL);
if (memcmp(header, &index_file_cookie, sizeof(index_file_cookie)) != 0) {
free(header);
@@ -292,12 +293,12 @@ datafile_verify_file(buffered_file *file)
node_offset offset = bf_lastcommit(file);
- //fprintf(stderr, "verifying commit: %llu\n", offset);
+ dprintf(READ, (stderr, "verifying commit: %llu\n", offset));
struct commit_info *data_commit =
read_data_commit_backward(file, &offset);
if (data_commit == NULL || validate_checksum(data_commit, file) < 0) {
- //fprintf(stderr, "commit broken: %llu\n", offset);
+ dprintf(READ, (stderr, "commit broken: %llu\n", offset));
free(data_commit);
return -1;
}
@@ -327,8 +328,8 @@ read_data_commit(buffered_file *file, node_offset *offset)
}
*offset += sizeof(uint32_t);
struct commit_info *commit = malloc(sizeof(struct commit_info));
- //fprintf(stderr, "read commit: %llu\n", *offset);
- //print_hex(data, sizeof(uint32_t) + SHA256_DIGEST_SIZE);
+ dprintf(READ, (stderr, "read commit: %llu\n", *offset));
+ dprinthex(READ, data, sizeof(uint32_t) + SHA256_DIGEST_SIZE);
commit->length = read_be32(data);
commit->start = *offset - commit->length;
memcpy(&commit->checksum, data + sizeof(uint32_t), SHA256_DIGEST_SIZE);