FTAM/9000 Programmer's Guide

Chapter 4 183
Using Support Functions
Responding to Asynchronous Calls
#include %<stdio.h>
#include %</opt/ftam/include/map.h>
#define BITS_PER_INT 32
#define SET_MASK(f,fds) (fds)[((f)/BITS_PER_INT)] |=
(1%<%<((f)%BITS_PER_INT))
#define TST_MASK(f,fds) ((fds)[((f)/BITS_PER_INT)] &
(1%<%<((f)%BITS_PER_INT)))
main()
{
Bool done;
Local_event_name map_event;
Return_code map_rc;
Api_rc map_result;
char *ret_str;
char *ven_str;
int nfds;
unsigned readfds[2]; /* handles upto 64 fds */
/* Read and process the first command. No FTAM operations are
** outstanding at this time, so do not wait for any to complete.
*/
done = read_and_process_command();
/* Wait indefinitely for MAP and non-MAP (i.e., stdin readable) events
** to occur. If an EME032_IPC_ERROR occurs, the MAP operation
** identified by map_event is treated as having completed with the IPC
** error. Non-MAP events can also return in this case, so they
** are processed as well.
**
** If any other error occurs, there is a programming error when calling
** em_hp_select(); in this case, use em_gperror() and em_fdmemory() to
** translate the error into printable character strings, then
** abort processing so you can fix the coding error.
**
** Continue processing both FTAM and non-FTAM events until a “Quit”
command
** is entered as the non-FTAM event.
*/