Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/src/utils/filebuffer.c
2017-02-19 23:31:46 +01:00

38 lines
1.3 KiB
C

/* ************************************************************************** */
/* _____ _ */
/* utils/filebuffer.c |_ _|__ _ _| |__ ___ _ _ */
/* | Project: libg1m | |/ _ \| | | | '_ \ / _ \ | | | */
/* | | (_) | |_| | | | | __/ |_| | */
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
/* Last updated: 2017/02/19 22:35:20 |___/ */
/* */
/* ************************************************************************** */
#include <libg1m/internals.h>
#ifndef G1M_DISABLED_FILE
/**
* g1m_filebuffer_read:
* Read from a filebuffer.
*
* @arg vcookie the FILE* (uncasted)
* @arg buf the buffer to fill.
* @arg size the size to read.
* @return the error (if any).
*/
int g1m_filebuffer_read(void *vcookie, unsigned char *buf, size_t size)
{
FILE *file = (void*)vcookie;
size_t read = fread(buf, 1, size, file);
if (!read) {
log_error("READING failed: read %" PRIuSIZE "/%" PRIuSIZE
" bytes, %" PRIuSIZE " missing.", read, size, size - read);
return (g1m_error_eof);
}
/* no error */
return (0);
}
#endif