[Robelle] [SmugBook] [Index] [Prev] [Next]

FOPEN Routine in MPE and UNIX

Both MPE and UNIX have routines named FOPEN and FCLOSE which open and close files. The MPE versions are more complex, since the MPE file system is more complex (it has record types and sizes, user labels, etc.). On UNIX a file is just a stream of bytes. In fact, MPE has superseded FOPEN with the even more complex HPFOPEN routine.

Foptions Means File-Type-Options

The Foptions value is a 16-bit unsigned integer made up of 1, 2 and 3-bit fields. The 1-bit fields have value 1 to enable the option. Most fields default to the 0 value. Remember that MPE numbers bit fields as (startbit:bitcount) and leftmost bit is 0:

Text version.

(1:1)(2:3)(5:1)(6:1)(7:1)(8:2)(10:3)(13:1)(14:2)
Byte
stream
File
type?
No
:File
Tape
label
CCTL Record
format
Def.
desig
ASCII/
Binary
Domain
New!!0=std0=fix0=file0=new
1=ksam1=var1=$stdlist1=old
2=rio2=undef2=$newpass2=temp
3=ksam/xl3=spool3=$oldpass3=either
4=cir4=$stdin
5=nm spoofle5=$stdinx
6=msg6=$null
7=ksam64

Aoptions Means Access-Type Options

The Aoptions value is a 16-bit unsigned integer made up of 1 to 4-bit fields. The 1-bit fields have value 1 to enable the option. Most fields default to the 0 value. Remember that MPE numbers bit fields as (startbit:bitcount) and leftmost bit is 0:

Text version.

(2:1)(3:1)(4:1)(5:2)(7:1)(8:2)(10:1)(11:1)(12:4)
Glob
open
File
Copy
Nowait
I/O
Multi
Access
Nobuf Excl
acc
Locking Multi
record
Access
type
0=none0=default0=read
1=intra-job1=exclusive1=write
2=inter-job2=excl+read2=write/save
3=share3=append
4=inout
5=update
6=execute
9=readdir

HPFOPEN Gives You Mapped Access and More

When HP needed new parameters and options for opening files, they added a new intrinsic to MPE: HPFOPEN. It accepts a variable number of pairs of parameters, the first of which is an Itemnum and the second is the Item_Value.

Text version.

HPFOPEN (filenum,{32-bit integer by reference}
status,{32-bit integer by reference}
itemnum,{32-bit integer by value}
itemval,{type varies, by reference}
...{up to 41 pairs}
);

A few important things to remember: the status is actually decoded as two 16-bit values, Itemnum 2 the file name must have an opening "quote" that also appears at the end, you can open a new file and save it at the same time, and you can open a file with mapped access.

FCLOSE Intrinsic On MPE

FCLOSE does at least five distinct functions:
 FCLOSE(filenum      {16-bit integer value }

       ,disposition  {0=as is, 1=save, 2= temp}
                     {3=temp, no rewind, 4=delete}
                     {5=convert perm to temp NEW!!}
                     {.(11:2)=1 truncates, 2=trims}
       ,securitycode {1=tight, creator only}
       );

FCONTROL versus fcntl

The MPE FCONTROL intrinsic and the UNIX fcntl function both provide control over open files, but are otherwise dissimilar. The terminal control functions of FCONTROL, such as control code 12 to turn Echo on, are not part of fcntl; see stty, termio, and ioctl instead. The file lock functions of fctnl are provided by the FLOCK and FUNLOCK intrinsics of MPE, if at all. The undocumented control codes 31 and 30 of FCONTROL (Vplus Block mode On and Off) are incorporated into the blmode functions of HP-UX.


[Robelle] [SmugBook] [Index] [MPEtips] [Prev] [Next]