#include "one_to_many_structs.h"
#include "one_to_many_cat.h"
#include <stdio.h>
#include <stdlib.h>
static const ONE ones[] = {{"John"}, {"James"}, {"Duncan"}};
static const MANY johns[] = {
static const MANY no_one[] = {
static const MANY duncans[] = {
int32_t main_one_to_manyTutorial (int32_t argc, const char *const *argv)
{
{
{
{
}
{
{
{
printf ("Can't open the one_to_many database.");
}
}
{
}
{
{
}
else
{
}
}
{
db, table_one,
RDM_LEN (table_one), NULL, 0, NULL);
}
{
uint32_t iO;
{
db, TABLE_ONE, &ones[iO], sizeof (ones[iO]), NULL);
}
{
}
else
{
}
}
{
db, table_many,
RDM_LEN (table_many), table_one,
}
{
uint32_t iM;
{
db, TABLE_MANY, &johns[iM], sizeof (johns[iM]),
NULL);
}
{
}
else
{
}
}
{
db, table_many,
RDM_LEN (table_many), NULL, 0, NULL);
}
{
uint32_t iM;
{
db, TABLE_MANY, &no_one[iM], sizeof (no_one[iM]),
NULL);
}
{
}
else
{
}
}
{
db, table_many,
RDM_LEN (table_many), table_one,
}
{
uint32_t iM;
db, KEY_ONE_MYCHAR, &ones[2], sizeof (ones[2]),
&cursorOne);
{
db, TABLE_MANY, &duncans[iM], sizeof (duncans[iM]),
&cursorMany);
{
cursorMany, REF_MANY_MYCHAR_ONE, cursorOne);
}
}
{
}
else
{
}
{
db, tables,
RDM_LEN (tables), NULL);
}
{
{
printf ("Displaying all of the rows in the many "
"table\n");
printf ("many.mychar_one many.mychar\n");
printf (
"____________________ ____________________\n");
}
{
MANY sMany;
cursor, &sMany, sizeof (sMany), NULL);
{
printf (
"%-20s %-20s\n",
sMany._mychar_one_has_value ==
? "**NULL**"
: sMany.mychar_one,
? "**NULL**"
: sMany.mychar);
}
}
{
}
}
{
db, tables,
RDM_LEN (tables), NULL);
}
{
{
printf ("\n\nDisplaying all of the rows in the one "
"table (and their associated many rows)\n");
}
{
ONE sOne;
cursorOne, &sOne, sizeof (sOne), NULL);
{
printf ("%s\n", sOne.mychar);
cursorOne, REF_MANY_MYCHAR_ONE,
&cursorMany);
}
{
}
{
MANY sMany;
cursorMany, COL_MANY_MYCHAR, sMany.mychar,
sizeof (sMany.mychar), NULL);
{
printf (" %s\n", sMany.mychar);
}
{
printf (" **NULL**\n");
}
{
}
}
{
}
{
}
}
{
}
}
}
}
}
}
{
printf (
"There was an error in this Tutorial (%s - %s)\n",
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}