#include <cmsio.h> int cmsffind(struct EXT_FILEINFO *info, char *pattern);
cmsffind
replaces cmsdfind
for programs that will be used in
VM/XA and VM/ESA operating systems.
cmsffind
searches for the first 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 fileid can
contain the special wildcard characters "*"
(asterisk) and "%"
(percent). The asterisk represents any number of characters, including 0.
You can use as many asterisks as required in each part of the pattern. The
percent character represents exactly one character.
If the pattern string omits any part of the fileid, an asterisk is used. For
example, the pattern "* EXEC A"
matches all files on the A disk with a
filetype of EXEC. The pattern "PROFILE *"
matches all files on any
accessed disk having a filename of PROFILE. The pattern "%%%% * *"
matches all files on all accessed disks whose filenames have exactly four
characters. The pattern "* HELP* Y2"
matches all files on the Y disk
whose filemode number is 2 and which have a file type beginning with HELP.
If a match is found, cmsffind
fills in the EXT_FILEINFO
structure
pointed to by info
. This structure is defined in the <cmsio.h>
header file. The structure is defined as
__alignmem struct EXT_FILEINFO { unsigned int internal_data[7]; char Filename[9]; char Filetype[9]; char Filemode[3]; char Format; unsigned int Lrecl; unsigned int Recs; unsigned int Blocks; char Date[9]; char Time[9]; char Fileid[21]; };
Subsequent CMS files whose fileids match the pattern may be found by
calling cmsfnext
using a pointer to the same EXT_FILEINFO
structure. When all the fileids have been found, call cmsfquit
to
release the data reserved by cmsffind
.
cmsffind
returns 0 if a match is found or a non-zero value if a match is
not found.
After a successful match, cmsffind
fills in the fields in the structure
as follows:
Filename
Filetype
Filemode
Format
F
or V
.
Lrecl
Recs
Blocks
Date
MM/DD/YY
.
Time
HH/MM/SS
.
Fileid
FILENAME FILETYPE FM
in a NULL-terminated
string. The parts of fileid
are separated by one blank space.
cmsffind
uses the DMSERP (Extract/Replace) routine of the CMS Callable
Services Library. This routine is not available in VM/SP.
internal_data
field in the EXT_FILEINFO
structure is reserved
for subsequent calls to cmsfnext
. Do not alter these data.
cmsffind
invokes the DMSERP RESET function to initialize the
Extract/Replace facility. If the program has previously used the
Extract/Replace facility, any environmental information left over from that use will be
destroyed. Thus, you cannot have more than one unterminated
cmsffind
/cmsfnext
loop running simultaneously.
#include <stdio.h> #include <cmsio.h> int main(void) { int match; /* Type the names of all the files on the C disk whose */ /* filenames have an "A" as the second character, whose */ /* filetype is "EXEC" followed by any characters, and */ /* whose filemode number is 2. */ match = cmsffind(&info, "%A* EXEC* C2"); while (match == 0) { puts(info.Fileid); match = cmsfnext(&info); } cmsfquit(); return 0; }
cmsdfind
, cmsfnext
, cmsfquit
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.