FTAM/9000 Programmer's Guide
184 Chapter 4
Using Support Functions
Responding to Asynchronous Calls
while ( ! done )
{
readfds[0] = 0;
readfds[1] = 0;
SET_MASK(stdin, readfds);
nfds = stdin + 1;
map_rc = em_hp_select(FOREVER, & map_event, & nfds, readfds, NULL,
NULL,
& map_result);
if ((map_rc == SUCCESS) || (map_rc == EME032_IPC_ERROR))
{
if ((map_event != 0))
map_operation_completed(map_event, map_rc);
if (TST_MASK(stdin, readfds))
done = read_and_process_command();
}
else
{
ret_str = NULL;
ven_str = NULL;
map_rc = em_gperror(& map_result, & ret_str, & ven_str, &
map_result);
if (map_rc == SUCCESS)
fprintf(stderr, ā%s%sā, ret_str, ven_str);
em_fdmemory(ret_str, & map_result);
em_fdmemory(ven_str, & map_result);
exit(1);
}
} /* while */
/* You finished entering commands, but all of the MAP operations may not
** be complete. Since only MAP events are left, em_wait() is used instead
** of em_hp_select(). An EME002_EXP_EMPTY result indicates all MAP
** operations have completed.
*/
done = FALSE;
do {
map_rc = em_wait(FOREVER, & map_event, & map_result);
if ((map_rc == SUCCESS) || (map_rc == EME032_IPC_ERROR))
map_operation_completed(map_event, map_rc);
else if (map_rc == EME002_EXP_EMPTY)
done = TRUE;
else
{
done = TRUE;
ret_str = NULL;
ven_str = NULL;
map_rc = em_gperror(& map_result, & ret_str, & ven_str, & map_result);
if (map_rc == SUCCESS)
fprintf(stderr, ā%s%sā, ret_str, ven_str);
em_fdmemory(ret_str, & map_result);
em_fdmemory(ven_str, & map_result);
exit(2);
}
} while ( ! done );
exit(0);
} /* main */