OSI/AS Programming Manual

Example 1: Session Layer
Sample Programs
056783 Tandem Computers Incorporated E–9
-- Wait for an event and make certain it is the one that
-- is expected.
--
------------------------------------------------------------
PROC wait_for_event( cepi, expected_event_code );
INT cepi; -- i : cepi to wait on
INT expected_event_code; -- i : expected event
BEGIN
LITERAL time_limit = -1D; -- wait indefinitely
status := APS_EVENT_RECEIVE_( cepi
, time_limit
, ! tag !
);
IF ( status <> ZAPS^VAL^STATUS^EVENT ) THEN
CALL display_aps_status( cepi, error_event_proc );
--
-- Find out which event was received.
--
error := APS_STATUS_( cepi
, event_code
, device_name
, error_code
, error_subcode
, service_id
, diagnostic_buffer
, original_error_info
);
IF ( error <> ZAPS^ERR^OK ) THEN
CALL display_aps_error( error_status_proc );
--
-- Check for expected event.
-- A real application would take appropriate action.
--
IF ( event_code <> expected_event_code ) THEN
CALL DEBUG;
END; -- proc wait_for_event
? PAGE
------------------------------------------------------------
--
-- Read the startup message, open the output file, and
-- initialize the API.
--
------------------------------------------------------------
PROC initialize_appl;
BEGIN
INT receive;
INT .receive_name[0:11] :=
[ "$RECEIVE", 8*[" "] ];
STRUCT .startup;
BEGIN