*copyc OSD$DEFAULT_PRAGMATS
MODULE ifm$change_term_conn_defaults;

{ PURPOSE:  This ring 3 module calls a ring 2 counterpart to change
{           the default connection attributes for the task.  The
{           effects of this change are not retroactive, i.e., the
{           attributes of files created before the change are not
{           affected, but subsequent file creations are.
{
{  DESIGN:  Either IIM$CHANGE_TERM_CONN_DEFAULTS is called for dual
{           state connections or IIM$ST_CHANGE_TERM_CONN_DEFAULTS for
{           standalone connections.  These routines directly change
{           the attributes in the task's task-shared attribute table
{           managed by IF to the corresponding input attribute values.
{
?? TITLE := 'MODULE ifm$change_term_conn_defaults' ??

?? PUSH (LISTEXT := ON) ??
*copyc fst$file_reference
*copyc ife$error_codes
*copyc ifk$keypoints
*copyc iip$change_term_conn_defaults
*copyc iip$st_chnge_term_conn_defaults
*copyc iit$connection_description
*copyc iiv$interactive_terminated
?? POP ??

*copyc clp$validate_name
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc rmp$get_device_class

?? NEWTITLE := 'PROCEDURE ifp$change_term_conn_defaults', EJECT ??
*copyc ifh$change_term_conn_defaults

  PROCEDURE [XDCL, #GATE {TS_gate} ] ifp$change_term_conn_defaults
    (terminal_file_name: fst$file_reference;
        term_conn_attributes: ift$connection_attributes;
    VAR status: ost$status);

    VAR
      i:integer,
      converted_name: ost$name,
      device_assigned: boolean,
      device_class: rmt$device_class,
      device_is_network: boolean,
      valid_name: boolean;

    status.normal := TRUE;
    #KEYPOINT (osk$entry, 0, ifk$change_term_conn_defaults);

  /change_term_conn_defaults/
    BEGIN
      IF STRLENGTH (terminal_file_name) > osc$max_name_size THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$file_name_ill_formed, terminal_file_name, status);
        osp$append_status_parameter (osc$status_parameter_delimiter,
          'IFP$CHANGE_TERM_CONN_DEFAULTS', status);
        EXIT /change_term_conn_defaults/;
      IFEND;

    { Convert and validate the file name.

      clp$validate_name (terminal_file_name, converted_name, valid_name);
      IF NOT valid_name THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$file_name_ill_formed, terminal_file_name, status);
        osp$append_status_parameter (osc$status_parameter_delimiter,
              'IFP$CHANGE_TERM_CONN_DEFAULTS', status);
        EXIT /change_term_conn_defaults/;
      IFEND;

    { Verify that the terminal file exists and that it is a network file.

      rmp$get_device_class (converted_name, device_assigned, device_class,
            status);
      IF NOT status.normal THEN
        EXIT /change_term_conn_defaults/;
      IFEND;
      device_is_network := (device_class = rmc$network_device) OR (device_class = rmc$terminal_device);

      IF NOT device_is_network THEN
        osp$set_status_abnormal (ifc$interactive_facility_id,
              ife$file_is_not_network_file, converted_name, status);
        EXIT /change_term_conn_defaults/;
      IFEND;

      CASE iiv$network_identifier OF
      = iic$cdcnet_network =

      { STANDALONE }
        iip$st_chnge_term_conn_defaults (converted_name, term_conn_attributes,
               status);

      = iic$dsiaf_network =

      { DUAL STATE }

{ Check for attributes which have no meaning on this type of terminal connection.

        IF NOT iiv$cdcnet_connection THEN
          FOR i := 1 TO UPPERBOUND (term_conn_attributes) DO
            CASE term_conn_attributes [i].key OF
            = ifc$trans_protocol_mode =
              osp$set_status_abnormal (ifc$interactive_facility_id,
                    ife$illegal_nam_ccp_conn_change,
                    'IFP$CHANGE_TERM_CONN_DEFAULTS', status);

              EXIT /change_term_conn_defaults/;
            ELSE
            CASEND;
          FOREND;
        IFEND;

        iip$change_term_conn_defaults (term_conn_attributes, status);

      CASEND;

    END /change_term_conn_defaults/;
    #KEYPOINT (osk$exit, 0, ifk$change_term_conn_defaults);

  PROCEND ifp$change_term_conn_defaults;
MODEND ifm$change_term_conn_defaults;
