Products Support Documentation Download
Macros | Functions
Core04.c File Reference

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

#include <stdio.h>
#include <string.h>
#include "rdm.h"
#include "core04_db_structs.h"
#include "core04_db_cat.h"

Macros

#define print_error(rc)   print_errorEx (rc, __FILE__, __LINE__)
 Standard error print macro.
 
#define RLEN(x)   (sizeof(x)/sizeof(x[0]))
 Macro to determine number of elements in an array of ptrs.
 

Functions

void print_errorEx (RDM_RETCODE rc, const char *file, int line)
 Standard error print format for popcorn examples. More...
 
RDM_RETCODE openEmptyDatabase (RDM_TFS *pTFS, RDM_DB *pDB)
 Initialize the RDM runtime library for use in the core04 example. More...
 
void cleanup (RDM_TFS hTFS, RDM_DB hDB)
 Cleanup the RDM runtime library. More...
 
RDM_RETCODE insertArtist (RDM_DB hDB, int artistID, const char *artistName, RDM_CURSOR *artistCursor)
 Insert an artis. More...
 
RDM_RETCODE insertAlbum (RDM_DB hDB, RDM_CURSOR artistCursor, int albumID, const char *albumTitle, const char **trackList, size_t listSize)
 Insert an artist and all of the albums associated with the artist. More...
 
RDM_RETCODE readAllAlbums (RDM_DB hDB)
 Read all the artists and the associated albums and tracks. More...
 
int main (void)
 Main function for core04 example. More...
 

Detailed Description

Source code for the RDM core04 example.

Function Documentation

◆ cleanup()

void cleanup ( RDM_TFS  hTFS,
RDM_DB  hDB 
)

Cleanup the RDM runtime library.

This functions closes all open databases and cleans up the RDM runtime task used in the core04 example.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[out]hTFSPointer to the TFS handle to be terminated
[out]hDBPointer to the DB handle to be terminated

◆ insertAlbum()

RDM_RETCODE insertAlbum ( RDM_DB  hDB,
RDM_CURSOR  artistCursor,
int  albumID,
const char *  albumTitle,
const char **  trackList,
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]hDBDatabase handle to open database
[in]artistCursorCursor of the artist
[in]albumIDUnique albumID number
[in]albumTitleArtist name to insert
[in]trackListList of album names for the artist
[in]listSizeNumber of album names in the list

◆ insertArtist()

RDM_RETCODE insertArtist ( RDM_DB  hDB,
int  artistID,
const char *  artistName,
RDM_CURSOR *  artistCursor 
)

Insert an artis.

This function adds one more row to the ARTIST table in the core03 database.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]hDBDatabase handle to open database
[in]artistIDUnique ID for artist
[in]artistNameArtist name to insert
[out]artistCursorCursor to the the row we just inserted

◆ main()

int main ( void  )

Main function for core04 example.

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

Returns
Returns the RDM_RETCODE on exit.

◆ openEmptyDatabase()

RDM_RETCODE openEmptyDatabase ( RDM_TFS *  pTFS,
RDM_DB *  pDB 
)

Initialize the RDM runtime library for use in the core04 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 "core04" database in exclusive mode. Exclusve mode does not require database locks or transactions.

Returns
Returns RDM_RETCODE status code (sOKAY if successful)
Parameters
[out]pTFSPointer to the TFS handle
[out]pDBPointer to the RDM database handle

◆ print_errorEx()

void print_errorEx ( RDM_RETCODE  rc,
const char *  file,
int  line 
)

Standard error print format for popcorn examples.

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

Parameters
[in]rcRDM_RETCODE to analyze
[in]fileSourcec filename
[in]lineLineno in source file

◆ readAllAlbums()

RDM_RETCODE readAllAlbums ( RDM_DB  hDB)

Read all the artists and the associated albums and tracks.

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

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]hDBDatabase handle to open database