c_fread - Reads an input file and converts data to the local endian

SYNTAX

#include "lasfileio.h"

size_t c_fread 
(
     void *buf,
     size_t size,
     size_t count,
     FILE *stream
)

PARAMETERS

buf (input, VOID *)

Pointer to a buffer for the data read from the file. The data is converted from big endian byte order to the local byte order.

size (input, size_t)

Specifies the size, in bytes, of each element read from the file. This is limited to be 1, 2, 4, or 8 bytes to match the sizes of standard data types.

count (input, size_t)

Specifies the number of elements of size bytes to read from the file.

stream (input, FILE *)

Pointer to the file to read. This file should be opened by the standard C fopen call.

DESCRIPTION

All data files for LAS are written using big endian byte order. This is the byte order used by Mips, Sparc, and Motorola processors. The c_fread() routine is the equivalent of the standard C fread routine that will perform byte swapping on platforms that use little endian byte order.

RETURN VALUE

c_fread() returns the number of items successfully read. If an error occurs, or the end-of-file is reached, the return value is a short item count. E_FAIL (-1) may be returned if the size or count parameters are invalid.