FORM
4.2.1
|
#include "form3.h"
Go to the source code of this file.
Macros | |
#define | SAVEREVISION 0x02 |
Functions | |
WORD | OpenTemp () |
VOID | SeekScratch (FILEHANDLE *fi, POSITION *pos) |
VOID | SetEndScratch (FILEHANDLE *f, POSITION *position) |
VOID | SetEndHScratch (FILEHANDLE *f, POSITION *position) |
VOID | SetScratch (FILEHANDLE *f, POSITION *position) |
WORD | RevertScratch () |
WORD | ResetScratch () |
int | ReadFromScratch (FILEHANDLE *fi, POSITION *pos, UBYTE *buffer, POSITION *length) |
int | AddToScratch (FILEHANDLE *fi, POSITION *pos, UBYTE *buffer, POSITION *length, int withflush) |
int | CoSave (UBYTE *inp) |
int | CoLoad (UBYTE *inp) |
WORD | DeleteStore (WORD par) |
WORD | PutInStore (INDEXENTRY *ind, WORD num) |
WORD | GetTerm (PHEAD WORD *term) |
WORD | GetOneTerm (PHEAD WORD *term, FILEHANDLE *fi, POSITION *pos, int par) |
WORD | GetMoreTerms (WORD *term) |
WORD | GetMoreFromMem (WORD *term, WORD **tpoin) |
WORD | GetFromStore (WORD *to, POSITION *position, RENUMBER renumber, WORD *InCompState, WORD nexpr) |
VOID | DetVars (WORD *term, WORD par) |
WORD | ToStorage (EXPRESSIONS e, POSITION *length) |
INDEXENTRY * | NextFileIndex (POSITION *indexpos) |
WORD | SetFileIndex () |
WORD | VarStore (UBYTE *s, WORD n, WORD name, WORD namesize) |
WORD | TermRenumber (WORD *term, RENUMBER renumber, WORD nexpr) |
WORD | FindrNumber (WORD n, VARRENUM *v) |
INDEXENTRY * | FindInIndex (WORD expr, FILEDATA *f, WORD par, WORD mode) |
RENUMBER | GetTable (WORD expr, POSITION *position, WORD mode) |
int | CopyExpression (FILEHANDLE *from, FILEHANDLE *to) |
WORD | WriteStoreHeader (WORD handle) |
WORD | ReadSaveHeader () |
WORD | ReadSaveIndex (FILEINDEX *fileind) |
WORD | ReadSaveVariables (UBYTE *buffer, UBYTE *top, LONG *size, LONG *outsize, INDEXENTRY *ind, LONG *stage) |
UBYTE * | ReadSaveTerm32 (UBYTE *bin, UBYTE *binend, UBYTE **bout, UBYTE *boutend, UBYTE *top, int terminbuf) |
WORD | ReadSaveExpression (UBYTE *buffer, UBYTE *top, LONG *size, LONG *outsize) |
Contains all functions that deal with store-files and the system independent save-files.
Definition in file store.c.
WORD SetFileIndex | ( | ) |
Reads the next file index and puts it into AR.StoreData.Index. TODO
Definition at line 2300 of file store.c.
References WriteStoreHeader().
WORD TermRenumber | ( | WORD * | term, |
RENUMBER | renumber, | ||
WORD | nexpr | ||
) |
!! WORD *memterm=term; static LONG ctrap=0; !!!
!! ctrap++; !!!
Definition at line 2407 of file store.c.
References ReNuMbEr::func, ReNuMbEr::funnum, ReNuMbEr::indi, ReNuMbEr::indnum, ReNuMbEr::symb, ReNuMbEr::symnum, TermRenumber(), ReNuMbEr::vecnum, and ReNuMbEr::vect.
Referenced by TermRenumber().
WORD WriteStoreHeader | ( | WORD | handle | ) |
Writes header with information about system architecture and FORM revision to an open store file.
Called by SetFileIndex().
handle | specifies open file to which header will be written |
Definition at line 3926 of file store.c.
References STOREHEADER::endianness, STOREHEADER::lenLONG, STOREHEADER::lenPOINTER, STOREHEADER::lenPOS, STOREHEADER::lenWORD, STOREHEADER::maxpower, STOREHEADER::sFun, STOREHEADER::sInd, STOREHEADER::sSym, STOREHEADER::sVec, and STOREHEADER::wildoffset.
Referenced by SetFileIndex().
WORD ReadSaveHeader | ( | ) |
Reads the header in the save file and sets function pointers and flags according to the information found there. Must be called before any other ReadSave... function.
Currently works only for the exchange between 32bit and 64bit machines (WORD size must be 2 or 4 bytes)!
It is called by CoLoad().
WORD ReadSaveIndex | ( | FILEINDEX * | fileind | ) |
Reads a FILEINDEX from the open save file specified by AO.SaveData.Handle. Translations for adjusting endianness and data sizes are done if necessary.
Depends on the assumption that sizeof(FILEINDEX) is the same everywhere. If FILEINDEX or INDEXENTRY change, then this functions has to be adjusted.
Called by CoLoad() and FindInIndex().
fileind | contains the read FILEINDEX after succesful return. must point to allocated, big enough memory. |
Definition at line 4137 of file store.c.
References INFILEINDEX, FiLeInDeX::next, FiLeInDeX::number, and FuNcTiOn::number.
WORD ReadSaveVariables | ( | UBYTE * | buffer, |
UBYTE * | top, | ||
LONG * | size, | ||
LONG * | outsize, | ||
INDEXENTRY * | ind, | ||
LONG * | stage | ||
) |
Reads the variables from the open file specified by AO.SaveData.Handle. It reads the *size bytes and writes them to the *buffer. It is called by PutInStore().
If translation is necessary, the data might shrink or grow in size, then *size is adjusted so that the reading and writing fits into the memory from the buffer to the top. The actual number of read bytes is returned in *size, the number of written bytes is returned in *outsize.
If the *size is smaller than the actual size of the variables, this function will be called several times and needs to remember the current position in the variable structure. The parameter stage does this job. When ReadSaveVariables() is called for the first time, this parameter should have the value -1.
The parameter ind is used to get the number of variables.
buffer | read variables are written into this allocated memory |
top | upper end of allocated memory |
size | number of bytes to read. might return a smaller number of read bytes if translation was necessary |
outsize | if translation has be done, outsize contains the number of written bytes |
ind | pointer of INDEXENTRY for the current expression. read-only |
stage | should be -1 for the first call, will be increased by ReadSaveVariables to memorize the position in the variable structure |
Definition at line 4323 of file store.c.
References InDeXeNtRy::nfunctions, InDeXeNtRy::nindices, InDeXeNtRy::nsymbols, InDeXeNtRy::nvectors, and FuNcTiOn::spec.
UBYTE* ReadSaveTerm32 | ( | UBYTE * | bin, |
UBYTE * | binend, | ||
UBYTE ** | bout, | ||
UBYTE * | boutend, | ||
UBYTE * | top, | ||
int | terminbuf | ||
) |
Reads a single term from the given buffer at bin and write the translated term back to this buffer at bout.
ReadSaveTerm32() is currently the only instantiation of a ReadSaveTerm-function. It only deals with data that already has the correct endianness and that is resized to 32bit words but without being renumbered or translated in any other way. It uses the compress buffer AR.CompressBuffer.
The function is reentrant in order to cope with nested function arguments. It is called by ReadSaveExpression() and itself.
The return value indicates the position in the input buffer up to which the data has already been successfully processed. The parameter bout returns the corresponding position in the output buffer.
bin | start of the input buffer |
binend | end of the input buffer |
bout | as input points to the beginning of the output buffer, as output points behind the already translated data in the output buffer |
boutend | end of already decompressed data in output buffer |
top | end of output buffer |
terminbuf | flag whether decompressed data is already in the output buffer. used in recursive calls |
Definition at line 4683 of file store.c.
References ReadSaveTerm32().
Referenced by ReadSaveExpression(), and ReadSaveTerm32().
WORD ReadSaveExpression | ( | UBYTE * | buffer, |
UBYTE * | top, | ||
LONG * | size, | ||
LONG * | outsize | ||
) |
Reads an expression from the open file specified by AO.SaveData.Handle. The endianness flip and a resizing without renumbering is done in this function. Thereafter the buffer consists of chunks with a uniform maximal word size (32bit at the moment). The actual renumbering is then done by calling the function ReadSaveTerm32(). The result is returned in buffer.
If the translation at some point doesn't fit into the buffer anymore, the function returns and must be called again. In any case size returns the number of successfully read bytes, outsize returns the number of successfully written bytes, and the file will be positioned at the next byte after the successfully read data.
It is called by PutInStore().
buffer | output buffer, holds the (translated) expression |
top | end of buffer |
size | number of read bytes |
outsize | number of written bytes |
Definition at line 5092 of file store.c.
References ReadSaveTerm32().