C\
C\ Print the error and the API that received the error
C\
C EXCEPT BAD_NEWS
C\
C ENDSR
OQPRINT E BAD_NEWS 1
O 'Failed in API '
O API_NAME
O 'with error '
O QUSEI
UNIX-Type APIs—Examples
The simple example program on the following pages illustrates the use of several
integrated file system functions. The program performs the following operations:
.1/ Uses the getuid() function to determine the real user ID (uid).
.2/ Uses the getcwd() function to determine the current directory.
.3/ Uses the open() function to create a file. The owner (the person who created
the file) is given read, write, and execute authority to the file.
.4/ Uses the write() function to write a byte string to the file. The file is identified
by the file descriptor that was provided in the open operation (.3/).
.5/ Uses the close() function to close the file.
.6/ Uses the open() function to open the file for read only.
.7/ Uses the read() function to read a byte string from the file. The file is identi-
fied by the file descriptor that was provided in the open operation (.6/).
.8/ Uses the close() function to close the file.
.9/ Uses the unlink() function to remove the link to the file.
Using the Integrated File System—ILE C Example
This example program uses the integrated file system from ILE C.
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\ \/
/\ Language: ILE C \/
/\ \/
/\ Description: Demonstrate use of integrated file system \/
/\ from ILE C \/
/\ \/
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#define BUFFER_SIZE 2ð48
#define TEST_FILE "test.file"
Appendix B. Original Examples in Additional Languages B-175