kjb_fread - Reads a specifed number of bytes from a stream.


#include "l/l_sys_io.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

long kjb_fread
	FILE *fp,
	void *buff,
	size_t len


This is essentially a front end for fread, but there are some differences. First, the arguments are different. The file pointer is first, and the size arguments are combined. Second, the error reporting is more consistent with the rest of the library. This routine can only read up to LONG_MAX bytes at a time. If the number of bytes requested is more than MIN_OF(LONG_MAX, SSIZE_MAX), this routine returns ERROR. The routine kjb_read() can be used to read up the number of bytes that can stored in size_t. This function is not re-entrant (i.e., not thread-safe).


On success kjb_fread returns the number of bytes read. On end of file. EOF is returned. On failure ERROR is returned and an error message is set. If the I/O is non blocking, then WOULD_BLOCK may also be returned. Finally, depending on the type of signal handling in place, INTERRUPTED may also be returned.


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


set_low_level_io_options , kjb_read_exact , kjb_read , kjb_read_2 , safe_pipe_write , kjb_write , kjb_write_2 , kjb_fread_exact , kjb_fread_2 , kjb_fwrite , kjb_fwrite_2 , kjb_safe_fflush , kjb_fflush , kjb_ioctl , set_blocking , set_no_blocking , stdin_get_line , fget_line , dget_line , fput_line , kjb_mkdir , kjb_mkdir_2 , kjb_unlink , kjb_unlink_2 , kjb_rmdir , kjb_fopen , kjb_freopen , kjb_fdopen , kjb_fclose , kjb_realpath , get_fd_name , get_user_fd_name , kjb_fseek , kjb_ftell , kjb_fputs , kjb_fgetc , kjb_fputc , pso , p_stderr , kjb_fprintf , pdo , kjb_vfprintf , is_file , is_directory , fp_get_path_type , get_path_type , get_file_size , fp_get_byte_size , get_file_age , stream_younger , stream_older , get_file_mod_time , kjb_isatty , print_underlined , start_stdout_shadow , stop_stdout_shadow , start_stderr_shadow , stop_stderr_shadow , enable_stdout , disable_stdout , kjb_glob , kjb_simple_glob