HP 9000 Series 300 Tutorials Manual page 33

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

The integer variable ofiag specifies the access mode for the opened file, and
can have one of six possible values, as defined in the /usr/include/fcntl. h
header file:
O_RDONLY
(value
=
0) requests read-only access,
O_WRONLY
(value
=
1) requests write-only access, and
O_RDWR
(value
=
2) requests both read
and write access (three values with O_NDELAY not set, three values with
O_NDELAY set - see io_lock (31) in the
HP-UX Reference,
for a total of
six values). To use these constants in a programs, the #include C-compiler
directive must be present as shown in the example above.
An
open
system call on an interface special file returns an integer representing
the entity identifier
(eid)
for the opened interface. As mentioned earlier, the
entity identifier is required as a parameter in all DIL subroutine calls. It is also
required as a parameter for all read/write operations to the opened file.
The following code defines an entity identifier called
eid
and opens an interface
file called /dev/raw_hpib with access enabled for both reading and writing:
#include <fcntl.h>
#include <errno.h>
int
eid;
eid
=
open ("/dev/raw_hpib", O_RDWR);
Special files can also be opened by placing the character string name of the file
being opened in a string variable, then executing the
open
system call with a
pointer to the variable as shown in the following code segment:
#include <fcntl.h>
int
eid;
char *buffer;
buffer
=
"/dev/raw_hpib";
if «eid
=
open (buffer , O_RDWR))
==
-1) {
printf("open failed, errno
=
%d\n", errno);
exit(2);
}
If the call to open succeeds, a non-negative integer is returned as the entity
identifier. If an error occurs and the file is not opened, -1 is returned and
errno
is set to indicate the error.
General-Purpose Routines
2-5

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents