From 10db41c732c861616fbc8ca0997f948399a61e5a Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 1 Mar 2013 20:17:41 +0100 Subject: [PATCH] Fixes compilation in Windows. --- handle.c | 18 +++++++++--------- handle.h | 4 ++-- parity.c | 10 +++++----- parity.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/handle.c b/handle.c index 522a712b..25415836 100644 --- a/handle.c +++ b/handle.c @@ -109,7 +109,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file) return 0; } -int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* stdout) +int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out) { int ret; @@ -131,7 +131,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE handle->f = -1; handle->valid_size = 0; - fprintf(stdout, "Error opening file '%s'. %s.\n", handle->path, strerror(errno)); + fprintf(out, "Error opening file '%s'. %s.\n", handle->path, strerror(errno)); return -1; } @@ -141,7 +141,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE /* get the stat info */ ret = fstat(handle->f, &handle->st); if (ret != 0) { - fprintf(stdout, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); + fprintf(out, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); return -1; } @@ -152,7 +152,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE /* advise sequential access */ ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL); if (ret != 0) { - fprintf(stdout, "Error advising file '%s'. %s.\n", handle->path, strerror(ret)); + fprintf(out, "Error advising file '%s'. %s.\n", handle->path, strerror(ret)); return -1; } #endif @@ -186,7 +186,7 @@ int handle_close(struct snapraid_handle* handle) return 0; } -int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* stdout) +int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out) { ssize_t read_ret; data_off_t offset; @@ -197,7 +197,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un /* check if we are going to read only not initialized data */ if (offset >= handle->valid_size) { - fprintf(stdout, "Reading missing data from file '%s' at offset %"PRIu64".\n", handle->path, offset); + fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", handle->path, offset); return -1; } @@ -205,7 +205,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un #if !HAVE_PREAD if (lseek(handle->f, offset, SEEK_SET) != offset) { - fprintf(stdout, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); + fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); return -1; } #endif @@ -220,11 +220,11 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un #endif if (read_ret < 0) { - fprintf(stdout, "Error reading file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); + fprintf(out, "Error reading file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); return -1; } if (read_ret == 0) { - fprintf(stdout, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); + fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno)); return -1; } diff --git a/handle.h b/handle.h index 1bdfe7d0..006d015e 100644 --- a/handle.h +++ b/handle.h @@ -47,7 +47,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file); * Opens a file. * The file is opened for reading. */ -int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* stdout); +int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out); /** * Closes a file. @@ -58,7 +58,7 @@ int handle_close(struct snapraid_handle* handle); * Read a block from a file. * If the read block is shorter, it's padded with 0. */ -int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* stdout); +int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out); /** * Writes a block to a file. diff --git a/parity.c b/parity.c index 4bb75e18..d4ea392e 100644 --- a/parity.c +++ b/parity.c @@ -363,7 +363,7 @@ int parity_write(struct snapraid_parity* parity, block_off_t pos, unsigned char* return 0; } -int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* stdout) +int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out) { ssize_t read_ret; data_off_t offset; @@ -373,13 +373,13 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* /* check if we are going to read only not initialized data */ if (offset >= parity->valid_size) { - fprintf(stdout, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset); + fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset); return -1; } #if !HAVE_PREAD if (lseek(parity->f, offset, SEEK_SET) != offset) { - fprintf(stdout, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); + fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); return -1; } #endif @@ -393,11 +393,11 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* read_ret = read(parity->f, block_buffer + count, block_size - count); #endif if (read_ret < 0) { - fprintf(stdout, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); + fprintf(out, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); return -1; } if (read_ret == 0) { - fprintf(stdout, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); + fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); return -1; } diff --git a/parity.h b/parity.h index 7ca29857..6a940752 100644 --- a/parity.h +++ b/parity.h @@ -68,7 +68,7 @@ int parity_close(struct snapraid_parity* parity); /** * Read a block from the parity file. */ -int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* stdout); +int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out); /** * Writes a block in the parity file.