FEDEM Solver  R8.0
Source code of the dynamics solver
Classes | Functions | Variables
FFaTag.C File Reference

Utilities for reading and writing of file tags. More...

#include <cstring>
#include "FFaLib/FFaOS/FFaTag.H"
Include dependency graph for FFaTag.C:

Classes

class  FFa_stream
 Interface class for stream-based reading/writing of file tags. More...
 
class  F_stream
 Class for file stream based on standard IO. More...
 

Functions

static int FFaTag_error (const char *, int status)
 Dummy function for silent runs. More...
 
static int FFaTag_checkEndian (short myEndian)
 Checks the current system endian. More...
 
int FFa_endian ()
 Returns the current system endian. More...
 
static int FFaTag_read (FFa_stream &fs, std::string &tag, unsigned int &cs, int tagLength)
 Reads the file tag and checksum from the provided file stream. More...
 
int FFaTag_write (FFa_stream &fs, const char *tag, int nchar, unsigned int cs, int tagLength)
 Writes the file tag and checksum to the provided file stream. More...
 
int FFa_readTag (FT_FILE fd, char *tag, int nchar, unsigned int *cs)
 Reads the file tag, endian field and checksum from a specified file. More...
 
int FFa_writeTag (FT_FILE fd, const char *tag, int nchar, unsigned int cs)
 Writes the file tag, endian field and checksum to a specified file. More...
 

Variables

static short EndianField = 0x1234
 16-bit value used to determine endian More...
 
static unsigned char EF1 = 0x12
 Little endian value. More...
 
static unsigned char EF2 = 0x34
 Big endian value. More...
 

Detailed Description

Utilities for reading and writing of file tags.

Function Documentation

◆ FFa_endian()

int FFa_endian ( )

Returns the current system endian.

◆ FFa_readTag()

int FFa_readTag ( FT_FILE  fd,
char *  tag,
int  nchar,
unsigned int *  cs 
)

Reads the file tag, endian field and checksum from a specified file.

Parameters
fdFile descriptor/pointer to the investigated file
[out]tagFile tag
[in]ncharMax number of characters in the tag string
[out]csChecksum value
Returns
0 : This is an ASCII file
1 : This is a big endian binary file
2 : This is a little endian binary file
-1 : Wrong file start, first read character should be a #
-2 : Error reading file tag
-3 : Invalid or error reading endian field
-4 : Error reading checksum field

◆ FFa_writeTag()

int FFa_writeTag ( FT_FILE  fd,
const char *  tag,
int  nchar,
unsigned int  cs 
)

Writes the file tag, endian field and checksum to a specified file.

Parameters
fdFile descriptor/pointer to the written file
[in]tagFile tag
[in]ncharNumber of characters in the tag string
[in]csChecksum value
Returns
  0 : OK
-1 : Error writing file tag
-2 : Error writing endian field
-3 : Error writing checksum field

◆ FFaTag_checkEndian()

static int FFaTag_checkEndian ( short  myEndian)
static

Checks the current system endian.

◆ FFaTag_error()

static int FFaTag_error ( const char *  ,
int  status 
)
static

Dummy function for silent runs.

◆ FFaTag_read()

static int FFaTag_read ( FFa_stream fs,
std::string &  tag,
unsigned int &  cs,
int  tagLength 
)
static

Reads the file tag and checksum from the provided file stream.

Parameters
fsFile stream to read from
[out]tagFile tag
[out]csChecksum value
[in]tagLengthNumber of characters in the tag string on file
Returns
0 : This is an ASCII file
1 : This is a big endian binary file
2 : This is a little endian binary file
-1 : Wrong file start, first read character should be a #
-2 : Error reading file tag
-3 : Invalid or error reading endian field
-4 : Error reading checksum field

◆ FFaTag_write()

int FFaTag_write ( FFa_stream fs,
const char *  tag,
int  nchar,
unsigned int  cs,
int  tagLength 
)

Writes the file tag and checksum to the provided file stream.

Parameters
fsFile stream to write to
[in]tagFile tag
[in]ncharNumber of characters in the provided tag string
[in]csChecksum value
[in]tagLengthNumber of characters in the tag string on file
Returns
  0 : OK
-1 : Error writing file tag
-2 : Error writing endian field
-3 : Error writing checksum field

Variable Documentation

◆ EF1

unsigned char EF1 = 0x12
static

Little endian value.

◆ EF2

unsigned char EF2 = 0x34
static

Big endian value.

◆ EndianField

short EndianField = 0x1234
static

16-bit value used to determine endian