core34Example_main.c
                                            
                                            Basic tutorial in C where a connection to a database using different Uniform Resource Identifiers (URI) are used. This example needs a compiled schema, core34Example.sdl.
#include "rdm.h"
                                                    
                                                    #include "rdmapi.h"
                                                    
                                                    #include "rdmtfsapi.h"
                                                    
                                                    #include "core34Example_cat.h"
                                                    
                                                    #include "rdmstartupapi.h"
                                                    
                                                    #include <stdio.h>
                                                    
                                                    #include <stdlib.h>
                                                    
                                                    int32_t main_uriTutorial(int32_t argc, const char* const* argv)
                                                    {
                                                    RDM_RETCODE rc;
                                                    RDM_TFS tfs = NULL;
                                                    RDM_DB db = NULL;
                                                    RDM_UNREF(argc);
                                                    RDM_UNREF(argv);
                                                    /* Allocate a TFS Handle */
                                                    
                                                        rc = rdm_rdmAllocTFS(&tfs);
                                                    
                                                        {
                                                            rc = rdm_tfsInitialize(tfs);
                                                    /* Allocate a database hande */
                                                    
                                                    if (rc == sOKAY)
                                                            {
                                                                rc = rdm_tfsAllocDatabase(tfs, &db);
                                                    if (rc == sOKAY)
                                                                {
                                                                    rc = rdm_dbSetCatalog(db, core34Example_cat);
                                                                }
                                                            }
                                                    /* Test opening with no URI */
                                                    
                                                    if (rc == sOKAY)
                                                            {
                                                    /* Open the database using no URI (all default values) */
                                                    
                                                    
                                                    if (rc == sOKAY)
                                                                {
                                                                    printf("Connected to the remote TFS using all defaults "
                                                    "(core34Example)\n");
                                                    /* Remove all of the rows from the database, in exclusive
                                                    
                                                                    mode we still need to use a transaction */
                                                    
                                                    
                                                                    rc = rdm_dbDeleteAllRowsFromDatabase(db);
                                                                    rc = rdm_dbEnd(db);
                                                    /* Close the database */
                                                    
                                                    rdm_dbClose(db);
                                                                }
                                                    
                                                                {
                                                                    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/core34Example",
                                                    
                                                    if (rc == sOKAY)
                                                                {
                                                                    printf("Connected to the remote TFS using tcp/ip "
                                                    "(tfs-tcp://localhost:21553/core34Example)\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_dbDeleteAllRowsFromDatabase(db);
                                                                    rc = rdm_dbEnd(db);
                                                    /* Close the database */
                                                    
                                                    rdm_dbClose(db);
                                                                }
                                                    
                                                                {
                                                                    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/core34Example", RDM_OPEN_EXCLUSIVE);
                                                    if (rc == sOKAY)
                                                                {
                                                                    printf("Connected to the remote TFS using shared memory "
                                                    "(tfs-shm://21553/core34Example)\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_dbDeleteAllRowsFromDatabase(db);
                                                                    rc = rdm_dbEnd(db);
                                                    /* Close the database */
                                                    
                                                    rdm_dbClose(db);
                                                                }
                                                    
                                                                {
                                                                    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 */
                                                    
                                                    
                                                    if (rc == sOKAY)
                                                                {
                                                                    printf("Connected to the remote TFS using default transport "
                                                    "(tfs:///core34Example)\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_dbDeleteAllRowsFromDatabase(db);
                                                                    rc = rdm_dbEnd(db);
                                                    /* Close the database */
                                                    
                                                    rdm_dbClose(db);
                                                                }
                                                    
                                                                {
                                                                    printf(
                                                    "Could not connect to the remote TFS, make sure one has "
                                                    
                                                    "been started.\n");
                                                                }
                                                            }
                                                    rdm_dbFree(db);
                                                    rdm_tfsFree(tfs);
                                                        }
                                                    if (rc != sOKAY)
                                                        {
                                                            printf(
                                                    "There was an error in this Tutorial (%s - %s)\n",
                                                    
                                                    return EXIT_FAILURE;
                                                        }
                                                    return EXIT_SUCCESS;
                                                    }
                                                    RDM_STARTUP_EXAMPLE(uriTutorial)
                                                const char * rdm_retcodeGetName(RDM_RETCODE retcode)
                                            Get the mnemonic name for an error or status code.
                                        Header for the native RDM Runtime API.
                                        Header for the RDM Core API.
                                        RDM_RETCODE rdm_dbDeleteAllRowsFromDatabase(RDM_DB db)
                                            Remove all rows from a database.
                                        RDM_RETCODE rdm_dbClose(RDM_DB db)
                                            Close the database associated with a database handle.
                                        RDM_RETCODE rdm_dbSetCatalog(RDM_DB db, const char *catalog)
                                            Associate a catalog with an allocated database.
                                        RDM_RETCODE rdm_dbOpen(RDM_DB db, const char *dbNameSpec, RDM_OPEN_MODE mode)
                                            Open an existing RDM database using the specified database handle.
                                        RDM_RETCODE rdm_tfsAllocDatabase(RDM_TFS tfs, RDM_DB *pDb)
                                            Allocate memory for a new RDM db.
                                        Header for the Transactional File Server (TFS) API.
                                        const char * rdm_retcodeGetDescription(RDM_RETCODE retcode)
                                            Invoke RDM error handler.
                                        RDM_RETCODE rdm_dbStartUpdate(RDM_DB db, const RDM_TABLE_ID *writeTableIds, uint32_t numWriteTableIds, const RDM_TABLE_ID *readTableIds, uint32_t numReadTableIds, RDM_TRANS *pTrans)
                                            Get write locks.
                                        Internal RDM Startup API used by startup macros.