Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

bs2fstat - Access file name from catalog

&pagelevel(4)&pagelevel

Definition

#include <stdlib.h>

int bs2fstat(const char *pattern, void (*fct)(const char *f_name, int len));

bs2fstat returns

  • the fully qualified file names (:catid:$userid.filename) of one or more files that satisfy the selection criterion given by pattern, and

  • the length of the particular file name including the terminating null byte (\0).

For each file found, bs2fstat calls a function fct (which must be supplied by the user) and passes to it the particular file name f_name (string char *) and the name length len (integer) as current arguments.

If no file matches the selection criterion pattern or if pattern is errored the function fct is not called and bs2fstat returns a DMS error message.

Parameters

const char *pattern:

String specifying the selection criterion for one or more files.
pattern is a fully or partially qualified file name with wildcard syntax.

For compatibility reasons, further parameters can also be specified to determine which files are selected, e.g.:

      • file and catalog attributes (FCBTYPE, SHARE etc.)
      • creation and access date (CREATE, EXDATE etc.)

These parameters must be specified in the syntax of the ISP command FSTAT.
The pattern "*,crdate=today", for example, returns the names of all files that were created or updated on today’s date.

void (*fct)(const char *f_name, int len)

A user-supplied function with the parameters f_name (file name) and len (name length).
These parameters are supplied with current values by bf2stat on each function call.
The function calls are made automatically by bs2fstat (in a while loop).

Returnwert

 0     

if the call was successful.                                                                                          


DMS error message code



if the call was not successful.

Note

The DMS error message code can be only queried from outside the user-own function fct, since the function is not called if the search was unsuccessful (see also example).

Example

In the following program, all files matching the name pattern entered by the user are made shareable with the MODIFY-FILE-ATTRIBUTES command.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void share(const char *, int);
int main(void)
{
  char name[54];
  int result;
  printf("Which files are to be made shareable?\n");
  gets(name);
  result = bs2fstat(name, share);
  if(result != 0)
     printf("Error code: DMS%x\n", result);
  return 0;
}
void share(const char *nam, int len)
                        /* The formal parameters nam and len are      */
                        /* supplied as current parameters by bs2fstat */
{
  char cmd[200];
  strcpy(cmd, "/MODIFY-FILE-ATTRIBUTES ");
  strcat(cmd, nam);
  strcat(cmd, ",PROTECTION=PAR(USER-ACCESS=ALL-USERS)");
  system("/MODIFY-TERMINAL-OPTIONS OVERFLOW-CONTROL=NO-CONTROL");
  printf("%s\n", cmd);
  system(cmd);
}

See also

system