VWriteHeader


Name

VWriteHeader - writes the 3DVIEWNIX file header.

Synopsis

VWriteHeader(fp, vh, group, element)
FILE *fp;
ViewnixHeader *vh;
char group[5], element[5];

Description

VWriteHeader writes the file header information to a disk file specified by the user from the ViewnixHeader structure *vh, according to the data set type stored in the file header.

Structures

  typedef struct {
        GeneralInfo gen;        /*general header information*/
        SceneInfo scn;          /*scene data header information*/
        StructureInfo str;      /*structure data header information*/
        DisplayInfo dsp;        /*display data header information*/
  } ViewnixHeader;
See Appendix B for description of GeneralInfo, SceneInfo, StructureInfo and DisplayInfo.

Return Value

0 - work successfully.
1 - memory allocation fault.
2 - read error.
5 - improper seeks.
7 - 3DVIEWNIX directory pathname not given in environment variable.
100 - incorrect 3DVIEWNIX file format.
102 - invalid data set type.
103 - cannot open specification file.
104 - invalid value in the file header for Type 1.
106 - invalid value in the file header for Type 1D.
107 - invalid value in the file header for 2, 2D, or 3.
105 - invalid recognition code.

Parameters

fp - a pointer to the output data file.
vh - pointer to the struct where the function puts the information.
group - the group number of the error item.
element - the element number of the error item.

Side Effects

If the flag is 0 (invalid item), VWriteHeader writes the corresponding group number and element number (stored in the specification files), and a value length of 0 to the file, and ignores the value specified in vh. If the data item is of char pointer type and the flag is 1, VWriteHeader writes the corresponding group number, element number, value length, and the value to the file irrespective of what the value length is. If the data item is a pointer of type short, int, or float with a value that is not NULL and the flag is 1, then VWriteHeader writes the corresponding group number, element number, the value length (the number of bytes corresponding to the value in vh) and the values(s) in ViewnixHeader to the file. If the data item is of type 1D and the flag is 0, VWriteHeader assigns a default value(s) to the item and writes the group number, element number, length of the value(s) and the value(s) to the file and no error is returned. If the value of the recognition code stored in vh does not have any matching set of specification files and ViewnixHeader, VWriteHeader gives a fatal error, otherwise the matching files and structure are used for writing the data.

Entry Conditions

The environment variable "VIEWNIX_ENV" must be set to the 3DVIEWNIX system directory. The proper specification files must be present.

Related Functions

VReadHeader