summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/e2e.c24
-rw-r--r--src/e2e.h2
2 files changed, 14 insertions, 12 deletions
diff --git a/src/e2e.c b/src/e2e.c
index cb5dc62..d7d214f 100644
--- a/src/e2e.c
+++ b/src/e2e.c
@@ -118,7 +118,7 @@ static int read_image(struct e2e_data *data, const char *cursor,
struct e2e_image *image)
{
if (cursor + IMAGE_IMAGE > data->end) {
- fprintf(stderr, "Image data at %td ends past the end of file.\n",
+ errorf("Image data at %td ends past the end of file.\n",
cursor - data->start);
return 1;
}
@@ -147,25 +147,25 @@ static int read_entry(struct e2e_data *data, const char *cursor,
struct e2e_chunk *chunk;
if (cursor + ENTRY_END > data->end) {
- fprintf(stderr, "Entry at %td data->ends past the data->end of file.\n",
+ errorf("Entry at %td data->ends past the data->end of file.\n",
cursor - data->start);
return 1;
}
if (make_pointer(data, cursor + ENTRY_POS, &pos)) {
- fprintf(stderr, "Entry at %td has a bad 'pos' entry.\n",
+ errorf("Entry at %td has a bad 'pos' entry.\n",
cursor - data->start);
return 1;
}
if (pos != cursor) {
- fprintf(stderr, "Entry at %td has a 'pos' entry that differs from the entry's actual position",
+ errorf("Entry at %td has a 'pos' entry that differs from the entry's actual position",
cursor - data->start);
return 1;
}
if (make_pointer(data, cursor + ENTRY_START, &entry->start)) {
- fprintf(stderr, "Entry at %td has a bad 'data->start' entry.\n",
+ errorf("Entry at %td has a bad 'data->start' entry.\n",
cursor - data->start);
return 1;
}
@@ -188,19 +188,19 @@ static int read_entry(struct e2e_data *data, const char *cursor,
chunk->origin = cursor;
if (cursor + CHUNK_HEADER_END > data->end) {
- fprintf(stderr, "Chunk at %td ends past the end of file.\n",
+ errorf("Chunk at %td ends past the end of file.\n",
cursor - data->start);
return 1;
}
if (make_pointer(data, cursor + CHUNK_POS, &pos)) {
- fprintf(stderr, "Chunk at %td has a bad 'pos' entry.\n",
+ errorf("Chunk at %td has a bad 'pos' entry.\n",
cursor - data->start);
return 1;
}
if (pos != cursor) {
- fprintf(stderr, "Chunk at %td has a 'pos' entry that differs from the entry's actual position.\n",
+ errorf("Chunk at %td has a 'pos' entry that differs from the entry's actual position.\n",
cursor - data->start);
return 1;
}
@@ -225,7 +225,7 @@ static int read_directory(struct e2e_data *data, const char *cursor,
struct e2e_directory *dir)
{
if (cursor + DIRECTORY_END > data->end) {
- fprintf(stderr, "Directory at %td data->ends past the data->end of file.\n",
+ errorf("Directory at %td data->ends past the data->end of file.\n",
cursor - data->start);
return 1;
}
@@ -233,13 +233,13 @@ static int read_directory(struct e2e_data *data, const char *cursor,
dir->num_entries = u32le(cursor + DIRECTORY_NUM_ENTRIES);
if (make_pointer(data, cursor + DIRECTORY_CURRENT, &dir->current)) {
- fprintf(stderr, "Directory at %td contains a bad 'current' field.\n",
+ errorf("Directory at %td contains a bad 'current' field.\n",
cursor - data->start);
return 1;
}
if (make_pointer(data, cursor + DIRECTORY_NEXT, &dir->next)) {
- fprintf(stderr, "Directory at %td contains a bad 'current' field.\n",
+ errorf("Directory at %td contains a bad 'current' field.\n",
cursor - data->start);
return 1;
}
@@ -281,7 +281,7 @@ int e2e_read(struct e2e_data *data, const char *start, const char *end)
data->dirs = NULL;
if (start + HEADER_END > end) {
- fprintf(stderr, "File too short to be an E2E file.\n");
+ errorf("File too short to be an E2E file.\n");
return 1;
}
diff --git a/src/e2e.h b/src/e2e.h
index 167a83a..72ba8a2 100644
--- a/src/e2e.h
+++ b/src/e2e.h
@@ -1,6 +1,8 @@
#include <inttypes.h>
#include "eli.h"
+#define errorf(fmt, ...) (fprintf(stderr, fmt, ##__VA_ARGS__))
+
#define IMAGE_FUNDUS 0x02010201
#define IMAGE_TOMOGRAM 0x02200201