Table of Contents

NAME

QccChannelReadWholefile, QccChannelReadHeader, QccChannelStartRead, QccChannelEndRead, QccChannelReadBlock - reading of QccChannel structures from CHN-format files

SYNOPSIS

#include "libQccPack.h"

int QccChannelReadWholefile(QccChannel *channel);
int QccChannelReadHeader(QccChannel *channel);
int QccChannelStartRead(QccChannel *channel);
int QccChannelEndRead(QccChannel *channel);
int QccChannelReadBlock(QccChannel *channel);

DESCRIPTION

These routines implement the reading of QccChannel channels from CHN-format files. There are two distinct modes in which the channel-symbol data in channels may be read: the whole file may be read at once, or the file may be read in non-overlapping blocks.

QccChannelReadWholefile() reads the CHN-format file whose filename is given by channel->filename. The entire file is read, including the header, and the symbols are returned in the channel->channel_symbols. If channel->channel_symbols is NULL, channel->channel_symbols is allocated via a call to QccChannelAlloc() prior to reading; otherwise, it is assumed that sufficient space has already been allocated.

QccChannelReadHeader() reads the header information of the CHN-format file pointed to by channel->fileptr, which must be already open and positioned at the start of the file. Information read from the header is returned in the fields of channel.

QccChannelStartRead() must be called before any block-based read of channel. QccChannelStartRead() opens the file with QccFileOpen(3) , reads the file's header with QccChannelReadHeader(3) , and allocates storage space, if needed, for the channel symbols by calling QccChannelAlloc(3) (note that allocation is performed only if channel->channel_symbols is NULL). Prior to calling QccChannelStartRead(), channel->filename must contain the name of the file and channel->access_block_size must give the block size desired for subsequent block-based reads. The remaining fields of channel are filled in from the file's header. After QccChannelStartRead() returns, channel->fileptr contains the FILE pointer to the open file, and the file is positioned at the start of the channel-symbol data, ready for reading the first block of symbols.

QccChannelEndRead() closes a channel file opened by a previous call to QccChannelStartRead(); additionally, the symbol array, channel->channel_symbols, is freed with a call to QccChannelFree(3) .

QccChannelReadBlock() reads the next block of symbols in the channel. channel must be prepared by a prior call to QccChannelStartRead(); that is, channel->fileptr must point to an open file, channel->access_block_size must contain the size of the block of symbols to read, and channel->channel_symbols must be allocated with space sufficient for storing the block of symbols. QccChannelReadBlock() reads non-overlapping blocks of data from the file; after QccChannelReadBlock() returns, the file is positioned at the start of the subsequent block.

RETURN VALUE

These routines return 0 on successful completion, 1 if an error occurs while reading the file.

SEE ALSO

QccChannelWrite(3) , QccChannel(3) , QccFileOpen(3) , QccChannel(3) , QccPack(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads