#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
#define NUMBER_OF_RECORDS (MAX_X - MIN_X + 1)
#pragma pack(1)
typedef struct {
uint8_t x;
uint16_t xSquared;
double xSquareRoot;
} record_t;
#pragma pack()
typedef uint8_t _key_t;
{
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
int i;
record_t record;
for (i = MIN_X; i <= MAX_X; i++)
{
record.x = (uint8_t)i;
record.xSquared = (uint16_t)(i * i);
record.xSquareRoot = sqrt((double)i);
{
goto leave;
}
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
long long cursorPosition;
int numerator;
int percentage;
record_t record;
uint8_t key;
{
goto leave;
}
printf("First: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByPercentage: 0%% record: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByFraction: %d/%d record: (%u, %u, %f)\n", 0, NUMBER_OF_RECORDS, record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByPercentage: 50%% record: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByFraction: %d/%d record: (%u, %u, %f)\n", NUMBER_OF_RECORDS / 2, NUMBER_OF_RECORDS, record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
{
goto leave;
}
printf("Last: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByPercentage: 100.00%% record: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByFraction: %d/%d record: (%u, %u, %f)\n", NUMBER_OF_RECORDS, NUMBER_OF_RECORDS, record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
printf("ByCursorPosition: record: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
key = (MAX_X - MIN_X) / 2;
{
goto leave;
}
printf("GetPercentage using Index: %d%% key: %d\n", percentage / 100, key);
if ((percentage = btrieveFile->
GetPercentage(cursorPosition)) == -1)
{
goto leave;
}
printf("GetPercentage using Cursor Position: %d%%\n", percentage / 100);
{
goto leave;
}
printf("GetNumerator using Index: %d/%d key: %d\n", numerator, NUMBER_OF_RECORDS, key);
if ((numerator = btrieveFile->
GetNumerator(cursorPosition, NUMBER_OF_RECORDS)) == -1)
{
goto leave;
}
printf("GetNumerator using Cursor Position: %d/%d\n", numerator, NUMBER_OF_RECORDS);
leave:
return status;
}
int
main(int argc, char *argv[])
{
if (argc != 1)
{
printf("Usage: %s\n", argv[0]);
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}