Chapter Contents |
Previous |
Next |
cmsdfind |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <cmsio.h> int cmsdfind(struct FILEINFO *info, char *pattern);
DESCRIPTION |
cmsdfind
searches for a CMS file whose name matches the pattern pointed to by
pattern
. The pattern is a string of the form filename filetype filemode, where one or more parts of the file ID
can be an
"*"
. For example,
"* EXEC A"
is a pattern that matches all files with filetype EXEC on
the A disk. Similarly,
"DATA * C"
is a
pattern that matches all files with a filename of DATA on the C disk. If
a match is found,
cmsdfind
fills in the
FILEINFO
structure.
You can specify
pattern
in any form of the
cms
or
xed
style that provides a file ID for a CMS disk
file. For example,
"cms:*.exec.*"
is a
pattern that matches all file IDS with a filetype of EXEC on any accessed
disk.
The header file
<cmsio.h>
contains the structure
FILEINFO
.
This structure is used for both
cmsdfind
and
cmsdnext
. The structure is defined
as follows:
struct FILEINFO { char _[22]; /* reserved - do not alter */ char recfm; /* file RECFM */ char _1; int lrecl; /* file LRECL */ int norecs; /* number of records in file */ char name[21]; /* null-terminated fileid */ };
RETURN VALUE |
cmsdfind
returns 0 if a match is found or a non-zero value if a match is not found.
If a match is found, the
name
element in the
FILEINFO
structure
is filled in with the filename, filetype, and filemode of the matching fileid.
The filename and filetype are padded on the right with blanks to eight characters.
All parts of the fileid are in uppercase letters. The fileid is terminated
with a null character.
The
recfm
field contains
either 'F' or 'V', depending on the RECFM of the file. The
lrecl
field contains the LRECL of the file, and the
norecs
field contains the number of records in the file. Other file
information can be retrieved with the
cmsstat
or
cmsstate
functions.
CAUTION |
The first 22 characters in the
FILEINFO
structure are reserved for subsequent calls to
cmsdnext
. This area contains a copy of the pattern and a
pointer to
an internal control block. Do not alter this area.
Disk I/O is not permitted between calls to
cmsdfind
and
cmsdnext
if the I/O
is to the same disk that is being searched by
cmsdfind
and
cmsdnext
. You also
cannot use
cmspid
between
cmsdfind
and
cmsdnext
if these functions
refer to the same disk. Note that if you run VM/XA or
VM/ESA, you can use
cmsffind
and
cmsfnext
in place of
cmsdfind
and
cmsdnext
to avoid these
restrictions.
EXAMPLE |
#include <cmsio.h> int rc; struct FILEINFO info; /* List all files with filename PROFILE. */ rc = cmsdfind(&info,"PROFILE * *"); while (rc == 0) { puts(info.name); rc = cmsdnext(&info); }
RELATED FUNCTIONS |
cmsdnext
,
cmsffind
,
opendir
,
osdfind
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.