Chapter Contents

Previous

Next
cmsffind

cmsffind



Find the First CMS Fileid That Matches a Pattern

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
IMPLEMENTATION
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <cmsio.h>

int cmsffind(struct EXT_FILEINFO *info, char *pattern);


DESCRIPTION

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 .

To determine the century of the Date member of EXT_FILEINFO, call the cmsfcent function.


RETURN VALUE

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 contains the filename of the matching fileid.
Filetype contains the filetype of the matching fileid.
Filemode contains the filemode letter and number of the matching fileid.

The above three fields are NULL terminated and are not padded with blanks.
Format is the record format of the file, either F or V .
Lrecl is the maximum record length of the file.
Recs is the number of records in the file.
Blocks is the number of mini-disk blocks occupied by the file.
Date is the date of the last update to the file in the form MM/DD/YY.
Time is the time of the last update to the file in the form HH/MM/SS.
Fileid is the fileid in the form FILENAME FILETYPE FM in a NULL-terminated string. The parts of fileid are separated by one blank space.


IMPLEMENTATION

cmsffind uses the DMSERP (Extract/Replace) routine of the CMS Callable Services Library. This routine is not available in VM/SP.


CAUTION

The 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.


EXAMPLE

#include <stdio.h>
#include <cmsio.h>

int main(void)
{
 int exitrc = 0
 int century_ind;
 struct EXT_FILEINFO info;
 /*   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(exitrc == 0)
  {
   printf("fileid  : %20.20s  ", info.Fileid);
   printf("date    : %s    time: %s \n", info.Date, info.Time);
   century_ind = cmsfcent(&info);
   if (century_ind == 1)
       printf("Century : 19yy\n......\n"); /* 1 = 19yy */
   else
       printf("Century : 20yy\n......\n"); /* 2 = 20yy */
   exitrc=cmsfnext(&info);
  };

 cmsfquit();
 return(0);
}


RELATED FUNCTIONS

cmsdfind , cmsfcent , cmsfnext , cmsfquit


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.