This is an example of file creation, load, access, and deletion.
#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;
} record_t;
#pragma pack()
typedef uint8_t _key_t;
static int
{
record_t record;
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
if (btrieveFileAttributes != NULL)
{
btrieveFileAttributes = NULL;
}
return status;
}
static int
{
{
goto leave;
}
return status;
leave:
if (btrieveFile != NULL)
{
*btrieveFile = NULL;
}
return status;
}
static int
{
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(i);
{
goto leave;
}
}
leave:
return status;
}
static int
{
{
goto leave;
}
btrieveFile = NULL;
leave:
return status;
}
static int
{
{
goto leave;
}
leave:
return status;
}
static int
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
if (btrieveIndexAttributes != NULL)
{
btrieveIndexAttributes = NULL;
}
if (btrieveKeySegment != NULL)
{
btrieveKeySegment = NULL;
}
return status;
}
int
main(int argc, char *argv[])
{
_key_t key;
record_t record;
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;
}
printf("record: (%u, %u, %f)\n", record.x, record.xSquared, record.xSquareRoot);
{
goto leave;
}
btrieveFile = NULL;
{
goto leave;
}
leave:
if (btrieveFile != NULL)
{
btrieveFile = NULL;
}
if (btrieveClient != NULL)
{
btrieveClient = NULL;
}
{
return 0;
}
return 1;
}