Back to index

tetex-bin  3.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
FoFiBase Class Reference

#include <FoFiBase.h>

Inheritance diagram for FoFiBase:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~FoFiBase ()

Protected Member Functions

 FoFiBase (char *fileA, int lenA, GBool freeFileDataA)
int getS8 (int pos, GBool *ok)
int getU8 (int pos, GBool *ok)
int getS16BE (int pos, GBool *ok)
int getU16BE (int pos, GBool *ok)
int getS32BE (int pos, GBool *ok)
Guint getU32BE (int pos, GBool *ok)
Guint getUVarBE (int pos, int size, GBool *ok)
GBool checkRegion (int pos, int size)

Static Protected Member Functions

static char * readFile (char *fileName, int *fileLen)

Protected Attributes

GucharfileData
Gucharfile
int len
GBool freeFileData

Detailed Description

Definition at line 28 of file FoFiBase.h.


Constructor & Destructor Documentation

FoFiBase::~FoFiBase ( ) [virtual]

Definition at line 29 of file FoFiBase.cc.

                    {
  if (freeFileData) {
    gfree(fileData);
  }
}

Here is the call graph for this function:

FoFiBase::FoFiBase ( char *  fileA,
int  lenA,
GBool  freeFileDataA 
) [protected]

Definition at line 23 of file FoFiBase.cc.

                                                             {
  fileData = file = (Guchar *)fileA;
  len = lenA;
  freeFileData = freeFileDataA;
}

Member Function Documentation

GBool FoFiBase::checkRegion ( int  pos,
int  size 
) [protected]

Definition at line 152 of file FoFiBase.cc.

                                             {
  return pos >= 0 &&
         pos + size >= pos &&
         pos + size <= len;
}

Here is the caller graph for this function:

int FoFiBase::getS16BE ( int  pos,
GBool ok 
) [protected]

Definition at line 79 of file FoFiBase.cc.

                                         {
  int x;

  if (pos < 0 || pos+1 >= len) {
    *ok = gFalse;
    return 0;
  }
  x = file[pos];
  x = (x << 8) + file[pos+1];
  if (x & 0x8000) {
    x |= ~0xffff;
  }
  return x;
}

Here is the caller graph for this function:

int FoFiBase::getS32BE ( int  pos,
GBool ok 
) [protected]

Definition at line 106 of file FoFiBase.cc.

                                         {
  int x;

  if (pos < 0 || pos+3 >= len) {
    *ok = gFalse;
    return 0;
  }
  x = file[pos];
  x = (x << 8) + file[pos+1];
  x = (x << 8) + file[pos+2];
  x = (x << 8) + file[pos+3];
  if (x & 0x80000000) {
    x |= ~0xffffffff;
  }
  return x;
}

Here is the caller graph for this function:

int FoFiBase::getS8 ( int  pos,
GBool ok 
) [protected]

Definition at line 57 of file FoFiBase.cc.

                                      {
  int x;

  if (pos < 0 || pos >= len) {
    *ok = gFalse;
    return 0;
  }
  x = file[pos];
  if (x & 0x80) {
    x |= ~0xff;
  }
  return x;
}
int FoFiBase::getU16BE ( int  pos,
GBool ok 
) [protected]

Definition at line 94 of file FoFiBase.cc.

                                         {
  int x;

  if (pos < 0 || pos+1 >= len) {
    *ok = gFalse;
    return 0;
  }
  x = file[pos];
  x = (x << 8) + file[pos+1];
  return x;
}

Here is the caller graph for this function:

Guint FoFiBase::getU32BE ( int  pos,
GBool ok 
) [protected]

Definition at line 123 of file FoFiBase.cc.

                                           {
  Guint x;

  if (pos < 0 || pos+3 >= len) {
    *ok = gFalse;
    return 0;
  }
  x = file[pos];
  x = (x << 8) + file[pos+1];
  x = (x << 8) + file[pos+2];
  x = (x << 8) + file[pos+3];
  return x;
}

Here is the caller graph for this function:

int FoFiBase::getU8 ( int  pos,
GBool ok 
) [protected]

Definition at line 71 of file FoFiBase.cc.

                                      {
  if (pos < 0 || pos >= len) {
    *ok = gFalse;
    return 0;
  }
  return file[pos];
}

Here is the caller graph for this function:

Guint FoFiBase::getUVarBE ( int  pos,
int  size,
GBool ok 
) [protected]

Definition at line 137 of file FoFiBase.cc.

                                                      {
  Guint x;
  int i;

  if (pos < 0 || pos + size > len) {
    *ok = gFalse;
    return 0;
  }
  x = 0;
  for (i = 0; i < size; ++i) {
    x = (x << 8) + file[pos + i];
  }
  return x;
}

Here is the caller graph for this function:

char * FoFiBase::readFile ( char *  fileName,
int fileLen 
) [static, protected]

Definition at line 35 of file FoFiBase.cc.

                                                     {
  FILE *f;
  char *buf;
  int n;

  if (!(f = fopen(fileName, "rb"))) {
    return NULL;
  }
  fseek(f, 0, SEEK_END);
  n = (int)ftell(f);
  fseek(f, 0, SEEK_SET);
  buf = (char *)gmalloc(n);
  if ((int)fread(buf, 1, n, f) != n) {
    gfree(buf);
    fclose(f);
    return NULL;
  }
  fclose(f);
  *fileLen = n;
  return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Guchar* FoFiBase::file [protected]

Definition at line 52 of file FoFiBase.h.

Guchar* FoFiBase::fileData [protected]

Definition at line 51 of file FoFiBase.h.

Definition at line 54 of file FoFiBase.h.

int FoFiBase::len [protected]

Definition at line 53 of file FoFiBase.h.


The documentation for this class was generated from the following files: