#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()
typedef uint8_t _key_t;
{
{
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[])
{
_key_t key;
uint64_t integerValue;
if (argc != 2)
{
printf("Usage: %s uint8_value\n", argv[0]);
goto leave;
}
integerValue = atoi(argv[1]);
if ((integerValue < MIN_X) || (integerValue > MAX_X))
{
printf("Usage: %s uint8_value\n", argv[0]);
goto leave;
}
key = (_key_t)integerValue;
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}