cursor/registerVoters.c
static
RDM_RETCODE
registerVoters (
RDM_CURSOR
adults,
RDM_DB
db)
{
RDM_RETCODE
rc;
RDM_CURSOR
voters = NULL;
RDM_CURSOR
system = NULL;
uint64_t count;
rc =
rdm_dbGetRows
(db, TABLE_SYSTEM_TBL, &system);
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorMoveToFirst
(system);
}
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorGetMemberCount
(system, REF_VOTERS, &count);
}
if
(rc ==
sOKAY
)
{
printf (
"Registering "
RDM_INT64_FMT_A
" voters"
, count);
rc =
rdm_cursorGetMemberRows
(system, REF_VOTERS, &voters);
}
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorMoveToFirst
(adults);
}
while
(rc ==
sOKAY
)
{
rc =
rdm_cursorAddMember
(voters, adults);
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorMoveToNext
(adults);
}
}
if
(rc ==
sENDOFCURSOR
)
rc =
sOKAY
;
/* The King can not vote, lets unlink him */
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorMoveToKey
(voters, KEY_ADULT_ADULT_NAME,
"The King"
, 0);
}
if
(rc ==
sOKAY
)
{
rc =
rdm_cursorRemoveMember
(voters);
}
rdm_cursorFree
(voters);
rdm_cursorFree
(system);
return
rc;
}