Okay -- my question was too generic. Specifically, it seems that the
TermFile tests fail on Solaris 10 because TermFile.mod tries to
open /
dev/tty and this does not work in Solaris 10. The recommended method
is to retrieve the name of the current terminal via ttyname() or
ttyname_r(), preferably the latter. In both cases, pointers to the
string containing the name are returned.
I wish to replace the Assign('/dev/tty', a) statement in
TermFile.getname() with a call to ttyname_r() but I do not know how
to define the latter in libc.def. If I define it as you suggest,
then it is unclear to me how to copy the contents of the string into
a (locus citato).
Hi John,
I hope you don't mind me CC:ing the list as this technique maybe
useful to others interfacing to C based libraries.
I understand the question better now I think and would use
the module DynamicStrings to create a String and CopyOut the
result. So
PROCEDURE getname (d: DeviceTablePtr;
VAR a: ARRAY OF CHAR) ;
BEGIN
Assign('/dev/tty', a)
END getname ;
could be replaced with the following code:
IMPORT DynamicStrings ;
...
PROCEDURE getname (d: DeviceTablePtr;
VAR a: ARRAY OF CHAR) ;
VAR
s: DynamicStrings.String ;
BEGIN
s := DynamicStrings.InitStringCharStar(ttyname_r()) ;
DynamicStrings.CopyOut(a, s) ;
s := DynamicStrings.KillString(s)
END getname ;