Up | Previous | Next | Title Page | Contents

3.2 Image I/O API

The nine routines for image I/O (line I/O and array I/O) are described below. A description of the optional arguments follows each subroutine description.

3.2.1 x/zvadd—Add information to control block

call xvadd(unit, status, <optionals>, ' ')
status = zvadd(unit, <optionals>, 0);

x/zvadd updates the internal control block information describing the file associated with UNIT. Each item of information is identified by a key word and is followed by a value which holds the update information. The keyword-value pairs are optional and may be entered in any order. To process the file, x/zvadd must be called before opening (with x/zvopen) the file.

Arguments:

Optional arguments:

ORG
N1
N2
N3
BSQ
NS
NL
NB
BIL
NS
NB
NL
BIP
NB
NS
NL

Table 10: File Organization

If the file is a tape file, an error condition will be raised if 'RANDOM' is specified. The specification of 'RANDOM' for a file with OP equal to 'WRITE' is equivalent to 'SEQ'.

The three values are independent. Thus 'SA' will cause a system message to be printed and the program to abort if an error occurs. If OPEN_ACT consists only of blanks, an error will cause the x/zvopen to return an error number in STATUS. Default is the action specified with x/zveaction.

The string may contain more than one substring, such as 'COND', 'NOBLOCK NOLABELS'. Default is to label and block files and hide the binary areas of the file.

The valid values for BINTFMT are exactly the same as for INTFMT above (including NATIVE and LOCAL).

Setting CONVERT to OFF turns off both of these conversions, giving you the bit patterns that are in the file directly. When writing a file, host conversion is possible (although not normally used), but the U_FORMAT data type conversion is normally performed. Setting CONVERT to OFF turns off both of these conversions as well, writing the bit patterns that are in memory directly to the file.

Note: Be careful! If you turn CONVERT OFF, you are responsible for doing your own data type conversions. Any given program should be able to read files written on any machine, so if you turn off CONVERT you should make use of the x/ztvtrans family of routines. See 1.3 Data Types and Host Representations, for details.

If the application does not know the binary label type, however (such as a general-purpose application), then it cannot convert the host format. In this case, set BIN_CVT to OFF. This means the output file will receive the binary label host types of the primary input file, defaulting to VAX-VMS if not available. The general-purpose application may then simply transfer the binary labels over to the output file without re-formatting them. The BHOST, BINTFMT, and BREALFMT optional arguments will override this setting, but if BIN_CVT is OFF (they are ignored if BIN_CVT is on). BIN_CVT is ignored for input files. See 1.7.2 Programming and Binary Labels, for more details.

3.2.2 x/zvclose—Close a file

call xvclose(unit, status, <optionals>, ' ')
status = zvclose(unit, <optionals>, 0);
x/zvclose will close an open image file. The use of x/zvclose is required in an application program.

Arguments:

Optional arguments:

3.2.3 x/zveaction—Set the default error handling action

call xveaction (action, message)
status = zveaction (action, message)

x/zveaction sets the default error handling action for the entire VICAR job. It is used as a default for all the error handling optionals such as OPEN_ACT, IO_ACT, LAB_ACT, and ERR_ACT, and it is used directly by routines that do not have their own independent error action arguments.
The default if x/zveaction is not called is a null string for both the action and the message.

Arguments:

The three values are independent of each other. Thus 'SA' will cause a system message to be printed and the program to abort if an error occurs. If ACTION consists only of blanks, or if x/zveaction has never been called, an error will cause the Executive to return an error number in a status variable (if one is available on the particular subroutine that had the error).

3.2.4 x/zvget—Retrieve control block information

call xvget(unit, status, <optionals>, ' ')
status = zvget(unit, <optionals>, 0);
x/zvget permits the programmer to request file information stored in the executive's internal control block associated with a unit number. The item of information is identified by an input key word field. The information is returned by x/zvget in the variable following the key word argument. The keyword-value pairs are optional and may be entered pairwise in any order.

Arguments:

Optional arguments:

int flags;

xvget(&unit, &stat, "FLAGS", &flags);
if (flags & OPEN) {. . .

The various flags listed here are predefined for applications written in C. Only the names should be used, to protect against changes in future versions of the executive.

The valid values for BINTFMT are exactly the same as for INTFMT (including NATIVE and LOCAL).

3.2.5 x/zvopen—Open a file

call xvopen(unit, status, <optionals>, ' ')
status = zvopen(unit, <optionals>, 0);
x/zvopen prepares the file for I/O processing. If the file is an input file, it verifies the file's existence and the existence and form of its label.
For output files, x/zvopen will ensure that the file is the right size, that being either the size indicated by the programmer on the call to x/zvopen, the size field for the file, or the input file, in that order. If the file does not exist, x/zvopen will create it. If the file exists but is too small, x/zvopen will expand it. If the file is a tape file, it will be positioned to the desired file.
For all output files, x/zvopen will create, unless the programmer negates this default function, an output label for the file.
A call to x/zvopen is required before I/O processing can take place on the file.

Arguments:

Optional arguments:

ORG
N1
N2
N3
BSQ
NS
NL
NB
BIL
NS
NB
NL
BIP
NB
NS
NL

Table 11: File Organization

free (malloc (1024*1024)); /* Fix Virtual Address Space Full error */ 

Indicates the access method for the file. Valid values are 'SEQ' (sequential) or 'RANDOM'. The default is 'SEQ'. 'SEQ' and 'RANDOM' only effect the internal buffering used by the executive; if the method is 'SEQ', then a larger buffer will be used for I/O, resulting in more efficient processing. If 'RANDOM' is given, a smaller buffer will be used to avoid reading unnecessary data.

If the file is a tape file, an error condition will be raised if 'RANDOM' is specified. The specification of 'RANDOM' for a file with OP equal to 'WRITE' is equivalent to 'SEQ'.

The three values are independent. Thus 'SA' will cause a system message to be printed and the program to abort if an error occurs. If OPEN_ACT consists only of blanks, an error will cause the x/zvopen to return an error number in STATUS. Default is the action specified with x/zveaction.

The string may contain more than one substring, such as 'COND', 'NOBLOCK NOLABELS'. Default is to label and block files and hide the binary areas of the file.

The valid values for BINTFMT are exactly the same as for INTFMT above (including NATIVE and LOCAL).

Setting CONVERT to OFF turns off both of these conversions, giving you the bit patterns that are in the file directly. When writing a file, host conversion is possible (although not normally used), but the U_FORMAT data type conversion is normally performed. Setting CONVERT to OFF turns off both of these conversions as well, writing the bit patterns that are in memory directly to the file.

Note: Be careful! If you turn CONVERT OFF, you are responsible for doing your own data type conversions. Any given program should be able to read files written on any machine, so if you turn off CONVERT you should make use of the x/ztvtrans family of routines. See 1.3 Data Types and Host Representations, for details.

If the application does not know the binary label type, however (such as a general-purpose application), then it cannot convert the host format. In this case, set BIN_CVT to OFF. This means the output file will receive the binary label host types of the primary input file, defaulting to VAX-VMS if not available. The general-purpose application may then simply transfer the binary labels over to the output file without re-formatting them. The BHOST, BINTFMT, and BREALFMT optional arguments will override this setting, but if BIN_CVT is OFF (they are ignored if BIN_CVT is on). BIN_CVT is ignored for input files. See 1.7.2 Programming and Binary Labels, for more details.

3.2.6 x/zvread—Read a line

call xvread(unit, buffer, status, <optionals>, ' ')
status = zvread(unit, buffer, <optionals>, 0);

x/zvread will read a single line from the file associated with the UNIT. The data will be returned in BUFFER and the status indicator will be returned in STATUS.

Arguments:

Optional arguments:

The three values are independent. Thus 'SA' will cause a system message to be printed and the program to abort if an error occurs. If OPEN_ACT consists only of blanks, an error will cause the x/zvopen to return an error number in STATUS. Default is the action specified with x/zveaction.

3.2.7 x/zvsignal—Signal an error

call xvsignal (unit, status, abend_flag) 
status = zvsignal (unit, status, abend_flag) 
x/zvsignal will signal an error if one has occurred in any of the image I/O routines (x/zv...) or label I/O routines (x/zl...). It uses the same internal routines that the OPEN_ACT, IO_ACT, LAB_ACT, and ERR_ACT optionals use, so no error checking is duplicated.

Arguments:

3.2.8 x/zvunit—Assign a unit number to a file

call xvunit(unit, name, instance, status, <optionals>, ' ')
status = zvunit(unit, name, instance, <optionals>, 0);
x/zvunit will return an unused file unit number. The programmer may use this number in any of the above routines. This routine must be called to obtain a unit number for every file that is to be accessed by the VICAR image and label I/O subroutine package.
Under UNIX, filenames accepted by the RTL (via x/zvunit, either the U_NAME optional or the INP or OUT parameters) can contain environment variables andusernames. A reference of the form $ var will be replaced with the value of the environment variable var. The name of the environment variable (but not the dollar sign) may optionally be enclosed in curly braces (${ var}). A tilde ( ~) followed by a username will be replaced with the home directory of that user. A tilde without a username will be replaced with the home directory of the current account. Both of these expansions exactly mimic the behavior of the C-shell, so they should be familiar to most UNIX users.

Arguments:

Optional arguments:

3.2.9 x/zvwrit—Write an image line

call xvwrit(unit, buffer, status, <optionals>, ' ')
status = zvwrit(unit, buffer, <optionals>, 0);
x/zvwrit will write a single line of pixels to the image file associatedwith the UNIT. The data will be written from BUFFER and the status indicator will be returned in STATUS.

Arguments:

Optional arguments:


Up | Previous | Next | Title Page | Contents