c-core/34_core/core34Example_main.c
#include "rdm.h"
#include "rdmapi.h"
#include "rdmtfsapi.h"
#include "uri_Tutorial_cat.h"
#include "rdmstartupapi.h"
#include <stdio.h>
#include <stdlib.h>
int32_t main_uriTutorial(int32_t argc, const char* const* argv)
{
RDM_TFS tfs = NULL;
RDM_DB db = NULL;
RDM_UNREF(argc);
RDM_UNREF(argv);
/* Allocate a TFS Handle */
rc = rdm_rdmAllocTFS(&tfs);
if (rc == sOKAY)
{
rc = rdm_tfsInitialize(tfs);
/* Allocate a database hande */
if (rc == sOKAY)
{
rc = rdm_tfsAllocDatabase(tfs, &db);
if (rc == sOKAY)
{
rc = rdm_dbSetCatalog(db, uri_Tutorial_cat);
}
}
/* Test opening with no URI */
if (rc == sOKAY)
{
/* Open the database using no URI (all default values) */
rc = rdm_dbOpen(db, "uri_Tutorial", RDM_OPEN_EXCLUSIVE);
if (rc == sOKAY)
{
printf("Connected to the remote TFS using all defaults "
"(uri_Tutorial)\n");
/* Remove all of the rows from the database, in exclusive
mode we still need to use a transaction */
rc = rdm_dbStartUpdate(db, RDM_LOCK_ALL, 0, NULL, 0, NULL);
rc = rdm_dbEnd(db);
/* Close the database */
}
else if (rc == eTX_CONNECT)
{
printf(
"Could not connect to the remote TFS, make sure one has "
"been started.\n");
}
}
/* Test opening with a URI that specifies the IPv4 TCP/IP transport*/
if (rc == sOKAY)
{
/* Open the database using a TCP/IP URI specification */
rc = rdm_dbOpen(
db, "tfs-tcp://localhost:21553/uri_Tutorial",
if (rc == sOKAY)
{
printf("Connected to the remote TFS using tcp/ip "
"(tfs-tcp://localhost:21553/uri_Tutorial)\n");
/* Remove all of the rows from the database, in exclusive
mode we still need to use a transaction */
rc = rdm_dbStartUpdate(db, RDM_LOCK_ALL, 0, NULL, 0, NULL);
rc = rdm_dbEnd(db);
/* Close the database */
}
else if (rc == eTX_CONNECT)
{
printf(
"Could not connect to the remote TFS, make sure one has "
"been started.\n");
}
}
/* Test opening with a URI that specifies the Shared Memory transport*/
if (rc == sOKAY)
{
/* Open the database using a Shared Memory specification */
rc = rdm_dbOpen(
db, "tfs-shm://21553/uri_Tutorial", RDM_OPEN_EXCLUSIVE);
if (rc == sOKAY)
{
printf("Connected to the remote TFS using shared memory "
"(tfs-shm://21553/uri_Tutorial)\n");
/* Remove all of the rows from the database, in exclusive
mode we still need to use a transaction */
rc = rdm_dbStartUpdate(db, RDM_LOCK_ALL, 0, NULL, 0, NULL);
rc = rdm_dbEnd(db);
/* Close the database */
}
else if (rc == eTX_CONNECT)
{
printf(
"Could not connect to the remote TFS, make sure one has "
"been started.\n");
}
}
/* Test opening with a URI that specifies the default transport*/
if (rc == sOKAY)
{
/* Open the database using the default specification */
rc = rdm_dbOpen(db, "tfs:///uri_Tutorial", RDM_OPEN_EXCLUSIVE);
if (rc == sOKAY)
{
printf("Connected to the remote TFS using default transport "
"(tfs:///uri_Tutorial)\n");
/* Remove all of the rows from the database, in exclusive
mode we still need to use a transaction */
rc = rdm_dbStartUpdate(db, RDM_LOCK_ALL, 0, NULL, 0, NULL);
rc = rdm_dbEnd(db);
/* Close the database */
}
else if (rc == eTX_CONNECT)
{
printf(
"Could not connect to the remote TFS, make sure one has "
"been started.\n");
}
}
}
if (rc != sOKAY)
{
printf(
"There was an error in this Tutorial (%s - %s)\n",
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
RDM_STARTUP_EXAMPLE(uriTutorial)