Products Support Documentation Download
Data Structures | Macros | Functions
Core03.c File Reference

Source code for the RDM core03 example. More...

#include <stdio.h>
#include <string.h>
#include "rdm.h"
#include "core03_db_structs.h"
#include "core03_db_cat.h"

Data Structures

struct  CORE03_CTX
 

Macros

#define PRINTERROR(rc)
 Standard error print format for popcorn examples. More...
 

Functions

RDM_RETCODE open_and_initialize (CORE03_CTX *ctx)
 Initialize the RDM runtime library for use in the core03 example. More...
 
void cleanup (CORE03_CTX *ctx)
 Cleanup the RDM runtime library. More...
 
RDM_RETCODE insertArtists (CORE03_CTX *ctx, const char *artistName, const char **albumList, size_t listSize)
 Insert an artist and all of the albums associated with the artist. More...
 
RDM_RETCODE readAllAlbums (CORE03_CTX *ctx)
 Reads and displays all rows in the core03 database. More...
 
int main (void)
 Main function for core03 example. More...
 

Detailed Description

Source code for the RDM core03 example.

Macro Definition Documentation

◆ PRINTERROR

#define PRINTERROR (   rc)
Value:
if (rc != sOKAY) \
fprintf(stderr, "%s:%d:0: error: %d (%s): %s\n", __FILE__, __LINE__, rc, \
rdm_retcodeGetName(rc), rdm_retcodeGetDescription(rc));

Standard error print format for popcorn examples.

This macro demonstrates the usage of the rdm_retcodeGetName() and rdm_retcodeGetDescription() functions

Function Documentation

◆ cleanup()

void cleanup ( CORE03_CTX ctx)

Cleanup the RDM runtime library.

This functions closes all open databases and cleans up the RDM db handle used in the core03 example. It also terminates the TFS used in the example.

Returns
Returns a RDM return code (sOKAY if successful)
Parameters
[in]ctxPointer to the application context

◆ insertArtists()

RDM_RETCODE insertArtists ( CORE03_CTX ctx,
const char *  artistName,
const char **  albumList,
size_t  listSize 
)

Insert an artist and all of the albums associated with the artist.

This function adds one more row to the ARTIST table in the core03 database and one to many rows to the ALBUM table associated with the given artist.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]ctxPointer to the application context
[in]artistNameArtist name to insert
[in]albumListList of album names for the artist
[in]listSizeNumber of album names in the list

◆ main()

int main ( void  )

Main function for core03 example.

The function initializes the RDM environment and runs the create, read operations.

Returns
Returns the RDM_RETCODE on exit.

◆ open_and_initialize()

RDM_RETCODE open_and_initialize ( CORE03_CTX ctx)

Initialize the RDM runtime library for use in the core03 example.

This function initializes the RDM Transactional File Server (TFS) to use the EMBEDED TFS implementation. It also allocates a database handle and opens the "core03" database in exclusive mode. Exclusve mode does not require database locks or transactions.

Returns
Returns RDM_RETCODE status code (sOKAY if successful)
Parameters
[in,out]ctxPointer to the application context

◆ readAllAlbums()

RDM_RETCODE readAllAlbums ( CORE03_CTX ctx)

Reads and displays all rows in the core03 database.

This function reads and displays each row from the ARTIST table in the core03 database and the ALBUMS associated with the artist.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]ctxPointer to the application context