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 integrated file system functions. The program performs the following op

.1/

Uses

thegetuid()

function to determine the real user ID (uid).

 

.2/

Uses

thegetcwd()

function to determine the current directory.

 

.3/

Uses

theopen()

function to create a file. The

owner

(the

person

w

 

the

file) is

given read, write, and execute authority to the

.4/

Uses

thewrite()

function to write a byte string to the file. The

 

by the

file

descriptor that was provided .in3/).the open operation

.5/

Uses

theclose()

function to close the file.

 

 

 

 

 

.6/

Uses

theopen()

function to open the file for read only.

 

 

.7/

Uses

theread()

function to read a byte string

from

the file. The

 

fied

by

the file descriptor

that

was

provided.6/).in the

open

op

.8/

Uses

theclose()

function to close the file.

 

 

 

 

 

.9/

Uses

theunlink()

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 BLanguages-175

Page 453
Image 453
IBM Version 4 manual UNIX-Type APIs-Examples, Theread