Table of Contents

NAME

QccChannelWriteWholefile, QccChannelWriteHeader, QccChannelStartWrite, QccChannelEndWrite, QccChannelWriteBlock - writing of QccChannel structures to CHN-format files

SYNOPSIS

#include "libQccPack.h"

int QccChannelWriteWholefile(QccChannel *channel);
int QccChannelWriteHeader(QccChannel *channel);
int QccChannelStartWrite(QccChannel *channel);
int QccChannelEndWrite(QccChannel *channel);
int QccChannelWriteBlock(QccChannel *channel);

DESCRIPTION

These routines implement the writing of QccChannel channels to CHN-format files. There are two distinct modes in which the channel-symbol data in channels may be written: the whole file may be written at once, or the file may be written in non-overlapping blocks. For each of these routines, appropriate values must be supplied in channel->channel_length and channel->alphabet_size prior to calling the routines.

QccChannelWriteWholefile() writes the CHN-format file whose filename is given by channel->filename. The whole file, including the header and all symbols of the channel, is written at once. channel->channel_symbols is assumed to be allocated and to contain all channel -> channel_length symbols of the channel.

QccChannelWriteHeader() writes header information to the CHN-format file pointed to by channel->fileptr, which must be already open for writing and positioned at the start of the file. The magic number and version information is supplied automatically by QccFileWriteMagicNumber(3) .

QccChannelStartWrite() must be called before any block-based write to channel. QccChannelStartWrite() opens the file with QccFileOpen(3) and writes the file's header with QccChannelWriteHeader(3) . If the symbol array is not already allocated (i.e., if channel->channel_symbols is NULL) the symbol array is allocated by calling QccChannelAlloc(3) . Prior to calling QccChannelStartWrite(), channel->filename must contain the name of the file, channel->alphabet_size must contain the channel alphabet size, channel->channel_length must contain the total length of the channel, and channel->access_block_size must give the block size desired for subsequent block-based writes. After QccChannelStartWrite() returns, channel->fileptr contains the FILE pointer to the open file, and the file is positioned immediately after the header, ready for writing the first block of symbols.

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

QccChannelWriteBlock() writes the next block of symbols in the channel. channel must be prepared by a prior call to QccChannelStartWrite(); that is, channel->fileptr must point to an open file and channel->access_block_size must contain the size of the block of symbols to write. Additionally, channel->channel_symbols must contain the block of symbols to be written. QccChannelWriteBlock() writes non-overlapping blocks of data to the file; after QccChannelWriteBlock() returns, the file is positioned to write the subsequent block.

RETURN VALUE

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

SEE ALSO

QccChannelRead(3) , QccFileWriteMagicNumber(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