gtpc2m78C/C++ Language Support User's Guide

tape_access-Access a Tape

This function is used to permit an entry control block (ECB) to gain control of a tape without first checking to see if the tape is already open. It also allows the ECB to specify a timeout value if the tape is not immediately available.

Format

#include <tpftape.h>
long tape_access (const char *name,
                        int   io,
                        int   buffmode,
                        char *message,
                        int   timeout);

name
A pointer to type char, which must be a 3-character string identifying the tape that will be opened. This function can only be called for a general tape.

io
Code one of the following two terms as defined in the tpftape.h header file.

INPUT
To read the tape.

OUTPUT
To write to the tape.

buffmode
Indicates if the buffered mode of operation will be used. This argument is ignored for input tapes.

NOBUFF
A defined term used to specify no buffering (write immediate mode).

BUFFERED
A defined term used to specify buffered write mode (preferred).

message
A pointer to a message string that will be sent to the console if the function is canceled because of a timeout condition. If a NULL pointer is passed, no message will be sent.

timeout
The number of seconds that will lapse before the tape_access attempt is canceled. If no value is specified, the function will never time out.

Normal Return

The normal return is a positive value.

Error Return

An error return is indicated by a negative return code.

Programming Considerations

Examples

The following example uses tape_access to gain exclusive control of a tape device.

#include <tpftape.h>
long example()
{
char *tape_name;
char *message;
long timeout;
long tape_return_code;
 

  ·
  ·
  ·
if ((tape_return_code = tape_access(tape_name, INPUT, BUFFERED, message, timeout)) != tape_OK ) { if (tape_return_code == tape_openTimeOut) { printf("tape_access timed out\n"); } else { if (tape_return_code == tape_wrongIOmode) { printf("tape_access failed due to mode conflict\n"); } else { printf("tape_access failed\n"); } } } else { printf("tape_access successful\n"); }
  ·
  ·
  ·
}

Related Information