open_tab - Opens a labeled table (LT) with specified access

SYNTAX

#include "ltable.h"

FUNCTION open_tab (tab,hname,access)

     struct TAB_DEF     *tab;
     char               *hname;
     long                access;

PARAMETERS

tab (Input/Output, struct TAB_DEF

Pointer to a structure defining the LT file structure. The other LT utility routines access various fields within this structure.

hname (Input, char, length(*))

Host file of the LT file. Directory specifications may be included using the host computer filenaming conventions.

access (Input, long)

Specifies the type of access the LT is being opened for. Valid values are:

          = 0:  read access
          = 1:  write access
          = 2:  append (read/write) access

DESCRIPTION

The open_tab() routine opens the LT file with the specified access. It initializes the data structures by allocating the I/O buffers and assigning appropriate values to each of the structure fields. The following fields of parameter tab are assigned for all types of access.

     1. LT host filename          (hname)
     2. Type of file access       (access)
     3. File descriptor           (fd)
     4. Allocate LT I/O buffer    (buf)
If the LT is opened for read access, it reads the first two logical records of the LT file. The following fields of parameter tab are assigned:

     1. Number of associated files          (nsubs)
     2. Array of associated filenames       (subfile)
     3. LT file type                        (ftype)
     4. LT file description                 (fdesc)
If the LT is opened for write access, it writes the first two logical records into the LT. It expects the following fields of parameter tab to be assigned prior to calling open_tab():
     1. Number of associated files          (nsubs)
     2. Array of associated filenames       (subfile)
     3. LT file type                        (ftype)
     4. LT file description                 (fdesc)
If the LT is opened for append and the file does not exist, it is treated exactly as if it were being opened for write access. That is, it writes the first two logical records into the LT, and it expects the following fields of parameter tab to be assigned prior to calling open_tab():
     1. Number of associated files          (nsubs)
     2. Array of associated filenames       (subfile)
     3. LT file type                        (ftype)
     4. LT file description                 (fdesc)
If the LT is opened for append and the file already exists, error checking is done to ensure the subfile(s) and file type correspond between the calling program and the existing LT. The function get_vector() is called to retrieve the current label vector and the file pointer is positioned to the end of the file. It expects the following fields of parameter tab to be assigned prior to calling open_tab():
     1. Number of associated files          (nsubs)
     2. Array of associated filenames       (subfile)
     3. LT file type                        (ftype)
     4. LT file description                 (fdesc)

RETURN VALUE

open_tab() has no return values.

SPECIAL CONSIDERATIONS:

The open_tab() call is for C only.