#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
static char *btrieveFileName = (char *)"squaresAndSquareRoots.btr";
#define MIN_X 0
#define MAX_X 255
#pragma pack(1)
typedef struct {
uint8_t x;
uint16_t xSquared;
double xSquareRoot;
} chunk_t;
#pragma pack()
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
chunk_t chunk;
int i;
chunk.x = 0;
chunk.xSquared = 0;
chunk.xSquareRoot = 0;
{
goto leave;
}
for (i = MIN_X; i <= MAX_X; i++)
{
chunk.x = (uint8_t)i;
chunk.xSquared = (uint16_t)(i * i);
chunk.xSquareRoot = sqrt((double)i);
if (i == MIN_X)
{
{
goto leave;
}
}
else
{
{
goto leave;
}
}
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
chunk_t chunk;
int i;
{
goto leave;
}
for (i = MIN_X; i <= MAX_X; i++)
{
chunk.x = 0;
chunk.xSquared = 0;
chunk.xSquareRoot = 0;
if (i == MIN_X)
{
if (btrieveFile->
RecordRetrieveChunk(0,
sizeof(chunk), (
char *)&chunk,
sizeof(chunk)) !=
sizeof(chunk))
{
goto leave;
}
}
else
{
if (btrieveFile->
RecordRetrieveChunk(
sizeof(chunk), (
char *)&chunk,
sizeof(chunk)) !=
sizeof(chunk))
{
goto leave;
}
}
if (chunk.x == *key)
{
break;
}
}
printf("chunk: (%u, %u, %f)\n", chunk.x, chunk.xSquared, chunk.xSquareRoot);
leave:
return status;
}
int
main(int argc, char *argv[])
{
static const char *usage = "Usage: %s uint8_value\n";
uint8_t key;
uint64_t integerValue;
if (argc != 2)
{
printf(usage, argv[0]);
goto leave;
}
integerValue = atoi(argv[1]);
if ((integerValue < MIN_X) || (integerValue > MAX_X))
{
printf(usage, argv[0]);
goto leave;
}
key = (uint8_t)integerValue;
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}
The Btrieve client class.
Definition btrieveCpp.h:1388
Btrieve::StatusCode FileCreate(BtrieveFileAttributes *btrieveFileAttributes, const char *fileName, Btrieve::CreateMode createMode, Btrieve::LocationMode locationMode=Btrieve::LOCATION_MODE_NO_PREFERENCE)
Create a file.
Btrieve::StatusCode FileClose(BtrieveFile *btrieveFile)
Close a file.
Btrieve::StatusCode FileDelete(const char *fileName)
Delete a file.
Btrieve::StatusCode FileOpen(BtrieveFile *btrieveFile, const char *fileName, const char *ownerName, Btrieve::OpenMode openMode, Btrieve::LocationMode locationMode=Btrieve::LOCATION_MODE_NO_PREFERENCE)
Open a file.
The Btrieve file attributes class.
Definition btrieveCpp.h:2448
Btrieve::StatusCode SetVariableLengthRecordsMode(Btrieve::VariableLengthRecordsMode variableLengthRecordsMode)
Set the variable length records mode.
Btrieve::StatusCode SetFixedRecordLength(int fixedRecordLength)
Set the fixed record length.
The Btrieve file class.
Definition btrieveCpp.h:1729
Btrieve::StatusCode RecordCreate(char *record, int recordLength)
Create a record.
int RecordRetrieveFirst(Btrieve::Index index, char *record, int recordSize, Btrieve::LockMode lockMode=Btrieve::LOCK_MODE_NONE)
Retrieve the first record.
Btrieve::StatusCode GetLastStatusCode()
Get the last status code.
int RecordRetrieveChunk(int offset, int length, char *chunk, int chunkSize, Btrieve::LockMode lockMode=Btrieve::LOCK_MODE_NONE)
Retrieve a record chunk.
Btrieve::StatusCode RecordUpdateChunk(int offset, const char *chunk, int chunkLength)
Update a record chunk.
@ VARIABLE_LENGTH_RECORDS_MODE_YES
Yes.
Definition btrieveCpp.h:1243
static const char * StatusCodeToString(StatusCode statusCode)
Return a status code as a string.
@ CREATE_MODE_OVERWRITE
Overwrite.
Definition btrieveCpp.h:72
StatusCode
The Btrieve status codes.
Definition btrieveCpp.h:713
@ STATUS_CODE_UNKNOWN
-7 - Unknown.
Definition btrieveCpp.h:1194
@ STATUS_CODE_NO_ERROR
0 - No error.
Definition btrieveCpp.h:715
@ OPEN_MODE_NORMAL
Normal.
Definition btrieveCpp.h:606
@ INDEX_NONE
None.
Definition btrieveCpp.h:553