
*copyc OSD$DEFAULT_PRAGMATS
?? NEWTITLE := '170 NOS/VE REMOTE HOST' ??
MODULE rhmmli;

?? NEWTITLE := 'GLOBAL TYPE DECLARATIONS' ??
?? SET (LIST := OFF) ??
?? EJECT ??
*copyc RHT$FUNCTION_STATUS
*copyc OST$STATUS

?? TITLE := 'EXTERNAL PROCEDURES REFERENCED BY THIS MODULE' ??
?? SET (LIST := OFF) ??
?? EJECT ??
*copyc RHP$SIGN_ON_AND_OFF_OS
*copyc RHP$ADD_SENDER_OS
*copyc RHP$LOG_STATUS
*copyc RHP$WAIT

?? TITLE := 'MLI_LINK' ??
?? SET (LIST := ON) ??
?? EJECT ??

{ MLI_LINK
{
{     The purpose of this procedure is to provide all linkage
{ facilities to the MLI for all IRHF applications.  This
{ procedure allows an application to sign on and sign off
{ the MLI.  As part of the sign on facilities, the partner
{ sending application is also identified to the MLI.
{
{     MLI_LINK (DIRECTION,APPLICATION_NAMES)
{
{ DIRECTION: (input) This parameter specifies the linkage
{     direction; i.e., sign_on or sign_off.
{
{ APPLICATION_NAMES: (input) This parameter contains the sending and
{     receiving application names required for MLI communications.
{

  PROCEDURE [XDCL] mli_link (direction: rht$mli_link_direction;
    VAR application_names: rht$mli_application_names);

    VAR
      status: ost$status,
      waiting_for_dual_state: boolean,
      unique: mlt$application_name, { see note below }
      abnormal_mli_status_message: string (37),
      string_length: 1 .. 37;

    waiting_for_dual_state := FALSE;
    IF direction = on THEN
      REPEAT
{
{ WARNING:
{    This sign_on request assumes that the unique application name
{    generation feature of mli is not used.
{
        rhp$sign_on_os (application_names.application.application_name,
              0, unique, status);
        IF NOT status.normal THEN
          CASE status.condition OF
          = mlc$nosve_not_up =
            IF NOT waiting_for_dual_state THEN
              log_status (dayfile_log_and_display, 'waiting_for_nos/ve');
              waiting_for_dual_state := TRUE;
            IFEND;
          = mlc$ant_full, mlc$busy_interlock, mlc$pool_buffer_not_avail =
          ELSE
            abnormal_mli_status_message (1, 31) :=
              'sign on mli abnormal condition=';
            STRINGREP (abnormal_mli_status_message (32, 3), string_length,
                  status.condition);
            log_status (dayfile_log, abnormal_mli_status_message
                  (1, 31 + string_length));
          CASEND;
          wait (1000);
        IFEND;
      UNTIL status.normal;
      REPEAT
        rhp$add_sender_os (application_names.application.application_name,
              application_names.destination.application_name, status);
        IF NOT status.normal THEN
          IF status.condition <> mlc$busy_interlock THEN
            abnormal_mli_status_message (1, 34) :=
              'add sender mli abnormal condition=';
            STRINGREP (abnormal_mli_status_message (35, 3), string_length,
                  status.condition);
            log_status (dayfile_log, abnormal_mli_status_message
                  (1, 34 + string_length));
          IFEND;
          wait (1000);
        IFEND;
      UNTIL status.normal;
    ELSE
      REPEAT
        rhp$sign_off_os (application_names.application.application_name, status);
        IF NOT status.normal THEN
          CASE status.condition OF
          = mlc$nosve_not_up =
            status.normal := TRUE;
          = mlc$busy_interlock =
          = mlc$queued_msgs_lost, mlc$receiver_not_signed_on =
            status.normal := TRUE;
          ELSE
            abnormal_mli_status_message (1, 32) :=
              'sign off mli abnormal condition=';
            STRINGREP (abnormal_mli_status_message (33, 3), string_length,
                  status.condition);
            log_status (dayfile_log, abnormal_mli_status_message
                  (1, 32 + string_length));
          CASEND;
          wait (1000);
        IFEND;
      UNTIL status.normal;
    IFEND;

  PROCEND mli_link;

MODEND rhmmli;
