Table of Contents

NAME

QccFileReadMagicNumber, QccFileWriteMagicNumber, QccFileWriteMagicNumberVersion, QccFileGetMagicNumber, QccFilePrintFileInfo - read and write magic-number headers to files

SYNOPSIS

#include "libQccPack.h"

int QccFileReadMagicNumber(FILE *infile, QccString magic_num, int *major_version_number, int *minor_version_number);
int QccFileWriteMagicNumber(FILE *outfile, const QccString magic_num);
int QccFileGetMagicNumber(const QccString filename, QccString magic_num);
int QccFileWriteMagicNumberVersion(FILE *outfile, const QccString magic_num, int major_version_number, int minor_version_number);
int QccFilePrintFileInfo(const QccString filename, const QccString magic_num, int major_version, int minor_version);

DESCRIPTION

Each file written by QccPack includes identifying information that consists of a magic number (in alphabetic characters), which indicates the type of data in the file, and a version number, which indicates which version (major and minor version) of QccPack created the file. This header information is stored at the start of each file.

QccFileReadMagicNumber() reads the magic number and version information from the header of infile. The magic number, the major version number, and the minor version number are returned in locations pointed to by magic_num, major_version_number, and minor_version_number, respectively. Space in which to store the magic number and the two version numbers must be allocated prior to calling QccFileReadMagicNumber(). Also, infile must already be positioned to the start of file (via a prior call to QccFileOpen(3) , for example), as the magic number and version information is stored at the start of the file.

QccFileWriteMagicNumber() writes the magic number, as given by magic_num, and the version information, as returned by QccGetQccPackVersion(3) , to the start of outfile. It is assumed that outfile is already open and positioned to the start of the file (via a prior call to QccFileOpen(3) ). QccFileWriteMagicNumberVersion() does the same as QccFileWriteMagicNumber() except that major_version_number, and minor_version_number allow the explicit specification of the version number to appear in the file header.

QccFileGetMagicNumber() is similar to QccFileReadMagicNumber(), except that the file whose name is filename is examined, and its magic number (magic number only, no version numbers) is returned in magic_num.

QccFilePrintFileInfo() accepts a filename, a magic_num, and two version numbers, major_version and minor_version. This information, along with the the file size and modtime (from QccFileGetSize(3) and QccFileGetModTime(3) , respectively), is printed to stdout in a nice, attractive banner.

RETURN VALUES

Each of these functions return 0 on success and 1 on failure.

SEE ALSO

QccFileOpen(3) , QccGetQccPackVersion(3) , QccFileGetSize(3) , QccFileGetModTime(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