open (2) --- open a file 02/28/83 _C_a_l_l_i_n_g _I_n_f_o_r_m_a_t_i_o_n file_des function open (path, mode[, typ[, limit]]) character path (ARB) integer mode, typ, limit Library: vswtlb (standard Subsystem library) _F_u_n_c_t_i_o_n 'Open' is the primary means of opening files for reading, writing, etc. The first argument is the pathname of the file to be opened; it must be an EOS terminated string (e.g. open('/dir/file1's....). The second argument is the mode, READ, WRITE or READWRITE. The third argument is optional and should normally be omitted. It specifies the type associated with the file. The fourth argument is optional and should normally be omitted. It specifies the number of retries that should be made when a disk file is found to be in use. 'Open' returns a file descriptor which may be used for further i/o operations if the attempt to open was suc- cessful, or ERR if the attempt failed. The user is always left in the home directory after an attempt to open. By default, 'open' returns a file descriptor to a sequential access method (SAM) file when referring to a disk file. If creating a direct access method file (DAM) is desired, the 'mode' argument may be ORed with the KNDAM file key (i.e., 'mode' can be "READWRITE+KNDAM" to create a DAM file opened for reading or writing). The constant KNDAM is contained in the "PRIMOS_KEYS" include file. 'Open' may be used to produce file descriptors that allow access to many different devices. Depending on the path- name, the file opened may be a standard input or output port, the user's terminal, a line printer spool file, a disk file, or the null device. Such special pathnames always begin with the characters "/dev/" followed by context- dependent strings that may specify names, options, etc. For example, the pathname used to open files in the spool queue may include any of the following options: f use Fortran forms control r use raw forms control s use standard forms control h inhibit header page j inhibit final page eject n number all output lines a/location/ select destination printer d/time/ defer printing until specified time b/banner/ use given string on header page c/copies/ print given number of copies p/form/ select form type (wide, narrow, special, etc.) Slashes or blanks may be used to separate parameters. For open (2) - 1 - open (2) open (2) --- open a file 02/28/83 example, "/dev/lps/f/agt.b/c10" refers to a spool file with Fortran forms control, ten copies of which will be printed on the printer with name "gt.b". _I_m_p_l_e_m_e_n_t_a_t_i_o_n 'Open' first searches for an available file descriptor and, if found, performs initialization for the file. The form of the pathname given as the first argument controls subsequent actions, as follows: /dev/stdout For standard port names, the /dev/stdin allocated file descriptor is freed /dev/errout and the port descriptor is returned. /dev/errin /dev/stdout[123] /dev/stdin[123] /dev/null The null device is opened. /dev/tty The user's terminal is opened. /dev/lps?* 'Lopen$' is called to open a disk file in the spool queue otherwise, If the pathname does not begin with "/dev/", 'dopen$' is called to open a disk file. _A_r_g_u_m_e_n_t_s _M_o_d_i_f_i_e_d typ _C_a_l_l_s dopen$, lopen$, getfd$, expand, mapdn, strbsr, Primos break$ _S_e_e _A_l_s_o dopen$ (6), lopen$ (6), close (2), create (2), remove (2) open (2) - 2 - open (2)