Open System Services Programmer's Guide
Example 23 Using a Guardian Procedure to Get OSS File Information by Name
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cextdecs.h(PATHNAME_TO_FILENAME_,FILE_GETINFOBYNAME_)>
char *pathname;
char filename[64];
short filelen;
short status;
short typeinfo[5];
short flags;
int main(int argc, char *argv[]) {
short retcode, physreclen;
/* If no pathname is supplied, get information
about the default file. */
if(argc > 1)
pathname = argv[1];
else
pathname = "/usr/include/stdio.h";
/* Get the Guardian filename equivalent first. */
retcode = PATHNAME_TO_FILENAME_(pathname, /* OSS pathname */
filename, /* Guardian filename buffer */
64, /* Size of filename buffer */
&filelen, /* length of filename */
&status); /* if == 1, Guardian file (/G)
if == 0, OSS file */
/* If the procedure is unsuccessful, print a message and exit.*/
if (retcode != 0) {
fprintf(stderr, "Bad pathname, return code = %d\n", retcode);
exit(1);
}
/* Invoke the Guardian procedure call. */
retcode = FILE_GETINFOBYNAME_(filename, /* Guardian filename */
filelen, /* filename length */
typeinfo, /* return array of file information */
&physreclen, /* returned physical record length */
, /* desired options, if any */
, /* tag or timeout value, if any */
&flags); /* new OSS flags word */
if (retcode != 0) {
fprintf(stderr,"retcode = %d\n", retcode);
fprintf(stderr,"Non-existent file or pathname in bad format\n");
exit(1);
}
/* Print the information about file, indicating whether
it is an OSS file or a Guardian file. */
if(flags&1)
printf("OSS File, ");
else
printf("Guardian File, ");
printf("Pathname = %s\n", pathname);
printf("device type = %d\n", typeinfo[0]);
printf("device subtype = %d\n", typeinfo[1]);
printf("physical record length = %d\n", physreclen);
/* If the device type is a disk file,
print the disk file information. */
Accessing Files From the Guardian API 75