*copyc osd$default_pragmats
MODULE iim$get_page_length_width;

{ PURPOSE:  Retrieve the page length and width attribute values for a
{           connection.
{
{  DESIGN:  The retrieved PW and PL attribute values are returned in
{           a formal parameter.  These values are taken directly from
{           the attributes pointed at by IIV$CONNECTION_DESC_PTR.
{
{           If this interface is executed on a standalone connection,
{           i.e., iiv$network_identifier is iic$cdcnet_network, then
{           the appropriate connection table pointer is determined
{           from the terminal file name.
{
?? TITLE := 'MODULE iim$get_page_length_width' ??
?? PUSH (LISTEXT := ON) ??
*copyc clp$construct_path_handle_name
*copyc iip$clear_lock
*copyc iip$search_connection_desc
*copyc iip$set_lock
*copyc iip$xlate_local_file_to_session
*copyc iiv$connection_desc_ptr
*copyc iiv$interactive_terminated
?? POP ??
?? NEWTITLE := 'PROCEDURE iip$get_page_length_width' ??

  PROCEDURE [XDCL, #GATE] iip$get_page_length_width (terminal_path_handle: fmt$path_handle;
    VAR page_length_width: array [1 .. 2] of ift$terminal_attribute;
    VAR status: ost$status);

    VAR
      connection_desc_ptr: ^iit$connection_description,
      terminal_file_name: amt$local_file_name,
      session_file: amt$local_file_name;

  /get_pl_pw/
    BEGIN

      page_length_width [1].key := ifc$page_length;
      page_length_width [2].key := ifc$page_width;

      CASE iiv$network_identifier OF
      = iic$cdcnet_network =

        clp$construct_path_handle_name (terminal_path_handle, terminal_file_name);
        iip$xlate_local_file_to_session (terminal_file_name, session_file, status);
        IF NOT status.normal THEN
          EXIT /get_pl_pw/;
        IFEND;
        iip$search_connection_desc (session_file, connection_desc_ptr);
        IF connection_desc_ptr = NIL THEN
          EXIT /get_pl_pw/;
        IFEND;

        iip$set_lock (connection_desc_ptr^.connection_attributes_lock, osc$wait, status);
        IF status.normal THEN
          page_length_width [1].page_length := connection_desc_ptr^.page_length;
          page_length_width [2].page_width := connection_desc_ptr^.page_width;
          iip$clear_lock (connection_desc_ptr^.connection_attributes_lock, status);
        IFEND;

      = iic$dsiaf_network =

        iip$set_lock (iiv$connection_desc_ptr^.lock, osc$wait, status);
        IF status.normal THEN
          page_length_width [1].page_length := iiv$connection_desc_ptr^.terminal_attributes.
                page_length;
          page_length_width [2].page_width := iiv$connection_desc_ptr^.terminal_attributes.
                page_width;
          iip$clear_lock (iiv$connection_desc_ptr^.lock, status);
        IFEND;

      CASEND;

    END /get_pl_pw/;

  PROCEND iip$get_page_length_width;
MODEND iim$get_page_length_width;
