tf_read(), sf_read()

Purpose

Reads a specified amount of data from a file

Old names

#define _vnread tf_read
#define _anread sf_read

Syntax (CCOWN)

unsigned tf_read(int file_handle, void * data, unsigned bytes)
unsigned sf_read(int file_handle, void * data, unsigned bytes)

Syntax (DP4DBAPI)

dp4_file_size dp4_sf_read(FCONN * fconn,void * buffer,dp4_file_size nr_bytes);

Parameters

int file_handle

File handle of file from which to read, obtained earlier with a successful call to tf_open() or sf_open()

Parameters

FCONN * fconn

File handle of file from which to read, obtained earlier with a successful call to dp4_sf_open()

 

ANY* data

Pointer to buffer to hold data that is read

 

unsigned bytes

Number of bytes to read from file

Description

The tf_read() and sf_read() functions read the specified number of bytes from a file into a buffer .The sf_read() function calls the file handling support in the database manager, and the tf_read() function calls the file handling support in the terminal manager. You must not call an sf_ function with a handle obtained with tf_open(), or a tf_ function with a handle obtained with sf_open().

Return values

Returns the number of bytes read. This may be less than the requested number when the end of file is reached.

For dp4_sf_read only. If an error occurs when dp4_sf_read() is called, then the return value will be the number of bytes that had been read when the error occurred: If you do not have an error callback installed, then you will need to cal dp4_error_status() to check whether an error occurred.

See also

tf_write_record()