
#include <lcio.h>
FILE *afopen(const char *name, const char *mode,
const char *am, const char *amparms);
afopen function is an augmented version of the standard I/O
fopen function. It enables the specification of various
implementation-dependent and system-dependent parameters.
The name argument is the external name (sometimes called a
pathname) of the file to be opened. Its form is operating-system-
dependent. See General filename specification for syntax details.
The mode argument is a string defining how the file will be
used. The mode string contains one to three characters with
the following syntax:
r | [b]
w | [+] | [k]
a
r
w
a
a
is specified, the file is automatically positioned at the end of the
file immediately before data are physically written.) For a keyed
file, new data can be added anywhere in the file, but existing records
cannot be changed.
+
b
b nor k,
text access is assumed. k requests access as a
keyed stream.
The am argument is a string naming an access method. Remember
to enclose the method in quotes. The following specifications are
permitted:
""
term
seq access method
term access method is
automatically substituted.
rel
rel access method only when the open mode
specifies binary access.
kvs
kvs access method can be used only with VSAM files and only
when the mode specifies keyed access.
fd
If the file cannot be handled with the access method you specify, the
afopen operation fails.
See Library access method selection for more information on access method selection.
The amparms argument is a string specifying access method
parameters, which are system- and access-method-dependent file
processing options. See Access method parameters for a complete
description of amparms.
afopen returns a FILE object associated
with the named file. If the file cannot be opened, a NULL value
is returned.
afopen and files opened with fopen
interchangeably. The name and mode arguments to
afopen have the same meanings and formats as the corresponding
fopen arguments.
The function call afopen(name, mode, "", "") is equivalent to
fopen(name, mode).
matrix
with 10 rows of the matrix in each block of the file. If the file does
not exist, create it with enough space for the matrix.
#include <lcio.h>
#include <stdio.h>
main()
{
FILE *matrix_out;
char *matrix_name;
char path_name[50];
/* matrix parameters for afopen */
char matrix_parms[90];
int matrix_rows; /* number of rows in the matrix */
double *matrix; /* matrix definition */
matrix_name = "square";
sprintf(path_name,"tso:%s.matrix", matrix_name);
/* Set the afopen parameters. */
sprintf(matrix_parms,
"recfm=f, reclen=%d, blksize=%d, alcunit=block,"
"space=%d", matrix_rows*sizeof(double),
matrix_rows*sizeof(double)*10,
matrix_rows / 10 + 1);
matrix_out = afopen(path_name, "wb", "", matrix_parms);
/* Write the entire matrix out at once. */
if (matrix_out)
fwrite((char *)matrix, sizeof(double),
matrix_rows*matrix_rows, matrix_out);
else
puts("Matrix file failed to open.");
}
aopen, fopen
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.