[comp.lang.modula3] Udir.i3

mjordan (Mick Jordan) (04/27/91)

If you look at this interface, you will note that it has a comment
about a difference for SunOS (4.0 and upwards actually), but no
field inserted. This makes code which scans directories fail.

TYPE
  gen_dir = RECORD                    (* describes directory entry *)
    (* SunOS has another field here. *)
    gd_ino: Ctypes.unsigned_long;          (* inode number of entry *)
    gd_reclen: Ctypes.unsigned_short;      (* record length in bytes *)
    gd_namelen: Ctypes.unsigned_short;     (* name length in bytes *)
    gd_name: Ctypes.char; (* C array *)    (* name *)
  END;

The declaration should read:

TYPE
  gen_dir = RECORD                    (* describes directory entry *)
    gd_off: Ctypes.long;              (* offset of next disk  directory entry *)
    gd_ino: Ctypes.unsigned_long;          (* inode number of entry *)
    gd_reclen: Ctypes.unsigned_short;      (* record length in bytes *)
    gd_namelen: Ctypes.unsigned_short;     (* name length in bytes *)
    gd_name: Ctypes.char; (* C array *)    (* name *)
  END;

Sadly this means that simply using the "ultrix-3-1" library for SunOS
is no longer viable. Anyway, I am sure there are other differences.

Mick Jordan

orgass+@rchland.ibm.com (Dick Orgass) (04/27/91)

The intent of the target specific libraries is that they are to
accurately reflect the details of the target on which clients are
running.

In a lot of ways Udir.i3 is the most difficult of the target specific
interfaces.  All three of the IBM platforms are different from each
other and quite different from Ultrix.  These differences show up in two
ways: the details of the record declarations and the names of the record
fields.

The first is of very little consequence if the people doing the ports do
their job correctly (unlike this author) but the second is more
difficult.

Whe I did Udir.i3 for our platforms, I followed sys/dir.h for type
names, field size and field names.  This means I get a record type DIR
with fields of the form dd_* as well as record type struct_dirent with
fields whose names are of the form d_*.  It appears that for Ultrix and,
possibly, SunOS, one gets a record type gen_dir with field names gd_*.
It is this latter kind of difference that makes clients of Udir.i3
non-portable.

Perhaps we should agree to use exactly the type names and field names in
the POSIX or X/Open spec with possible additions or omissions to match
our targets.

Dick