

            readf (2) --- read raw words from a file                 03/25/82


            _C_a_l_l_i_n_g _I_n_f_o_r_m_a_t_i_o_n

                 integer function readf (buf, nw, fd)
                 integer buf (ARB), nw
                 file_des fd

                 Library:  vswtlb (standard Subsystem library)


            _F_u_n_c_t_i_o_n

                 'Readf'  is  used  to  read  words from a file, which may be
                 assigned to any device recognized by the Subsystem.  (A word
                 on the Prime is 16 bits long.)   The  first  argument  is  a
                 buffer to receive data transferred from the file; the second
                 argument  is  the  number  of  words  to  be read; the third
                 argument is the file descriptor of the file from which  data
                 will  be  read.   Words are transferred from the file to the
                 buffer until (1) the requested number of  words  are  trans-
                 ferred,  (2)  end-of-file  occurs,  or  (3) iiifff ttthhheee fffiiillleee fffrrrooommm
                 wwwhhhiiiccchhh ttthhheee  dddaaatttaaa  iiisss  rrreeeaaaddd  iiisss  aaa  ttttttyyy  fffiiillleee,,,  a  NEWLINE  is
                 encountered.

                 If  the  file  is not readable, the given file designator is
                 invalid, or the file's  error  flag  is  set,  the  function
                 return  is  ERR.  If end-of-file is encountered on the read,
                 the function return is EOF.  Otherwise, the function  return
                 is the number of words returned in the buffer.


            _I_m_p_l_e_m_e_n_t_a_t_i_o_n

                 'Readf'  first  calls  'mapsu'  to convert any standard port
                 descriptors it is passed into  Subsystem  file  descriptors.
                 If  the  last  operation  performed  on  the  file was not a
                 'readf', then 'flush$' is called to empty  the  file's  Sub-
                 system buffer.  Depending on the device type associated with
                 the  file,  a  device dependent driver ('dread$' for disk or
                 'tread$' for the user's terminal) is called to do the actual
                 work of getting data into the buffer.


            _A_r_g_u_m_e_n_t_s _M_o_d_i_f_i_e_d

                 buf


            _C_a_l_l_s

                 mapsu, dread$, tread$, flush$


            _B_u_g_s

                 Strange things may happen if you ask  for  more  words  than
                 'buf'  can  hold.   The  semantics of reading raw characters


            readf (2)                     - 1 -                     readf (2)




            readf (2) --- read raw words from a file                 03/25/82


                 from a terminal are a little shaky; since one character  per
                 word  is stored in a terminal buffer, 'readf' actually reads
                 characters from a terminal, not words.  There is a need  for
                 devices  other  than  "terminal" and "disk" (system console,
                 for example).  EOF is returned  if  any  error  occurs  when
                 reading  from  disk (in dread$); the user is not informed of
                 the actual error that occurs.


            _S_e_e _A_l_s_o

                 dread$ (6), tread$ (6), flush$ (6), mapsu (2),  writef  (2),
                 getlin (2)













































            readf (2)                     - 2 -                     readf (2)


