FreeBSD/usr.bin/lastcomm/readrec.c
/*
 * Read exactly one record of size size from stream f into ptr.
 * Failure to read the complete record is considered a file format error,
 * and will set errno to EFTYPE.
 * Return 0 on success, EOF on end of file or error.
 */
Read exactly one record of size size from stream f into ptr.
Failure to read the complete record is considered a file format error,
and will set errno to EFTYPE.
Return 0 on success, EOF on end of file or error.
Read exactly one record of size size from stream f into ptr . Failure to read the complete record is considered a file format error and will set errno to EFTYPE . Return 0 on success EOF on end of file or error .
static int
fread_record(void *ptr, size_t size, FILE *f)
{
	size_t rv;
	if ((rv = fread(ptr, 1, size, f)) == size)
		return (0);
	else if (ferror(f) || rv == 0)
		return (EOF);
	else {
		errno = EFTYPE;
		return (EOF);
	}
}
static int fread_record ( void * ptr , size_t size , FILE * f ) { size_t rv ; if ( ( rv = fread ( ptr , 1 , size , f ) ) == size ) return ( 0 ) ; else if ( ferror ( f ) || rv == 0 ) return ( EOF ) ; else { errno = EFTYPE ; return ( EOF ) ; } }
Read exactly one record of size size from stream f into ptr.
Read exactly one record of size size from stream f into ptr .
/* Short read. */