Open System Services Programmer's Guide

Example 17 Using the Guardian FILENAME_TO_PATHNAME_ Procedure
Guardian FILENAME_TO_PATHNAME procedure */
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tal.h>
#include <cextdecs.h(FILENAME_TO_PATHNAME_)>
char pathname[PATH_MAX];
short pathlen;
short index = 0;
int main(int argc, char *argv[]) {
short ret;
/* Make sure the correct number of arguments are entered.
If not, print a usage message and exit. */
if(argc < 2) {
fprintf(stderr,"Usage: filtopth filename\n");
exit (1);
}
/* Invoke Guardian procedure call. Note the special format for options */
while(index != -1) { /* print all possible pathnames */
ret = FILENAME_TO_PATHNAME_(argv[1], /* Guardian filename */
(short)strlen(argv[1]), /* length of filename */
pathname, /* buffer for OSS pathname */
PATH_MAX, /* length of buffer */
&pathlen, /* length of pathname */
6, /* absolute pathname wrt. system root */
/* includes system name in the form
/E/system/pathname */
&index /* index of link to file */
);
/* If the call fails, print a message and exit. */
if (ret != 0) {
fprintf(stderr,"Bad file name\n");
exit(1);
}
/* Print pathname */
printf("Pathname = %s\n", pathname);
}
return(0);
}
Example 18 shows the use of FILE_COMPLETE_SET, FILE_COMPLETE_, and
FILE_COMPLETE_GETINFO_ to wait for the completion of I/O on Guardian and OSS files. Once
enabled for completion, files from the specified set can be completed multiple times. Guardian
files are opened for NOWAIT I/O, and OSS files can be nonblocking or blocking.
The OSS and Guardian File Systems 59