/*-------------------------------------------------------------------+
| COPYRIGHT (C) 1995, SAS INSTITUTE INC. |
| UNPUBLISHED - ALL RIGHTS RESERVED |
| S A S / C S A M P L E |
| |
| |
| NAME: STAT |
| LANGUAGE: C |
| PURPOSE: Demonstrate CMSSTAT function . |
| CMS - |
| COMPILE: LC370 STAT |
| LINK: CLINK STAT (GENMOD STAT |
| INPUT/OUTPUT: stdin/stdout |
| USAGE: The "no-blanks" format of the fileid must be used |
| with this example so the input can be interpreted |
| from the command line correctly. For example: |
| stat cms:profile.exec.a |
| stat ddn:ddname(member) |
| See CMSSTAT documentation and Appendix B for fileid |
| format. |
| SYSTEM NOTES: CMS only |
| |
+-------------------------------------------------------------------*/
#eject
#include <cmsstat.h>
#define UNDEF1 0xFFFF
#define UNDEF2 0xFF
main(argc,argv)
int argc;
char **argv;
{
struct cmsstat fileinfo;
int rc;
argv++;
if (argc <= 1) return -1; /* File not specified. */
rc = cmsstat(*argv,&fileinfo);
if (rc != 0) return rc;
/* Fileid or dsn */
if (fileinfo.st_type & S_OS)
printf(" %s ",fileinfo.st_fid.dsn);
else
{
if (strlen(fileinfo.st_fid.file.name) != 0)
printf(" %s ",fileinfo.st_fid.file.name);
if (strlen(fileinfo.st_fid.file.type) != 0)
printf(" %s ",fileinfo.st_fid.file.type);
if (strlen(fileinfo.st_fid.file.mode) != 0)
printf(" %s ",fileinfo.st_fid.file.mode);
}
/* Member name */
if (strlen(fileinfo.st_mem) != 0)
printf(" member(%s) ",fileinfo.st_mem);
/* Disk label */
if (strlen(fileinfo.st_dlabl) != 0)
printf("on %s ",fileinfo.st_dlabl);
/* Device virtual address */
if (fileinfo.st_vaddr != UNDEF1)
printf("at virtual address %X \n",fileinfo.st_vaddr);
else
printf("\n");
/* Last modified date on file */
if (fileinfo.st_mtime != -1)
printf(" Last modified on %s",ctime(&fileinfo.st_mtime));
/* Type flags */
if (fileinfo.st_type & S_DUM)
printf(" File is a dummy \n");
if (fileinfo.st_type & S_DISK)
printf(" File is a disk file \n");
if (fileinfo.st_type & S_OS)
printf(" File is on an OS disk \n");
if (fileinfo.st_type & S_XED)
printf(" File is in XEDIT storage \n");
if (fileinfo.st_type & S_LIB)
printf(" File is a member in a library \n");
if (fileinfo.st_type & S_TAPE)
printf(" File is a tape \n");
if (fileinfo.st_type & S_UR)
printf(" File is a unit record device \n");
if (fileinfo.st_type & S_TERM)
{
printf(" File is a terminal \n");
if (fileinfo.st_type & S_3270)
printf(" Terminal is 3270 type \n");
}
else
if (fileinfo.st_type & S_OSFORMAT)
printf(" File is in OS format \n");
/* Access flags */
if (fileinfo.st_flags == S_RW)
printf(" Read/write access \n");
else if (fileinfo.st_flags & S_WO)
printf(" Write only access \n");
else if (fileinfo.st_flags & S_RWX)
printf(" Read/write extension access \n");
else if (fileinfo.st_flags & S_RO)
printf(" Read only access \n");
else
printf(" Read only extension access \n");
/* Number of records or terminal height */
if (fileinfo.st_norecs != -1)
{
if (fileinfo.st_type & S_TERM)
printf(" Terminal height %d \n",fileinfo.st_norecs);
else
printf(" Number of records %d \n",fileinfo.st_norecs);
}
/* RECFM */
if (fileinfo.st_recfm !=UNDEF2)
printf(" RECFM %c \n",fileinfo.st_recfm);
/* LRECL or terminal width */
if (fileinfo.st_lrecl != UNDEF1)
{
if (fileinfo.st_type & S_TERM)
printf(" Terminal width %d \n",fileinfo.st_lrecl);
else
printf(" LRECL %d \n",fileinfo.st_lrecl);
}
/* BLKSIZE */
if (fileinfo.st_bksiz != UNDEF1)
printf(" BLKSIZE %d \n",fileinfo.st_bksiz);
/* Number of disk data blocks */
if (fileinfo.st_dblks != -1)
printf(" Number of disk data blocks %d \n",fileinfo.st_dblks);
/* Minidisk blocksize */
if (fileinfo.st_dbksz != -1)
printf(" Minidisk blksize %d \n",fileinfo.st_dbksz);
return rc;
}
|