Open System Services Programmer's Guide

Example 16 Using the Guardian PATHNAME_TO_FILENAME_ Procedure
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cextdecs.h(PATHNAME_TO_FILENAME_)>
char filename[64];
short filelen;
short status;
int main(int argc, char *argv[]) {
short ret;
/* Make sure the correct number of arguments are entered.
If not, print usage message and exit. */
if(argc < 2) {
fprintf(stderr,"Usage: pthtofil pathname\n");
exit (1);
}
/* Invoke the Guardian procedure call.
Note the special format for options. */
ret = PATHNAME_TO_FILENAME_(argv[1], /* 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 call fails, print a message and exit. */
if (ret != 0) {
fprintf(stderr,"Bad path name\n");
exit(1);
}
filename[filelen] = '\000'; /* make NULL-terminated string */
/* Determine the file type and print the file. */
if(status&1)
printf("Guardian (/G) file = %s\n", filename);
else
printf("OSS file = %s\n", filename);
return(0);
}
Example 17 shows how to use the FILENAME_TO_PATHNAME_ procedure. The program takes
as its input a Guardian filename and prints out the corresponding OSS pathname. This program
example demonstrates the use of /E.
58 Managing Files