#include <os.h> int osdfind(struct DSNINFO *info, const char *pattern);
osdfind
searches for an MVS data set or PDS member whose name matches the
pattern pointed to by pattern
. Information about the first matching file
is returned in the structure pointed to by info
. Additional matching
files can be retrieved using the osdnext
function.
The pattern has the form of a MVS data set name, with several extensions:
<os.h>
defines the structure DSNINFO
. This structure is
used for osdfind
, osdnext
, and osdquit
. The structure is
defined as
struct DSNINFO { /* argument structure for osdfind/osdnext */ void * _ [4] ; /* reserved for library use */ char cattype; /* catalog entry type */ char dsname [45] ; /* null-terminated full dsname */ char mem [9] ; /* null-terminated member name */ char __; /* padding */ unsigned TTR: 24; /* TTR of start of member */ unsigned alias: 1; /* alias member bit */ unsigned user_TTR_count: 2; /* number of user TTRs */ unsigned user_data_halfwords: 5; /* halfwords of user data */ char user_data [62] ; /* user data from PDS directory */ };The following paragraphs describe some of the members of this structure.
The cattype
member is a one-character code indicating the type of file.
The values are
The mem
element is the member name when you specify a pattern ending in an
asterisk in parentheses (*). The mem
element is a null
string for other patterns.
The TTR, alias, user_TTR_count, user_data_halfwords
, and user_data
members contain information from the PDS directory entry for the member when an
(*) pattern is specified. See the MVS Data Administration Guide for more
information on PDS directory structures. These fields are not meaningful when
the pattern does not request the return of PDS members.
osdfind
returns 0 if a matching data set or PDS member is found or - 1
if no match is found. Other negative values may be returned to indicate fatal
errors, after which no more names can be returned. If a minor error occurs, a
positive value may be returned, indicating that the names of some files or
members could not be returned, but that another call to osdfind
may
successfully return additional names. For example, if osdfind
is unable
to return PDS members because a PDS directory is corrupt, osdfind
returns
a positive return code to indicate that it may be possible to return members of
other PDSs matching the pattern.
osdfind
assumes the PDS directory for an (*) pattern is not
modified during processing. If a write to the data set or member occurs during
the execution of osdfind
, the results are unpredictable. The results
are also unpredictable if files or members matching the pattern are added or
deleted between the call to osdfind
and the corresponding osdquit
.
The first 16 bytes of the DSNINFO
structure are reserved for use in
subsequent calls to osdnext
. Do not alter this area because the effects are
unpredictable.
The catalog searches by osdfind
use a 65-K buffer to hold data set names.
For this reason, all matching filenames may not be returned if the highest
level qualifier identifies more than about 1,400 filenames. For example, if
there are more than 1,400 files under the index ORDERS, then osdfind
with
the pattern ORDERS.*.LOG returns only matching names from the first 1,400. This
is a limitation of the operating system, not of SAS/C.
osdfind
and osdnext
to search all the
user's .C files for members that are defined in the SPF statistics as
belonging to a specific userid:
#include <os.h> #include <string.h> #include <stdio.h> void findmine(char *id) { struct spfstat { /* This structure maps SPF statistics. */ char version; char mod; char pad1[2]; int created; /* Julian date, packed decimal */ int changed; /* Julian date, packed decimal */ char changet[2]; /* time changed, hours and minutes */ short size; short init; short modified; char userid[8]; /* who edited it last */ } *s; struct DSNINFO d; /* Return information from */ /* osdfind/osdnext. */ int rc; rc = osdfind(&d, ".*.c(*)"); /* Find all my .C files. */ while(rc >= 0) { char resp; if (rc > 0) { puts("Error searching .C files. Continue?"); scanf(" %c", &resp); if (resp != 'y' && resp != 'Y') { osdquit(&d); /* If not continuing, free memory. */ break; } } else if (d.user_data_halfwords >= /* if user data looks like SPF data */ sizeof(struct spfstat)/2) { s = (struct spfstats *) d.user_data; /* if it's owned by this id */ if (memcmp(s->userid, id, 8) == 0) /* Print filename and member. */ printf("%s(%s)n", d.dsname, d.mem); } rc = osdnext(&d); /* Proceed to next one. */ } }
cmsdfind
, cmsffind
, opendir
, osdnext
, osdquit