Chapter Contents

Previous

Next
osdsinfo

osdsinfo



Obtain Information about a Data Set by DSname

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
PORTABILITY
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <os.h>

int osdsinfo(const char *dsnm, int tsoform, unsigned short *dsorgp,
             char *recfmp, int *lreclp, int *blksizep);


DESCRIPTION

The osdsinfo function obtains and returns information about the data set referenced by a particular DSname. This function works only under OS/390. The first argument, dsnm , is a null-terminated string specifying the DSname of the data set. You can specify in either uppercase or lowercase letters, and leading white space is not permitted. The tsoform flag indicates whether the DSname is a tso -style name or is fully qualified. If the value of tsoform is 0, the name is assumed to be complete. If the value of tsoform is not 0, the name is completed by prepending your TSO prefix (or your userid, if the program is running in batch and your userid can be determined).

The remaining arguments to osdsinfo are pointers that address areas where the data set information is stored. Any of these pointers can be NULL , which causes the corresponding information not to be stored. Because osdsinfo obtains only the requested information (and some information is time consuming to obtain), you should always pass NULL to osdsinfo for any information that you do not need. A number of flags are stored in the unsigned short addressed by the argument dsorgp ; the flags describe the file's data set organization. The symbolic values for these flags can be found in the header file <os.h> :

#define DSORG_IS 0x8000 /* indexed sequential       */
#define DSORG_PS 0x4000 /* physical sequential      */
#define DSORG_DA 0x2000 /* direct organization      */
#define DSORG_PO 0x0200 /* partitioned organization */
#define DSORG_U  0x0100 /* unmovable                */
#define DSORG_AM 0x0008 /* VSAM                     */

A 0 is stored in *dsorgp if the data set organization is not available.

A number of flags are stored in a single character that is addressed by the argument recfmp ; the flags describe the record format of the file. The symbolic values for these flags also can be found in the header file <os.h> :

#define RECFM_F 0x80   /* fixed-length records            */
#define RECFM_V 0x40   /* variable-length records         */
#define RECFM_U 0xc0   /* undefined-length records        */
#define RECFM_D 0x20   /* variable-length ASCII records   */
#define RECFM_T 0x20   /* track overflow                  */
#define RECFM_B 0x10   /* blocked records                 */
#define RECFM_S 0x08   /* spanned/standard records        */
#define RECFM_A 0x04   /* ANSI-defined control characters */
#define RECFM_M 0x02   /* machine control characters      */

Note:    You should test for RECFM_U before testing for RECFM_F or RECFM_V because the definition of RECFM_U is  [cautionend]

RECFM_U = RECFM_F | RECFM_V

A 0 is stored in *recfmp if record format information is not available.

The data set's logical-record length is stored in an integer that is addressed by the lreclp argument. If the logical-record length is not defined or cannot be obtained, 0 is stored. If the data set is defined with LRECL=X , the special value LRECL_X is stored.

The data set's block size is stored in an integer that is addressed by the blksizep argument. If the block size is not defined or cannot be obtained, 0 is stored.


RETURN VALUE

The osdsinfo function returns 0 if information about the DSname is available, or a nonzero value if it fails. If an error occurs, the return code is the same as the error code stored in errno .


CAUTION

You should not call the osdsinfo function for a file that is already open. Such calls can fail with dynamic-allocation errors, due to interference by system I/O processing. Consider using the fattr function to get information about the attributes of a file that is already open.


PORTABILITY

osdsinfo is implemented only under OS/390.


IMPLEMENTATION

The requested file is dynamically allocated using SVC 99. Additional information about the file that is not provided by SVC 99 is obtained by issuing the RDJFCB and OBTAIN macros.


EXAMPLE

This code fragment allocates a buffer for an input file. The buffer size should be lrecl if the file is F or U format, or the lrecl - 4 if the file is V format.

#include <os.h>
#include <stdlib.h>

char recfm;
int lrecl;
char *buffer;
if (osdsinfo("input.data", 1, NULL, &recfm, &lrecl, NULL) == 0)
   if (lrecl != 0 && lrecl != LRECL_X)
      buffer = malloc(recfm & RECFM_F? lrecl: lrecl - 4);
.
.
.


RELATED FUNCTIONS

cmsstat , fattr , osddinfo , stat


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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